Merge pull request #113 from TheBlueMatt/main
[ldk-java] / ts / bindings.c.body
1 #include "js-wasm.h"
2 #include <stdatomic.h>
3 #include <lightning.h>
4
5 // These should be provided...somehow...
6 void *memset(void *s, int c, size_t n);
7 void *memcpy(void *dest, const void *src, size_t n);
8 int memcmp(const void *s1, const void *s2, size_t n);
9
10 extern void __attribute__((noreturn)) abort(void);
11 static inline void assert(bool expression) {
12         if (!expression) { abort(); }
13 }
14
15 uint32_t __attribute__((export_name("test_bigint_pass_deadbeef0badf00d"))) test_bigint_pass_deadbeef0badf00d(uint64_t val) {
16         return val == 0xdeadbeef0badf00dULL;
17 }
18
19
20 void *malloc(size_t size);
21 void free(void *ptr);
22
23 #define MALLOC(a, _) malloc(a)
24 #define do_MALLOC(a, _b, _c) malloc(a)
25 #define FREE(p) if ((unsigned long)(p) > 4096) { free(p); }
26 #define DO_ASSERT(a) (void)(a)
27 #define CHECK(a)
28 #define CHECK_ACCESS(p)
29 #define CHECK_INNER_FIELD_ACCESS_OR_NULL(v)
30
31 // We assume that CVec_u8Z and u8slice are the same size and layout (and thus pointers to the two can be mixed)
32 _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKu8slice), "Vec<u8> and [u8] need to have been mapped identically");
33 _Static_assert(offsetof(LDKCVec_u8Z, data) == offsetof(LDKu8slice, data), "Vec<u8> and [u8] need to have been mapped identically");
34 _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKu8slice, datalen), "Vec<u8> and [u8] need to have been mapped identically");
35
36 _Static_assert(sizeof(void*) == 4, "Pointers mut be 32 bits");
37
38 #define DECL_ARR_TYPE(ty, name) \
39         struct name##array { \
40                 uint64_t arr_len; /* uint32_t would suffice but we want to align uint64_ts as well */ \
41                 ty elems[]; \
42         }; \
43         typedef struct name##array * name##Array; \
44         static inline name##Array init_##name##Array(size_t arr_len, int lineno) { \
45                 name##Array arr = (name##Array)do_MALLOC(arr_len * sizeof(ty) + sizeof(uint64_t), #name" array init", lineno); \
46                 arr->arr_len = arr_len; \
47                 return arr; \
48         }
49
50 DECL_ARR_TYPE(int64_t, int64_t);
51 DECL_ARR_TYPE(int8_t, int8_t);
52 DECL_ARR_TYPE(uint32_t, uint32_t);
53 DECL_ARR_TYPE(void*, ptr);
54 DECL_ARR_TYPE(char, char);
55 typedef charArray jstring;
56
57 static inline jstring str_ref_to_ts(const char* chars, size_t len) {
58         charArray arr = init_charArray(len, __LINE__);
59         memcpy(arr->elems, chars, len);
60         return arr;
61 }
62 static inline LDKStr str_ref_to_owned_c(const jstring str) {
63         char* newchars = MALLOC(str->arr_len + 1, "String chars");
64         memcpy(newchars, str->elems, str->arr_len);
65         newchars[str->arr_len] = 0;
66         LDKStr res = {
67                 .chars = newchars,
68                 .len = str->arr_len,
69                 .chars_is_owned = true
70         };
71         return res;
72 }
73
74 typedef bool jboolean;
75
76 uint32_t __attribute__((export_name("TS_malloc"))) TS_malloc(uint32_t size) {
77         return (uint32_t)MALLOC(size, "JS-Called malloc");
78 }
79 void __attribute__((export_name("TS_free"))) TS_free(uint32_t ptr) {
80         FREE((void*)ptr);
81 }
82
83 jstring __attribute__((export_name("TS_get_ldk_c_bindings_version"))) TS_get_ldk_c_bindings_version() {
84         const char *res = check_get_ldk_bindings_version();
85         if (res == NULL) return NULL;
86         return str_ref_to_ts(res, strlen(res));
87 }
88 jstring __attribute__((export_name("TS_get_ldk_version"))) get_ldk_version() {
89         const char *res = check_get_ldk_version();
90         if (res == NULL) return NULL;
91         return str_ref_to_ts(res, strlen(res));
92 }
93 #include "version.c"
94 static inline struct LDKThirtyTwoBytes ThirtyTwoBytes_clone(const struct LDKThirtyTwoBytes *orig) { struct LDKThirtyTwoBytes ret; memcpy(ret.data, orig->data, 32); return ret; }
95 static inline LDKAccessError LDKAccessError_from_js(int32_t ord) {
96         switch (ord) {
97                 case 0: return LDKAccessError_UnknownChain;
98                 case 1: return LDKAccessError_UnknownTx;
99         }
100         abort();
101 }
102 static inline int32_t LDKAccessError_to_js(LDKAccessError val) {
103         switch (val) {
104                 case LDKAccessError_UnknownChain: return 0;
105                 case LDKAccessError_UnknownTx: return 1;
106                 default: abort();
107         }
108 }
109 static inline LDKCOption_NoneZ LDKCOption_NoneZ_from_js(int32_t ord) {
110         switch (ord) {
111                 case 0: return LDKCOption_NoneZ_Some;
112                 case 1: return LDKCOption_NoneZ_None;
113         }
114         abort();
115 }
116 static inline int32_t LDKCOption_NoneZ_to_js(LDKCOption_NoneZ val) {
117         switch (val) {
118                 case LDKCOption_NoneZ_Some: return 0;
119                 case LDKCOption_NoneZ_None: return 1;
120                 default: abort();
121         }
122 }
123 static inline LDKChannelMonitorUpdateErr LDKChannelMonitorUpdateErr_from_js(int32_t ord) {
124         switch (ord) {
125                 case 0: return LDKChannelMonitorUpdateErr_TemporaryFailure;
126                 case 1: return LDKChannelMonitorUpdateErr_PermanentFailure;
127         }
128         abort();
129 }
130 static inline int32_t LDKChannelMonitorUpdateErr_to_js(LDKChannelMonitorUpdateErr val) {
131         switch (val) {
132                 case LDKChannelMonitorUpdateErr_TemporaryFailure: return 0;
133                 case LDKChannelMonitorUpdateErr_PermanentFailure: return 1;
134                 default: abort();
135         }
136 }
137 static inline LDKConfirmationTarget LDKConfirmationTarget_from_js(int32_t ord) {
138         switch (ord) {
139                 case 0: return LDKConfirmationTarget_Background;
140                 case 1: return LDKConfirmationTarget_Normal;
141                 case 2: return LDKConfirmationTarget_HighPriority;
142         }
143         abort();
144 }
145 static inline int32_t LDKConfirmationTarget_to_js(LDKConfirmationTarget val) {
146         switch (val) {
147                 case LDKConfirmationTarget_Background: return 0;
148                 case LDKConfirmationTarget_Normal: return 1;
149                 case LDKConfirmationTarget_HighPriority: return 2;
150                 default: abort();
151         }
152 }
153 static inline LDKCreationError LDKCreationError_from_js(int32_t ord) {
154         switch (ord) {
155                 case 0: return LDKCreationError_DescriptionTooLong;
156                 case 1: return LDKCreationError_RouteTooLong;
157                 case 2: return LDKCreationError_TimestampOutOfBounds;
158                 case 3: return LDKCreationError_InvalidAmount;
159                 case 4: return LDKCreationError_MissingRouteHints;
160         }
161         abort();
162 }
163 static inline int32_t LDKCreationError_to_js(LDKCreationError val) {
164         switch (val) {
165                 case LDKCreationError_DescriptionTooLong: return 0;
166                 case LDKCreationError_RouteTooLong: return 1;
167                 case LDKCreationError_TimestampOutOfBounds: return 2;
168                 case LDKCreationError_InvalidAmount: return 3;
169                 case LDKCreationError_MissingRouteHints: return 4;
170                 default: abort();
171         }
172 }
173 static inline LDKCurrency LDKCurrency_from_js(int32_t ord) {
174         switch (ord) {
175                 case 0: return LDKCurrency_Bitcoin;
176                 case 1: return LDKCurrency_BitcoinTestnet;
177                 case 2: return LDKCurrency_Regtest;
178                 case 3: return LDKCurrency_Simnet;
179                 case 4: return LDKCurrency_Signet;
180         }
181         abort();
182 }
183 static inline int32_t LDKCurrency_to_js(LDKCurrency val) {
184         switch (val) {
185                 case LDKCurrency_Bitcoin: return 0;
186                 case LDKCurrency_BitcoinTestnet: return 1;
187                 case LDKCurrency_Regtest: return 2;
188                 case LDKCurrency_Simnet: return 3;
189                 case LDKCurrency_Signet: return 4;
190                 default: abort();
191         }
192 }
193 static inline LDKIOError LDKIOError_from_js(int32_t ord) {
194         switch (ord) {
195                 case 0: return LDKIOError_NotFound;
196                 case 1: return LDKIOError_PermissionDenied;
197                 case 2: return LDKIOError_ConnectionRefused;
198                 case 3: return LDKIOError_ConnectionReset;
199                 case 4: return LDKIOError_ConnectionAborted;
200                 case 5: return LDKIOError_NotConnected;
201                 case 6: return LDKIOError_AddrInUse;
202                 case 7: return LDKIOError_AddrNotAvailable;
203                 case 8: return LDKIOError_BrokenPipe;
204                 case 9: return LDKIOError_AlreadyExists;
205                 case 10: return LDKIOError_WouldBlock;
206                 case 11: return LDKIOError_InvalidInput;
207                 case 12: return LDKIOError_InvalidData;
208                 case 13: return LDKIOError_TimedOut;
209                 case 14: return LDKIOError_WriteZero;
210                 case 15: return LDKIOError_Interrupted;
211                 case 16: return LDKIOError_Other;
212                 case 17: return LDKIOError_UnexpectedEof;
213         }
214         abort();
215 }
216 static inline int32_t LDKIOError_to_js(LDKIOError val) {
217         switch (val) {
218                 case LDKIOError_NotFound: return 0;
219                 case LDKIOError_PermissionDenied: return 1;
220                 case LDKIOError_ConnectionRefused: return 2;
221                 case LDKIOError_ConnectionReset: return 3;
222                 case LDKIOError_ConnectionAborted: return 4;
223                 case LDKIOError_NotConnected: return 5;
224                 case LDKIOError_AddrInUse: return 6;
225                 case LDKIOError_AddrNotAvailable: return 7;
226                 case LDKIOError_BrokenPipe: return 8;
227                 case LDKIOError_AlreadyExists: return 9;
228                 case LDKIOError_WouldBlock: return 10;
229                 case LDKIOError_InvalidInput: return 11;
230                 case LDKIOError_InvalidData: return 12;
231                 case LDKIOError_TimedOut: return 13;
232                 case LDKIOError_WriteZero: return 14;
233                 case LDKIOError_Interrupted: return 15;
234                 case LDKIOError_Other: return 16;
235                 case LDKIOError_UnexpectedEof: return 17;
236                 default: abort();
237         }
238 }
239 static inline LDKLevel LDKLevel_from_js(int32_t ord) {
240         switch (ord) {
241                 case 0: return LDKLevel_Gossip;
242                 case 1: return LDKLevel_Trace;
243                 case 2: return LDKLevel_Debug;
244                 case 3: return LDKLevel_Info;
245                 case 4: return LDKLevel_Warn;
246                 case 5: return LDKLevel_Error;
247         }
248         abort();
249 }
250 static inline int32_t LDKLevel_to_js(LDKLevel val) {
251         switch (val) {
252                 case LDKLevel_Gossip: return 0;
253                 case LDKLevel_Trace: return 1;
254                 case LDKLevel_Debug: return 2;
255                 case LDKLevel_Info: return 3;
256                 case LDKLevel_Warn: return 4;
257                 case LDKLevel_Error: return 5;
258                 default: abort();
259         }
260 }
261 static inline LDKNetwork LDKNetwork_from_js(int32_t ord) {
262         switch (ord) {
263                 case 0: return LDKNetwork_Bitcoin;
264                 case 1: return LDKNetwork_Testnet;
265                 case 2: return LDKNetwork_Regtest;
266                 case 3: return LDKNetwork_Signet;
267         }
268         abort();
269 }
270 static inline int32_t LDKNetwork_to_js(LDKNetwork val) {
271         switch (val) {
272                 case LDKNetwork_Bitcoin: return 0;
273                 case LDKNetwork_Testnet: return 1;
274                 case LDKNetwork_Regtest: return 2;
275                 case LDKNetwork_Signet: return 3;
276                 default: abort();
277         }
278 }
279 static inline LDKRecipient LDKRecipient_from_js(int32_t ord) {
280         switch (ord) {
281                 case 0: return LDKRecipient_Node;
282                 case 1: return LDKRecipient_PhantomNode;
283         }
284         abort();
285 }
286 static inline int32_t LDKRecipient_to_js(LDKRecipient val) {
287         switch (val) {
288                 case LDKRecipient_Node: return 0;
289                 case LDKRecipient_PhantomNode: return 1;
290                 default: abort();
291         }
292 }
293 static inline LDKSecp256k1Error LDKSecp256k1Error_from_js(int32_t ord) {
294         switch (ord) {
295                 case 0: return LDKSecp256k1Error_IncorrectSignature;
296                 case 1: return LDKSecp256k1Error_InvalidMessage;
297                 case 2: return LDKSecp256k1Error_InvalidPublicKey;
298                 case 3: return LDKSecp256k1Error_InvalidSignature;
299                 case 4: return LDKSecp256k1Error_InvalidSecretKey;
300                 case 5: return LDKSecp256k1Error_InvalidSharedSecret;
301                 case 6: return LDKSecp256k1Error_InvalidRecoveryId;
302                 case 7: return LDKSecp256k1Error_InvalidTweak;
303                 case 8: return LDKSecp256k1Error_NotEnoughMemory;
304                 case 9: return LDKSecp256k1Error_InvalidPublicKeySum;
305                 case 10: return LDKSecp256k1Error_InvalidParityValue;
306         }
307         abort();
308 }
309 static inline int32_t LDKSecp256k1Error_to_js(LDKSecp256k1Error val) {
310         switch (val) {
311                 case LDKSecp256k1Error_IncorrectSignature: return 0;
312                 case LDKSecp256k1Error_InvalidMessage: return 1;
313                 case LDKSecp256k1Error_InvalidPublicKey: return 2;
314                 case LDKSecp256k1Error_InvalidSignature: return 3;
315                 case LDKSecp256k1Error_InvalidSecretKey: return 4;
316                 case LDKSecp256k1Error_InvalidSharedSecret: return 5;
317                 case LDKSecp256k1Error_InvalidRecoveryId: return 6;
318                 case LDKSecp256k1Error_InvalidTweak: return 7;
319                 case LDKSecp256k1Error_NotEnoughMemory: return 8;
320                 case LDKSecp256k1Error_InvalidPublicKeySum: return 9;
321                 case LDKSecp256k1Error_InvalidParityValue: return 10;
322                 default: abort();
323         }
324 }
325 static inline LDKSemanticError LDKSemanticError_from_js(int32_t ord) {
326         switch (ord) {
327                 case 0: return LDKSemanticError_NoPaymentHash;
328                 case 1: return LDKSemanticError_MultiplePaymentHashes;
329                 case 2: return LDKSemanticError_NoDescription;
330                 case 3: return LDKSemanticError_MultipleDescriptions;
331                 case 4: return LDKSemanticError_NoPaymentSecret;
332                 case 5: return LDKSemanticError_MultiplePaymentSecrets;
333                 case 6: return LDKSemanticError_InvalidFeatures;
334                 case 7: return LDKSemanticError_InvalidRecoveryId;
335                 case 8: return LDKSemanticError_InvalidSignature;
336                 case 9: return LDKSemanticError_ImpreciseAmount;
337         }
338         abort();
339 }
340 static inline int32_t LDKSemanticError_to_js(LDKSemanticError val) {
341         switch (val) {
342                 case LDKSemanticError_NoPaymentHash: return 0;
343                 case LDKSemanticError_MultiplePaymentHashes: return 1;
344                 case LDKSemanticError_NoDescription: return 2;
345                 case LDKSemanticError_MultipleDescriptions: return 3;
346                 case LDKSemanticError_NoPaymentSecret: return 4;
347                 case LDKSemanticError_MultiplePaymentSecrets: return 5;
348                 case LDKSemanticError_InvalidFeatures: return 6;
349                 case LDKSemanticError_InvalidRecoveryId: return 7;
350                 case LDKSemanticError_InvalidSignature: return 8;
351                 case LDKSemanticError_ImpreciseAmount: return 9;
352                 default: abort();
353         }
354 }
355 static inline LDKSiPrefix LDKSiPrefix_from_js(int32_t ord) {
356         switch (ord) {
357                 case 0: return LDKSiPrefix_Milli;
358                 case 1: return LDKSiPrefix_Micro;
359                 case 2: return LDKSiPrefix_Nano;
360                 case 3: return LDKSiPrefix_Pico;
361         }
362         abort();
363 }
364 static inline int32_t LDKSiPrefix_to_js(LDKSiPrefix val) {
365         switch (val) {
366                 case LDKSiPrefix_Milli: return 0;
367                 case LDKSiPrefix_Micro: return 1;
368                 case LDKSiPrefix_Nano: return 2;
369                 case LDKSiPrefix_Pico: return 3;
370                 default: abort();
371         }
372 }
373 uint32_t __attribute__((export_name("TS_LDKBech32Error_ty_from_ptr"))) TS_LDKBech32Error_ty_from_ptr(uint32_t ptr) {
374         LDKBech32Error *obj = (LDKBech32Error*)(ptr & ~1);
375         switch(obj->tag) {
376                 case LDKBech32Error_MissingSeparator: return 0;
377                 case LDKBech32Error_InvalidChecksum: return 1;
378                 case LDKBech32Error_InvalidLength: return 2;
379                 case LDKBech32Error_InvalidChar: return 3;
380                 case LDKBech32Error_InvalidData: return 4;
381                 case LDKBech32Error_InvalidPadding: return 5;
382                 case LDKBech32Error_MixedCase: return 6;
383                 default: abort();
384         }
385 }
386 int32_t __attribute__((export_name("TS_LDKBech32Error_InvalidChar_get_invalid_char"))) TS_LDKBech32Error_InvalidChar_get_invalid_char(uint32_t ptr) {
387         LDKBech32Error *obj = (LDKBech32Error*)(ptr & ~1);
388         assert(obj->tag == LDKBech32Error_InvalidChar);
389                         int32_t invalid_char_conv = obj->invalid_char;
390         return invalid_char_conv;
391 }
392 int8_t __attribute__((export_name("TS_LDKBech32Error_InvalidData_get_invalid_data"))) TS_LDKBech32Error_InvalidData_get_invalid_data(uint32_t ptr) {
393         LDKBech32Error *obj = (LDKBech32Error*)(ptr & ~1);
394         assert(obj->tag == LDKBech32Error_InvalidData);
395                         int8_t invalid_data_conv = obj->invalid_data;
396         return invalid_data_conv;
397 }
398 static inline LDKCVec_u8Z CVec_u8Z_clone(const LDKCVec_u8Z *orig) {
399         LDKCVec_u8Z ret = { .data = MALLOC(sizeof(int8_t) * orig->datalen, "LDKCVec_u8Z clone bytes"), .datalen = orig->datalen };
400         memcpy(ret.data, orig->data, sizeof(int8_t) * ret.datalen);
401         return ret;
402 }
403 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(uint32_t thing) {
404         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
405         LDKCVec_u8Z ret_var = TxOut_get_script_pubkey(thing_conv);
406         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
407         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
408         CVec_u8Z_free(ret_var);
409         return ret_arr;
410 }
411
412 uint64_t TxOut_get_value (struct LDKTxOut* thing) {     return thing->value;}int64_t  __attribute__((export_name("TS_TxOut_get_value"))) TS_TxOut_get_value(uint32_t thing) {
413         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
414         int64_t ret_conv = TxOut_get_value(thing_conv);
415         return ret_conv;
416 }
417
418 static inline void CResult_NoneNoneZ_get_ok(LDKCResult_NoneNoneZ *NONNULL_PTR owner){
419 CHECK(owner->result_ok);
420         return *owner->contents.result;
421 }
422 void  __attribute__((export_name("TS_CResult_NoneNoneZ_get_ok"))) TS_CResult_NoneNoneZ_get_ok(uint32_t owner) {
423         LDKCResult_NoneNoneZ* owner_conv = (LDKCResult_NoneNoneZ*)(owner & ~1);
424         CResult_NoneNoneZ_get_ok(owner_conv);
425 }
426
427 static inline void CResult_NoneNoneZ_get_err(LDKCResult_NoneNoneZ *NONNULL_PTR owner){
428 CHECK(!owner->result_ok);
429         return *owner->contents.err;
430 }
431 void  __attribute__((export_name("TS_CResult_NoneNoneZ_get_err"))) TS_CResult_NoneNoneZ_get_err(uint32_t owner) {
432         LDKCResult_NoneNoneZ* owner_conv = (LDKCResult_NoneNoneZ*)(owner & ~1);
433         CResult_NoneNoneZ_get_err(owner_conv);
434 }
435
436 static inline struct LDKCounterpartyCommitmentSecrets CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR owner){
437 CHECK(owner->result_ok);
438         return CounterpartyCommitmentSecrets_clone(&*owner->contents.result);
439 }
440 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(uint32_t owner) {
441         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(owner & ~1);
442         LDKCounterpartyCommitmentSecrets ret_var = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(owner_conv);
443         uint32_t ret_ref = 0;
444         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
445         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
446         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
447         ret_ref = (uintptr_t)ret_var.inner;
448         if (ret_var.is_owned) {
449                 ret_ref |= 1;
450         }
451         return ret_ref;
452 }
453
454 static inline struct LDKDecodeError CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR owner){
455 CHECK(!owner->result_ok);
456         return DecodeError_clone(&*owner->contents.err);
457 }
458 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(uint32_t owner) {
459         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(owner & ~1);
460         LDKDecodeError ret_var = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(owner_conv);
461         uint32_t ret_ref = 0;
462         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
463         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
464         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
465         ret_ref = (uintptr_t)ret_var.inner;
466         if (ret_var.is_owned) {
467                 ret_ref |= 1;
468         }
469         return ret_ref;
470 }
471
472 static inline struct LDKSecretKey CResult_SecretKeyErrorZ_get_ok(LDKCResult_SecretKeyErrorZ *NONNULL_PTR owner){
473 CHECK(owner->result_ok);
474         return *owner->contents.result;
475 }
476 int8_tArray  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_get_ok"))) TS_CResult_SecretKeyErrorZ_get_ok(uint32_t owner) {
477         LDKCResult_SecretKeyErrorZ* owner_conv = (LDKCResult_SecretKeyErrorZ*)(owner & ~1);
478         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
479         memcpy(ret_arr->elems, CResult_SecretKeyErrorZ_get_ok(owner_conv).bytes, 32);
480         return ret_arr;
481 }
482
483 static inline enum LDKSecp256k1Error CResult_SecretKeyErrorZ_get_err(LDKCResult_SecretKeyErrorZ *NONNULL_PTR owner){
484 CHECK(!owner->result_ok);
485         return *owner->contents.err;
486 }
487 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_get_err"))) TS_CResult_SecretKeyErrorZ_get_err(uint32_t owner) {
488         LDKCResult_SecretKeyErrorZ* owner_conv = (LDKCResult_SecretKeyErrorZ*)(owner & ~1);
489         uint32_t ret_conv = LDKSecp256k1Error_to_js(CResult_SecretKeyErrorZ_get_err(owner_conv));
490         return ret_conv;
491 }
492
493 static inline struct LDKPublicKey CResult_PublicKeyErrorZ_get_ok(LDKCResult_PublicKeyErrorZ *NONNULL_PTR owner){
494 CHECK(owner->result_ok);
495         return *owner->contents.result;
496 }
497 int8_tArray  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_get_ok"))) TS_CResult_PublicKeyErrorZ_get_ok(uint32_t owner) {
498         LDKCResult_PublicKeyErrorZ* owner_conv = (LDKCResult_PublicKeyErrorZ*)(owner & ~1);
499         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
500         memcpy(ret_arr->elems, CResult_PublicKeyErrorZ_get_ok(owner_conv).compressed_form, 33);
501         return ret_arr;
502 }
503
504 static inline enum LDKSecp256k1Error CResult_PublicKeyErrorZ_get_err(LDKCResult_PublicKeyErrorZ *NONNULL_PTR owner){
505 CHECK(!owner->result_ok);
506         return *owner->contents.err;
507 }
508 uint32_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_get_err"))) TS_CResult_PublicKeyErrorZ_get_err(uint32_t owner) {
509         LDKCResult_PublicKeyErrorZ* owner_conv = (LDKCResult_PublicKeyErrorZ*)(owner & ~1);
510         uint32_t ret_conv = LDKSecp256k1Error_to_js(CResult_PublicKeyErrorZ_get_err(owner_conv));
511         return ret_conv;
512 }
513
514 static inline struct LDKTxCreationKeys CResult_TxCreationKeysDecodeErrorZ_get_ok(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR owner){
515 CHECK(owner->result_ok);
516         return TxCreationKeys_clone(&*owner->contents.result);
517 }
518 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_get_ok"))) TS_CResult_TxCreationKeysDecodeErrorZ_get_ok(uint32_t owner) {
519         LDKCResult_TxCreationKeysDecodeErrorZ* owner_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(owner & ~1);
520         LDKTxCreationKeys ret_var = CResult_TxCreationKeysDecodeErrorZ_get_ok(owner_conv);
521         uint32_t ret_ref = 0;
522         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
523         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
524         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
525         ret_ref = (uintptr_t)ret_var.inner;
526         if (ret_var.is_owned) {
527                 ret_ref |= 1;
528         }
529         return ret_ref;
530 }
531
532 static inline struct LDKDecodeError CResult_TxCreationKeysDecodeErrorZ_get_err(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR owner){
533 CHECK(!owner->result_ok);
534         return DecodeError_clone(&*owner->contents.err);
535 }
536 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_get_err"))) TS_CResult_TxCreationKeysDecodeErrorZ_get_err(uint32_t owner) {
537         LDKCResult_TxCreationKeysDecodeErrorZ* owner_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(owner & ~1);
538         LDKDecodeError ret_var = CResult_TxCreationKeysDecodeErrorZ_get_err(owner_conv);
539         uint32_t ret_ref = 0;
540         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
541         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
542         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
543         ret_ref = (uintptr_t)ret_var.inner;
544         if (ret_var.is_owned) {
545                 ret_ref |= 1;
546         }
547         return ret_ref;
548 }
549
550 static inline struct LDKChannelPublicKeys CResult_ChannelPublicKeysDecodeErrorZ_get_ok(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR owner){
551 CHECK(owner->result_ok);
552         return ChannelPublicKeys_clone(&*owner->contents.result);
553 }
554 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_get_ok"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_get_ok(uint32_t owner) {
555         LDKCResult_ChannelPublicKeysDecodeErrorZ* owner_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(owner & ~1);
556         LDKChannelPublicKeys ret_var = CResult_ChannelPublicKeysDecodeErrorZ_get_ok(owner_conv);
557         uint32_t ret_ref = 0;
558         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
559         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
560         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
561         ret_ref = (uintptr_t)ret_var.inner;
562         if (ret_var.is_owned) {
563                 ret_ref |= 1;
564         }
565         return ret_ref;
566 }
567
568 static inline struct LDKDecodeError CResult_ChannelPublicKeysDecodeErrorZ_get_err(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR owner){
569 CHECK(!owner->result_ok);
570         return DecodeError_clone(&*owner->contents.err);
571 }
572 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_get_err"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_get_err(uint32_t owner) {
573         LDKCResult_ChannelPublicKeysDecodeErrorZ* owner_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(owner & ~1);
574         LDKDecodeError ret_var = CResult_ChannelPublicKeysDecodeErrorZ_get_err(owner_conv);
575         uint32_t ret_ref = 0;
576         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
577         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
578         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
579         ret_ref = (uintptr_t)ret_var.inner;
580         if (ret_var.is_owned) {
581                 ret_ref |= 1;
582         }
583         return ret_ref;
584 }
585
586 static inline struct LDKTxCreationKeys CResult_TxCreationKeysErrorZ_get_ok(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR owner){
587 CHECK(owner->result_ok);
588         return TxCreationKeys_clone(&*owner->contents.result);
589 }
590 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_get_ok"))) TS_CResult_TxCreationKeysErrorZ_get_ok(uint32_t owner) {
591         LDKCResult_TxCreationKeysErrorZ* owner_conv = (LDKCResult_TxCreationKeysErrorZ*)(owner & ~1);
592         LDKTxCreationKeys ret_var = CResult_TxCreationKeysErrorZ_get_ok(owner_conv);
593         uint32_t ret_ref = 0;
594         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
595         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
596         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
597         ret_ref = (uintptr_t)ret_var.inner;
598         if (ret_var.is_owned) {
599                 ret_ref |= 1;
600         }
601         return ret_ref;
602 }
603
604 static inline enum LDKSecp256k1Error CResult_TxCreationKeysErrorZ_get_err(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR owner){
605 CHECK(!owner->result_ok);
606         return *owner->contents.err;
607 }
608 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_get_err"))) TS_CResult_TxCreationKeysErrorZ_get_err(uint32_t owner) {
609         LDKCResult_TxCreationKeysErrorZ* owner_conv = (LDKCResult_TxCreationKeysErrorZ*)(owner & ~1);
610         uint32_t ret_conv = LDKSecp256k1Error_to_js(CResult_TxCreationKeysErrorZ_get_err(owner_conv));
611         return ret_conv;
612 }
613
614 uint32_t __attribute__((export_name("TS_LDKCOption_u32Z_ty_from_ptr"))) TS_LDKCOption_u32Z_ty_from_ptr(uint32_t ptr) {
615         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)(ptr & ~1);
616         switch(obj->tag) {
617                 case LDKCOption_u32Z_Some: return 0;
618                 case LDKCOption_u32Z_None: return 1;
619                 default: abort();
620         }
621 }
622 int32_t __attribute__((export_name("TS_LDKCOption_u32Z_Some_get_some"))) TS_LDKCOption_u32Z_Some_get_some(uint32_t ptr) {
623         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)(ptr & ~1);
624         assert(obj->tag == LDKCOption_u32Z_Some);
625                         int32_t some_conv = obj->some;
626         return some_conv;
627 }
628 static inline struct LDKHTLCOutputInCommitment CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR owner){
629 CHECK(owner->result_ok);
630         return HTLCOutputInCommitment_clone(&*owner->contents.result);
631 }
632 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(uint32_t owner) {
633         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* owner_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(owner & ~1);
634         LDKHTLCOutputInCommitment ret_var = CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(owner_conv);
635         uint32_t ret_ref = 0;
636         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
637         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
638         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
639         ret_ref = (uintptr_t)ret_var.inner;
640         if (ret_var.is_owned) {
641                 ret_ref |= 1;
642         }
643         return ret_ref;
644 }
645
646 static inline struct LDKDecodeError CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR owner){
647 CHECK(!owner->result_ok);
648         return DecodeError_clone(&*owner->contents.err);
649 }
650 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(uint32_t owner) {
651         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* owner_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(owner & ~1);
652         LDKDecodeError ret_var = CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(owner_conv);
653         uint32_t ret_ref = 0;
654         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
655         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
656         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
657         ret_ref = (uintptr_t)ret_var.inner;
658         if (ret_var.is_owned) {
659                 ret_ref |= 1;
660         }
661         return ret_ref;
662 }
663
664 static inline struct LDKCounterpartyChannelTransactionParameters CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
665 CHECK(owner->result_ok);
666         return CounterpartyChannelTransactionParameters_clone(&*owner->contents.result);
667 }
668 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(uint32_t owner) {
669         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
670         LDKCounterpartyChannelTransactionParameters ret_var = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(owner_conv);
671         uint32_t ret_ref = 0;
672         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
673         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
674         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
675         ret_ref = (uintptr_t)ret_var.inner;
676         if (ret_var.is_owned) {
677                 ret_ref |= 1;
678         }
679         return ret_ref;
680 }
681
682 static inline struct LDKDecodeError CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
683 CHECK(!owner->result_ok);
684         return DecodeError_clone(&*owner->contents.err);
685 }
686 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(uint32_t owner) {
687         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
688         LDKDecodeError ret_var = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(owner_conv);
689         uint32_t ret_ref = 0;
690         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
691         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
692         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
693         ret_ref = (uintptr_t)ret_var.inner;
694         if (ret_var.is_owned) {
695                 ret_ref |= 1;
696         }
697         return ret_ref;
698 }
699
700 static inline struct LDKChannelTransactionParameters CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
701 CHECK(owner->result_ok);
702         return ChannelTransactionParameters_clone(&*owner->contents.result);
703 }
704 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_get_ok"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(uint32_t owner) {
705         LDKCResult_ChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
706         LDKChannelTransactionParameters ret_var = CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(owner_conv);
707         uint32_t ret_ref = 0;
708         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
709         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
710         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
711         ret_ref = (uintptr_t)ret_var.inner;
712         if (ret_var.is_owned) {
713                 ret_ref |= 1;
714         }
715         return ret_ref;
716 }
717
718 static inline struct LDKDecodeError CResult_ChannelTransactionParametersDecodeErrorZ_get_err(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
719 CHECK(!owner->result_ok);
720         return DecodeError_clone(&*owner->contents.err);
721 }
722 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_get_err"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_get_err(uint32_t owner) {
723         LDKCResult_ChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
724         LDKDecodeError ret_var = CResult_ChannelTransactionParametersDecodeErrorZ_get_err(owner_conv);
725         uint32_t ret_ref = 0;
726         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
727         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
728         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
729         ret_ref = (uintptr_t)ret_var.inner;
730         if (ret_var.is_owned) {
731                 ret_ref |= 1;
732         }
733         return ret_ref;
734 }
735
736 static inline struct LDKHolderCommitmentTransaction CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
737 CHECK(owner->result_ok);
738         return HolderCommitmentTransaction_clone(&*owner->contents.result);
739 }
740 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(uint32_t owner) {
741         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(owner & ~1);
742         LDKHolderCommitmentTransaction ret_var = CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
743         uint32_t ret_ref = 0;
744         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
745         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
746         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
747         ret_ref = (uintptr_t)ret_var.inner;
748         if (ret_var.is_owned) {
749                 ret_ref |= 1;
750         }
751         return ret_ref;
752 }
753
754 static inline struct LDKDecodeError CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
755 CHECK(!owner->result_ok);
756         return DecodeError_clone(&*owner->contents.err);
757 }
758 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_get_err"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(uint32_t owner) {
759         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(owner & ~1);
760         LDKDecodeError ret_var = CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(owner_conv);
761         uint32_t ret_ref = 0;
762         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
763         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
764         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
765         ret_ref = (uintptr_t)ret_var.inner;
766         if (ret_var.is_owned) {
767                 ret_ref |= 1;
768         }
769         return ret_ref;
770 }
771
772 static inline struct LDKBuiltCommitmentTransaction CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
773 CHECK(owner->result_ok);
774         return BuiltCommitmentTransaction_clone(&*owner->contents.result);
775 }
776 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(uint32_t owner) {
777         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(owner & ~1);
778         LDKBuiltCommitmentTransaction ret_var = CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
779         uint32_t ret_ref = 0;
780         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
781         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
782         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
783         ret_ref = (uintptr_t)ret_var.inner;
784         if (ret_var.is_owned) {
785                 ret_ref |= 1;
786         }
787         return ret_ref;
788 }
789
790 static inline struct LDKDecodeError CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
791 CHECK(!owner->result_ok);
792         return DecodeError_clone(&*owner->contents.err);
793 }
794 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(uint32_t owner) {
795         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(owner & ~1);
796         LDKDecodeError ret_var = CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(owner_conv);
797         uint32_t ret_ref = 0;
798         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
799         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
800         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
801         ret_ref = (uintptr_t)ret_var.inner;
802         if (ret_var.is_owned) {
803                 ret_ref |= 1;
804         }
805         return ret_ref;
806 }
807
808 static inline struct LDKTrustedClosingTransaction *CResult_TrustedClosingTransactionNoneZ_get_ok(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner){
809 CHECK(owner->result_ok);
810         return &*owner->contents.result;
811 }
812 uint32_t  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_get_ok"))) TS_CResult_TrustedClosingTransactionNoneZ_get_ok(uint32_t owner) {
813         LDKCResult_TrustedClosingTransactionNoneZ* owner_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(owner & ~1);
814         LDKTrustedClosingTransaction ret_var = *CResult_TrustedClosingTransactionNoneZ_get_ok(owner_conv);
815         uint32_t ret_ref = 0;
816         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
817         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
818         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
819         ret_ref = (uintptr_t)ret_var.inner & ~1;
820         return ret_ref;
821 }
822
823 static inline void CResult_TrustedClosingTransactionNoneZ_get_err(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner){
824 CHECK(!owner->result_ok);
825         return *owner->contents.err;
826 }
827 void  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_get_err"))) TS_CResult_TrustedClosingTransactionNoneZ_get_err(uint32_t owner) {
828         LDKCResult_TrustedClosingTransactionNoneZ* owner_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(owner & ~1);
829         CResult_TrustedClosingTransactionNoneZ_get_err(owner_conv);
830 }
831
832 static inline struct LDKCommitmentTransaction CResult_CommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
833 CHECK(owner->result_ok);
834         return CommitmentTransaction_clone(&*owner->contents.result);
835 }
836 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_get_ok"))) TS_CResult_CommitmentTransactionDecodeErrorZ_get_ok(uint32_t owner) {
837         LDKCResult_CommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(owner & ~1);
838         LDKCommitmentTransaction ret_var = CResult_CommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
839         uint32_t ret_ref = 0;
840         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
841         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
842         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
843         ret_ref = (uintptr_t)ret_var.inner;
844         if (ret_var.is_owned) {
845                 ret_ref |= 1;
846         }
847         return ret_ref;
848 }
849
850 static inline struct LDKDecodeError CResult_CommitmentTransactionDecodeErrorZ_get_err(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
851 CHECK(!owner->result_ok);
852         return DecodeError_clone(&*owner->contents.err);
853 }
854 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_get_err"))) TS_CResult_CommitmentTransactionDecodeErrorZ_get_err(uint32_t owner) {
855         LDKCResult_CommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(owner & ~1);
856         LDKDecodeError ret_var = CResult_CommitmentTransactionDecodeErrorZ_get_err(owner_conv);
857         uint32_t ret_ref = 0;
858         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
859         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
860         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
861         ret_ref = (uintptr_t)ret_var.inner;
862         if (ret_var.is_owned) {
863                 ret_ref |= 1;
864         }
865         return ret_ref;
866 }
867
868 static inline struct LDKTrustedCommitmentTransaction *CResult_TrustedCommitmentTransactionNoneZ_get_ok(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner){
869 CHECK(owner->result_ok);
870         return &*owner->contents.result;
871 }
872 uint32_t  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_get_ok"))) TS_CResult_TrustedCommitmentTransactionNoneZ_get_ok(uint32_t owner) {
873         LDKCResult_TrustedCommitmentTransactionNoneZ* owner_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(owner & ~1);
874         LDKTrustedCommitmentTransaction ret_var = *CResult_TrustedCommitmentTransactionNoneZ_get_ok(owner_conv);
875         uint32_t ret_ref = 0;
876         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
877         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
878         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
879         ret_ref = (uintptr_t)ret_var.inner & ~1;
880         return ret_ref;
881 }
882
883 static inline void CResult_TrustedCommitmentTransactionNoneZ_get_err(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner){
884 CHECK(!owner->result_ok);
885         return *owner->contents.err;
886 }
887 void  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_get_err"))) TS_CResult_TrustedCommitmentTransactionNoneZ_get_err(uint32_t owner) {
888         LDKCResult_TrustedCommitmentTransactionNoneZ* owner_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(owner & ~1);
889         CResult_TrustedCommitmentTransactionNoneZ_get_err(owner_conv);
890 }
891
892 static inline struct LDKCVec_SignatureZ CResult_CVec_SignatureZNoneZ_get_ok(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR owner){
893 CHECK(owner->result_ok);
894         return *owner->contents.result;
895 }
896 ptrArray  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_get_ok"))) TS_CResult_CVec_SignatureZNoneZ_get_ok(uint32_t owner) {
897         LDKCResult_CVec_SignatureZNoneZ* owner_conv = (LDKCResult_CVec_SignatureZNoneZ*)(owner & ~1);
898         LDKCVec_SignatureZ ret_var = CResult_CVec_SignatureZNoneZ_get_ok(owner_conv);
899         ptrArray ret_arr = NULL;
900         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
901         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 8);
902         for (size_t m = 0; m < ret_var.datalen; m++) {
903                 int8_tArray ret_conv_12_arr = init_int8_tArray(64, __LINE__);
904                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].compact_form, 64);
905                 ret_arr_ptr[m] = ret_conv_12_arr;
906         }
907         
908         return ret_arr;
909 }
910
911 static inline void CResult_CVec_SignatureZNoneZ_get_err(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR owner){
912 CHECK(!owner->result_ok);
913         return *owner->contents.err;
914 }
915 void  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_get_err"))) TS_CResult_CVec_SignatureZNoneZ_get_err(uint32_t owner) {
916         LDKCResult_CVec_SignatureZNoneZ* owner_conv = (LDKCResult_CVec_SignatureZNoneZ*)(owner & ~1);
917         CResult_CVec_SignatureZNoneZ_get_err(owner_conv);
918 }
919
920 static inline struct LDKShutdownScript CResult_ShutdownScriptDecodeErrorZ_get_ok(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR owner){
921 CHECK(owner->result_ok);
922         return ShutdownScript_clone(&*owner->contents.result);
923 }
924 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_get_ok"))) TS_CResult_ShutdownScriptDecodeErrorZ_get_ok(uint32_t owner) {
925         LDKCResult_ShutdownScriptDecodeErrorZ* owner_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(owner & ~1);
926         LDKShutdownScript ret_var = CResult_ShutdownScriptDecodeErrorZ_get_ok(owner_conv);
927         uint32_t ret_ref = 0;
928         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
929         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
930         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
931         ret_ref = (uintptr_t)ret_var.inner;
932         if (ret_var.is_owned) {
933                 ret_ref |= 1;
934         }
935         return ret_ref;
936 }
937
938 static inline struct LDKDecodeError CResult_ShutdownScriptDecodeErrorZ_get_err(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR owner){
939 CHECK(!owner->result_ok);
940         return DecodeError_clone(&*owner->contents.err);
941 }
942 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_get_err"))) TS_CResult_ShutdownScriptDecodeErrorZ_get_err(uint32_t owner) {
943         LDKCResult_ShutdownScriptDecodeErrorZ* owner_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(owner & ~1);
944         LDKDecodeError ret_var = CResult_ShutdownScriptDecodeErrorZ_get_err(owner_conv);
945         uint32_t ret_ref = 0;
946         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
947         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
948         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
949         ret_ref = (uintptr_t)ret_var.inner;
950         if (ret_var.is_owned) {
951                 ret_ref |= 1;
952         }
953         return ret_ref;
954 }
955
956 static inline struct LDKShutdownScript CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR owner){
957 CHECK(owner->result_ok);
958         return ShutdownScript_clone(&*owner->contents.result);
959 }
960 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(uint32_t owner) {
961         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* owner_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(owner & ~1);
962         LDKShutdownScript ret_var = CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(owner_conv);
963         uint32_t ret_ref = 0;
964         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
965         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
966         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
967         ret_ref = (uintptr_t)ret_var.inner;
968         if (ret_var.is_owned) {
969                 ret_ref |= 1;
970         }
971         return ret_ref;
972 }
973
974 static inline struct LDKInvalidShutdownScript CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR owner){
975 CHECK(!owner->result_ok);
976         return InvalidShutdownScript_clone(&*owner->contents.err);
977 }
978 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_get_err"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(uint32_t owner) {
979         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* owner_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(owner & ~1);
980         LDKInvalidShutdownScript ret_var = CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(owner_conv);
981         uint32_t ret_ref = 0;
982         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
983         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
984         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
985         ret_ref = (uintptr_t)ret_var.inner;
986         if (ret_var.is_owned) {
987                 ret_ref |= 1;
988         }
989         return ret_ref;
990 }
991
992 static inline struct LDKRouteHop CResult_RouteHopDecodeErrorZ_get_ok(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR owner){
993 CHECK(owner->result_ok);
994         return RouteHop_clone(&*owner->contents.result);
995 }
996 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_get_ok"))) TS_CResult_RouteHopDecodeErrorZ_get_ok(uint32_t owner) {
997         LDKCResult_RouteHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHopDecodeErrorZ*)(owner & ~1);
998         LDKRouteHop ret_var = CResult_RouteHopDecodeErrorZ_get_ok(owner_conv);
999         uint32_t ret_ref = 0;
1000         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1001         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1002         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1003         ret_ref = (uintptr_t)ret_var.inner;
1004         if (ret_var.is_owned) {
1005                 ret_ref |= 1;
1006         }
1007         return ret_ref;
1008 }
1009
1010 static inline struct LDKDecodeError CResult_RouteHopDecodeErrorZ_get_err(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR owner){
1011 CHECK(!owner->result_ok);
1012         return DecodeError_clone(&*owner->contents.err);
1013 }
1014 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_get_err"))) TS_CResult_RouteHopDecodeErrorZ_get_err(uint32_t owner) {
1015         LDKCResult_RouteHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHopDecodeErrorZ*)(owner & ~1);
1016         LDKDecodeError ret_var = CResult_RouteHopDecodeErrorZ_get_err(owner_conv);
1017         uint32_t ret_ref = 0;
1018         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1019         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1020         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1021         ret_ref = (uintptr_t)ret_var.inner;
1022         if (ret_var.is_owned) {
1023                 ret_ref |= 1;
1024         }
1025         return ret_ref;
1026 }
1027
1028 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
1029         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
1030         for (size_t i = 0; i < ret.datalen; i++) {
1031                 ret.data[i] = RouteHop_clone(&orig->data[i]);
1032         }
1033         return ret;
1034 }
1035 static inline LDKCVec_CVec_RouteHopZZ CVec_CVec_RouteHopZZ_clone(const LDKCVec_CVec_RouteHopZZ *orig) {
1036         LDKCVec_CVec_RouteHopZZ ret = { .data = MALLOC(sizeof(LDKCVec_RouteHopZ) * orig->datalen, "LDKCVec_CVec_RouteHopZZ clone bytes"), .datalen = orig->datalen };
1037         for (size_t i = 0; i < ret.datalen; i++) {
1038                 ret.data[i] = CVec_RouteHopZ_clone(&orig->data[i]);
1039         }
1040         return ret;
1041 }
1042 static inline struct LDKRoute CResult_RouteDecodeErrorZ_get_ok(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR owner){
1043 CHECK(owner->result_ok);
1044         return Route_clone(&*owner->contents.result);
1045 }
1046 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_get_ok"))) TS_CResult_RouteDecodeErrorZ_get_ok(uint32_t owner) {
1047         LDKCResult_RouteDecodeErrorZ* owner_conv = (LDKCResult_RouteDecodeErrorZ*)(owner & ~1);
1048         LDKRoute ret_var = CResult_RouteDecodeErrorZ_get_ok(owner_conv);
1049         uint32_t ret_ref = 0;
1050         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1051         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1052         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1053         ret_ref = (uintptr_t)ret_var.inner;
1054         if (ret_var.is_owned) {
1055                 ret_ref |= 1;
1056         }
1057         return ret_ref;
1058 }
1059
1060 static inline struct LDKDecodeError CResult_RouteDecodeErrorZ_get_err(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR owner){
1061 CHECK(!owner->result_ok);
1062         return DecodeError_clone(&*owner->contents.err);
1063 }
1064 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_get_err"))) TS_CResult_RouteDecodeErrorZ_get_err(uint32_t owner) {
1065         LDKCResult_RouteDecodeErrorZ* owner_conv = (LDKCResult_RouteDecodeErrorZ*)(owner & ~1);
1066         LDKDecodeError ret_var = CResult_RouteDecodeErrorZ_get_err(owner_conv);
1067         uint32_t ret_ref = 0;
1068         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1069         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1070         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1071         ret_ref = (uintptr_t)ret_var.inner;
1072         if (ret_var.is_owned) {
1073                 ret_ref |= 1;
1074         }
1075         return ret_ref;
1076 }
1077
1078 static inline struct LDKRouteParameters CResult_RouteParametersDecodeErrorZ_get_ok(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR owner){
1079 CHECK(owner->result_ok);
1080         return RouteParameters_clone(&*owner->contents.result);
1081 }
1082 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_get_ok"))) TS_CResult_RouteParametersDecodeErrorZ_get_ok(uint32_t owner) {
1083         LDKCResult_RouteParametersDecodeErrorZ* owner_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(owner & ~1);
1084         LDKRouteParameters ret_var = CResult_RouteParametersDecodeErrorZ_get_ok(owner_conv);
1085         uint32_t ret_ref = 0;
1086         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1087         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1088         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1089         ret_ref = (uintptr_t)ret_var.inner;
1090         if (ret_var.is_owned) {
1091                 ret_ref |= 1;
1092         }
1093         return ret_ref;
1094 }
1095
1096 static inline struct LDKDecodeError CResult_RouteParametersDecodeErrorZ_get_err(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR owner){
1097 CHECK(!owner->result_ok);
1098         return DecodeError_clone(&*owner->contents.err);
1099 }
1100 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_get_err"))) TS_CResult_RouteParametersDecodeErrorZ_get_err(uint32_t owner) {
1101         LDKCResult_RouteParametersDecodeErrorZ* owner_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(owner & ~1);
1102         LDKDecodeError ret_var = CResult_RouteParametersDecodeErrorZ_get_err(owner_conv);
1103         uint32_t ret_ref = 0;
1104         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1105         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1106         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1107         ret_ref = (uintptr_t)ret_var.inner;
1108         if (ret_var.is_owned) {
1109                 ret_ref |= 1;
1110         }
1111         return ret_ref;
1112 }
1113
1114 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
1115         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
1116         for (size_t i = 0; i < ret.datalen; i++) {
1117                 ret.data[i] = RouteHint_clone(&orig->data[i]);
1118         }
1119         return ret;
1120 }
1121 uint32_t __attribute__((export_name("TS_LDKCOption_u64Z_ty_from_ptr"))) TS_LDKCOption_u64Z_ty_from_ptr(uint32_t ptr) {
1122         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)(ptr & ~1);
1123         switch(obj->tag) {
1124                 case LDKCOption_u64Z_Some: return 0;
1125                 case LDKCOption_u64Z_None: return 1;
1126                 default: abort();
1127         }
1128 }
1129 int64_t __attribute__((export_name("TS_LDKCOption_u64Z_Some_get_some"))) TS_LDKCOption_u64Z_Some_get_some(uint32_t ptr) {
1130         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)(ptr & ~1);
1131         assert(obj->tag == LDKCOption_u64Z_Some);
1132                         int64_t some_conv = obj->some;
1133         return some_conv;
1134 }
1135 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
1136         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
1137         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
1138         return ret;
1139 }
1140 static inline struct LDKPaymentParameters CResult_PaymentParametersDecodeErrorZ_get_ok(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR owner){
1141 CHECK(owner->result_ok);
1142         return PaymentParameters_clone(&*owner->contents.result);
1143 }
1144 uint32_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_get_ok"))) TS_CResult_PaymentParametersDecodeErrorZ_get_ok(uint32_t owner) {
1145         LDKCResult_PaymentParametersDecodeErrorZ* owner_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(owner & ~1);
1146         LDKPaymentParameters ret_var = CResult_PaymentParametersDecodeErrorZ_get_ok(owner_conv);
1147         uint32_t ret_ref = 0;
1148         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1149         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1150         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1151         ret_ref = (uintptr_t)ret_var.inner;
1152         if (ret_var.is_owned) {
1153                 ret_ref |= 1;
1154         }
1155         return ret_ref;
1156 }
1157
1158 static inline struct LDKDecodeError CResult_PaymentParametersDecodeErrorZ_get_err(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR owner){
1159 CHECK(!owner->result_ok);
1160         return DecodeError_clone(&*owner->contents.err);
1161 }
1162 uint32_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_get_err"))) TS_CResult_PaymentParametersDecodeErrorZ_get_err(uint32_t owner) {
1163         LDKCResult_PaymentParametersDecodeErrorZ* owner_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(owner & ~1);
1164         LDKDecodeError ret_var = CResult_PaymentParametersDecodeErrorZ_get_err(owner_conv);
1165         uint32_t ret_ref = 0;
1166         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1167         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1168         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1169         ret_ref = (uintptr_t)ret_var.inner;
1170         if (ret_var.is_owned) {
1171                 ret_ref |= 1;
1172         }
1173         return ret_ref;
1174 }
1175
1176 static inline LDKCVec_RouteHintHopZ CVec_RouteHintHopZ_clone(const LDKCVec_RouteHintHopZ *orig) {
1177         LDKCVec_RouteHintHopZ ret = { .data = MALLOC(sizeof(LDKRouteHintHop) * orig->datalen, "LDKCVec_RouteHintHopZ clone bytes"), .datalen = orig->datalen };
1178         for (size_t i = 0; i < ret.datalen; i++) {
1179                 ret.data[i] = RouteHintHop_clone(&orig->data[i]);
1180         }
1181         return ret;
1182 }
1183 static inline struct LDKRouteHint CResult_RouteHintDecodeErrorZ_get_ok(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
1184 CHECK(owner->result_ok);
1185         return RouteHint_clone(&*owner->contents.result);
1186 }
1187 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_get_ok"))) TS_CResult_RouteHintDecodeErrorZ_get_ok(uint32_t owner) {
1188         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)(owner & ~1);
1189         LDKRouteHint ret_var = CResult_RouteHintDecodeErrorZ_get_ok(owner_conv);
1190         uint32_t ret_ref = 0;
1191         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1192         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1193         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1194         ret_ref = (uintptr_t)ret_var.inner;
1195         if (ret_var.is_owned) {
1196                 ret_ref |= 1;
1197         }
1198         return ret_ref;
1199 }
1200
1201 static inline struct LDKDecodeError CResult_RouteHintDecodeErrorZ_get_err(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
1202 CHECK(!owner->result_ok);
1203         return DecodeError_clone(&*owner->contents.err);
1204 }
1205 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_get_err"))) TS_CResult_RouteHintDecodeErrorZ_get_err(uint32_t owner) {
1206         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)(owner & ~1);
1207         LDKDecodeError ret_var = CResult_RouteHintDecodeErrorZ_get_err(owner_conv);
1208         uint32_t ret_ref = 0;
1209         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1210         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1211         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1212         ret_ref = (uintptr_t)ret_var.inner;
1213         if (ret_var.is_owned) {
1214                 ret_ref |= 1;
1215         }
1216         return ret_ref;
1217 }
1218
1219 static inline struct LDKRouteHintHop CResult_RouteHintHopDecodeErrorZ_get_ok(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
1220 CHECK(owner->result_ok);
1221         return RouteHintHop_clone(&*owner->contents.result);
1222 }
1223 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_get_ok"))) TS_CResult_RouteHintHopDecodeErrorZ_get_ok(uint32_t owner) {
1224         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(owner & ~1);
1225         LDKRouteHintHop ret_var = CResult_RouteHintHopDecodeErrorZ_get_ok(owner_conv);
1226         uint32_t ret_ref = 0;
1227         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1228         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1229         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1230         ret_ref = (uintptr_t)ret_var.inner;
1231         if (ret_var.is_owned) {
1232                 ret_ref |= 1;
1233         }
1234         return ret_ref;
1235 }
1236
1237 static inline struct LDKDecodeError CResult_RouteHintHopDecodeErrorZ_get_err(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
1238 CHECK(!owner->result_ok);
1239         return DecodeError_clone(&*owner->contents.err);
1240 }
1241 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_get_err"))) TS_CResult_RouteHintHopDecodeErrorZ_get_err(uint32_t owner) {
1242         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(owner & ~1);
1243         LDKDecodeError ret_var = CResult_RouteHintHopDecodeErrorZ_get_err(owner_conv);
1244         uint32_t ret_ref = 0;
1245         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1246         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1247         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1248         ret_ref = (uintptr_t)ret_var.inner;
1249         if (ret_var.is_owned) {
1250                 ret_ref |= 1;
1251         }
1252         return ret_ref;
1253 }
1254
1255 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
1256         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
1257         for (size_t i = 0; i < ret.datalen; i++) {
1258                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
1259         }
1260         return ret;
1261 }
1262 static inline struct LDKRoute CResult_RouteLightningErrorZ_get_ok(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
1263 CHECK(owner->result_ok);
1264         return Route_clone(&*owner->contents.result);
1265 }
1266 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_get_ok"))) TS_CResult_RouteLightningErrorZ_get_ok(uint32_t owner) {
1267         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)(owner & ~1);
1268         LDKRoute ret_var = CResult_RouteLightningErrorZ_get_ok(owner_conv);
1269         uint32_t ret_ref = 0;
1270         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1271         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1272         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1273         ret_ref = (uintptr_t)ret_var.inner;
1274         if (ret_var.is_owned) {
1275                 ret_ref |= 1;
1276         }
1277         return ret_ref;
1278 }
1279
1280 static inline struct LDKLightningError CResult_RouteLightningErrorZ_get_err(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
1281 CHECK(!owner->result_ok);
1282         return LightningError_clone(&*owner->contents.err);
1283 }
1284 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_get_err"))) TS_CResult_RouteLightningErrorZ_get_err(uint32_t owner) {
1285         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)(owner & ~1);
1286         LDKLightningError ret_var = CResult_RouteLightningErrorZ_get_err(owner_conv);
1287         uint32_t ret_ref = 0;
1288         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1289         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1290         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1291         ret_ref = (uintptr_t)ret_var.inner;
1292         if (ret_var.is_owned) {
1293                 ret_ref |= 1;
1294         }
1295         return ret_ref;
1296 }
1297
1298 uint32_t __attribute__((export_name("TS_LDKPaymentPurpose_ty_from_ptr"))) TS_LDKPaymentPurpose_ty_from_ptr(uint32_t ptr) {
1299         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
1300         switch(obj->tag) {
1301                 case LDKPaymentPurpose_InvoicePayment: return 0;
1302                 case LDKPaymentPurpose_SpontaneousPayment: return 1;
1303                 default: abort();
1304         }
1305 }
1306 int8_tArray __attribute__((export_name("TS_LDKPaymentPurpose_InvoicePayment_get_payment_preimage"))) TS_LDKPaymentPurpose_InvoicePayment_get_payment_preimage(uint32_t ptr) {
1307         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
1308         assert(obj->tag == LDKPaymentPurpose_InvoicePayment);
1309                         int8_tArray payment_preimage_arr = init_int8_tArray(32, __LINE__);
1310                         memcpy(payment_preimage_arr->elems, obj->invoice_payment.payment_preimage.data, 32);
1311         return payment_preimage_arr;
1312 }
1313 int8_tArray __attribute__((export_name("TS_LDKPaymentPurpose_InvoicePayment_get_payment_secret"))) TS_LDKPaymentPurpose_InvoicePayment_get_payment_secret(uint32_t ptr) {
1314         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
1315         assert(obj->tag == LDKPaymentPurpose_InvoicePayment);
1316                         int8_tArray payment_secret_arr = init_int8_tArray(32, __LINE__);
1317                         memcpy(payment_secret_arr->elems, obj->invoice_payment.payment_secret.data, 32);
1318         return payment_secret_arr;
1319 }
1320 int8_tArray __attribute__((export_name("TS_LDKPaymentPurpose_SpontaneousPayment_get_spontaneous_payment"))) TS_LDKPaymentPurpose_SpontaneousPayment_get_spontaneous_payment(uint32_t ptr) {
1321         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
1322         assert(obj->tag == LDKPaymentPurpose_SpontaneousPayment);
1323                         int8_tArray spontaneous_payment_arr = init_int8_tArray(32, __LINE__);
1324                         memcpy(spontaneous_payment_arr->elems, obj->spontaneous_payment.data, 32);
1325         return spontaneous_payment_arr;
1326 }
1327 static inline struct LDKPaymentPurpose CResult_PaymentPurposeDecodeErrorZ_get_ok(LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR owner){
1328 CHECK(owner->result_ok);
1329         return PaymentPurpose_clone(&*owner->contents.result);
1330 }
1331 uint32_t  __attribute__((export_name("TS_CResult_PaymentPurposeDecodeErrorZ_get_ok"))) TS_CResult_PaymentPurposeDecodeErrorZ_get_ok(uint32_t owner) {
1332         LDKCResult_PaymentPurposeDecodeErrorZ* owner_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)(owner & ~1);
1333         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
1334         *ret_copy = CResult_PaymentPurposeDecodeErrorZ_get_ok(owner_conv);
1335         uint32_t ret_ref = (uintptr_t)ret_copy;
1336         return ret_ref;
1337 }
1338
1339 static inline struct LDKDecodeError CResult_PaymentPurposeDecodeErrorZ_get_err(LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR owner){
1340 CHECK(!owner->result_ok);
1341         return DecodeError_clone(&*owner->contents.err);
1342 }
1343 uint32_t  __attribute__((export_name("TS_CResult_PaymentPurposeDecodeErrorZ_get_err"))) TS_CResult_PaymentPurposeDecodeErrorZ_get_err(uint32_t owner) {
1344         LDKCResult_PaymentPurposeDecodeErrorZ* owner_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)(owner & ~1);
1345         LDKDecodeError ret_var = CResult_PaymentPurposeDecodeErrorZ_get_err(owner_conv);
1346         uint32_t ret_ref = 0;
1347         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1348         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1349         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1350         ret_ref = (uintptr_t)ret_var.inner;
1351         if (ret_var.is_owned) {
1352                 ret_ref |= 1;
1353         }
1354         return ret_ref;
1355 }
1356
1357 uint32_t __attribute__((export_name("TS_LDKClosureReason_ty_from_ptr"))) TS_LDKClosureReason_ty_from_ptr(uint32_t ptr) {
1358         LDKClosureReason *obj = (LDKClosureReason*)(ptr & ~1);
1359         switch(obj->tag) {
1360                 case LDKClosureReason_CounterpartyForceClosed: return 0;
1361                 case LDKClosureReason_HolderForceClosed: return 1;
1362                 case LDKClosureReason_CooperativeClosure: return 2;
1363                 case LDKClosureReason_CommitmentTxConfirmed: return 3;
1364                 case LDKClosureReason_FundingTimedOut: return 4;
1365                 case LDKClosureReason_ProcessingError: return 5;
1366                 case LDKClosureReason_DisconnectedPeer: return 6;
1367                 case LDKClosureReason_OutdatedChannelManager: return 7;
1368                 default: abort();
1369         }
1370 }
1371 jstring __attribute__((export_name("TS_LDKClosureReason_CounterpartyForceClosed_get_peer_msg"))) TS_LDKClosureReason_CounterpartyForceClosed_get_peer_msg(uint32_t ptr) {
1372         LDKClosureReason *obj = (LDKClosureReason*)(ptr & ~1);
1373         assert(obj->tag == LDKClosureReason_CounterpartyForceClosed);
1374                         LDKStr peer_msg_str = obj->counterparty_force_closed.peer_msg;
1375                         jstring peer_msg_conv = str_ref_to_ts(peer_msg_str.chars, peer_msg_str.len);
1376         return peer_msg_conv;
1377 }
1378 jstring __attribute__((export_name("TS_LDKClosureReason_ProcessingError_get_err"))) TS_LDKClosureReason_ProcessingError_get_err(uint32_t ptr) {
1379         LDKClosureReason *obj = (LDKClosureReason*)(ptr & ~1);
1380         assert(obj->tag == LDKClosureReason_ProcessingError);
1381                         LDKStr err_str = obj->processing_error.err;
1382                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
1383         return err_conv;
1384 }
1385 uint32_t __attribute__((export_name("TS_LDKCOption_ClosureReasonZ_ty_from_ptr"))) TS_LDKCOption_ClosureReasonZ_ty_from_ptr(uint32_t ptr) {
1386         LDKCOption_ClosureReasonZ *obj = (LDKCOption_ClosureReasonZ*)(ptr & ~1);
1387         switch(obj->tag) {
1388                 case LDKCOption_ClosureReasonZ_Some: return 0;
1389                 case LDKCOption_ClosureReasonZ_None: return 1;
1390                 default: abort();
1391         }
1392 }
1393 uint32_t __attribute__((export_name("TS_LDKCOption_ClosureReasonZ_Some_get_some"))) TS_LDKCOption_ClosureReasonZ_Some_get_some(uint32_t ptr) {
1394         LDKCOption_ClosureReasonZ *obj = (LDKCOption_ClosureReasonZ*)(ptr & ~1);
1395         assert(obj->tag == LDKCOption_ClosureReasonZ_Some);
1396                         uint32_t some_ref = ((uintptr_t)&obj->some) | 1;
1397         return some_ref;
1398 }
1399 static inline struct LDKCOption_ClosureReasonZ CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
1400 CHECK(owner->result_ok);
1401         return COption_ClosureReasonZ_clone(&*owner->contents.result);
1402 }
1403 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_get_ok"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(uint32_t owner) {
1404         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(owner & ~1);
1405         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
1406         *ret_copy = CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(owner_conv);
1407         uint32_t ret_ref = (uintptr_t)ret_copy;
1408         return ret_ref;
1409 }
1410
1411 static inline struct LDKDecodeError CResult_COption_ClosureReasonZDecodeErrorZ_get_err(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
1412 CHECK(!owner->result_ok);
1413         return DecodeError_clone(&*owner->contents.err);
1414 }
1415 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_get_err"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_get_err(uint32_t owner) {
1416         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(owner & ~1);
1417         LDKDecodeError ret_var = CResult_COption_ClosureReasonZDecodeErrorZ_get_err(owner_conv);
1418         uint32_t ret_ref = 0;
1419         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1420         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1421         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1422         ret_ref = (uintptr_t)ret_var.inner;
1423         if (ret_var.is_owned) {
1424                 ret_ref |= 1;
1425         }
1426         return ret_ref;
1427 }
1428
1429 uint32_t __attribute__((export_name("TS_LDKHTLCDestination_ty_from_ptr"))) TS_LDKHTLCDestination_ty_from_ptr(uint32_t ptr) {
1430         LDKHTLCDestination *obj = (LDKHTLCDestination*)(ptr & ~1);
1431         switch(obj->tag) {
1432                 case LDKHTLCDestination_NextHopChannel: return 0;
1433                 case LDKHTLCDestination_UnknownNextHop: return 1;
1434                 case LDKHTLCDestination_FailedPayment: return 2;
1435                 default: abort();
1436         }
1437 }
1438 int8_tArray __attribute__((export_name("TS_LDKHTLCDestination_NextHopChannel_get_node_id"))) TS_LDKHTLCDestination_NextHopChannel_get_node_id(uint32_t ptr) {
1439         LDKHTLCDestination *obj = (LDKHTLCDestination*)(ptr & ~1);
1440         assert(obj->tag == LDKHTLCDestination_NextHopChannel);
1441                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
1442                         memcpy(node_id_arr->elems, obj->next_hop_channel.node_id.compressed_form, 33);
1443         return node_id_arr;
1444 }
1445 int8_tArray __attribute__((export_name("TS_LDKHTLCDestination_NextHopChannel_get_channel_id"))) TS_LDKHTLCDestination_NextHopChannel_get_channel_id(uint32_t ptr) {
1446         LDKHTLCDestination *obj = (LDKHTLCDestination*)(ptr & ~1);
1447         assert(obj->tag == LDKHTLCDestination_NextHopChannel);
1448                         int8_tArray channel_id_arr = init_int8_tArray(32, __LINE__);
1449                         memcpy(channel_id_arr->elems, obj->next_hop_channel.channel_id.data, 32);
1450         return channel_id_arr;
1451 }
1452 int64_t __attribute__((export_name("TS_LDKHTLCDestination_UnknownNextHop_get_requested_forward_scid"))) TS_LDKHTLCDestination_UnknownNextHop_get_requested_forward_scid(uint32_t ptr) {
1453         LDKHTLCDestination *obj = (LDKHTLCDestination*)(ptr & ~1);
1454         assert(obj->tag == LDKHTLCDestination_UnknownNextHop);
1455                         int64_t requested_forward_scid_conv = obj->unknown_next_hop.requested_forward_scid;
1456         return requested_forward_scid_conv;
1457 }
1458 int8_tArray __attribute__((export_name("TS_LDKHTLCDestination_FailedPayment_get_payment_hash"))) TS_LDKHTLCDestination_FailedPayment_get_payment_hash(uint32_t ptr) {
1459         LDKHTLCDestination *obj = (LDKHTLCDestination*)(ptr & ~1);
1460         assert(obj->tag == LDKHTLCDestination_FailedPayment);
1461                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1462                         memcpy(payment_hash_arr->elems, obj->failed_payment.payment_hash.data, 32);
1463         return payment_hash_arr;
1464 }
1465 uint32_t __attribute__((export_name("TS_LDKCOption_HTLCDestinationZ_ty_from_ptr"))) TS_LDKCOption_HTLCDestinationZ_ty_from_ptr(uint32_t ptr) {
1466         LDKCOption_HTLCDestinationZ *obj = (LDKCOption_HTLCDestinationZ*)(ptr & ~1);
1467         switch(obj->tag) {
1468                 case LDKCOption_HTLCDestinationZ_Some: return 0;
1469                 case LDKCOption_HTLCDestinationZ_None: return 1;
1470                 default: abort();
1471         }
1472 }
1473 uint32_t __attribute__((export_name("TS_LDKCOption_HTLCDestinationZ_Some_get_some"))) TS_LDKCOption_HTLCDestinationZ_Some_get_some(uint32_t ptr) {
1474         LDKCOption_HTLCDestinationZ *obj = (LDKCOption_HTLCDestinationZ*)(ptr & ~1);
1475         assert(obj->tag == LDKCOption_HTLCDestinationZ_Some);
1476                         uint32_t some_ref = ((uintptr_t)&obj->some) | 1;
1477         return some_ref;
1478 }
1479 static inline struct LDKCOption_HTLCDestinationZ CResult_COption_HTLCDestinationZDecodeErrorZ_get_ok(LDKCResult_COption_HTLCDestinationZDecodeErrorZ *NONNULL_PTR owner){
1480 CHECK(owner->result_ok);
1481         return COption_HTLCDestinationZ_clone(&*owner->contents.result);
1482 }
1483 uint32_t  __attribute__((export_name("TS_CResult_COption_HTLCDestinationZDecodeErrorZ_get_ok"))) TS_CResult_COption_HTLCDestinationZDecodeErrorZ_get_ok(uint32_t owner) {
1484         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* owner_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)(owner & ~1);
1485         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
1486         *ret_copy = CResult_COption_HTLCDestinationZDecodeErrorZ_get_ok(owner_conv);
1487         uint32_t ret_ref = (uintptr_t)ret_copy;
1488         return ret_ref;
1489 }
1490
1491 static inline struct LDKDecodeError CResult_COption_HTLCDestinationZDecodeErrorZ_get_err(LDKCResult_COption_HTLCDestinationZDecodeErrorZ *NONNULL_PTR owner){
1492 CHECK(!owner->result_ok);
1493         return DecodeError_clone(&*owner->contents.err);
1494 }
1495 uint32_t  __attribute__((export_name("TS_CResult_COption_HTLCDestinationZDecodeErrorZ_get_err"))) TS_CResult_COption_HTLCDestinationZDecodeErrorZ_get_err(uint32_t owner) {
1496         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* owner_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)(owner & ~1);
1497         LDKDecodeError ret_var = CResult_COption_HTLCDestinationZDecodeErrorZ_get_err(owner_conv);
1498         uint32_t ret_ref = 0;
1499         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1500         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1501         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1502         ret_ref = (uintptr_t)ret_var.inner;
1503         if (ret_var.is_owned) {
1504                 ret_ref |= 1;
1505         }
1506         return ret_ref;
1507 }
1508
1509 uint32_t __attribute__((export_name("TS_LDKNetworkUpdate_ty_from_ptr"))) TS_LDKNetworkUpdate_ty_from_ptr(uint32_t ptr) {
1510         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1511         switch(obj->tag) {
1512                 case LDKNetworkUpdate_ChannelUpdateMessage: return 0;
1513                 case LDKNetworkUpdate_ChannelFailure: return 1;
1514                 case LDKNetworkUpdate_NodeFailure: return 2;
1515                 default: abort();
1516         }
1517 }
1518 uint32_t __attribute__((export_name("TS_LDKNetworkUpdate_ChannelUpdateMessage_get_msg"))) TS_LDKNetworkUpdate_ChannelUpdateMessage_get_msg(uint32_t ptr) {
1519         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1520         assert(obj->tag == LDKNetworkUpdate_ChannelUpdateMessage);
1521                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
1522                         uint32_t msg_ref = 0;
1523                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1524                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1525                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1526                         msg_ref = (uintptr_t)msg_var.inner & ~1;
1527         return msg_ref;
1528 }
1529 int64_t __attribute__((export_name("TS_LDKNetworkUpdate_ChannelFailure_get_short_channel_id"))) TS_LDKNetworkUpdate_ChannelFailure_get_short_channel_id(uint32_t ptr) {
1530         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1531         assert(obj->tag == LDKNetworkUpdate_ChannelFailure);
1532                         int64_t short_channel_id_conv = obj->channel_failure.short_channel_id;
1533         return short_channel_id_conv;
1534 }
1535 jboolean __attribute__((export_name("TS_LDKNetworkUpdate_ChannelFailure_get_is_permanent"))) TS_LDKNetworkUpdate_ChannelFailure_get_is_permanent(uint32_t ptr) {
1536         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1537         assert(obj->tag == LDKNetworkUpdate_ChannelFailure);
1538                         jboolean is_permanent_conv = obj->channel_failure.is_permanent;
1539         return is_permanent_conv;
1540 }
1541 int8_tArray __attribute__((export_name("TS_LDKNetworkUpdate_NodeFailure_get_node_id"))) TS_LDKNetworkUpdate_NodeFailure_get_node_id(uint32_t ptr) {
1542         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1543         assert(obj->tag == LDKNetworkUpdate_NodeFailure);
1544                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
1545                         memcpy(node_id_arr->elems, obj->node_failure.node_id.compressed_form, 33);
1546         return node_id_arr;
1547 }
1548 jboolean __attribute__((export_name("TS_LDKNetworkUpdate_NodeFailure_get_is_permanent"))) TS_LDKNetworkUpdate_NodeFailure_get_is_permanent(uint32_t ptr) {
1549         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1550         assert(obj->tag == LDKNetworkUpdate_NodeFailure);
1551                         jboolean is_permanent_conv = obj->node_failure.is_permanent;
1552         return is_permanent_conv;
1553 }
1554 uint32_t __attribute__((export_name("TS_LDKCOption_NetworkUpdateZ_ty_from_ptr"))) TS_LDKCOption_NetworkUpdateZ_ty_from_ptr(uint32_t ptr) {
1555         LDKCOption_NetworkUpdateZ *obj = (LDKCOption_NetworkUpdateZ*)(ptr & ~1);
1556         switch(obj->tag) {
1557                 case LDKCOption_NetworkUpdateZ_Some: return 0;
1558                 case LDKCOption_NetworkUpdateZ_None: return 1;
1559                 default: abort();
1560         }
1561 }
1562 uint32_t __attribute__((export_name("TS_LDKCOption_NetworkUpdateZ_Some_get_some"))) TS_LDKCOption_NetworkUpdateZ_Some_get_some(uint32_t ptr) {
1563         LDKCOption_NetworkUpdateZ *obj = (LDKCOption_NetworkUpdateZ*)(ptr & ~1);
1564         assert(obj->tag == LDKCOption_NetworkUpdateZ_Some);
1565                         uint32_t some_ref = ((uintptr_t)&obj->some) | 1;
1566         return some_ref;
1567 }
1568 uint32_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_ty_from_ptr"))) TS_LDKSpendableOutputDescriptor_ty_from_ptr(uint32_t ptr) {
1569         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1570         switch(obj->tag) {
1571                 case LDKSpendableOutputDescriptor_StaticOutput: return 0;
1572                 case LDKSpendableOutputDescriptor_DelayedPaymentOutput: return 1;
1573                 case LDKSpendableOutputDescriptor_StaticPaymentOutput: return 2;
1574                 default: abort();
1575         }
1576 }
1577 uint32_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_StaticOutput_get_outpoint"))) TS_LDKSpendableOutputDescriptor_StaticOutput_get_outpoint(uint32_t ptr) {
1578         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1579         assert(obj->tag == LDKSpendableOutputDescriptor_StaticOutput);
1580                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
1581                         uint32_t outpoint_ref = 0;
1582                         CHECK((((uintptr_t)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1583                         CHECK((((uintptr_t)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1584                         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_var);
1585                         outpoint_ref = (uintptr_t)outpoint_var.inner & ~1;
1586         return outpoint_ref;
1587 }
1588 uint32_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_StaticOutput_get_output"))) TS_LDKSpendableOutputDescriptor_StaticOutput_get_output(uint32_t ptr) {
1589         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1590         assert(obj->tag == LDKSpendableOutputDescriptor_StaticOutput);
1591                         uint32_t output_ref = ((uintptr_t)&obj->static_output.output) | 1;
1592         return (uint32_t)output_ref;
1593 }
1594 uint32_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_DelayedPaymentOutput_get_delayed_payment_output"))) TS_LDKSpendableOutputDescriptor_DelayedPaymentOutput_get_delayed_payment_output(uint32_t ptr) {
1595         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1596         assert(obj->tag == LDKSpendableOutputDescriptor_DelayedPaymentOutput);
1597                         LDKDelayedPaymentOutputDescriptor delayed_payment_output_var = obj->delayed_payment_output;
1598                         uint32_t delayed_payment_output_ref = 0;
1599                         CHECK((((uintptr_t)delayed_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1600                         CHECK((((uintptr_t)&delayed_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1601                         CHECK_INNER_FIELD_ACCESS_OR_NULL(delayed_payment_output_var);
1602                         delayed_payment_output_ref = (uintptr_t)delayed_payment_output_var.inner & ~1;
1603         return delayed_payment_output_ref;
1604 }
1605 uint32_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_StaticPaymentOutput_get_static_payment_output"))) TS_LDKSpendableOutputDescriptor_StaticPaymentOutput_get_static_payment_output(uint32_t ptr) {
1606         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1607         assert(obj->tag == LDKSpendableOutputDescriptor_StaticPaymentOutput);
1608                         LDKStaticPaymentOutputDescriptor static_payment_output_var = obj->static_payment_output;
1609                         uint32_t static_payment_output_ref = 0;
1610                         CHECK((((uintptr_t)static_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1611                         CHECK((((uintptr_t)&static_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1612                         CHECK_INNER_FIELD_ACCESS_OR_NULL(static_payment_output_var);
1613                         static_payment_output_ref = (uintptr_t)static_payment_output_var.inner & ~1;
1614         return static_payment_output_ref;
1615 }
1616 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
1617         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
1618         for (size_t i = 0; i < ret.datalen; i++) {
1619                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
1620         }
1621         return ret;
1622 }
1623 uint32_t __attribute__((export_name("TS_LDKEvent_ty_from_ptr"))) TS_LDKEvent_ty_from_ptr(uint32_t ptr) {
1624         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1625         switch(obj->tag) {
1626                 case LDKEvent_FundingGenerationReady: return 0;
1627                 case LDKEvent_PaymentReceived: return 1;
1628                 case LDKEvent_PaymentClaimed: return 2;
1629                 case LDKEvent_PaymentSent: return 3;
1630                 case LDKEvent_PaymentFailed: return 4;
1631                 case LDKEvent_PaymentPathSuccessful: return 5;
1632                 case LDKEvent_PaymentPathFailed: return 6;
1633                 case LDKEvent_ProbeSuccessful: return 7;
1634                 case LDKEvent_ProbeFailed: return 8;
1635                 case LDKEvent_PendingHTLCsForwardable: return 9;
1636                 case LDKEvent_SpendableOutputs: return 10;
1637                 case LDKEvent_PaymentForwarded: return 11;
1638                 case LDKEvent_ChannelClosed: return 12;
1639                 case LDKEvent_DiscardFunding: return 13;
1640                 case LDKEvent_OpenChannelRequest: return 14;
1641                 case LDKEvent_HTLCHandlingFailed: return 15;
1642                 default: abort();
1643         }
1644 }
1645 int8_tArray __attribute__((export_name("TS_LDKEvent_FundingGenerationReady_get_temporary_channel_id"))) TS_LDKEvent_FundingGenerationReady_get_temporary_channel_id(uint32_t ptr) {
1646         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1647         assert(obj->tag == LDKEvent_FundingGenerationReady);
1648                         int8_tArray temporary_channel_id_arr = init_int8_tArray(32, __LINE__);
1649                         memcpy(temporary_channel_id_arr->elems, obj->funding_generation_ready.temporary_channel_id.data, 32);
1650         return temporary_channel_id_arr;
1651 }
1652 int8_tArray __attribute__((export_name("TS_LDKEvent_FundingGenerationReady_get_counterparty_node_id"))) TS_LDKEvent_FundingGenerationReady_get_counterparty_node_id(uint32_t ptr) {
1653         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1654         assert(obj->tag == LDKEvent_FundingGenerationReady);
1655                         int8_tArray counterparty_node_id_arr = init_int8_tArray(33, __LINE__);
1656                         memcpy(counterparty_node_id_arr->elems, obj->funding_generation_ready.counterparty_node_id.compressed_form, 33);
1657         return counterparty_node_id_arr;
1658 }
1659 int64_t __attribute__((export_name("TS_LDKEvent_FundingGenerationReady_get_channel_value_satoshis"))) TS_LDKEvent_FundingGenerationReady_get_channel_value_satoshis(uint32_t ptr) {
1660         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1661         assert(obj->tag == LDKEvent_FundingGenerationReady);
1662                         int64_t channel_value_satoshis_conv = obj->funding_generation_ready.channel_value_satoshis;
1663         return channel_value_satoshis_conv;
1664 }
1665 int8_tArray __attribute__((export_name("TS_LDKEvent_FundingGenerationReady_get_output_script"))) TS_LDKEvent_FundingGenerationReady_get_output_script(uint32_t ptr) {
1666         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1667         assert(obj->tag == LDKEvent_FundingGenerationReady);
1668                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
1669                         int8_tArray output_script_arr = init_int8_tArray(output_script_var.datalen, __LINE__);
1670                         memcpy(output_script_arr->elems, output_script_var.data, output_script_var.datalen);
1671         return output_script_arr;
1672 }
1673 int64_t __attribute__((export_name("TS_LDKEvent_FundingGenerationReady_get_user_channel_id"))) TS_LDKEvent_FundingGenerationReady_get_user_channel_id(uint32_t ptr) {
1674         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1675         assert(obj->tag == LDKEvent_FundingGenerationReady);
1676                         int64_t user_channel_id_conv = obj->funding_generation_ready.user_channel_id;
1677         return user_channel_id_conv;
1678 }
1679 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentReceived_get_payment_hash"))) TS_LDKEvent_PaymentReceived_get_payment_hash(uint32_t ptr) {
1680         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1681         assert(obj->tag == LDKEvent_PaymentReceived);
1682                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1683                         memcpy(payment_hash_arr->elems, obj->payment_received.payment_hash.data, 32);
1684         return payment_hash_arr;
1685 }
1686 int64_t __attribute__((export_name("TS_LDKEvent_PaymentReceived_get_amount_msat"))) TS_LDKEvent_PaymentReceived_get_amount_msat(uint32_t ptr) {
1687         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1688         assert(obj->tag == LDKEvent_PaymentReceived);
1689                         int64_t amount_msat_conv = obj->payment_received.amount_msat;
1690         return amount_msat_conv;
1691 }
1692 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentReceived_get_purpose"))) TS_LDKEvent_PaymentReceived_get_purpose(uint32_t ptr) {
1693         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1694         assert(obj->tag == LDKEvent_PaymentReceived);
1695                         uint32_t purpose_ref = ((uintptr_t)&obj->payment_received.purpose) | 1;
1696         return purpose_ref;
1697 }
1698 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentClaimed_get_payment_hash"))) TS_LDKEvent_PaymentClaimed_get_payment_hash(uint32_t ptr) {
1699         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1700         assert(obj->tag == LDKEvent_PaymentClaimed);
1701                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1702                         memcpy(payment_hash_arr->elems, obj->payment_claimed.payment_hash.data, 32);
1703         return payment_hash_arr;
1704 }
1705 int64_t __attribute__((export_name("TS_LDKEvent_PaymentClaimed_get_amount_msat"))) TS_LDKEvent_PaymentClaimed_get_amount_msat(uint32_t ptr) {
1706         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1707         assert(obj->tag == LDKEvent_PaymentClaimed);
1708                         int64_t amount_msat_conv = obj->payment_claimed.amount_msat;
1709         return amount_msat_conv;
1710 }
1711 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentClaimed_get_purpose"))) TS_LDKEvent_PaymentClaimed_get_purpose(uint32_t ptr) {
1712         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1713         assert(obj->tag == LDKEvent_PaymentClaimed);
1714                         uint32_t purpose_ref = ((uintptr_t)&obj->payment_claimed.purpose) | 1;
1715         return purpose_ref;
1716 }
1717 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentSent_get_payment_id"))) TS_LDKEvent_PaymentSent_get_payment_id(uint32_t ptr) {
1718         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1719         assert(obj->tag == LDKEvent_PaymentSent);
1720                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
1721                         memcpy(payment_id_arr->elems, obj->payment_sent.payment_id.data, 32);
1722         return payment_id_arr;
1723 }
1724 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentSent_get_payment_preimage"))) TS_LDKEvent_PaymentSent_get_payment_preimage(uint32_t ptr) {
1725         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1726         assert(obj->tag == LDKEvent_PaymentSent);
1727                         int8_tArray payment_preimage_arr = init_int8_tArray(32, __LINE__);
1728                         memcpy(payment_preimage_arr->elems, obj->payment_sent.payment_preimage.data, 32);
1729         return payment_preimage_arr;
1730 }
1731 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentSent_get_payment_hash"))) TS_LDKEvent_PaymentSent_get_payment_hash(uint32_t ptr) {
1732         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1733         assert(obj->tag == LDKEvent_PaymentSent);
1734                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1735                         memcpy(payment_hash_arr->elems, obj->payment_sent.payment_hash.data, 32);
1736         return payment_hash_arr;
1737 }
1738 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentSent_get_fee_paid_msat"))) TS_LDKEvent_PaymentSent_get_fee_paid_msat(uint32_t ptr) {
1739         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1740         assert(obj->tag == LDKEvent_PaymentSent);
1741                         uint32_t fee_paid_msat_ref = ((uintptr_t)&obj->payment_sent.fee_paid_msat) | 1;
1742         return fee_paid_msat_ref;
1743 }
1744 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentFailed_get_payment_id"))) TS_LDKEvent_PaymentFailed_get_payment_id(uint32_t ptr) {
1745         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1746         assert(obj->tag == LDKEvent_PaymentFailed);
1747                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
1748                         memcpy(payment_id_arr->elems, obj->payment_failed.payment_id.data, 32);
1749         return payment_id_arr;
1750 }
1751 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentFailed_get_payment_hash"))) TS_LDKEvent_PaymentFailed_get_payment_hash(uint32_t ptr) {
1752         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1753         assert(obj->tag == LDKEvent_PaymentFailed);
1754                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1755                         memcpy(payment_hash_arr->elems, obj->payment_failed.payment_hash.data, 32);
1756         return payment_hash_arr;
1757 }
1758 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathSuccessful_get_payment_id"))) TS_LDKEvent_PaymentPathSuccessful_get_payment_id(uint32_t ptr) {
1759         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1760         assert(obj->tag == LDKEvent_PaymentPathSuccessful);
1761                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
1762                         memcpy(payment_id_arr->elems, obj->payment_path_successful.payment_id.data, 32);
1763         return payment_id_arr;
1764 }
1765 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathSuccessful_get_payment_hash"))) TS_LDKEvent_PaymentPathSuccessful_get_payment_hash(uint32_t ptr) {
1766         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1767         assert(obj->tag == LDKEvent_PaymentPathSuccessful);
1768                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1769                         memcpy(payment_hash_arr->elems, obj->payment_path_successful.payment_hash.data, 32);
1770         return payment_hash_arr;
1771 }
1772 uint32_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathSuccessful_get_path"))) TS_LDKEvent_PaymentPathSuccessful_get_path(uint32_t ptr) {
1773         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1774         assert(obj->tag == LDKEvent_PaymentPathSuccessful);
1775                         LDKCVec_RouteHopZ path_var = obj->payment_path_successful.path;
1776                         uint32_tArray path_arr = NULL;
1777                         path_arr = init_uint32_tArray(path_var.datalen, __LINE__);
1778                         uint32_t *path_arr_ptr = (uint32_t*)(((uint8_t*)path_arr) + 8);
1779                         for (size_t k = 0; k < path_var.datalen; k++) {
1780                                 LDKRouteHop path_conv_10_var = path_var.data[k];
1781                                 uint32_t path_conv_10_ref = 0;
1782                                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1783                                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1784                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
1785                                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner & ~1;
1786                                 path_arr_ptr[k] = path_conv_10_ref;
1787                         }
1788                         
1789         return path_arr;
1790 }
1791 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_payment_id"))) TS_LDKEvent_PaymentPathFailed_get_payment_id(uint32_t ptr) {
1792         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1793         assert(obj->tag == LDKEvent_PaymentPathFailed);
1794                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
1795                         memcpy(payment_id_arr->elems, obj->payment_path_failed.payment_id.data, 32);
1796         return payment_id_arr;
1797 }
1798 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_payment_hash"))) TS_LDKEvent_PaymentPathFailed_get_payment_hash(uint32_t ptr) {
1799         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1800         assert(obj->tag == LDKEvent_PaymentPathFailed);
1801                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1802                         memcpy(payment_hash_arr->elems, obj->payment_path_failed.payment_hash.data, 32);
1803         return payment_hash_arr;
1804 }
1805 jboolean __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_rejected_by_dest"))) TS_LDKEvent_PaymentPathFailed_get_rejected_by_dest(uint32_t ptr) {
1806         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1807         assert(obj->tag == LDKEvent_PaymentPathFailed);
1808                         jboolean rejected_by_dest_conv = obj->payment_path_failed.rejected_by_dest;
1809         return rejected_by_dest_conv;
1810 }
1811 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_network_update"))) TS_LDKEvent_PaymentPathFailed_get_network_update(uint32_t ptr) {
1812         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1813         assert(obj->tag == LDKEvent_PaymentPathFailed);
1814                         uint32_t network_update_ref = ((uintptr_t)&obj->payment_path_failed.network_update) | 1;
1815         return network_update_ref;
1816 }
1817 jboolean __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_all_paths_failed"))) TS_LDKEvent_PaymentPathFailed_get_all_paths_failed(uint32_t ptr) {
1818         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1819         assert(obj->tag == LDKEvent_PaymentPathFailed);
1820                         jboolean all_paths_failed_conv = obj->payment_path_failed.all_paths_failed;
1821         return all_paths_failed_conv;
1822 }
1823 uint32_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_path"))) TS_LDKEvent_PaymentPathFailed_get_path(uint32_t ptr) {
1824         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1825         assert(obj->tag == LDKEvent_PaymentPathFailed);
1826                         LDKCVec_RouteHopZ path_var = obj->payment_path_failed.path;
1827                         uint32_tArray path_arr = NULL;
1828                         path_arr = init_uint32_tArray(path_var.datalen, __LINE__);
1829                         uint32_t *path_arr_ptr = (uint32_t*)(((uint8_t*)path_arr) + 8);
1830                         for (size_t k = 0; k < path_var.datalen; k++) {
1831                                 LDKRouteHop path_conv_10_var = path_var.data[k];
1832                                 uint32_t path_conv_10_ref = 0;
1833                                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1834                                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1835                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
1836                                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner & ~1;
1837                                 path_arr_ptr[k] = path_conv_10_ref;
1838                         }
1839                         
1840         return path_arr;
1841 }
1842 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_short_channel_id"))) TS_LDKEvent_PaymentPathFailed_get_short_channel_id(uint32_t ptr) {
1843         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1844         assert(obj->tag == LDKEvent_PaymentPathFailed);
1845                         uint32_t short_channel_id_ref = ((uintptr_t)&obj->payment_path_failed.short_channel_id) | 1;
1846         return short_channel_id_ref;
1847 }
1848 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_retry"))) TS_LDKEvent_PaymentPathFailed_get_retry(uint32_t ptr) {
1849         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1850         assert(obj->tag == LDKEvent_PaymentPathFailed);
1851                         LDKRouteParameters retry_var = obj->payment_path_failed.retry;
1852                         uint32_t retry_ref = 0;
1853                         if ((uintptr_t)retry_var.inner > 4096) {
1854                                 CHECK((((uintptr_t)retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1855                                 CHECK((((uintptr_t)&retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1856                         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_var);
1857                                 retry_ref = (uintptr_t)retry_var.inner & ~1;
1858                         }
1859         return retry_ref;
1860 }
1861 int8_tArray __attribute__((export_name("TS_LDKEvent_ProbeSuccessful_get_payment_id"))) TS_LDKEvent_ProbeSuccessful_get_payment_id(uint32_t ptr) {
1862         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1863         assert(obj->tag == LDKEvent_ProbeSuccessful);
1864                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
1865                         memcpy(payment_id_arr->elems, obj->probe_successful.payment_id.data, 32);
1866         return payment_id_arr;
1867 }
1868 int8_tArray __attribute__((export_name("TS_LDKEvent_ProbeSuccessful_get_payment_hash"))) TS_LDKEvent_ProbeSuccessful_get_payment_hash(uint32_t ptr) {
1869         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1870         assert(obj->tag == LDKEvent_ProbeSuccessful);
1871                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1872                         memcpy(payment_hash_arr->elems, obj->probe_successful.payment_hash.data, 32);
1873         return payment_hash_arr;
1874 }
1875 uint32_tArray __attribute__((export_name("TS_LDKEvent_ProbeSuccessful_get_path"))) TS_LDKEvent_ProbeSuccessful_get_path(uint32_t ptr) {
1876         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1877         assert(obj->tag == LDKEvent_ProbeSuccessful);
1878                         LDKCVec_RouteHopZ path_var = obj->probe_successful.path;
1879                         uint32_tArray path_arr = NULL;
1880                         path_arr = init_uint32_tArray(path_var.datalen, __LINE__);
1881                         uint32_t *path_arr_ptr = (uint32_t*)(((uint8_t*)path_arr) + 8);
1882                         for (size_t k = 0; k < path_var.datalen; k++) {
1883                                 LDKRouteHop path_conv_10_var = path_var.data[k];
1884                                 uint32_t path_conv_10_ref = 0;
1885                                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1886                                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1887                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
1888                                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner & ~1;
1889                                 path_arr_ptr[k] = path_conv_10_ref;
1890                         }
1891                         
1892         return path_arr;
1893 }
1894 int8_tArray __attribute__((export_name("TS_LDKEvent_ProbeFailed_get_payment_id"))) TS_LDKEvent_ProbeFailed_get_payment_id(uint32_t ptr) {
1895         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1896         assert(obj->tag == LDKEvent_ProbeFailed);
1897                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
1898                         memcpy(payment_id_arr->elems, obj->probe_failed.payment_id.data, 32);
1899         return payment_id_arr;
1900 }
1901 int8_tArray __attribute__((export_name("TS_LDKEvent_ProbeFailed_get_payment_hash"))) TS_LDKEvent_ProbeFailed_get_payment_hash(uint32_t ptr) {
1902         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1903         assert(obj->tag == LDKEvent_ProbeFailed);
1904                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1905                         memcpy(payment_hash_arr->elems, obj->probe_failed.payment_hash.data, 32);
1906         return payment_hash_arr;
1907 }
1908 uint32_tArray __attribute__((export_name("TS_LDKEvent_ProbeFailed_get_path"))) TS_LDKEvent_ProbeFailed_get_path(uint32_t ptr) {
1909         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1910         assert(obj->tag == LDKEvent_ProbeFailed);
1911                         LDKCVec_RouteHopZ path_var = obj->probe_failed.path;
1912                         uint32_tArray path_arr = NULL;
1913                         path_arr = init_uint32_tArray(path_var.datalen, __LINE__);
1914                         uint32_t *path_arr_ptr = (uint32_t*)(((uint8_t*)path_arr) + 8);
1915                         for (size_t k = 0; k < path_var.datalen; k++) {
1916                                 LDKRouteHop path_conv_10_var = path_var.data[k];
1917                                 uint32_t path_conv_10_ref = 0;
1918                                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1919                                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1920                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
1921                                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner & ~1;
1922                                 path_arr_ptr[k] = path_conv_10_ref;
1923                         }
1924                         
1925         return path_arr;
1926 }
1927 uint32_t __attribute__((export_name("TS_LDKEvent_ProbeFailed_get_short_channel_id"))) TS_LDKEvent_ProbeFailed_get_short_channel_id(uint32_t ptr) {
1928         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1929         assert(obj->tag == LDKEvent_ProbeFailed);
1930                         uint32_t short_channel_id_ref = ((uintptr_t)&obj->probe_failed.short_channel_id) | 1;
1931         return short_channel_id_ref;
1932 }
1933 int64_t __attribute__((export_name("TS_LDKEvent_PendingHTLCsForwardable_get_time_forwardable"))) TS_LDKEvent_PendingHTLCsForwardable_get_time_forwardable(uint32_t ptr) {
1934         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1935         assert(obj->tag == LDKEvent_PendingHTLCsForwardable);
1936                         int64_t time_forwardable_conv = obj->pending_htl_cs_forwardable.time_forwardable;
1937         return time_forwardable_conv;
1938 }
1939 uint32_tArray __attribute__((export_name("TS_LDKEvent_SpendableOutputs_get_outputs"))) TS_LDKEvent_SpendableOutputs_get_outputs(uint32_t ptr) {
1940         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1941         assert(obj->tag == LDKEvent_SpendableOutputs);
1942                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
1943                         uint32_tArray outputs_arr = NULL;
1944                         outputs_arr = init_uint32_tArray(outputs_var.datalen, __LINE__);
1945                         uint32_t *outputs_arr_ptr = (uint32_t*)(((uint8_t*)outputs_arr) + 8);
1946                         for (size_t b = 0; b < outputs_var.datalen; b++) {
1947                                 uint32_t outputs_conv_27_ref = ((uintptr_t)&outputs_var.data[b]) | 1;
1948                                 outputs_arr_ptr[b] = outputs_conv_27_ref;
1949                         }
1950                         
1951         return outputs_arr;
1952 }
1953 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentForwarded_get_prev_channel_id"))) TS_LDKEvent_PaymentForwarded_get_prev_channel_id(uint32_t ptr) {
1954         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1955         assert(obj->tag == LDKEvent_PaymentForwarded);
1956                         int8_tArray prev_channel_id_arr = init_int8_tArray(32, __LINE__);
1957                         memcpy(prev_channel_id_arr->elems, obj->payment_forwarded.prev_channel_id.data, 32);
1958         return prev_channel_id_arr;
1959 }
1960 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentForwarded_get_next_channel_id"))) TS_LDKEvent_PaymentForwarded_get_next_channel_id(uint32_t ptr) {
1961         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1962         assert(obj->tag == LDKEvent_PaymentForwarded);
1963                         int8_tArray next_channel_id_arr = init_int8_tArray(32, __LINE__);
1964                         memcpy(next_channel_id_arr->elems, obj->payment_forwarded.next_channel_id.data, 32);
1965         return next_channel_id_arr;
1966 }
1967 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentForwarded_get_fee_earned_msat"))) TS_LDKEvent_PaymentForwarded_get_fee_earned_msat(uint32_t ptr) {
1968         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1969         assert(obj->tag == LDKEvent_PaymentForwarded);
1970                         uint32_t fee_earned_msat_ref = ((uintptr_t)&obj->payment_forwarded.fee_earned_msat) | 1;
1971         return fee_earned_msat_ref;
1972 }
1973 jboolean __attribute__((export_name("TS_LDKEvent_PaymentForwarded_get_claim_from_onchain_tx"))) TS_LDKEvent_PaymentForwarded_get_claim_from_onchain_tx(uint32_t ptr) {
1974         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1975         assert(obj->tag == LDKEvent_PaymentForwarded);
1976                         jboolean claim_from_onchain_tx_conv = obj->payment_forwarded.claim_from_onchain_tx;
1977         return claim_from_onchain_tx_conv;
1978 }
1979 int8_tArray __attribute__((export_name("TS_LDKEvent_ChannelClosed_get_channel_id"))) TS_LDKEvent_ChannelClosed_get_channel_id(uint32_t ptr) {
1980         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1981         assert(obj->tag == LDKEvent_ChannelClosed);
1982                         int8_tArray channel_id_arr = init_int8_tArray(32, __LINE__);
1983                         memcpy(channel_id_arr->elems, obj->channel_closed.channel_id.data, 32);
1984         return channel_id_arr;
1985 }
1986 int64_t __attribute__((export_name("TS_LDKEvent_ChannelClosed_get_user_channel_id"))) TS_LDKEvent_ChannelClosed_get_user_channel_id(uint32_t ptr) {
1987         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1988         assert(obj->tag == LDKEvent_ChannelClosed);
1989                         int64_t user_channel_id_conv = obj->channel_closed.user_channel_id;
1990         return user_channel_id_conv;
1991 }
1992 uint32_t __attribute__((export_name("TS_LDKEvent_ChannelClosed_get_reason"))) TS_LDKEvent_ChannelClosed_get_reason(uint32_t ptr) {
1993         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1994         assert(obj->tag == LDKEvent_ChannelClosed);
1995                         uint32_t reason_ref = ((uintptr_t)&obj->channel_closed.reason) | 1;
1996         return reason_ref;
1997 }
1998 int8_tArray __attribute__((export_name("TS_LDKEvent_DiscardFunding_get_channel_id"))) TS_LDKEvent_DiscardFunding_get_channel_id(uint32_t ptr) {
1999         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
2000         assert(obj->tag == LDKEvent_DiscardFunding);
2001                         int8_tArray channel_id_arr = init_int8_tArray(32, __LINE__);
2002                         memcpy(channel_id_arr->elems, obj->discard_funding.channel_id.data, 32);
2003         return channel_id_arr;
2004 }
2005 int8_tArray __attribute__((export_name("TS_LDKEvent_DiscardFunding_get_transaction"))) TS_LDKEvent_DiscardFunding_get_transaction(uint32_t ptr) {
2006         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
2007         assert(obj->tag == LDKEvent_DiscardFunding);
2008                         LDKTransaction transaction_var = obj->discard_funding.transaction;
2009                         int8_tArray transaction_arr = init_int8_tArray(transaction_var.datalen, __LINE__);
2010                         memcpy(transaction_arr->elems, transaction_var.data, transaction_var.datalen);
2011         return transaction_arr;
2012 }
2013 int8_tArray __attribute__((export_name("TS_LDKEvent_OpenChannelRequest_get_temporary_channel_id"))) TS_LDKEvent_OpenChannelRequest_get_temporary_channel_id(uint32_t ptr) {
2014         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
2015         assert(obj->tag == LDKEvent_OpenChannelRequest);
2016                         int8_tArray temporary_channel_id_arr = init_int8_tArray(32, __LINE__);
2017                         memcpy(temporary_channel_id_arr->elems, obj->open_channel_request.temporary_channel_id.data, 32);
2018         return temporary_channel_id_arr;
2019 }
2020 int8_tArray __attribute__((export_name("TS_LDKEvent_OpenChannelRequest_get_counterparty_node_id"))) TS_LDKEvent_OpenChannelRequest_get_counterparty_node_id(uint32_t ptr) {
2021         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
2022         assert(obj->tag == LDKEvent_OpenChannelRequest);
2023                         int8_tArray counterparty_node_id_arr = init_int8_tArray(33, __LINE__);
2024                         memcpy(counterparty_node_id_arr->elems, obj->open_channel_request.counterparty_node_id.compressed_form, 33);
2025         return counterparty_node_id_arr;
2026 }
2027 int64_t __attribute__((export_name("TS_LDKEvent_OpenChannelRequest_get_funding_satoshis"))) TS_LDKEvent_OpenChannelRequest_get_funding_satoshis(uint32_t ptr) {
2028         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
2029         assert(obj->tag == LDKEvent_OpenChannelRequest);
2030                         int64_t funding_satoshis_conv = obj->open_channel_request.funding_satoshis;
2031         return funding_satoshis_conv;
2032 }
2033 int64_t __attribute__((export_name("TS_LDKEvent_OpenChannelRequest_get_push_msat"))) TS_LDKEvent_OpenChannelRequest_get_push_msat(uint32_t ptr) {
2034         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
2035         assert(obj->tag == LDKEvent_OpenChannelRequest);
2036                         int64_t push_msat_conv = obj->open_channel_request.push_msat;
2037         return push_msat_conv;
2038 }
2039 uint32_t __attribute__((export_name("TS_LDKEvent_OpenChannelRequest_get_channel_type"))) TS_LDKEvent_OpenChannelRequest_get_channel_type(uint32_t ptr) {
2040         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
2041         assert(obj->tag == LDKEvent_OpenChannelRequest);
2042                         LDKChannelTypeFeatures channel_type_var = obj->open_channel_request.channel_type;
2043                         uint32_t channel_type_ref = 0;
2044                         CHECK((((uintptr_t)channel_type_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2045                         CHECK((((uintptr_t)&channel_type_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2046                         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_var);
2047                         channel_type_ref = (uintptr_t)channel_type_var.inner & ~1;
2048         return channel_type_ref;
2049 }
2050 int8_tArray __attribute__((export_name("TS_LDKEvent_HTLCHandlingFailed_get_prev_channel_id"))) TS_LDKEvent_HTLCHandlingFailed_get_prev_channel_id(uint32_t ptr) {
2051         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
2052         assert(obj->tag == LDKEvent_HTLCHandlingFailed);
2053                         int8_tArray prev_channel_id_arr = init_int8_tArray(32, __LINE__);
2054                         memcpy(prev_channel_id_arr->elems, obj->htlc_handling_failed.prev_channel_id.data, 32);
2055         return prev_channel_id_arr;
2056 }
2057 uint32_t __attribute__((export_name("TS_LDKEvent_HTLCHandlingFailed_get_failed_next_destination"))) TS_LDKEvent_HTLCHandlingFailed_get_failed_next_destination(uint32_t ptr) {
2058         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
2059         assert(obj->tag == LDKEvent_HTLCHandlingFailed);
2060                         uint32_t failed_next_destination_ref = ((uintptr_t)&obj->htlc_handling_failed.failed_next_destination) | 1;
2061         return failed_next_destination_ref;
2062 }
2063 uint32_t __attribute__((export_name("TS_LDKCOption_EventZ_ty_from_ptr"))) TS_LDKCOption_EventZ_ty_from_ptr(uint32_t ptr) {
2064         LDKCOption_EventZ *obj = (LDKCOption_EventZ*)(ptr & ~1);
2065         switch(obj->tag) {
2066                 case LDKCOption_EventZ_Some: return 0;
2067                 case LDKCOption_EventZ_None: return 1;
2068                 default: abort();
2069         }
2070 }
2071 uint32_t __attribute__((export_name("TS_LDKCOption_EventZ_Some_get_some"))) TS_LDKCOption_EventZ_Some_get_some(uint32_t ptr) {
2072         LDKCOption_EventZ *obj = (LDKCOption_EventZ*)(ptr & ~1);
2073         assert(obj->tag == LDKCOption_EventZ_Some);
2074                         uint32_t some_ref = ((uintptr_t)&obj->some) | 1;
2075         return some_ref;
2076 }
2077 static inline struct LDKCOption_EventZ CResult_COption_EventZDecodeErrorZ_get_ok(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
2078 CHECK(owner->result_ok);
2079         return COption_EventZ_clone(&*owner->contents.result);
2080 }
2081 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_get_ok"))) TS_CResult_COption_EventZDecodeErrorZ_get_ok(uint32_t owner) {
2082         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(owner & ~1);
2083         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
2084         *ret_copy = CResult_COption_EventZDecodeErrorZ_get_ok(owner_conv);
2085         uint32_t ret_ref = (uintptr_t)ret_copy;
2086         return ret_ref;
2087 }
2088
2089 static inline struct LDKDecodeError CResult_COption_EventZDecodeErrorZ_get_err(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
2090 CHECK(!owner->result_ok);
2091         return DecodeError_clone(&*owner->contents.err);
2092 }
2093 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_get_err"))) TS_CResult_COption_EventZDecodeErrorZ_get_err(uint32_t owner) {
2094         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(owner & ~1);
2095         LDKDecodeError ret_var = CResult_COption_EventZDecodeErrorZ_get_err(owner_conv);
2096         uint32_t ret_ref = 0;
2097         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2098         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2099         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2100         ret_ref = (uintptr_t)ret_var.inner;
2101         if (ret_var.is_owned) {
2102                 ret_ref |= 1;
2103         }
2104         return ret_ref;
2105 }
2106
2107 uint32_t __attribute__((export_name("TS_LDKErrorAction_ty_from_ptr"))) TS_LDKErrorAction_ty_from_ptr(uint32_t ptr) {
2108         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
2109         switch(obj->tag) {
2110                 case LDKErrorAction_DisconnectPeer: return 0;
2111                 case LDKErrorAction_IgnoreError: return 1;
2112                 case LDKErrorAction_IgnoreAndLog: return 2;
2113                 case LDKErrorAction_IgnoreDuplicateGossip: return 3;
2114                 case LDKErrorAction_SendErrorMessage: return 4;
2115                 case LDKErrorAction_SendWarningMessage: return 5;
2116                 default: abort();
2117         }
2118 }
2119 uint32_t __attribute__((export_name("TS_LDKErrorAction_DisconnectPeer_get_msg"))) TS_LDKErrorAction_DisconnectPeer_get_msg(uint32_t ptr) {
2120         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
2121         assert(obj->tag == LDKErrorAction_DisconnectPeer);
2122                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
2123                         uint32_t msg_ref = 0;
2124                         if ((uintptr_t)msg_var.inner > 4096) {
2125                                 CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2126                                 CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2127                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2128                                 msg_ref = (uintptr_t)msg_var.inner & ~1;
2129                         }
2130         return msg_ref;
2131 }
2132 uint32_t __attribute__((export_name("TS_LDKErrorAction_IgnoreAndLog_get_ignore_and_log"))) TS_LDKErrorAction_IgnoreAndLog_get_ignore_and_log(uint32_t ptr) {
2133         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
2134         assert(obj->tag == LDKErrorAction_IgnoreAndLog);
2135                         uint32_t ignore_and_log_conv = LDKLevel_to_js(obj->ignore_and_log);
2136         return ignore_and_log_conv;
2137 }
2138 uint32_t __attribute__((export_name("TS_LDKErrorAction_SendErrorMessage_get_msg"))) TS_LDKErrorAction_SendErrorMessage_get_msg(uint32_t ptr) {
2139         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
2140         assert(obj->tag == LDKErrorAction_SendErrorMessage);
2141                         LDKErrorMessage msg_var = obj->send_error_message.msg;
2142                         uint32_t msg_ref = 0;
2143                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2144                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2145                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2146                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2147         return msg_ref;
2148 }
2149 uint32_t __attribute__((export_name("TS_LDKErrorAction_SendWarningMessage_get_msg"))) TS_LDKErrorAction_SendWarningMessage_get_msg(uint32_t ptr) {
2150         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
2151         assert(obj->tag == LDKErrorAction_SendWarningMessage);
2152                         LDKWarningMessage msg_var = obj->send_warning_message.msg;
2153                         uint32_t msg_ref = 0;
2154                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2155                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2156                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2157                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2158         return msg_ref;
2159 }
2160 uint32_t __attribute__((export_name("TS_LDKErrorAction_SendWarningMessage_get_log_level"))) TS_LDKErrorAction_SendWarningMessage_get_log_level(uint32_t ptr) {
2161         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
2162         assert(obj->tag == LDKErrorAction_SendWarningMessage);
2163                         uint32_t log_level_conv = LDKLevel_to_js(obj->send_warning_message.log_level);
2164         return log_level_conv;
2165 }
2166 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_ty_from_ptr"))) TS_LDKMessageSendEvent_ty_from_ptr(uint32_t ptr) {
2167         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2168         switch(obj->tag) {
2169                 case LDKMessageSendEvent_SendAcceptChannel: return 0;
2170                 case LDKMessageSendEvent_SendOpenChannel: return 1;
2171                 case LDKMessageSendEvent_SendFundingCreated: return 2;
2172                 case LDKMessageSendEvent_SendFundingSigned: return 3;
2173                 case LDKMessageSendEvent_SendChannelReady: return 4;
2174                 case LDKMessageSendEvent_SendAnnouncementSignatures: return 5;
2175                 case LDKMessageSendEvent_UpdateHTLCs: return 6;
2176                 case LDKMessageSendEvent_SendRevokeAndACK: return 7;
2177                 case LDKMessageSendEvent_SendClosingSigned: return 8;
2178                 case LDKMessageSendEvent_SendShutdown: return 9;
2179                 case LDKMessageSendEvent_SendChannelReestablish: return 10;
2180                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: return 11;
2181                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: return 12;
2182                 case LDKMessageSendEvent_BroadcastChannelUpdate: return 13;
2183                 case LDKMessageSendEvent_SendChannelUpdate: return 14;
2184                 case LDKMessageSendEvent_HandleError: return 15;
2185                 case LDKMessageSendEvent_SendChannelRangeQuery: return 16;
2186                 case LDKMessageSendEvent_SendShortIdsQuery: return 17;
2187                 case LDKMessageSendEvent_SendReplyChannelRange: return 18;
2188                 case LDKMessageSendEvent_SendGossipTimestampFilter: return 19;
2189                 default: abort();
2190         }
2191 }
2192 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendAcceptChannel_get_node_id"))) TS_LDKMessageSendEvent_SendAcceptChannel_get_node_id(uint32_t ptr) {
2193         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2194         assert(obj->tag == LDKMessageSendEvent_SendAcceptChannel);
2195                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2196                         memcpy(node_id_arr->elems, obj->send_accept_channel.node_id.compressed_form, 33);
2197         return node_id_arr;
2198 }
2199 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendAcceptChannel_get_msg"))) TS_LDKMessageSendEvent_SendAcceptChannel_get_msg(uint32_t ptr) {
2200         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2201         assert(obj->tag == LDKMessageSendEvent_SendAcceptChannel);
2202                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
2203                         uint32_t msg_ref = 0;
2204                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2205                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2206                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2207                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2208         return msg_ref;
2209 }
2210 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendOpenChannel_get_node_id"))) TS_LDKMessageSendEvent_SendOpenChannel_get_node_id(uint32_t ptr) {
2211         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2212         assert(obj->tag == LDKMessageSendEvent_SendOpenChannel);
2213                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2214                         memcpy(node_id_arr->elems, obj->send_open_channel.node_id.compressed_form, 33);
2215         return node_id_arr;
2216 }
2217 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendOpenChannel_get_msg"))) TS_LDKMessageSendEvent_SendOpenChannel_get_msg(uint32_t ptr) {
2218         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2219         assert(obj->tag == LDKMessageSendEvent_SendOpenChannel);
2220                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
2221                         uint32_t msg_ref = 0;
2222                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2223                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2224                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2225                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2226         return msg_ref;
2227 }
2228 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingCreated_get_node_id"))) TS_LDKMessageSendEvent_SendFundingCreated_get_node_id(uint32_t ptr) {
2229         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2230         assert(obj->tag == LDKMessageSendEvent_SendFundingCreated);
2231                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2232                         memcpy(node_id_arr->elems, obj->send_funding_created.node_id.compressed_form, 33);
2233         return node_id_arr;
2234 }
2235 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingCreated_get_msg"))) TS_LDKMessageSendEvent_SendFundingCreated_get_msg(uint32_t ptr) {
2236         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2237         assert(obj->tag == LDKMessageSendEvent_SendFundingCreated);
2238                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
2239                         uint32_t msg_ref = 0;
2240                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2241                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2242                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2243                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2244         return msg_ref;
2245 }
2246 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingSigned_get_node_id"))) TS_LDKMessageSendEvent_SendFundingSigned_get_node_id(uint32_t ptr) {
2247         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2248         assert(obj->tag == LDKMessageSendEvent_SendFundingSigned);
2249                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2250                         memcpy(node_id_arr->elems, obj->send_funding_signed.node_id.compressed_form, 33);
2251         return node_id_arr;
2252 }
2253 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingSigned_get_msg"))) TS_LDKMessageSendEvent_SendFundingSigned_get_msg(uint32_t ptr) {
2254         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2255         assert(obj->tag == LDKMessageSendEvent_SendFundingSigned);
2256                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
2257                         uint32_t msg_ref = 0;
2258                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2259                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2260                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2261                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2262         return msg_ref;
2263 }
2264 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelReady_get_node_id"))) TS_LDKMessageSendEvent_SendChannelReady_get_node_id(uint32_t ptr) {
2265         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2266         assert(obj->tag == LDKMessageSendEvent_SendChannelReady);
2267                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2268                         memcpy(node_id_arr->elems, obj->send_channel_ready.node_id.compressed_form, 33);
2269         return node_id_arr;
2270 }
2271 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelReady_get_msg"))) TS_LDKMessageSendEvent_SendChannelReady_get_msg(uint32_t ptr) {
2272         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2273         assert(obj->tag == LDKMessageSendEvent_SendChannelReady);
2274                         LDKChannelReady msg_var = obj->send_channel_ready.msg;
2275                         uint32_t msg_ref = 0;
2276                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2277                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2278                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2279                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2280         return msg_ref;
2281 }
2282 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendAnnouncementSignatures_get_node_id"))) TS_LDKMessageSendEvent_SendAnnouncementSignatures_get_node_id(uint32_t ptr) {
2283         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2284         assert(obj->tag == LDKMessageSendEvent_SendAnnouncementSignatures);
2285                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2286                         memcpy(node_id_arr->elems, obj->send_announcement_signatures.node_id.compressed_form, 33);
2287         return node_id_arr;
2288 }
2289 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendAnnouncementSignatures_get_msg"))) TS_LDKMessageSendEvent_SendAnnouncementSignatures_get_msg(uint32_t ptr) {
2290         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2291         assert(obj->tag == LDKMessageSendEvent_SendAnnouncementSignatures);
2292                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
2293                         uint32_t msg_ref = 0;
2294                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2295                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2296                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2297                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2298         return msg_ref;
2299 }
2300 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_UpdateHTLCs_get_node_id"))) TS_LDKMessageSendEvent_UpdateHTLCs_get_node_id(uint32_t ptr) {
2301         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2302         assert(obj->tag == LDKMessageSendEvent_UpdateHTLCs);
2303                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2304                         memcpy(node_id_arr->elems, obj->update_htl_cs.node_id.compressed_form, 33);
2305         return node_id_arr;
2306 }
2307 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_UpdateHTLCs_get_updates"))) TS_LDKMessageSendEvent_UpdateHTLCs_get_updates(uint32_t ptr) {
2308         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2309         assert(obj->tag == LDKMessageSendEvent_UpdateHTLCs);
2310                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
2311                         uint32_t updates_ref = 0;
2312                         CHECK((((uintptr_t)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2313                         CHECK((((uintptr_t)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2314                         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_var);
2315                         updates_ref = (uintptr_t)updates_var.inner & ~1;
2316         return updates_ref;
2317 }
2318 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendRevokeAndACK_get_node_id"))) TS_LDKMessageSendEvent_SendRevokeAndACK_get_node_id(uint32_t ptr) {
2319         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2320         assert(obj->tag == LDKMessageSendEvent_SendRevokeAndACK);
2321                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2322                         memcpy(node_id_arr->elems, obj->send_revoke_and_ack.node_id.compressed_form, 33);
2323         return node_id_arr;
2324 }
2325 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendRevokeAndACK_get_msg"))) TS_LDKMessageSendEvent_SendRevokeAndACK_get_msg(uint32_t ptr) {
2326         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2327         assert(obj->tag == LDKMessageSendEvent_SendRevokeAndACK);
2328                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
2329                         uint32_t msg_ref = 0;
2330                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2331                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2332                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2333                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2334         return msg_ref;
2335 }
2336 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendClosingSigned_get_node_id"))) TS_LDKMessageSendEvent_SendClosingSigned_get_node_id(uint32_t ptr) {
2337         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2338         assert(obj->tag == LDKMessageSendEvent_SendClosingSigned);
2339                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2340                         memcpy(node_id_arr->elems, obj->send_closing_signed.node_id.compressed_form, 33);
2341         return node_id_arr;
2342 }
2343 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendClosingSigned_get_msg"))) TS_LDKMessageSendEvent_SendClosingSigned_get_msg(uint32_t ptr) {
2344         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2345         assert(obj->tag == LDKMessageSendEvent_SendClosingSigned);
2346                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
2347                         uint32_t msg_ref = 0;
2348                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2349                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2350                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2351                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2352         return msg_ref;
2353 }
2354 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendShutdown_get_node_id"))) TS_LDKMessageSendEvent_SendShutdown_get_node_id(uint32_t ptr) {
2355         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2356         assert(obj->tag == LDKMessageSendEvent_SendShutdown);
2357                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2358                         memcpy(node_id_arr->elems, obj->send_shutdown.node_id.compressed_form, 33);
2359         return node_id_arr;
2360 }
2361 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendShutdown_get_msg"))) TS_LDKMessageSendEvent_SendShutdown_get_msg(uint32_t ptr) {
2362         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2363         assert(obj->tag == LDKMessageSendEvent_SendShutdown);
2364                         LDKShutdown msg_var = obj->send_shutdown.msg;
2365                         uint32_t msg_ref = 0;
2366                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2367                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2368                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2369                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2370         return msg_ref;
2371 }
2372 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelReestablish_get_node_id"))) TS_LDKMessageSendEvent_SendChannelReestablish_get_node_id(uint32_t ptr) {
2373         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2374         assert(obj->tag == LDKMessageSendEvent_SendChannelReestablish);
2375                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2376                         memcpy(node_id_arr->elems, obj->send_channel_reestablish.node_id.compressed_form, 33);
2377         return node_id_arr;
2378 }
2379 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelReestablish_get_msg"))) TS_LDKMessageSendEvent_SendChannelReestablish_get_msg(uint32_t ptr) {
2380         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2381         assert(obj->tag == LDKMessageSendEvent_SendChannelReestablish);
2382                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
2383                         uint32_t msg_ref = 0;
2384                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2385                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2386                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2387                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2388         return msg_ref;
2389 }
2390 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_BroadcastChannelAnnouncement_get_msg"))) TS_LDKMessageSendEvent_BroadcastChannelAnnouncement_get_msg(uint32_t ptr) {
2391         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2392         assert(obj->tag == LDKMessageSendEvent_BroadcastChannelAnnouncement);
2393                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
2394                         uint32_t msg_ref = 0;
2395                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2396                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2397                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2398                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2399         return msg_ref;
2400 }
2401 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_BroadcastChannelAnnouncement_get_update_msg"))) TS_LDKMessageSendEvent_BroadcastChannelAnnouncement_get_update_msg(uint32_t ptr) {
2402         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2403         assert(obj->tag == LDKMessageSendEvent_BroadcastChannelAnnouncement);
2404                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
2405                         uint32_t update_msg_ref = 0;
2406                         CHECK((((uintptr_t)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2407                         CHECK((((uintptr_t)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2408                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_var);
2409                         update_msg_ref = (uintptr_t)update_msg_var.inner & ~1;
2410         return update_msg_ref;
2411 }
2412 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_BroadcastNodeAnnouncement_get_msg"))) TS_LDKMessageSendEvent_BroadcastNodeAnnouncement_get_msg(uint32_t ptr) {
2413         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2414         assert(obj->tag == LDKMessageSendEvent_BroadcastNodeAnnouncement);
2415                         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
2416                         uint32_t msg_ref = 0;
2417                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2418                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2419                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2420                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2421         return msg_ref;
2422 }
2423 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_BroadcastChannelUpdate_get_msg"))) TS_LDKMessageSendEvent_BroadcastChannelUpdate_get_msg(uint32_t ptr) {
2424         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2425         assert(obj->tag == LDKMessageSendEvent_BroadcastChannelUpdate);
2426                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
2427                         uint32_t msg_ref = 0;
2428                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2429                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2430                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2431                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2432         return msg_ref;
2433 }
2434 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelUpdate_get_node_id"))) TS_LDKMessageSendEvent_SendChannelUpdate_get_node_id(uint32_t ptr) {
2435         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2436         assert(obj->tag == LDKMessageSendEvent_SendChannelUpdate);
2437                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2438                         memcpy(node_id_arr->elems, obj->send_channel_update.node_id.compressed_form, 33);
2439         return node_id_arr;
2440 }
2441 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelUpdate_get_msg"))) TS_LDKMessageSendEvent_SendChannelUpdate_get_msg(uint32_t ptr) {
2442         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2443         assert(obj->tag == LDKMessageSendEvent_SendChannelUpdate);
2444                         LDKChannelUpdate msg_var = obj->send_channel_update.msg;
2445                         uint32_t msg_ref = 0;
2446                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2447                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2448                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2449                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2450         return msg_ref;
2451 }
2452 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_HandleError_get_node_id"))) TS_LDKMessageSendEvent_HandleError_get_node_id(uint32_t ptr) {
2453         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2454         assert(obj->tag == LDKMessageSendEvent_HandleError);
2455                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2456                         memcpy(node_id_arr->elems, obj->handle_error.node_id.compressed_form, 33);
2457         return node_id_arr;
2458 }
2459 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_HandleError_get_action"))) TS_LDKMessageSendEvent_HandleError_get_action(uint32_t ptr) {
2460         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2461         assert(obj->tag == LDKMessageSendEvent_HandleError);
2462                         uint32_t action_ref = ((uintptr_t)&obj->handle_error.action) | 1;
2463         return action_ref;
2464 }
2465 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelRangeQuery_get_node_id"))) TS_LDKMessageSendEvent_SendChannelRangeQuery_get_node_id(uint32_t ptr) {
2466         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2467         assert(obj->tag == LDKMessageSendEvent_SendChannelRangeQuery);
2468                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2469                         memcpy(node_id_arr->elems, obj->send_channel_range_query.node_id.compressed_form, 33);
2470         return node_id_arr;
2471 }
2472 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelRangeQuery_get_msg"))) TS_LDKMessageSendEvent_SendChannelRangeQuery_get_msg(uint32_t ptr) {
2473         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2474         assert(obj->tag == LDKMessageSendEvent_SendChannelRangeQuery);
2475                         LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
2476                         uint32_t msg_ref = 0;
2477                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2478                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2479                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2480                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2481         return msg_ref;
2482 }
2483 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendShortIdsQuery_get_node_id"))) TS_LDKMessageSendEvent_SendShortIdsQuery_get_node_id(uint32_t ptr) {
2484         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2485         assert(obj->tag == LDKMessageSendEvent_SendShortIdsQuery);
2486                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2487                         memcpy(node_id_arr->elems, obj->send_short_ids_query.node_id.compressed_form, 33);
2488         return node_id_arr;
2489 }
2490 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendShortIdsQuery_get_msg"))) TS_LDKMessageSendEvent_SendShortIdsQuery_get_msg(uint32_t ptr) {
2491         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2492         assert(obj->tag == LDKMessageSendEvent_SendShortIdsQuery);
2493                         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
2494                         uint32_t msg_ref = 0;
2495                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2496                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2497                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2498                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2499         return msg_ref;
2500 }
2501 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendReplyChannelRange_get_node_id"))) TS_LDKMessageSendEvent_SendReplyChannelRange_get_node_id(uint32_t ptr) {
2502         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2503         assert(obj->tag == LDKMessageSendEvent_SendReplyChannelRange);
2504                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2505                         memcpy(node_id_arr->elems, obj->send_reply_channel_range.node_id.compressed_form, 33);
2506         return node_id_arr;
2507 }
2508 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendReplyChannelRange_get_msg"))) TS_LDKMessageSendEvent_SendReplyChannelRange_get_msg(uint32_t ptr) {
2509         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2510         assert(obj->tag == LDKMessageSendEvent_SendReplyChannelRange);
2511                         LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
2512                         uint32_t msg_ref = 0;
2513                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2514                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2515                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2516                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2517         return msg_ref;
2518 }
2519 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendGossipTimestampFilter_get_node_id"))) TS_LDKMessageSendEvent_SendGossipTimestampFilter_get_node_id(uint32_t ptr) {
2520         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2521         assert(obj->tag == LDKMessageSendEvent_SendGossipTimestampFilter);
2522                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2523                         memcpy(node_id_arr->elems, obj->send_gossip_timestamp_filter.node_id.compressed_form, 33);
2524         return node_id_arr;
2525 }
2526 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendGossipTimestampFilter_get_msg"))) TS_LDKMessageSendEvent_SendGossipTimestampFilter_get_msg(uint32_t ptr) {
2527         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2528         assert(obj->tag == LDKMessageSendEvent_SendGossipTimestampFilter);
2529                         LDKGossipTimestampFilter msg_var = obj->send_gossip_timestamp_filter.msg;
2530                         uint32_t msg_ref = 0;
2531                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2532                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2533                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2534                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2535         return msg_ref;
2536 }
2537 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
2538         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
2539         for (size_t i = 0; i < ret.datalen; i++) {
2540                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
2541         }
2542         return ret;
2543 }
2544 static inline struct LDKTxOut CResult_TxOutAccessErrorZ_get_ok(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR owner){
2545 CHECK(owner->result_ok);
2546         return TxOut_clone(&*owner->contents.result);
2547 }
2548 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_get_ok"))) TS_CResult_TxOutAccessErrorZ_get_ok(uint32_t owner) {
2549         LDKCResult_TxOutAccessErrorZ* owner_conv = (LDKCResult_TxOutAccessErrorZ*)(owner & ~1);
2550         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
2551         *ret_ref = CResult_TxOutAccessErrorZ_get_ok(owner_conv);
2552         return (uint32_t)ret_ref;
2553 }
2554
2555 static inline enum LDKAccessError CResult_TxOutAccessErrorZ_get_err(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR owner){
2556 CHECK(!owner->result_ok);
2557         return AccessError_clone(&*owner->contents.err);
2558 }
2559 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_get_err"))) TS_CResult_TxOutAccessErrorZ_get_err(uint32_t owner) {
2560         LDKCResult_TxOutAccessErrorZ* owner_conv = (LDKCResult_TxOutAccessErrorZ*)(owner & ~1);
2561         uint32_t ret_conv = LDKAccessError_to_js(CResult_TxOutAccessErrorZ_get_err(owner_conv));
2562         return ret_conv;
2563 }
2564
2565 static inline uintptr_t C2Tuple_usizeTransactionZ_get_a(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
2566         return owner->a;
2567 }
2568 uint32_t  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_get_a"))) TS_C2Tuple_usizeTransactionZ_get_a(uint32_t owner) {
2569         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)(owner & ~1);
2570         uint32_t ret_conv = C2Tuple_usizeTransactionZ_get_a(owner_conv);
2571         return ret_conv;
2572 }
2573
2574 static inline struct LDKTransaction C2Tuple_usizeTransactionZ_get_b(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
2575         return owner->b;
2576 }
2577 int8_tArray  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_get_b"))) TS_C2Tuple_usizeTransactionZ_get_b(uint32_t owner) {
2578         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)(owner & ~1);
2579         LDKTransaction ret_var = C2Tuple_usizeTransactionZ_get_b(owner_conv);
2580         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
2581         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
2582         return ret_arr;
2583 }
2584
2585 static inline LDKCVec_C2Tuple_usizeTransactionZZ CVec_C2Tuple_usizeTransactionZZ_clone(const LDKCVec_C2Tuple_usizeTransactionZZ *orig) {
2586         LDKCVec_C2Tuple_usizeTransactionZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * orig->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ clone bytes"), .datalen = orig->datalen };
2587         for (size_t i = 0; i < ret.datalen; i++) {
2588                 ret.data[i] = C2Tuple_usizeTransactionZ_clone(&orig->data[i]);
2589         }
2590         return ret;
2591 }
2592 static inline LDKCVec_TxidZ CVec_TxidZ_clone(const LDKCVec_TxidZ *orig) {
2593         LDKCVec_TxidZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_TxidZ clone bytes"), .datalen = orig->datalen };
2594         for (size_t i = 0; i < ret.datalen; i++) {
2595                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
2596         }
2597         return ret;
2598 }
2599 static inline void CResult_NoneChannelMonitorUpdateErrZ_get_ok(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR owner){
2600 CHECK(owner->result_ok);
2601         return *owner->contents.result;
2602 }
2603 void  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_get_ok"))) TS_CResult_NoneChannelMonitorUpdateErrZ_get_ok(uint32_t owner) {
2604         LDKCResult_NoneChannelMonitorUpdateErrZ* owner_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(owner & ~1);
2605         CResult_NoneChannelMonitorUpdateErrZ_get_ok(owner_conv);
2606 }
2607
2608 static inline enum LDKChannelMonitorUpdateErr CResult_NoneChannelMonitorUpdateErrZ_get_err(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR owner){
2609 CHECK(!owner->result_ok);
2610         return ChannelMonitorUpdateErr_clone(&*owner->contents.err);
2611 }
2612 uint32_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_get_err"))) TS_CResult_NoneChannelMonitorUpdateErrZ_get_err(uint32_t owner) {
2613         LDKCResult_NoneChannelMonitorUpdateErrZ* owner_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(owner & ~1);
2614         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(CResult_NoneChannelMonitorUpdateErrZ_get_err(owner_conv));
2615         return ret_conv;
2616 }
2617
2618 uint32_t __attribute__((export_name("TS_LDKMonitorEvent_ty_from_ptr"))) TS_LDKMonitorEvent_ty_from_ptr(uint32_t ptr) {
2619         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
2620         switch(obj->tag) {
2621                 case LDKMonitorEvent_HTLCEvent: return 0;
2622                 case LDKMonitorEvent_CommitmentTxConfirmed: return 1;
2623                 case LDKMonitorEvent_UpdateCompleted: return 2;
2624                 case LDKMonitorEvent_UpdateFailed: return 3;
2625                 default: abort();
2626         }
2627 }
2628 uint32_t __attribute__((export_name("TS_LDKMonitorEvent_HTLCEvent_get_htlc_event"))) TS_LDKMonitorEvent_HTLCEvent_get_htlc_event(uint32_t ptr) {
2629         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
2630         assert(obj->tag == LDKMonitorEvent_HTLCEvent);
2631                         LDKHTLCUpdate htlc_event_var = obj->htlc_event;
2632                         uint32_t htlc_event_ref = 0;
2633                         CHECK((((uintptr_t)htlc_event_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2634                         CHECK((((uintptr_t)&htlc_event_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2635                         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_event_var);
2636                         htlc_event_ref = (uintptr_t)htlc_event_var.inner & ~1;
2637         return htlc_event_ref;
2638 }
2639 uint32_t __attribute__((export_name("TS_LDKMonitorEvent_CommitmentTxConfirmed_get_commitment_tx_confirmed"))) TS_LDKMonitorEvent_CommitmentTxConfirmed_get_commitment_tx_confirmed(uint32_t ptr) {
2640         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
2641         assert(obj->tag == LDKMonitorEvent_CommitmentTxConfirmed);
2642                         LDKOutPoint commitment_tx_confirmed_var = obj->commitment_tx_confirmed;
2643                         uint32_t commitment_tx_confirmed_ref = 0;
2644                         CHECK((((uintptr_t)commitment_tx_confirmed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2645                         CHECK((((uintptr_t)&commitment_tx_confirmed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2646                         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_confirmed_var);
2647                         commitment_tx_confirmed_ref = (uintptr_t)commitment_tx_confirmed_var.inner & ~1;
2648         return commitment_tx_confirmed_ref;
2649 }
2650 uint32_t __attribute__((export_name("TS_LDKMonitorEvent_UpdateCompleted_get_funding_txo"))) TS_LDKMonitorEvent_UpdateCompleted_get_funding_txo(uint32_t ptr) {
2651         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
2652         assert(obj->tag == LDKMonitorEvent_UpdateCompleted);
2653                         LDKOutPoint funding_txo_var = obj->update_completed.funding_txo;
2654                         uint32_t funding_txo_ref = 0;
2655                         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2656                         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2657                         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
2658                         funding_txo_ref = (uintptr_t)funding_txo_var.inner & ~1;
2659         return funding_txo_ref;
2660 }
2661 int64_t __attribute__((export_name("TS_LDKMonitorEvent_UpdateCompleted_get_monitor_update_id"))) TS_LDKMonitorEvent_UpdateCompleted_get_monitor_update_id(uint32_t ptr) {
2662         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
2663         assert(obj->tag == LDKMonitorEvent_UpdateCompleted);
2664                         int64_t monitor_update_id_conv = obj->update_completed.monitor_update_id;
2665         return monitor_update_id_conv;
2666 }
2667 uint32_t __attribute__((export_name("TS_LDKMonitorEvent_UpdateFailed_get_update_failed"))) TS_LDKMonitorEvent_UpdateFailed_get_update_failed(uint32_t ptr) {
2668         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
2669         assert(obj->tag == LDKMonitorEvent_UpdateFailed);
2670                         LDKOutPoint update_failed_var = obj->update_failed;
2671                         uint32_t update_failed_ref = 0;
2672                         CHECK((((uintptr_t)update_failed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2673                         CHECK((((uintptr_t)&update_failed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2674                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_failed_var);
2675                         update_failed_ref = (uintptr_t)update_failed_var.inner & ~1;
2676         return update_failed_ref;
2677 }
2678 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
2679         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
2680         for (size_t i = 0; i < ret.datalen; i++) {
2681                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
2682         }
2683         return ret;
2684 }
2685 static inline struct LDKOutPoint C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_a(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *NONNULL_PTR owner){
2686         return OutPoint_clone(&owner->a);
2687 }
2688 uint32_t  __attribute__((export_name("TS_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_a"))) TS_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_a(uint32_t owner) {
2689         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* owner_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(owner & ~1);
2690         LDKOutPoint ret_var = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_a(owner_conv);
2691         uint32_t ret_ref = 0;
2692         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2693         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2694         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2695         ret_ref = (uintptr_t)ret_var.inner;
2696         if (ret_var.is_owned) {
2697                 ret_ref |= 1;
2698         }
2699         return ret_ref;
2700 }
2701
2702 static inline struct LDKCVec_MonitorEventZ C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_b(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *NONNULL_PTR owner){
2703         return CVec_MonitorEventZ_clone(&owner->b);
2704 }
2705 uint32_tArray  __attribute__((export_name("TS_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_b"))) TS_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_b(uint32_t owner) {
2706         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* owner_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(owner & ~1);
2707         LDKCVec_MonitorEventZ ret_var = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_b(owner_conv);
2708         uint32_tArray ret_arr = NULL;
2709         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
2710         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 8);
2711         for (size_t o = 0; o < ret_var.datalen; o++) {
2712                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
2713                 *ret_conv_14_copy = ret_var.data[o];
2714                 uint32_t ret_conv_14_ref = (uintptr_t)ret_conv_14_copy;
2715                 ret_arr_ptr[o] = ret_conv_14_ref;
2716         }
2717         
2718         FREE(ret_var.data);
2719         return ret_arr;
2720 }
2721
2722 static inline struct LDKPublicKey C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_c(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *NONNULL_PTR owner){
2723         return owner->c;
2724 }
2725 int8_tArray  __attribute__((export_name("TS_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_c"))) TS_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_c(uint32_t owner) {
2726         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* owner_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(owner & ~1);
2727         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
2728         memcpy(ret_arr->elems, C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_c(owner_conv).compressed_form, 33);
2729         return ret_arr;
2730 }
2731
2732 static inline LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ_clone(const LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ *orig) {
2733         LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ) * orig->datalen, "LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ clone bytes"), .datalen = orig->datalen };
2734         for (size_t i = 0; i < ret.datalen; i++) {
2735                 ret.data[i] = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone(&orig->data[i]);
2736         }
2737         return ret;
2738 }
2739 uint32_t __attribute__((export_name("TS_LDKCOption_C2Tuple_usizeTransactionZZ_ty_from_ptr"))) TS_LDKCOption_C2Tuple_usizeTransactionZZ_ty_from_ptr(uint32_t ptr) {
2740         LDKCOption_C2Tuple_usizeTransactionZZ *obj = (LDKCOption_C2Tuple_usizeTransactionZZ*)(ptr & ~1);
2741         switch(obj->tag) {
2742                 case LDKCOption_C2Tuple_usizeTransactionZZ_Some: return 0;
2743                 case LDKCOption_C2Tuple_usizeTransactionZZ_None: return 1;
2744                 default: abort();
2745         }
2746 }
2747 uint32_t __attribute__((export_name("TS_LDKCOption_C2Tuple_usizeTransactionZZ_Some_get_some"))) TS_LDKCOption_C2Tuple_usizeTransactionZZ_Some_get_some(uint32_t ptr) {
2748         LDKCOption_C2Tuple_usizeTransactionZZ *obj = (LDKCOption_C2Tuple_usizeTransactionZZ*)(ptr & ~1);
2749         assert(obj->tag == LDKCOption_C2Tuple_usizeTransactionZZ_Some);
2750                         LDKC2Tuple_usizeTransactionZ* some_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
2751                         *some_conv = obj->some;
2752                         *some_conv = C2Tuple_usizeTransactionZ_clone(some_conv);
2753         return ((uint32_t)some_conv);
2754 }
2755 static inline struct LDKFixedPenaltyScorer CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR owner){
2756 CHECK(owner->result_ok);
2757         return FixedPenaltyScorer_clone(&*owner->contents.result);
2758 }
2759 uint32_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_get_ok"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(uint32_t owner) {
2760         LDKCResult_FixedPenaltyScorerDecodeErrorZ* owner_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(owner & ~1);
2761         LDKFixedPenaltyScorer ret_var = CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(owner_conv);
2762         uint32_t ret_ref = 0;
2763         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2764         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2765         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2766         ret_ref = (uintptr_t)ret_var.inner;
2767         if (ret_var.is_owned) {
2768                 ret_ref |= 1;
2769         }
2770         return ret_ref;
2771 }
2772
2773 static inline struct LDKDecodeError CResult_FixedPenaltyScorerDecodeErrorZ_get_err(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR owner){
2774 CHECK(!owner->result_ok);
2775         return DecodeError_clone(&*owner->contents.err);
2776 }
2777 uint32_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_get_err"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_get_err(uint32_t owner) {
2778         LDKCResult_FixedPenaltyScorerDecodeErrorZ* owner_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(owner & ~1);
2779         LDKDecodeError ret_var = CResult_FixedPenaltyScorerDecodeErrorZ_get_err(owner_conv);
2780         uint32_t ret_ref = 0;
2781         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2782         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2783         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2784         ret_ref = (uintptr_t)ret_var.inner;
2785         if (ret_var.is_owned) {
2786                 ret_ref |= 1;
2787         }
2788         return ret_ref;
2789 }
2790
2791 static inline uint64_t C2Tuple_u64u64Z_get_a(LDKC2Tuple_u64u64Z *NONNULL_PTR owner){
2792         return owner->a;
2793 }
2794 int64_t  __attribute__((export_name("TS_C2Tuple_u64u64Z_get_a"))) TS_C2Tuple_u64u64Z_get_a(uint32_t owner) {
2795         LDKC2Tuple_u64u64Z* owner_conv = (LDKC2Tuple_u64u64Z*)(owner & ~1);
2796         int64_t ret_conv = C2Tuple_u64u64Z_get_a(owner_conv);
2797         return ret_conv;
2798 }
2799
2800 static inline uint64_t C2Tuple_u64u64Z_get_b(LDKC2Tuple_u64u64Z *NONNULL_PTR owner){
2801         return owner->b;
2802 }
2803 int64_t  __attribute__((export_name("TS_C2Tuple_u64u64Z_get_b"))) TS_C2Tuple_u64u64Z_get_b(uint32_t owner) {
2804         LDKC2Tuple_u64u64Z* owner_conv = (LDKC2Tuple_u64u64Z*)(owner & ~1);
2805         int64_t ret_conv = C2Tuple_u64u64Z_get_b(owner_conv);
2806         return ret_conv;
2807 }
2808
2809 uint32_t __attribute__((export_name("TS_LDKCOption_C2Tuple_u64u64ZZ_ty_from_ptr"))) TS_LDKCOption_C2Tuple_u64u64ZZ_ty_from_ptr(uint32_t ptr) {
2810         LDKCOption_C2Tuple_u64u64ZZ *obj = (LDKCOption_C2Tuple_u64u64ZZ*)(ptr & ~1);
2811         switch(obj->tag) {
2812                 case LDKCOption_C2Tuple_u64u64ZZ_Some: return 0;
2813                 case LDKCOption_C2Tuple_u64u64ZZ_None: return 1;
2814                 default: abort();
2815         }
2816 }
2817 uint32_t __attribute__((export_name("TS_LDKCOption_C2Tuple_u64u64ZZ_Some_get_some"))) TS_LDKCOption_C2Tuple_u64u64ZZ_Some_get_some(uint32_t ptr) {
2818         LDKCOption_C2Tuple_u64u64ZZ *obj = (LDKCOption_C2Tuple_u64u64ZZ*)(ptr & ~1);
2819         assert(obj->tag == LDKCOption_C2Tuple_u64u64ZZ_Some);
2820                         LDKC2Tuple_u64u64Z* some_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
2821                         *some_conv = obj->some;
2822                         *some_conv = C2Tuple_u64u64Z_clone(some_conv);
2823         return ((uint32_t)some_conv);
2824 }
2825 static inline LDKCVec_NodeIdZ CVec_NodeIdZ_clone(const LDKCVec_NodeIdZ *orig) {
2826         LDKCVec_NodeIdZ ret = { .data = MALLOC(sizeof(LDKNodeId) * orig->datalen, "LDKCVec_NodeIdZ clone bytes"), .datalen = orig->datalen };
2827         for (size_t i = 0; i < ret.datalen; i++) {
2828                 ret.data[i] = NodeId_clone(&orig->data[i]);
2829         }
2830         return ret;
2831 }
2832 typedef struct LDKLogger_JCalls {
2833         atomic_size_t refcnt;
2834         uint32_t instance_ptr;
2835 } LDKLogger_JCalls;
2836 static void LDKLogger_JCalls_free(void* this_arg) {
2837         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
2838         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2839                 FREE(j_calls);
2840         }
2841 }
2842 void log_LDKLogger_jcall(const void* this_arg, const LDKRecord * record) {
2843         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
2844         LDKRecord record_var = *record;
2845         uint32_t record_ref = 0;
2846         record_var = Record_clone(&record_var);
2847         CHECK((((uintptr_t)record_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2848         CHECK((((uintptr_t)&record_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2849         CHECK_INNER_FIELD_ACCESS_OR_NULL(record_var);
2850         record_ref = (uintptr_t)record_var.inner;
2851         if (record_var.is_owned) {
2852                 record_ref |= 1;
2853         }
2854         js_invoke_function_uuuuuu(j_calls->instance_ptr, 0, (uint32_t)record_ref, 0, 0, 0, 0, 0);
2855 }
2856 static void LDKLogger_JCalls_cloned(LDKLogger* new_obj) {
2857         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) new_obj->this_arg;
2858         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2859 }
2860 static inline LDKLogger LDKLogger_init (JSValue o) {
2861         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
2862         atomic_init(&calls->refcnt, 1);
2863         calls->instance_ptr = o;
2864
2865         LDKLogger ret = {
2866                 .this_arg = (void*) calls,
2867                 .log = log_LDKLogger_jcall,
2868                 .free = LDKLogger_JCalls_free,
2869         };
2870         return ret;
2871 }
2872 long  __attribute__((export_name("TS_LDKLogger_new"))) TS_LDKLogger_new(JSValue o) {
2873         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
2874         *res_ptr = LDKLogger_init(o);
2875         return (long)res_ptr;
2876 }
2877 static inline struct LDKProbabilisticScorer *CResult_ProbabilisticScorerDecodeErrorZ_get_ok(LDKCResult_ProbabilisticScorerDecodeErrorZ *NONNULL_PTR owner){
2878 CHECK(owner->result_ok);
2879         return &*owner->contents.result;
2880 }
2881 uint32_t  __attribute__((export_name("TS_CResult_ProbabilisticScorerDecodeErrorZ_get_ok"))) TS_CResult_ProbabilisticScorerDecodeErrorZ_get_ok(uint32_t owner) {
2882         LDKCResult_ProbabilisticScorerDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)(owner & ~1);
2883         LDKProbabilisticScorer ret_var = *CResult_ProbabilisticScorerDecodeErrorZ_get_ok(owner_conv);
2884         uint32_t ret_ref = 0;
2885         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2886         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2887         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2888         ret_ref = (uintptr_t)ret_var.inner & ~1;
2889         return ret_ref;
2890 }
2891
2892 static inline struct LDKDecodeError CResult_ProbabilisticScorerDecodeErrorZ_get_err(LDKCResult_ProbabilisticScorerDecodeErrorZ *NONNULL_PTR owner){
2893 CHECK(!owner->result_ok);
2894         return DecodeError_clone(&*owner->contents.err);
2895 }
2896 uint32_t  __attribute__((export_name("TS_CResult_ProbabilisticScorerDecodeErrorZ_get_err"))) TS_CResult_ProbabilisticScorerDecodeErrorZ_get_err(uint32_t owner) {
2897         LDKCResult_ProbabilisticScorerDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)(owner & ~1);
2898         LDKDecodeError ret_var = CResult_ProbabilisticScorerDecodeErrorZ_get_err(owner_conv);
2899         uint32_t ret_ref = 0;
2900         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2901         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2902         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2903         ret_ref = (uintptr_t)ret_var.inner;
2904         if (ret_var.is_owned) {
2905                 ret_ref |= 1;
2906         }
2907         return ret_ref;
2908 }
2909
2910 static inline struct LDKInitFeatures CResult_InitFeaturesDecodeErrorZ_get_ok(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
2911 CHECK(owner->result_ok);
2912         return InitFeatures_clone(&*owner->contents.result);
2913 }
2914 uint32_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_get_ok"))) TS_CResult_InitFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
2915         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(owner & ~1);
2916         LDKInitFeatures ret_var = CResult_InitFeaturesDecodeErrorZ_get_ok(owner_conv);
2917         uint32_t ret_ref = 0;
2918         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2919         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2920         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2921         ret_ref = (uintptr_t)ret_var.inner;
2922         if (ret_var.is_owned) {
2923                 ret_ref |= 1;
2924         }
2925         return ret_ref;
2926 }
2927
2928 static inline struct LDKDecodeError CResult_InitFeaturesDecodeErrorZ_get_err(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
2929 CHECK(!owner->result_ok);
2930         return DecodeError_clone(&*owner->contents.err);
2931 }
2932 uint32_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_get_err"))) TS_CResult_InitFeaturesDecodeErrorZ_get_err(uint32_t owner) {
2933         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(owner & ~1);
2934         LDKDecodeError ret_var = CResult_InitFeaturesDecodeErrorZ_get_err(owner_conv);
2935         uint32_t ret_ref = 0;
2936         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2937         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2938         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2939         ret_ref = (uintptr_t)ret_var.inner;
2940         if (ret_var.is_owned) {
2941                 ret_ref |= 1;
2942         }
2943         return ret_ref;
2944 }
2945
2946 static inline struct LDKChannelFeatures CResult_ChannelFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
2947 CHECK(owner->result_ok);
2948         return ChannelFeatures_clone(&*owner->contents.result);
2949 }
2950 uint32_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_get_ok"))) TS_CResult_ChannelFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
2951         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(owner & ~1);
2952         LDKChannelFeatures ret_var = CResult_ChannelFeaturesDecodeErrorZ_get_ok(owner_conv);
2953         uint32_t ret_ref = 0;
2954         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2955         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2956         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2957         ret_ref = (uintptr_t)ret_var.inner;
2958         if (ret_var.is_owned) {
2959                 ret_ref |= 1;
2960         }
2961         return ret_ref;
2962 }
2963
2964 static inline struct LDKDecodeError CResult_ChannelFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
2965 CHECK(!owner->result_ok);
2966         return DecodeError_clone(&*owner->contents.err);
2967 }
2968 uint32_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_get_err"))) TS_CResult_ChannelFeaturesDecodeErrorZ_get_err(uint32_t owner) {
2969         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(owner & ~1);
2970         LDKDecodeError ret_var = CResult_ChannelFeaturesDecodeErrorZ_get_err(owner_conv);
2971         uint32_t ret_ref = 0;
2972         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2973         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2974         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2975         ret_ref = (uintptr_t)ret_var.inner;
2976         if (ret_var.is_owned) {
2977                 ret_ref |= 1;
2978         }
2979         return ret_ref;
2980 }
2981
2982 static inline struct LDKNodeFeatures CResult_NodeFeaturesDecodeErrorZ_get_ok(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
2983 CHECK(owner->result_ok);
2984         return NodeFeatures_clone(&*owner->contents.result);
2985 }
2986 uint32_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_get_ok"))) TS_CResult_NodeFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
2987         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(owner & ~1);
2988         LDKNodeFeatures ret_var = CResult_NodeFeaturesDecodeErrorZ_get_ok(owner_conv);
2989         uint32_t ret_ref = 0;
2990         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2991         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2992         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2993         ret_ref = (uintptr_t)ret_var.inner;
2994         if (ret_var.is_owned) {
2995                 ret_ref |= 1;
2996         }
2997         return ret_ref;
2998 }
2999
3000 static inline struct LDKDecodeError CResult_NodeFeaturesDecodeErrorZ_get_err(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
3001 CHECK(!owner->result_ok);
3002         return DecodeError_clone(&*owner->contents.err);
3003 }
3004 uint32_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_get_err"))) TS_CResult_NodeFeaturesDecodeErrorZ_get_err(uint32_t owner) {
3005         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(owner & ~1);
3006         LDKDecodeError ret_var = CResult_NodeFeaturesDecodeErrorZ_get_err(owner_conv);
3007         uint32_t ret_ref = 0;
3008         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3009         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3010         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3011         ret_ref = (uintptr_t)ret_var.inner;
3012         if (ret_var.is_owned) {
3013                 ret_ref |= 1;
3014         }
3015         return ret_ref;
3016 }
3017
3018 static inline struct LDKInvoiceFeatures CResult_InvoiceFeaturesDecodeErrorZ_get_ok(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
3019 CHECK(owner->result_ok);
3020         return InvoiceFeatures_clone(&*owner->contents.result);
3021 }
3022 uint32_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_get_ok"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
3023         LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(owner & ~1);
3024         LDKInvoiceFeatures ret_var = CResult_InvoiceFeaturesDecodeErrorZ_get_ok(owner_conv);
3025         uint32_t ret_ref = 0;
3026         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3027         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3028         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3029         ret_ref = (uintptr_t)ret_var.inner;
3030         if (ret_var.is_owned) {
3031                 ret_ref |= 1;
3032         }
3033         return ret_ref;
3034 }
3035
3036 static inline struct LDKDecodeError CResult_InvoiceFeaturesDecodeErrorZ_get_err(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
3037 CHECK(!owner->result_ok);
3038         return DecodeError_clone(&*owner->contents.err);
3039 }
3040 uint32_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_get_err"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_get_err(uint32_t owner) {
3041         LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(owner & ~1);
3042         LDKDecodeError ret_var = CResult_InvoiceFeaturesDecodeErrorZ_get_err(owner_conv);
3043         uint32_t ret_ref = 0;
3044         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3045         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3046         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3047         ret_ref = (uintptr_t)ret_var.inner;
3048         if (ret_var.is_owned) {
3049                 ret_ref |= 1;
3050         }
3051         return ret_ref;
3052 }
3053
3054 static inline struct LDKChannelTypeFeatures CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
3055 CHECK(owner->result_ok);
3056         return ChannelTypeFeatures_clone(&*owner->contents.result);
3057 }
3058 uint32_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
3059         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(owner & ~1);
3060         LDKChannelTypeFeatures ret_var = CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(owner_conv);
3061         uint32_t ret_ref = 0;
3062         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3063         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3064         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3065         ret_ref = (uintptr_t)ret_var.inner;
3066         if (ret_var.is_owned) {
3067                 ret_ref |= 1;
3068         }
3069         return ret_ref;
3070 }
3071
3072 static inline struct LDKDecodeError CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
3073 CHECK(!owner->result_ok);
3074         return DecodeError_clone(&*owner->contents.err);
3075 }
3076 uint32_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_get_err"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(uint32_t owner) {
3077         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(owner & ~1);
3078         LDKDecodeError ret_var = CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(owner_conv);
3079         uint32_t ret_ref = 0;
3080         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3081         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3082         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3083         ret_ref = (uintptr_t)ret_var.inner;
3084         if (ret_var.is_owned) {
3085                 ret_ref |= 1;
3086         }
3087         return ret_ref;
3088 }
3089
3090 static inline struct LDKNodeId CResult_NodeIdDecodeErrorZ_get_ok(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
3091 CHECK(owner->result_ok);
3092         return NodeId_clone(&*owner->contents.result);
3093 }
3094 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_get_ok"))) TS_CResult_NodeIdDecodeErrorZ_get_ok(uint32_t owner) {
3095         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)(owner & ~1);
3096         LDKNodeId ret_var = CResult_NodeIdDecodeErrorZ_get_ok(owner_conv);
3097         uint32_t ret_ref = 0;
3098         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3099         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3100         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3101         ret_ref = (uintptr_t)ret_var.inner;
3102         if (ret_var.is_owned) {
3103                 ret_ref |= 1;
3104         }
3105         return ret_ref;
3106 }
3107
3108 static inline struct LDKDecodeError CResult_NodeIdDecodeErrorZ_get_err(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
3109 CHECK(!owner->result_ok);
3110         return DecodeError_clone(&*owner->contents.err);
3111 }
3112 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_get_err"))) TS_CResult_NodeIdDecodeErrorZ_get_err(uint32_t owner) {
3113         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)(owner & ~1);
3114         LDKDecodeError ret_var = CResult_NodeIdDecodeErrorZ_get_err(owner_conv);
3115         uint32_t ret_ref = 0;
3116         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3117         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3118         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3119         ret_ref = (uintptr_t)ret_var.inner;
3120         if (ret_var.is_owned) {
3121                 ret_ref |= 1;
3122         }
3123         return ret_ref;
3124 }
3125
3126 static inline struct LDKCOption_NetworkUpdateZ CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
3127 CHECK(owner->result_ok);
3128         return COption_NetworkUpdateZ_clone(&*owner->contents.result);
3129 }
3130 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(uint32_t owner) {
3131         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(owner & ~1);
3132         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
3133         *ret_copy = CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(owner_conv);
3134         uint32_t ret_ref = (uintptr_t)ret_copy;
3135         return ret_ref;
3136 }
3137
3138 static inline struct LDKDecodeError CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
3139 CHECK(!owner->result_ok);
3140         return DecodeError_clone(&*owner->contents.err);
3141 }
3142 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_get_err"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(uint32_t owner) {
3143         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(owner & ~1);
3144         LDKDecodeError ret_var = CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(owner_conv);
3145         uint32_t ret_ref = 0;
3146         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3147         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3148         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3149         ret_ref = (uintptr_t)ret_var.inner;
3150         if (ret_var.is_owned) {
3151                 ret_ref |= 1;
3152         }
3153         return ret_ref;
3154 }
3155
3156 typedef struct LDKAccess_JCalls {
3157         atomic_size_t refcnt;
3158         uint32_t instance_ptr;
3159 } LDKAccess_JCalls;
3160 static void LDKAccess_JCalls_free(void* this_arg) {
3161         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
3162         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3163                 FREE(j_calls);
3164         }
3165 }
3166 LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
3167         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
3168         int8_tArray genesis_hash_arr = init_int8_tArray(32, __LINE__);
3169         memcpy(genesis_hash_arr->elems, *genesis_hash, 32);
3170         int64_t short_channel_id_conv = short_channel_id;
3171         uint32_t ret = js_invoke_function_ubuuuu(j_calls->instance_ptr, 1, (uint32_t)genesis_hash_arr, (uint32_t)short_channel_id_conv, 0, 0, 0, 0);
3172         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3173         CHECK_ACCESS(ret_ptr);
3174         LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(ret_ptr);
3175         FREE((void*)ret);
3176         return ret_conv;
3177 }
3178 static void LDKAccess_JCalls_cloned(LDKAccess* new_obj) {
3179         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) new_obj->this_arg;
3180         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3181 }
3182 static inline LDKAccess LDKAccess_init (JSValue o) {
3183         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
3184         atomic_init(&calls->refcnt, 1);
3185         calls->instance_ptr = o;
3186
3187         LDKAccess ret = {
3188                 .this_arg = (void*) calls,
3189                 .get_utxo = get_utxo_LDKAccess_jcall,
3190                 .free = LDKAccess_JCalls_free,
3191         };
3192         return ret;
3193 }
3194 long  __attribute__((export_name("TS_LDKAccess_new"))) TS_LDKAccess_new(JSValue o) {
3195         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
3196         *res_ptr = LDKAccess_init(o);
3197         return (long)res_ptr;
3198 }
3199 uint32_t  __attribute__((export_name("TS_Access_get_utxo"))) TS_Access_get_utxo(uint32_t this_arg, int8_tArray genesis_hash, int64_t short_channel_id) {
3200         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3201         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3202         LDKAccess* this_arg_conv = (LDKAccess*)this_arg_ptr;
3203         unsigned char genesis_hash_arr[32];
3204         CHECK(genesis_hash->arr_len == 32);
3205         memcpy(genesis_hash_arr, genesis_hash->elems, 32); FREE(genesis_hash);
3206         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
3207         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
3208         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
3209         return (uint32_t)ret_conv;
3210 }
3211
3212 uint32_t __attribute__((export_name("TS_LDKCOption_AccessZ_ty_from_ptr"))) TS_LDKCOption_AccessZ_ty_from_ptr(uint32_t ptr) {
3213         LDKCOption_AccessZ *obj = (LDKCOption_AccessZ*)(ptr & ~1);
3214         switch(obj->tag) {
3215                 case LDKCOption_AccessZ_Some: return 0;
3216                 case LDKCOption_AccessZ_None: return 1;
3217                 default: abort();
3218         }
3219 }
3220 uint32_t __attribute__((export_name("TS_LDKCOption_AccessZ_Some_get_some"))) TS_LDKCOption_AccessZ_Some_get_some(uint32_t ptr) {
3221         LDKCOption_AccessZ *obj = (LDKCOption_AccessZ*)(ptr & ~1);
3222         assert(obj->tag == LDKCOption_AccessZ_Some);
3223                         LDKAccess* some_ret = MALLOC(sizeof(LDKAccess), "LDKAccess");
3224                         *some_ret = obj->some;
3225                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
3226                         if ((*some_ret).free == LDKAccess_JCalls_free) {
3227                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
3228                                 LDKAccess_JCalls_cloned(&(*some_ret));
3229                         }
3230         return (uint32_t)some_ret;
3231 }
3232 static inline bool CResult_boolLightningErrorZ_get_ok(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
3233 CHECK(owner->result_ok);
3234         return *owner->contents.result;
3235 }
3236 jboolean  __attribute__((export_name("TS_CResult_boolLightningErrorZ_get_ok"))) TS_CResult_boolLightningErrorZ_get_ok(uint32_t owner) {
3237         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)(owner & ~1);
3238         jboolean ret_conv = CResult_boolLightningErrorZ_get_ok(owner_conv);
3239         return ret_conv;
3240 }
3241
3242 static inline struct LDKLightningError CResult_boolLightningErrorZ_get_err(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
3243 CHECK(!owner->result_ok);
3244         return LightningError_clone(&*owner->contents.err);
3245 }
3246 uint32_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_get_err"))) TS_CResult_boolLightningErrorZ_get_err(uint32_t owner) {
3247         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)(owner & ~1);
3248         LDKLightningError ret_var = CResult_boolLightningErrorZ_get_err(owner_conv);
3249         uint32_t ret_ref = 0;
3250         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3251         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3252         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3253         ret_ref = (uintptr_t)ret_var.inner;
3254         if (ret_var.is_owned) {
3255                 ret_ref |= 1;
3256         }
3257         return ret_ref;
3258 }
3259
3260 static inline struct LDKChannelAnnouncement C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
3261         return ChannelAnnouncement_clone(&owner->a);
3262 }
3263 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(uint32_t owner) {
3264         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
3265         LDKChannelAnnouncement ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(owner_conv);
3266         uint32_t ret_ref = 0;
3267         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3268         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3269         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3270         ret_ref = (uintptr_t)ret_var.inner;
3271         if (ret_var.is_owned) {
3272                 ret_ref |= 1;
3273         }
3274         return ret_ref;
3275 }
3276
3277 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
3278         return ChannelUpdate_clone(&owner->b);
3279 }
3280 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(uint32_t owner) {
3281         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
3282         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(owner_conv);
3283         uint32_t ret_ref = 0;
3284         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3285         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3286         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3287         ret_ref = (uintptr_t)ret_var.inner;
3288         if (ret_var.is_owned) {
3289                 ret_ref |= 1;
3290         }
3291         return ret_ref;
3292 }
3293
3294 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
3295         return ChannelUpdate_clone(&owner->c);
3296 }
3297 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(uint32_t owner) {
3298         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
3299         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(owner_conv);
3300         uint32_t ret_ref = 0;
3301         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3302         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3303         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3304         ret_ref = (uintptr_t)ret_var.inner;
3305         if (ret_var.is_owned) {
3306                 ret_ref |= 1;
3307         }
3308         return ret_ref;
3309 }
3310
3311 static inline LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *orig) {
3312         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * orig->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ clone bytes"), .datalen = orig->datalen };
3313         for (size_t i = 0; i < ret.datalen; i++) {
3314                 ret.data[i] = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(&orig->data[i]);
3315         }
3316         return ret;
3317 }
3318 static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCVec_NodeAnnouncementZ *orig) {
3319         LDKCVec_NodeAnnouncementZ ret = { .data = MALLOC(sizeof(LDKNodeAnnouncement) * orig->datalen, "LDKCVec_NodeAnnouncementZ clone bytes"), .datalen = orig->datalen };
3320         for (size_t i = 0; i < ret.datalen; i++) {
3321                 ret.data[i] = NodeAnnouncement_clone(&orig->data[i]);
3322         }
3323         return ret;
3324 }
3325 static inline void CResult_NoneLightningErrorZ_get_ok(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
3326 CHECK(owner->result_ok);
3327         return *owner->contents.result;
3328 }
3329 void  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_get_ok"))) TS_CResult_NoneLightningErrorZ_get_ok(uint32_t owner) {
3330         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)(owner & ~1);
3331         CResult_NoneLightningErrorZ_get_ok(owner_conv);
3332 }
3333
3334 static inline struct LDKLightningError CResult_NoneLightningErrorZ_get_err(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
3335 CHECK(!owner->result_ok);
3336         return LightningError_clone(&*owner->contents.err);
3337 }
3338 uint32_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_get_err"))) TS_CResult_NoneLightningErrorZ_get_err(uint32_t owner) {
3339         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)(owner & ~1);
3340         LDKLightningError ret_var = CResult_NoneLightningErrorZ_get_err(owner_conv);
3341         uint32_t ret_ref = 0;
3342         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3343         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3344         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3345         ret_ref = (uintptr_t)ret_var.inner;
3346         if (ret_var.is_owned) {
3347                 ret_ref |= 1;
3348         }
3349         return ret_ref;
3350 }
3351
3352 static inline struct LDKChannelUpdateInfo CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR owner){
3353 CHECK(owner->result_ok);
3354         return ChannelUpdateInfo_clone(&*owner->contents.result);
3355 }
3356 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_get_ok"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(uint32_t owner) {
3357         LDKCResult_ChannelUpdateInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(owner & ~1);
3358         LDKChannelUpdateInfo ret_var = CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(owner_conv);
3359         uint32_t ret_ref = 0;
3360         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3361         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3362         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3363         ret_ref = (uintptr_t)ret_var.inner;
3364         if (ret_var.is_owned) {
3365                 ret_ref |= 1;
3366         }
3367         return ret_ref;
3368 }
3369
3370 static inline struct LDKDecodeError CResult_ChannelUpdateInfoDecodeErrorZ_get_err(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR owner){
3371 CHECK(!owner->result_ok);
3372         return DecodeError_clone(&*owner->contents.err);
3373 }
3374 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_get_err"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_get_err(uint32_t owner) {
3375         LDKCResult_ChannelUpdateInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(owner & ~1);
3376         LDKDecodeError ret_var = CResult_ChannelUpdateInfoDecodeErrorZ_get_err(owner_conv);
3377         uint32_t ret_ref = 0;
3378         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3379         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3380         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3381         ret_ref = (uintptr_t)ret_var.inner;
3382         if (ret_var.is_owned) {
3383                 ret_ref |= 1;
3384         }
3385         return ret_ref;
3386 }
3387
3388 static inline struct LDKChannelInfo CResult_ChannelInfoDecodeErrorZ_get_ok(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
3389 CHECK(owner->result_ok);
3390         return ChannelInfo_clone(&*owner->contents.result);
3391 }
3392 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_get_ok"))) TS_CResult_ChannelInfoDecodeErrorZ_get_ok(uint32_t owner) {
3393         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(owner & ~1);
3394         LDKChannelInfo ret_var = CResult_ChannelInfoDecodeErrorZ_get_ok(owner_conv);
3395         uint32_t ret_ref = 0;
3396         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3397         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3398         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3399         ret_ref = (uintptr_t)ret_var.inner;
3400         if (ret_var.is_owned) {
3401                 ret_ref |= 1;
3402         }
3403         return ret_ref;
3404 }
3405
3406 static inline struct LDKDecodeError CResult_ChannelInfoDecodeErrorZ_get_err(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
3407 CHECK(!owner->result_ok);
3408         return DecodeError_clone(&*owner->contents.err);
3409 }
3410 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_get_err"))) TS_CResult_ChannelInfoDecodeErrorZ_get_err(uint32_t owner) {
3411         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(owner & ~1);
3412         LDKDecodeError ret_var = CResult_ChannelInfoDecodeErrorZ_get_err(owner_conv);
3413         uint32_t ret_ref = 0;
3414         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3415         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3416         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3417         ret_ref = (uintptr_t)ret_var.inner;
3418         if (ret_var.is_owned) {
3419                 ret_ref |= 1;
3420         }
3421         return ret_ref;
3422 }
3423
3424 static inline struct LDKRoutingFees CResult_RoutingFeesDecodeErrorZ_get_ok(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
3425 CHECK(owner->result_ok);
3426         return RoutingFees_clone(&*owner->contents.result);
3427 }
3428 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_get_ok"))) TS_CResult_RoutingFeesDecodeErrorZ_get_ok(uint32_t owner) {
3429         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(owner & ~1);
3430         LDKRoutingFees ret_var = CResult_RoutingFeesDecodeErrorZ_get_ok(owner_conv);
3431         uint32_t ret_ref = 0;
3432         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3433         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3434         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3435         ret_ref = (uintptr_t)ret_var.inner;
3436         if (ret_var.is_owned) {
3437                 ret_ref |= 1;
3438         }
3439         return ret_ref;
3440 }
3441
3442 static inline struct LDKDecodeError CResult_RoutingFeesDecodeErrorZ_get_err(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
3443 CHECK(!owner->result_ok);
3444         return DecodeError_clone(&*owner->contents.err);
3445 }
3446 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_get_err"))) TS_CResult_RoutingFeesDecodeErrorZ_get_err(uint32_t owner) {
3447         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(owner & ~1);
3448         LDKDecodeError ret_var = CResult_RoutingFeesDecodeErrorZ_get_err(owner_conv);
3449         uint32_t ret_ref = 0;
3450         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3451         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3452         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3453         ret_ref = (uintptr_t)ret_var.inner;
3454         if (ret_var.is_owned) {
3455                 ret_ref |= 1;
3456         }
3457         return ret_ref;
3458 }
3459
3460 uint32_t __attribute__((export_name("TS_LDKNetAddress_ty_from_ptr"))) TS_LDKNetAddress_ty_from_ptr(uint32_t ptr) {
3461         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3462         switch(obj->tag) {
3463                 case LDKNetAddress_IPv4: return 0;
3464                 case LDKNetAddress_IPv6: return 1;
3465                 case LDKNetAddress_OnionV2: return 2;
3466                 case LDKNetAddress_OnionV3: return 3;
3467                 case LDKNetAddress_Hostname: return 4;
3468                 default: abort();
3469         }
3470 }
3471 int8_tArray __attribute__((export_name("TS_LDKNetAddress_IPv4_get_addr"))) TS_LDKNetAddress_IPv4_get_addr(uint32_t ptr) {
3472         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3473         assert(obj->tag == LDKNetAddress_IPv4);
3474                         int8_tArray addr_arr = init_int8_tArray(4, __LINE__);
3475                         memcpy(addr_arr->elems, obj->i_pv4.addr.data, 4);
3476         return addr_arr;
3477 }
3478 int16_t __attribute__((export_name("TS_LDKNetAddress_IPv4_get_port"))) TS_LDKNetAddress_IPv4_get_port(uint32_t ptr) {
3479         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3480         assert(obj->tag == LDKNetAddress_IPv4);
3481                         int16_t port_conv = obj->i_pv4.port;
3482         return port_conv;
3483 }
3484 int8_tArray __attribute__((export_name("TS_LDKNetAddress_IPv6_get_addr"))) TS_LDKNetAddress_IPv6_get_addr(uint32_t ptr) {
3485         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3486         assert(obj->tag == LDKNetAddress_IPv6);
3487                         int8_tArray addr_arr = init_int8_tArray(16, __LINE__);
3488                         memcpy(addr_arr->elems, obj->i_pv6.addr.data, 16);
3489         return addr_arr;
3490 }
3491 int16_t __attribute__((export_name("TS_LDKNetAddress_IPv6_get_port"))) TS_LDKNetAddress_IPv6_get_port(uint32_t ptr) {
3492         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3493         assert(obj->tag == LDKNetAddress_IPv6);
3494                         int16_t port_conv = obj->i_pv6.port;
3495         return port_conv;
3496 }
3497 int8_tArray __attribute__((export_name("TS_LDKNetAddress_OnionV2_get_onion_v2"))) TS_LDKNetAddress_OnionV2_get_onion_v2(uint32_t ptr) {
3498         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3499         assert(obj->tag == LDKNetAddress_OnionV2);
3500                         int8_tArray onion_v2_arr = init_int8_tArray(12, __LINE__);
3501                         memcpy(onion_v2_arr->elems, obj->onion_v2.data, 12);
3502         return onion_v2_arr;
3503 }
3504 int8_tArray __attribute__((export_name("TS_LDKNetAddress_OnionV3_get_ed25519_pubkey"))) TS_LDKNetAddress_OnionV3_get_ed25519_pubkey(uint32_t ptr) {
3505         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3506         assert(obj->tag == LDKNetAddress_OnionV3);
3507                         int8_tArray ed25519_pubkey_arr = init_int8_tArray(32, __LINE__);
3508                         memcpy(ed25519_pubkey_arr->elems, obj->onion_v3.ed25519_pubkey.data, 32);
3509         return ed25519_pubkey_arr;
3510 }
3511 int16_t __attribute__((export_name("TS_LDKNetAddress_OnionV3_get_checksum"))) TS_LDKNetAddress_OnionV3_get_checksum(uint32_t ptr) {
3512         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3513         assert(obj->tag == LDKNetAddress_OnionV3);
3514                         int16_t checksum_conv = obj->onion_v3.checksum;
3515         return checksum_conv;
3516 }
3517 int8_t __attribute__((export_name("TS_LDKNetAddress_OnionV3_get_version"))) TS_LDKNetAddress_OnionV3_get_version(uint32_t ptr) {
3518         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3519         assert(obj->tag == LDKNetAddress_OnionV3);
3520                         int8_t version_conv = obj->onion_v3.version;
3521         return version_conv;
3522 }
3523 int16_t __attribute__((export_name("TS_LDKNetAddress_OnionV3_get_port"))) TS_LDKNetAddress_OnionV3_get_port(uint32_t ptr) {
3524         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3525         assert(obj->tag == LDKNetAddress_OnionV3);
3526                         int16_t port_conv = obj->onion_v3.port;
3527         return port_conv;
3528 }
3529 uint32_t __attribute__((export_name("TS_LDKNetAddress_Hostname_get_hostname"))) TS_LDKNetAddress_Hostname_get_hostname(uint32_t ptr) {
3530         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3531         assert(obj->tag == LDKNetAddress_Hostname);
3532                         LDKHostname hostname_var = obj->hostname.hostname;
3533                         uint32_t hostname_ref = 0;
3534                         CHECK((((uintptr_t)hostname_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3535                         CHECK((((uintptr_t)&hostname_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3536                         CHECK_INNER_FIELD_ACCESS_OR_NULL(hostname_var);
3537                         hostname_ref = (uintptr_t)hostname_var.inner & ~1;
3538         return hostname_ref;
3539 }
3540 int16_t __attribute__((export_name("TS_LDKNetAddress_Hostname_get_port"))) TS_LDKNetAddress_Hostname_get_port(uint32_t ptr) {
3541         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3542         assert(obj->tag == LDKNetAddress_Hostname);
3543                         int16_t port_conv = obj->hostname.port;
3544         return port_conv;
3545 }
3546 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
3547         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
3548         for (size_t i = 0; i < ret.datalen; i++) {
3549                 ret.data[i] = NetAddress_clone(&orig->data[i]);
3550         }
3551         return ret;
3552 }
3553 static inline struct LDKNodeAnnouncementInfo CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
3554 CHECK(owner->result_ok);
3555         return NodeAnnouncementInfo_clone(&*owner->contents.result);
3556 }
3557 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(uint32_t owner) {
3558         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(owner & ~1);
3559         LDKNodeAnnouncementInfo ret_var = CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(owner_conv);
3560         uint32_t ret_ref = 0;
3561         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3562         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3563         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3564         ret_ref = (uintptr_t)ret_var.inner;
3565         if (ret_var.is_owned) {
3566                 ret_ref |= 1;
3567         }
3568         return ret_ref;
3569 }
3570
3571 static inline struct LDKDecodeError CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
3572 CHECK(!owner->result_ok);
3573         return DecodeError_clone(&*owner->contents.err);
3574 }
3575 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_get_err"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(uint32_t owner) {
3576         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(owner & ~1);
3577         LDKDecodeError ret_var = CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(owner_conv);
3578         uint32_t ret_ref = 0;
3579         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3580         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3581         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3582         ret_ref = (uintptr_t)ret_var.inner;
3583         if (ret_var.is_owned) {
3584                 ret_ref |= 1;
3585         }
3586         return ret_ref;
3587 }
3588
3589 static inline struct LDKNodeAlias CResult_NodeAliasDecodeErrorZ_get_ok(LDKCResult_NodeAliasDecodeErrorZ *NONNULL_PTR owner){
3590 CHECK(owner->result_ok);
3591         return NodeAlias_clone(&*owner->contents.result);
3592 }
3593 uint32_t  __attribute__((export_name("TS_CResult_NodeAliasDecodeErrorZ_get_ok"))) TS_CResult_NodeAliasDecodeErrorZ_get_ok(uint32_t owner) {
3594         LDKCResult_NodeAliasDecodeErrorZ* owner_conv = (LDKCResult_NodeAliasDecodeErrorZ*)(owner & ~1);
3595         LDKNodeAlias ret_var = CResult_NodeAliasDecodeErrorZ_get_ok(owner_conv);
3596         uint32_t ret_ref = 0;
3597         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3598         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3599         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3600         ret_ref = (uintptr_t)ret_var.inner;
3601         if (ret_var.is_owned) {
3602                 ret_ref |= 1;
3603         }
3604         return ret_ref;
3605 }
3606
3607 static inline struct LDKDecodeError CResult_NodeAliasDecodeErrorZ_get_err(LDKCResult_NodeAliasDecodeErrorZ *NONNULL_PTR owner){
3608 CHECK(!owner->result_ok);
3609         return DecodeError_clone(&*owner->contents.err);
3610 }
3611 uint32_t  __attribute__((export_name("TS_CResult_NodeAliasDecodeErrorZ_get_err"))) TS_CResult_NodeAliasDecodeErrorZ_get_err(uint32_t owner) {
3612         LDKCResult_NodeAliasDecodeErrorZ* owner_conv = (LDKCResult_NodeAliasDecodeErrorZ*)(owner & ~1);
3613         LDKDecodeError ret_var = CResult_NodeAliasDecodeErrorZ_get_err(owner_conv);
3614         uint32_t ret_ref = 0;
3615         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3616         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3617         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3618         ret_ref = (uintptr_t)ret_var.inner;
3619         if (ret_var.is_owned) {
3620                 ret_ref |= 1;
3621         }
3622         return ret_ref;
3623 }
3624
3625 static inline struct LDKNodeInfo CResult_NodeInfoDecodeErrorZ_get_ok(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
3626 CHECK(owner->result_ok);
3627         return NodeInfo_clone(&*owner->contents.result);
3628 }
3629 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_get_ok"))) TS_CResult_NodeInfoDecodeErrorZ_get_ok(uint32_t owner) {
3630         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(owner & ~1);
3631         LDKNodeInfo ret_var = CResult_NodeInfoDecodeErrorZ_get_ok(owner_conv);
3632         uint32_t ret_ref = 0;
3633         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3634         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3635         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3636         ret_ref = (uintptr_t)ret_var.inner;
3637         if (ret_var.is_owned) {
3638                 ret_ref |= 1;
3639         }
3640         return ret_ref;
3641 }
3642
3643 static inline struct LDKDecodeError CResult_NodeInfoDecodeErrorZ_get_err(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
3644 CHECK(!owner->result_ok);
3645         return DecodeError_clone(&*owner->contents.err);
3646 }
3647 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_get_err"))) TS_CResult_NodeInfoDecodeErrorZ_get_err(uint32_t owner) {
3648         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(owner & ~1);
3649         LDKDecodeError ret_var = CResult_NodeInfoDecodeErrorZ_get_err(owner_conv);
3650         uint32_t ret_ref = 0;
3651         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3652         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3653         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3654         ret_ref = (uintptr_t)ret_var.inner;
3655         if (ret_var.is_owned) {
3656                 ret_ref |= 1;
3657         }
3658         return ret_ref;
3659 }
3660
3661 static inline struct LDKNetworkGraph *CResult_NetworkGraphDecodeErrorZ_get_ok(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
3662 CHECK(owner->result_ok);
3663         return &*owner->contents.result;
3664 }
3665 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_get_ok"))) TS_CResult_NetworkGraphDecodeErrorZ_get_ok(uint32_t owner) {
3666         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(owner & ~1);
3667         LDKNetworkGraph ret_var = *CResult_NetworkGraphDecodeErrorZ_get_ok(owner_conv);
3668         uint32_t ret_ref = 0;
3669         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3670         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3671         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3672         ret_ref = (uintptr_t)ret_var.inner & ~1;
3673         return ret_ref;
3674 }
3675
3676 static inline struct LDKDecodeError CResult_NetworkGraphDecodeErrorZ_get_err(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
3677 CHECK(!owner->result_ok);
3678         return DecodeError_clone(&*owner->contents.err);
3679 }
3680 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_get_err"))) TS_CResult_NetworkGraphDecodeErrorZ_get_err(uint32_t owner) {
3681         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(owner & ~1);
3682         LDKDecodeError ret_var = CResult_NetworkGraphDecodeErrorZ_get_err(owner_conv);
3683         uint32_t ret_ref = 0;
3684         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3685         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3686         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3687         ret_ref = (uintptr_t)ret_var.inner;
3688         if (ret_var.is_owned) {
3689                 ret_ref |= 1;
3690         }
3691         return ret_ref;
3692 }
3693
3694 uint32_t __attribute__((export_name("TS_LDKCOption_CVec_NetAddressZZ_ty_from_ptr"))) TS_LDKCOption_CVec_NetAddressZZ_ty_from_ptr(uint32_t ptr) {
3695         LDKCOption_CVec_NetAddressZZ *obj = (LDKCOption_CVec_NetAddressZZ*)(ptr & ~1);
3696         switch(obj->tag) {
3697                 case LDKCOption_CVec_NetAddressZZ_Some: return 0;
3698                 case LDKCOption_CVec_NetAddressZZ_None: return 1;
3699                 default: abort();
3700         }
3701 }
3702 uint32_tArray __attribute__((export_name("TS_LDKCOption_CVec_NetAddressZZ_Some_get_some"))) TS_LDKCOption_CVec_NetAddressZZ_Some_get_some(uint32_t ptr) {
3703         LDKCOption_CVec_NetAddressZZ *obj = (LDKCOption_CVec_NetAddressZZ*)(ptr & ~1);
3704         assert(obj->tag == LDKCOption_CVec_NetAddressZZ_Some);
3705                         LDKCVec_NetAddressZ some_var = obj->some;
3706                         uint32_tArray some_arr = NULL;
3707                         some_arr = init_uint32_tArray(some_var.datalen, __LINE__);
3708                         uint32_t *some_arr_ptr = (uint32_t*)(((uint8_t*)some_arr) + 8);
3709                         for (size_t m = 0; m < some_var.datalen; m++) {
3710                                 uint32_t some_conv_12_ref = ((uintptr_t)&some_var.data[m]) | 1;
3711                                 some_arr_ptr[m] = some_conv_12_ref;
3712                         }
3713                         
3714         return some_arr;
3715 }
3716 static inline struct LDKDelayedPaymentOutputDescriptor CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3717 CHECK(owner->result_ok);
3718         return DelayedPaymentOutputDescriptor_clone(&*owner->contents.result);
3719 }
3720 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(uint32_t owner) {
3721         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
3722         LDKDelayedPaymentOutputDescriptor ret_var = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
3723         uint32_t ret_ref = 0;
3724         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3725         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3726         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3727         ret_ref = (uintptr_t)ret_var.inner;
3728         if (ret_var.is_owned) {
3729                 ret_ref |= 1;
3730         }
3731         return ret_ref;
3732 }
3733
3734 static inline struct LDKDecodeError CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3735 CHECK(!owner->result_ok);
3736         return DecodeError_clone(&*owner->contents.err);
3737 }
3738 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(uint32_t owner) {
3739         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
3740         LDKDecodeError ret_var = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
3741         uint32_t ret_ref = 0;
3742         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3743         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3744         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3745         ret_ref = (uintptr_t)ret_var.inner;
3746         if (ret_var.is_owned) {
3747                 ret_ref |= 1;
3748         }
3749         return ret_ref;
3750 }
3751
3752 static inline struct LDKStaticPaymentOutputDescriptor CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3753 CHECK(owner->result_ok);
3754         return StaticPaymentOutputDescriptor_clone(&*owner->contents.result);
3755 }
3756 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(uint32_t owner) {
3757         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
3758         LDKStaticPaymentOutputDescriptor ret_var = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
3759         uint32_t ret_ref = 0;
3760         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3761         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3762         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3763         ret_ref = (uintptr_t)ret_var.inner;
3764         if (ret_var.is_owned) {
3765                 ret_ref |= 1;
3766         }
3767         return ret_ref;
3768 }
3769
3770 static inline struct LDKDecodeError CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3771 CHECK(!owner->result_ok);
3772         return DecodeError_clone(&*owner->contents.err);
3773 }
3774 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(uint32_t owner) {
3775         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
3776         LDKDecodeError ret_var = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
3777         uint32_t ret_ref = 0;
3778         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3779         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3780         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3781         ret_ref = (uintptr_t)ret_var.inner;
3782         if (ret_var.is_owned) {
3783                 ret_ref |= 1;
3784         }
3785         return ret_ref;
3786 }
3787
3788 static inline struct LDKSpendableOutputDescriptor CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3789 CHECK(owner->result_ok);
3790         return SpendableOutputDescriptor_clone(&*owner->contents.result);
3791 }
3792 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(uint32_t owner) {
3793         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(owner & ~1);
3794         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
3795         *ret_copy = CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
3796         uint32_t ret_ref = (uintptr_t)ret_copy;
3797         return ret_ref;
3798 }
3799
3800 static inline struct LDKDecodeError CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3801 CHECK(!owner->result_ok);
3802         return DecodeError_clone(&*owner->contents.err);
3803 }
3804 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_get_err"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(uint32_t owner) {
3805         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(owner & ~1);
3806         LDKDecodeError ret_var = CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(owner_conv);
3807         uint32_t ret_ref = 0;
3808         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3809         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3810         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3811         ret_ref = (uintptr_t)ret_var.inner;
3812         if (ret_var.is_owned) {
3813                 ret_ref |= 1;
3814         }
3815         return ret_ref;
3816 }
3817
3818 static inline LDKCVec_PaymentPreimageZ CVec_PaymentPreimageZ_clone(const LDKCVec_PaymentPreimageZ *orig) {
3819         LDKCVec_PaymentPreimageZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_PaymentPreimageZ clone bytes"), .datalen = orig->datalen };
3820         for (size_t i = 0; i < ret.datalen; i++) {
3821                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
3822         }
3823         return ret;
3824 }
3825 static inline struct LDKSignature C2Tuple_SignatureCVec_SignatureZZ_get_a(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
3826         return owner->a;
3827 }
3828 int8_tArray  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_get_a"))) TS_C2Tuple_SignatureCVec_SignatureZZ_get_a(uint32_t owner) {
3829         LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(owner & ~1);
3830         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
3831         memcpy(ret_arr->elems, C2Tuple_SignatureCVec_SignatureZZ_get_a(owner_conv).compact_form, 64);
3832         return ret_arr;
3833 }
3834
3835 static inline struct LDKCVec_SignatureZ C2Tuple_SignatureCVec_SignatureZZ_get_b(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
3836         return owner->b;
3837 }
3838 ptrArray  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_get_b"))) TS_C2Tuple_SignatureCVec_SignatureZZ_get_b(uint32_t owner) {
3839         LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(owner & ~1);
3840         LDKCVec_SignatureZ ret_var = C2Tuple_SignatureCVec_SignatureZZ_get_b(owner_conv);
3841         ptrArray ret_arr = NULL;
3842         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
3843         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 8);
3844         for (size_t m = 0; m < ret_var.datalen; m++) {
3845                 int8_tArray ret_conv_12_arr = init_int8_tArray(64, __LINE__);
3846                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].compact_form, 64);
3847                 ret_arr_ptr[m] = ret_conv_12_arr;
3848         }
3849         
3850         return ret_arr;
3851 }
3852
3853 static inline struct LDKC2Tuple_SignatureCVec_SignatureZZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
3854 CHECK(owner->result_ok);
3855         return C2Tuple_SignatureCVec_SignatureZZ_clone(&*owner->contents.result);
3856 }
3857 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(uint32_t owner) {
3858         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(owner & ~1);
3859         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
3860         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(owner_conv);
3861         return ((uint32_t)ret_conv);
3862 }
3863
3864 static inline void CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
3865 CHECK(!owner->result_ok);
3866         return *owner->contents.err;
3867 }
3868 void  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(uint32_t owner) {
3869         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(owner & ~1);
3870         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(owner_conv);
3871 }
3872
3873 static inline struct LDKSignature CResult_SignatureNoneZ_get_ok(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
3874 CHECK(owner->result_ok);
3875         return *owner->contents.result;
3876 }
3877 int8_tArray  __attribute__((export_name("TS_CResult_SignatureNoneZ_get_ok"))) TS_CResult_SignatureNoneZ_get_ok(uint32_t owner) {
3878         LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)(owner & ~1);
3879         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
3880         memcpy(ret_arr->elems, CResult_SignatureNoneZ_get_ok(owner_conv).compact_form, 64);
3881         return ret_arr;
3882 }
3883
3884 static inline void CResult_SignatureNoneZ_get_err(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
3885 CHECK(!owner->result_ok);
3886         return *owner->contents.err;
3887 }
3888 void  __attribute__((export_name("TS_CResult_SignatureNoneZ_get_err"))) TS_CResult_SignatureNoneZ_get_err(uint32_t owner) {
3889         LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)(owner & ~1);
3890         CResult_SignatureNoneZ_get_err(owner_conv);
3891 }
3892
3893 static inline struct LDKSignature C2Tuple_SignatureSignatureZ_get_a(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR owner){
3894         return owner->a;
3895 }
3896 int8_tArray  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_get_a"))) TS_C2Tuple_SignatureSignatureZ_get_a(uint32_t owner) {
3897         LDKC2Tuple_SignatureSignatureZ* owner_conv = (LDKC2Tuple_SignatureSignatureZ*)(owner & ~1);
3898         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
3899         memcpy(ret_arr->elems, C2Tuple_SignatureSignatureZ_get_a(owner_conv).compact_form, 64);
3900         return ret_arr;
3901 }
3902
3903 static inline struct LDKSignature C2Tuple_SignatureSignatureZ_get_b(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR owner){
3904         return owner->b;
3905 }
3906 int8_tArray  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_get_b"))) TS_C2Tuple_SignatureSignatureZ_get_b(uint32_t owner) {
3907         LDKC2Tuple_SignatureSignatureZ* owner_conv = (LDKC2Tuple_SignatureSignatureZ*)(owner & ~1);
3908         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
3909         memcpy(ret_arr->elems, C2Tuple_SignatureSignatureZ_get_b(owner_conv).compact_form, 64);
3910         return ret_arr;
3911 }
3912
3913 static inline struct LDKC2Tuple_SignatureSignatureZ CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR owner){
3914 CHECK(owner->result_ok);
3915         return C2Tuple_SignatureSignatureZ_clone(&*owner->contents.result);
3916 }
3917 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(uint32_t owner) {
3918         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(owner & ~1);
3919         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
3920         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(owner_conv);
3921         return ((uint32_t)ret_conv);
3922 }
3923
3924 static inline void CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR owner){
3925 CHECK(!owner->result_ok);
3926         return *owner->contents.err;
3927 }
3928 void  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_get_err"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(uint32_t owner) {
3929         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(owner & ~1);
3930         CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(owner_conv);
3931 }
3932
3933 static inline struct LDKSecretKey CResult_SecretKeyNoneZ_get_ok(LDKCResult_SecretKeyNoneZ *NONNULL_PTR owner){
3934 CHECK(owner->result_ok);
3935         return *owner->contents.result;
3936 }
3937 int8_tArray  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_get_ok"))) TS_CResult_SecretKeyNoneZ_get_ok(uint32_t owner) {
3938         LDKCResult_SecretKeyNoneZ* owner_conv = (LDKCResult_SecretKeyNoneZ*)(owner & ~1);
3939         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
3940         memcpy(ret_arr->elems, CResult_SecretKeyNoneZ_get_ok(owner_conv).bytes, 32);
3941         return ret_arr;
3942 }
3943
3944 static inline void CResult_SecretKeyNoneZ_get_err(LDKCResult_SecretKeyNoneZ *NONNULL_PTR owner){
3945 CHECK(!owner->result_ok);
3946         return *owner->contents.err;
3947 }
3948 void  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_get_err"))) TS_CResult_SecretKeyNoneZ_get_err(uint32_t owner) {
3949         LDKCResult_SecretKeyNoneZ* owner_conv = (LDKCResult_SecretKeyNoneZ*)(owner & ~1);
3950         CResult_SecretKeyNoneZ_get_err(owner_conv);
3951 }
3952
3953 typedef struct LDKBaseSign_JCalls {
3954         atomic_size_t refcnt;
3955         uint32_t instance_ptr;
3956 } LDKBaseSign_JCalls;
3957 static void LDKBaseSign_JCalls_free(void* this_arg) {
3958         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3959         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3960                 FREE(j_calls);
3961         }
3962 }
3963 LDKPublicKey get_per_commitment_point_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
3964         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3965         int64_t idx_conv = idx;
3966         int8_tArray ret = (int8_tArray)js_invoke_function_buuuuu(j_calls->instance_ptr, 2, (uint32_t)idx_conv, 0, 0, 0, 0, 0);
3967         LDKPublicKey ret_ref;
3968         CHECK(ret->arr_len == 33);
3969         memcpy(ret_ref.compressed_form, ret->elems, 33); FREE(ret);
3970         return ret_ref;
3971 }
3972 LDKThirtyTwoBytes release_commitment_secret_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
3973         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3974         int64_t idx_conv = idx;
3975         int8_tArray ret = (int8_tArray)js_invoke_function_buuuuu(j_calls->instance_ptr, 3, (uint32_t)idx_conv, 0, 0, 0, 0, 0);
3976         LDKThirtyTwoBytes ret_ref;
3977         CHECK(ret->arr_len == 32);
3978         memcpy(ret_ref.data, ret->elems, 32); FREE(ret);
3979         return ret_ref;
3980 }
3981 LDKCResult_NoneNoneZ validate_holder_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * holder_tx, LDKCVec_PaymentPreimageZ preimages) {
3982         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3983         LDKHolderCommitmentTransaction holder_tx_var = *holder_tx;
3984         uint32_t holder_tx_ref = 0;
3985         holder_tx_var = HolderCommitmentTransaction_clone(&holder_tx_var);
3986         CHECK((((uintptr_t)holder_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3987         CHECK((((uintptr_t)&holder_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3988         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_var);
3989         holder_tx_ref = (uintptr_t)holder_tx_var.inner;
3990         if (holder_tx_var.is_owned) {
3991                 holder_tx_ref |= 1;
3992         }
3993         LDKCVec_PaymentPreimageZ preimages_var = preimages;
3994         ptrArray preimages_arr = NULL;
3995         preimages_arr = init_ptrArray(preimages_var.datalen, __LINE__);
3996         int8_tArray *preimages_arr_ptr = (int8_tArray*)(((uint8_t*)preimages_arr) + 8);
3997         for (size_t m = 0; m < preimages_var.datalen; m++) {
3998                 int8_tArray preimages_conv_12_arr = init_int8_tArray(32, __LINE__);
3999                 memcpy(preimages_conv_12_arr->elems, preimages_var.data[m].data, 32);
4000                 preimages_arr_ptr[m] = preimages_conv_12_arr;
4001         }
4002         
4003         FREE(preimages_var.data);
4004         uint32_t ret = js_invoke_function_uuuuuu(j_calls->instance_ptr, 4, (uint32_t)holder_tx_ref, (uint32_t)preimages_arr, 0, 0, 0, 0);
4005         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4006         CHECK_ACCESS(ret_ptr);
4007         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
4008         FREE((void*)ret);
4009         return ret_conv;
4010 }
4011 LDKThirtyTwoBytes channel_keys_id_LDKBaseSign_jcall(const void* this_arg) {
4012         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4013         int8_tArray ret = (int8_tArray)js_invoke_function_uuuuuu(j_calls->instance_ptr, 5, 0, 0, 0, 0, 0, 0);
4014         LDKThirtyTwoBytes ret_ref;
4015         CHECK(ret->arr_len == 32);
4016         memcpy(ret_ref.data, ret->elems, 32); FREE(ret);
4017         return ret_ref;
4018 }
4019 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx, LDKCVec_PaymentPreimageZ preimages) {
4020         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4021         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
4022         uint32_t commitment_tx_ref = 0;
4023         commitment_tx_var = CommitmentTransaction_clone(&commitment_tx_var);
4024         CHECK((((uintptr_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4025         CHECK((((uintptr_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4026         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
4027         commitment_tx_ref = (uintptr_t)commitment_tx_var.inner;
4028         if (commitment_tx_var.is_owned) {
4029                 commitment_tx_ref |= 1;
4030         }
4031         LDKCVec_PaymentPreimageZ preimages_var = preimages;
4032         ptrArray preimages_arr = NULL;
4033         preimages_arr = init_ptrArray(preimages_var.datalen, __LINE__);
4034         int8_tArray *preimages_arr_ptr = (int8_tArray*)(((uint8_t*)preimages_arr) + 8);
4035         for (size_t m = 0; m < preimages_var.datalen; m++) {
4036                 int8_tArray preimages_conv_12_arr = init_int8_tArray(32, __LINE__);
4037                 memcpy(preimages_conv_12_arr->elems, preimages_var.data[m].data, 32);
4038                 preimages_arr_ptr[m] = preimages_conv_12_arr;
4039         }
4040         
4041         FREE(preimages_var.data);
4042         uint32_t ret = js_invoke_function_uuuuuu(j_calls->instance_ptr, 6, (uint32_t)commitment_tx_ref, (uint32_t)preimages_arr, 0, 0, 0, 0);
4043         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4044         CHECK_ACCESS(ret_ptr);
4045         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
4046         FREE((void*)ret);
4047         return ret_conv;
4048 }
4049 LDKCResult_NoneNoneZ validate_counterparty_revocation_LDKBaseSign_jcall(const void* this_arg, uint64_t idx, const uint8_t (* secret)[32]) {
4050         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4051         int64_t idx_conv = idx;
4052         int8_tArray secret_arr = init_int8_tArray(32, __LINE__);
4053         memcpy(secret_arr->elems, *secret, 32);
4054         uint32_t ret = js_invoke_function_buuuuu(j_calls->instance_ptr, 7, (uint32_t)idx_conv, (uint32_t)secret_arr, 0, 0, 0, 0);
4055         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4056         CHECK_ACCESS(ret_ptr);
4057         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
4058         FREE((void*)ret);
4059         return ret_conv;
4060 }
4061 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
4062         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4063         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
4064         uint32_t commitment_tx_ref = 0;
4065         commitment_tx_var = HolderCommitmentTransaction_clone(&commitment_tx_var);
4066         CHECK((((uintptr_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4067         CHECK((((uintptr_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4068         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
4069         commitment_tx_ref = (uintptr_t)commitment_tx_var.inner;
4070         if (commitment_tx_var.is_owned) {
4071                 commitment_tx_ref |= 1;
4072         }
4073         uint32_t ret = js_invoke_function_uuuuuu(j_calls->instance_ptr, 8, (uint32_t)commitment_tx_ref, 0, 0, 0, 0, 0);
4074         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4075         CHECK_ACCESS(ret_ptr);
4076         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
4077         FREE((void*)ret);
4078         return ret_conv;
4079 }
4080 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]) {
4081         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4082         LDKTransaction justice_tx_var = justice_tx;
4083         int8_tArray justice_tx_arr = init_int8_tArray(justice_tx_var.datalen, __LINE__);
4084         memcpy(justice_tx_arr->elems, justice_tx_var.data, justice_tx_var.datalen);
4085         Transaction_free(justice_tx_var);
4086         uint32_t input_conv = input;
4087         int64_t amount_conv = amount;
4088         int8_tArray per_commitment_key_arr = init_int8_tArray(32, __LINE__);
4089         memcpy(per_commitment_key_arr->elems, *per_commitment_key, 32);
4090         uint32_t ret = js_invoke_function_uubuuu(j_calls->instance_ptr, 9, (uint32_t)justice_tx_arr, (uint32_t)input_conv, (uint32_t)amount_conv, (uint32_t)per_commitment_key_arr, 0, 0);
4091         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4092         CHECK_ACCESS(ret_ptr);
4093         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
4094         FREE((void*)ret);
4095         return ret_conv;
4096 }
4097 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) {
4098         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4099         LDKTransaction justice_tx_var = justice_tx;
4100         int8_tArray justice_tx_arr = init_int8_tArray(justice_tx_var.datalen, __LINE__);
4101         memcpy(justice_tx_arr->elems, justice_tx_var.data, justice_tx_var.datalen);
4102         Transaction_free(justice_tx_var);
4103         uint32_t input_conv = input;
4104         int64_t amount_conv = amount;
4105         int8_tArray per_commitment_key_arr = init_int8_tArray(32, __LINE__);
4106         memcpy(per_commitment_key_arr->elems, *per_commitment_key, 32);
4107         LDKHTLCOutputInCommitment htlc_var = *htlc;
4108         uint32_t htlc_ref = 0;
4109         htlc_var = HTLCOutputInCommitment_clone(&htlc_var);
4110         CHECK((((uintptr_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4111         CHECK((((uintptr_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4112         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
4113         htlc_ref = (uintptr_t)htlc_var.inner;
4114         if (htlc_var.is_owned) {
4115                 htlc_ref |= 1;
4116         }
4117         uint32_t ret = js_invoke_function_uubuuu(j_calls->instance_ptr, 10, (uint32_t)justice_tx_arr, (uint32_t)input_conv, (uint32_t)amount_conv, (uint32_t)per_commitment_key_arr, (uint32_t)htlc_ref, 0);
4118         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4119         CHECK_ACCESS(ret_ptr);
4120         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
4121         FREE((void*)ret);
4122         return ret_conv;
4123 }
4124 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) {
4125         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4126         LDKTransaction htlc_tx_var = htlc_tx;
4127         int8_tArray htlc_tx_arr = init_int8_tArray(htlc_tx_var.datalen, __LINE__);
4128         memcpy(htlc_tx_arr->elems, htlc_tx_var.data, htlc_tx_var.datalen);
4129         Transaction_free(htlc_tx_var);
4130         uint32_t input_conv = input;
4131         int64_t amount_conv = amount;
4132         int8_tArray per_commitment_point_arr = init_int8_tArray(33, __LINE__);
4133         memcpy(per_commitment_point_arr->elems, per_commitment_point.compressed_form, 33);
4134         LDKHTLCOutputInCommitment htlc_var = *htlc;
4135         uint32_t htlc_ref = 0;
4136         htlc_var = HTLCOutputInCommitment_clone(&htlc_var);
4137         CHECK((((uintptr_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4138         CHECK((((uintptr_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4139         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
4140         htlc_ref = (uintptr_t)htlc_var.inner;
4141         if (htlc_var.is_owned) {
4142                 htlc_ref |= 1;
4143         }
4144         uint32_t ret = js_invoke_function_uubuuu(j_calls->instance_ptr, 11, (uint32_t)htlc_tx_arr, (uint32_t)input_conv, (uint32_t)amount_conv, (uint32_t)per_commitment_point_arr, (uint32_t)htlc_ref, 0);
4145         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4146         CHECK_ACCESS(ret_ptr);
4147         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
4148         FREE((void*)ret);
4149         return ret_conv;
4150 }
4151 LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* this_arg, const LDKClosingTransaction * closing_tx) {
4152         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4153         LDKClosingTransaction closing_tx_var = *closing_tx;
4154         uint32_t closing_tx_ref = 0;
4155         closing_tx_var = ClosingTransaction_clone(&closing_tx_var);
4156         CHECK((((uintptr_t)closing_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4157         CHECK((((uintptr_t)&closing_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4158         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_var);
4159         closing_tx_ref = (uintptr_t)closing_tx_var.inner;
4160         if (closing_tx_var.is_owned) {
4161                 closing_tx_ref |= 1;
4162         }
4163         uint32_t ret = js_invoke_function_uuuuuu(j_calls->instance_ptr, 12, (uint32_t)closing_tx_ref, 0, 0, 0, 0, 0);
4164         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4165         CHECK_ACCESS(ret_ptr);
4166         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
4167         FREE((void*)ret);
4168         return ret_conv;
4169 }
4170 LDKCResult_C2Tuple_SignatureSignatureZNoneZ sign_channel_announcement_LDKBaseSign_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
4171         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4172         LDKUnsignedChannelAnnouncement msg_var = *msg;
4173         uint32_t msg_ref = 0;
4174         msg_var = UnsignedChannelAnnouncement_clone(&msg_var);
4175         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4176         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4177         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4178         msg_ref = (uintptr_t)msg_var.inner;
4179         if (msg_var.is_owned) {
4180                 msg_ref |= 1;
4181         }
4182         uint32_t ret = js_invoke_function_uuuuuu(j_calls->instance_ptr, 13, (uint32_t)msg_ref, 0, 0, 0, 0, 0);
4183         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4184         CHECK_ACCESS(ret_ptr);
4185         LDKCResult_C2Tuple_SignatureSignatureZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(ret_ptr);
4186         FREE((void*)ret);
4187         return ret_conv;
4188 }
4189 void ready_channel_LDKBaseSign_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
4190         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4191         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
4192         uint32_t channel_parameters_ref = 0;
4193         channel_parameters_var = ChannelTransactionParameters_clone(&channel_parameters_var);
4194         CHECK((((uintptr_t)channel_parameters_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4195         CHECK((((uintptr_t)&channel_parameters_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4196         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_var);
4197         channel_parameters_ref = (uintptr_t)channel_parameters_var.inner;
4198         if (channel_parameters_var.is_owned) {
4199                 channel_parameters_ref |= 1;
4200         }
4201         js_invoke_function_uuuuuu(j_calls->instance_ptr, 14, (uint32_t)channel_parameters_ref, 0, 0, 0, 0, 0);
4202 }
4203 static void LDKBaseSign_JCalls_cloned(LDKBaseSign* new_obj) {
4204         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) new_obj->this_arg;
4205         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4206 }
4207 static inline LDKBaseSign LDKBaseSign_init (JSValue o, uint32_t pubkeys) {
4208         LDKBaseSign_JCalls *calls = MALLOC(sizeof(LDKBaseSign_JCalls), "LDKBaseSign_JCalls");
4209         atomic_init(&calls->refcnt, 1);
4210         calls->instance_ptr = o;
4211
4212         LDKChannelPublicKeys pubkeys_conv;
4213         pubkeys_conv.inner = (void*)(pubkeys & (~1));
4214         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
4215         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
4216
4217         LDKBaseSign ret = {
4218                 .this_arg = (void*) calls,
4219                 .get_per_commitment_point = get_per_commitment_point_LDKBaseSign_jcall,
4220                 .release_commitment_secret = release_commitment_secret_LDKBaseSign_jcall,
4221                 .validate_holder_commitment = validate_holder_commitment_LDKBaseSign_jcall,
4222                 .channel_keys_id = channel_keys_id_LDKBaseSign_jcall,
4223                 .sign_counterparty_commitment = sign_counterparty_commitment_LDKBaseSign_jcall,
4224                 .validate_counterparty_revocation = validate_counterparty_revocation_LDKBaseSign_jcall,
4225                 .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_LDKBaseSign_jcall,
4226                 .sign_justice_revoked_output = sign_justice_revoked_output_LDKBaseSign_jcall,
4227                 .sign_justice_revoked_htlc = sign_justice_revoked_htlc_LDKBaseSign_jcall,
4228                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_LDKBaseSign_jcall,
4229                 .sign_closing_transaction = sign_closing_transaction_LDKBaseSign_jcall,
4230                 .sign_channel_announcement = sign_channel_announcement_LDKBaseSign_jcall,
4231                 .ready_channel = ready_channel_LDKBaseSign_jcall,
4232                 .free = LDKBaseSign_JCalls_free,
4233                 .pubkeys = pubkeys_conv,
4234                 .set_pubkeys = NULL,
4235         };
4236         return ret;
4237 }
4238 long  __attribute__((export_name("TS_LDKBaseSign_new"))) TS_LDKBaseSign_new(JSValue o, uint32_t pubkeys) {
4239         LDKBaseSign *res_ptr = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
4240         *res_ptr = LDKBaseSign_init(o, pubkeys);
4241         return (long)res_ptr;
4242 }
4243 int8_tArray  __attribute__((export_name("TS_BaseSign_get_per_commitment_point"))) TS_BaseSign_get_per_commitment_point(uint32_t this_arg, int64_t idx) {
4244         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4245         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4246         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4247         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
4248         memcpy(ret_arr->elems, (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form, 33);
4249         return ret_arr;
4250 }
4251
4252 int8_tArray  __attribute__((export_name("TS_BaseSign_release_commitment_secret"))) TS_BaseSign_release_commitment_secret(uint32_t this_arg, int64_t idx) {
4253         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4254         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4255         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4256         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4257         memcpy(ret_arr->elems, (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data, 32);
4258         return ret_arr;
4259 }
4260
4261 uint32_t  __attribute__((export_name("TS_BaseSign_validate_holder_commitment"))) TS_BaseSign_validate_holder_commitment(uint32_t this_arg, uint32_t holder_tx, ptrArray preimages) {
4262         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4263         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4264         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4265         LDKHolderCommitmentTransaction holder_tx_conv;
4266         holder_tx_conv.inner = (void*)(holder_tx & (~1));
4267         holder_tx_conv.is_owned = false;
4268         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_conv);
4269         LDKCVec_PaymentPreimageZ preimages_constr;
4270         preimages_constr.datalen = preimages->arr_len;
4271         if (preimages_constr.datalen > 0)
4272                 preimages_constr.data = MALLOC(preimages_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
4273         else
4274                 preimages_constr.data = NULL;
4275         int8_tArray* preimages_vals = (void*) preimages->elems;
4276         for (size_t m = 0; m < preimages_constr.datalen; m++) {
4277                 int8_tArray preimages_conv_12 = preimages_vals[m];
4278                 LDKThirtyTwoBytes preimages_conv_12_ref;
4279                 CHECK(preimages_conv_12->arr_len == 32);
4280                 memcpy(preimages_conv_12_ref.data, preimages_conv_12->elems, 32); FREE(preimages_conv_12);
4281                 preimages_constr.data[m] = preimages_conv_12_ref;
4282         }
4283         FREE(preimages);
4284         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
4285         *ret_conv = (this_arg_conv->validate_holder_commitment)(this_arg_conv->this_arg, &holder_tx_conv, preimages_constr);
4286         return (uint32_t)ret_conv;
4287 }
4288
4289 int8_tArray  __attribute__((export_name("TS_BaseSign_channel_keys_id"))) TS_BaseSign_channel_keys_id(uint32_t this_arg) {
4290         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4291         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4292         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4293         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4294         memcpy(ret_arr->elems, (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data, 32);
4295         return ret_arr;
4296 }
4297
4298 uint32_t  __attribute__((export_name("TS_BaseSign_sign_counterparty_commitment"))) TS_BaseSign_sign_counterparty_commitment(uint32_t this_arg, uint32_t commitment_tx, ptrArray preimages) {
4299         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4300         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4301         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4302         LDKCommitmentTransaction commitment_tx_conv;
4303         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
4304         commitment_tx_conv.is_owned = false;
4305         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
4306         LDKCVec_PaymentPreimageZ preimages_constr;
4307         preimages_constr.datalen = preimages->arr_len;
4308         if (preimages_constr.datalen > 0)
4309                 preimages_constr.data = MALLOC(preimages_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
4310         else
4311                 preimages_constr.data = NULL;
4312         int8_tArray* preimages_vals = (void*) preimages->elems;
4313         for (size_t m = 0; m < preimages_constr.datalen; m++) {
4314                 int8_tArray preimages_conv_12 = preimages_vals[m];
4315                 LDKThirtyTwoBytes preimages_conv_12_ref;
4316                 CHECK(preimages_conv_12->arr_len == 32);
4317                 memcpy(preimages_conv_12_ref.data, preimages_conv_12->elems, 32); FREE(preimages_conv_12);
4318                 preimages_constr.data[m] = preimages_conv_12_ref;
4319         }
4320         FREE(preimages);
4321         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
4322         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv, preimages_constr);
4323         return (uint32_t)ret_conv;
4324 }
4325
4326 uint32_t  __attribute__((export_name("TS_BaseSign_validate_counterparty_revocation"))) TS_BaseSign_validate_counterparty_revocation(uint32_t this_arg, int64_t idx, int8_tArray secret) {
4327         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4328         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4329         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4330         unsigned char secret_arr[32];
4331         CHECK(secret->arr_len == 32);
4332         memcpy(secret_arr, secret->elems, 32); FREE(secret);
4333         unsigned char (*secret_ref)[32] = &secret_arr;
4334         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
4335         *ret_conv = (this_arg_conv->validate_counterparty_revocation)(this_arg_conv->this_arg, idx, secret_ref);
4336         return (uint32_t)ret_conv;
4337 }
4338
4339 uint32_t  __attribute__((export_name("TS_BaseSign_sign_holder_commitment_and_htlcs"))) TS_BaseSign_sign_holder_commitment_and_htlcs(uint32_t this_arg, uint32_t commitment_tx) {
4340         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4341         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4342         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4343         LDKHolderCommitmentTransaction commitment_tx_conv;
4344         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
4345         commitment_tx_conv.is_owned = false;
4346         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
4347         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
4348         *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
4349         return (uint32_t)ret_conv;
4350 }
4351
4352 uint32_t  __attribute__((export_name("TS_BaseSign_sign_justice_revoked_output"))) TS_BaseSign_sign_justice_revoked_output(uint32_t this_arg, int8_tArray justice_tx, uint32_t input, int64_t amount, int8_tArray per_commitment_key) {
4353         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4354         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4355         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4356         LDKTransaction justice_tx_ref;
4357         justice_tx_ref.datalen = justice_tx->arr_len;
4358         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
4359         memcpy(justice_tx_ref.data, justice_tx->elems, justice_tx_ref.datalen); FREE(justice_tx);
4360         justice_tx_ref.data_is_owned = true;
4361         unsigned char per_commitment_key_arr[32];
4362         CHECK(per_commitment_key->arr_len == 32);
4363         memcpy(per_commitment_key_arr, per_commitment_key->elems, 32); FREE(per_commitment_key);
4364         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
4365         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
4366         *ret_conv = (this_arg_conv->sign_justice_revoked_output)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref);
4367         return (uint32_t)ret_conv;
4368 }
4369
4370 uint32_t  __attribute__((export_name("TS_BaseSign_sign_justice_revoked_htlc"))) TS_BaseSign_sign_justice_revoked_htlc(uint32_t this_arg, int8_tArray justice_tx, uint32_t input, int64_t amount, int8_tArray per_commitment_key, uint32_t htlc) {
4371         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4372         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4373         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4374         LDKTransaction justice_tx_ref;
4375         justice_tx_ref.datalen = justice_tx->arr_len;
4376         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
4377         memcpy(justice_tx_ref.data, justice_tx->elems, justice_tx_ref.datalen); FREE(justice_tx);
4378         justice_tx_ref.data_is_owned = true;
4379         unsigned char per_commitment_key_arr[32];
4380         CHECK(per_commitment_key->arr_len == 32);
4381         memcpy(per_commitment_key_arr, per_commitment_key->elems, 32); FREE(per_commitment_key);
4382         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
4383         LDKHTLCOutputInCommitment htlc_conv;
4384         htlc_conv.inner = (void*)(htlc & (~1));
4385         htlc_conv.is_owned = false;
4386         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
4387         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
4388         *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);
4389         return (uint32_t)ret_conv;
4390 }
4391
4392 uint32_t  __attribute__((export_name("TS_BaseSign_sign_counterparty_htlc_transaction"))) TS_BaseSign_sign_counterparty_htlc_transaction(uint32_t this_arg, int8_tArray htlc_tx, uint32_t input, int64_t amount, int8_tArray per_commitment_point, uint32_t htlc) {
4393         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4394         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4395         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4396         LDKTransaction htlc_tx_ref;
4397         htlc_tx_ref.datalen = htlc_tx->arr_len;
4398         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
4399         memcpy(htlc_tx_ref.data, htlc_tx->elems, htlc_tx_ref.datalen); FREE(htlc_tx);
4400         htlc_tx_ref.data_is_owned = true;
4401         LDKPublicKey per_commitment_point_ref;
4402         CHECK(per_commitment_point->arr_len == 33);
4403         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
4404         LDKHTLCOutputInCommitment htlc_conv;
4405         htlc_conv.inner = (void*)(htlc & (~1));
4406         htlc_conv.is_owned = false;
4407         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
4408         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
4409         *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);
4410         return (uint32_t)ret_conv;
4411 }
4412
4413 uint32_t  __attribute__((export_name("TS_BaseSign_sign_closing_transaction"))) TS_BaseSign_sign_closing_transaction(uint32_t this_arg, uint32_t closing_tx) {
4414         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4415         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4416         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4417         LDKClosingTransaction closing_tx_conv;
4418         closing_tx_conv.inner = (void*)(closing_tx & (~1));
4419         closing_tx_conv.is_owned = false;
4420         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_conv);
4421         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
4422         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, &closing_tx_conv);
4423         return (uint32_t)ret_conv;
4424 }
4425
4426 uint32_t  __attribute__((export_name("TS_BaseSign_sign_channel_announcement"))) TS_BaseSign_sign_channel_announcement(uint32_t this_arg, uint32_t msg) {
4427         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4428         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4429         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4430         LDKUnsignedChannelAnnouncement msg_conv;
4431         msg_conv.inner = (void*)(msg & (~1));
4432         msg_conv.is_owned = false;
4433         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
4434         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
4435         *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
4436         return (uint32_t)ret_conv;
4437 }
4438
4439 void  __attribute__((export_name("TS_BaseSign_ready_channel"))) TS_BaseSign_ready_channel(uint32_t this_arg, uint32_t channel_parameters) {
4440         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4441         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4442         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4443         LDKChannelTransactionParameters channel_parameters_conv;
4444         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
4445         channel_parameters_conv.is_owned = false;
4446         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
4447         (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
4448 }
4449
4450 LDKChannelPublicKeys LDKBaseSign_set_get_pubkeys(LDKBaseSign* this_arg) {
4451         if (this_arg->set_pubkeys != NULL)
4452                 this_arg->set_pubkeys(this_arg);
4453         return this_arg->pubkeys;
4454 }
4455 uint32_t  __attribute__((export_name("TS_BaseSign_get_pubkeys"))) TS_BaseSign_get_pubkeys(uint32_t this_arg) {
4456         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4457         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4458         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4459         LDKChannelPublicKeys ret_var = LDKBaseSign_set_get_pubkeys(this_arg_conv);
4460         uint32_t ret_ref = 0;
4461         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4462         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4463         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4464         ret_ref = (uintptr_t)ret_var.inner;
4465         if (ret_var.is_owned) {
4466                 ret_ref |= 1;
4467         }
4468         return ret_ref;
4469 }
4470
4471 typedef struct LDKSign_JCalls {
4472         atomic_size_t refcnt;
4473         uint32_t instance_ptr;
4474         LDKBaseSign_JCalls* BaseSign;
4475 } LDKSign_JCalls;
4476 static void LDKSign_JCalls_free(void* this_arg) {
4477         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
4478         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4479                 FREE(j_calls);
4480         }
4481 }
4482 LDKCVec_u8Z write_LDKSign_jcall(const void* this_arg) {
4483         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
4484         int8_tArray ret = (int8_tArray)js_invoke_function_uuuuuu(j_calls->instance_ptr, 15, 0, 0, 0, 0, 0, 0);
4485         LDKCVec_u8Z ret_ref;
4486         ret_ref.datalen = ret->arr_len;
4487         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
4488         memcpy(ret_ref.data, ret->elems, ret_ref.datalen); FREE(ret);
4489         return ret_ref;
4490 }
4491 static void LDKSign_JCalls_cloned(LDKSign* new_obj) {
4492         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) new_obj->this_arg;
4493         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4494         atomic_fetch_add_explicit(&j_calls->BaseSign->refcnt, 1, memory_order_release);
4495 }
4496 static inline LDKSign LDKSign_init (JSValue o, JSValue BaseSign, uint32_t pubkeys) {
4497         LDKSign_JCalls *calls = MALLOC(sizeof(LDKSign_JCalls), "LDKSign_JCalls");
4498         atomic_init(&calls->refcnt, 1);
4499         calls->instance_ptr = o;
4500
4501         LDKChannelPublicKeys pubkeys_conv;
4502         pubkeys_conv.inner = (void*)(pubkeys & (~1));
4503         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
4504         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
4505
4506         LDKSign ret = {
4507                 .this_arg = (void*) calls,
4508                 .write = write_LDKSign_jcall,
4509                 .cloned = LDKSign_JCalls_cloned,
4510                 .free = LDKSign_JCalls_free,
4511                 .BaseSign = LDKBaseSign_init(BaseSign, pubkeys),
4512         };
4513         calls->BaseSign = ret.BaseSign.this_arg;
4514         return ret;
4515 }
4516 long  __attribute__((export_name("TS_LDKSign_new"))) TS_LDKSign_new(JSValue o, JSValue BaseSign, uint32_t pubkeys) {
4517         LDKSign *res_ptr = MALLOC(sizeof(LDKSign), "LDKSign");
4518         *res_ptr = LDKSign_init(o, BaseSign, pubkeys);
4519         return (long)res_ptr;
4520 }
4521 int8_tArray  __attribute__((export_name("TS_Sign_write"))) TS_Sign_write(uint32_t this_arg) {
4522         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4523         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4524         LDKSign* this_arg_conv = (LDKSign*)this_arg_ptr;
4525         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
4526         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
4527         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
4528         CVec_u8Z_free(ret_var);
4529         return ret_arr;
4530 }
4531
4532 static inline struct LDKSign CResult_SignDecodeErrorZ_get_ok(LDKCResult_SignDecodeErrorZ *NONNULL_PTR owner){
4533 CHECK(owner->result_ok);
4534         return Sign_clone(&*owner->contents.result);
4535 }
4536 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_get_ok"))) TS_CResult_SignDecodeErrorZ_get_ok(uint32_t owner) {
4537         LDKCResult_SignDecodeErrorZ* owner_conv = (LDKCResult_SignDecodeErrorZ*)(owner & ~1);
4538         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
4539         *ret_ret = CResult_SignDecodeErrorZ_get_ok(owner_conv);
4540         return (uint32_t)ret_ret;
4541 }
4542
4543 static inline struct LDKDecodeError CResult_SignDecodeErrorZ_get_err(LDKCResult_SignDecodeErrorZ *NONNULL_PTR owner){
4544 CHECK(!owner->result_ok);
4545         return DecodeError_clone(&*owner->contents.err);
4546 }
4547 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_get_err"))) TS_CResult_SignDecodeErrorZ_get_err(uint32_t owner) {
4548         LDKCResult_SignDecodeErrorZ* owner_conv = (LDKCResult_SignDecodeErrorZ*)(owner & ~1);
4549         LDKDecodeError ret_var = CResult_SignDecodeErrorZ_get_err(owner_conv);
4550         uint32_t ret_ref = 0;
4551         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4552         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4553         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4554         ret_ref = (uintptr_t)ret_var.inner;
4555         if (ret_var.is_owned) {
4556                 ret_ref |= 1;
4557         }
4558         return ret_ref;
4559 }
4560
4561 static inline struct LDKRecoverableSignature CResult_RecoverableSignatureNoneZ_get_ok(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
4562 CHECK(owner->result_ok);
4563         return *owner->contents.result;
4564 }
4565 int8_tArray  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_get_ok"))) TS_CResult_RecoverableSignatureNoneZ_get_ok(uint32_t owner) {
4566         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)(owner & ~1);
4567         int8_tArray ret_arr = init_int8_tArray(68, __LINE__);
4568         memcpy(ret_arr->elems, CResult_RecoverableSignatureNoneZ_get_ok(owner_conv).serialized_form, 68);
4569         return ret_arr;
4570 }
4571
4572 static inline void CResult_RecoverableSignatureNoneZ_get_err(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
4573 CHECK(!owner->result_ok);
4574         return *owner->contents.err;
4575 }
4576 void  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_get_err"))) TS_CResult_RecoverableSignatureNoneZ_get_err(uint32_t owner) {
4577         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)(owner & ~1);
4578         CResult_RecoverableSignatureNoneZ_get_err(owner_conv);
4579 }
4580
4581 static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
4582         LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
4583         for (size_t i = 0; i < ret.datalen; i++) {
4584                 ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
4585         }
4586         return ret;
4587 }
4588 static inline struct LDKCVec_CVec_u8ZZ CResult_CVec_CVec_u8ZZNoneZ_get_ok(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
4589 CHECK(owner->result_ok);
4590         return CVec_CVec_u8ZZ_clone(&*owner->contents.result);
4591 }
4592 ptrArray  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_get_ok"))) TS_CResult_CVec_CVec_u8ZZNoneZ_get_ok(uint32_t owner) {
4593         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(owner & ~1);
4594         LDKCVec_CVec_u8ZZ ret_var = CResult_CVec_CVec_u8ZZNoneZ_get_ok(owner_conv);
4595         ptrArray ret_arr = NULL;
4596         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
4597         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 8);
4598         for (size_t m = 0; m < ret_var.datalen; m++) {
4599                 LDKCVec_u8Z ret_conv_12_var = ret_var.data[m];
4600                 int8_tArray ret_conv_12_arr = init_int8_tArray(ret_conv_12_var.datalen, __LINE__);
4601                 memcpy(ret_conv_12_arr->elems, ret_conv_12_var.data, ret_conv_12_var.datalen);
4602                 CVec_u8Z_free(ret_conv_12_var);
4603                 ret_arr_ptr[m] = ret_conv_12_arr;
4604         }
4605         
4606         FREE(ret_var.data);
4607         return ret_arr;
4608 }
4609
4610 static inline void CResult_CVec_CVec_u8ZZNoneZ_get_err(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
4611 CHECK(!owner->result_ok);
4612         return *owner->contents.err;
4613 }
4614 void  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_get_err"))) TS_CResult_CVec_CVec_u8ZZNoneZ_get_err(uint32_t owner) {
4615         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(owner & ~1);
4616         CResult_CVec_CVec_u8ZZNoneZ_get_err(owner_conv);
4617 }
4618
4619 static inline struct LDKInMemorySigner CResult_InMemorySignerDecodeErrorZ_get_ok(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
4620 CHECK(owner->result_ok);
4621         return InMemorySigner_clone(&*owner->contents.result);
4622 }
4623 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_get_ok"))) TS_CResult_InMemorySignerDecodeErrorZ_get_ok(uint32_t owner) {
4624         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(owner & ~1);
4625         LDKInMemorySigner ret_var = CResult_InMemorySignerDecodeErrorZ_get_ok(owner_conv);
4626         uint32_t ret_ref = 0;
4627         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4628         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4629         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4630         ret_ref = (uintptr_t)ret_var.inner;
4631         if (ret_var.is_owned) {
4632                 ret_ref |= 1;
4633         }
4634         return ret_ref;
4635 }
4636
4637 static inline struct LDKDecodeError CResult_InMemorySignerDecodeErrorZ_get_err(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
4638 CHECK(!owner->result_ok);
4639         return DecodeError_clone(&*owner->contents.err);
4640 }
4641 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_get_err"))) TS_CResult_InMemorySignerDecodeErrorZ_get_err(uint32_t owner) {
4642         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(owner & ~1);
4643         LDKDecodeError ret_var = CResult_InMemorySignerDecodeErrorZ_get_err(owner_conv);
4644         uint32_t ret_ref = 0;
4645         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4646         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4647         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4648         ret_ref = (uintptr_t)ret_var.inner;
4649         if (ret_var.is_owned) {
4650                 ret_ref |= 1;
4651         }
4652         return ret_ref;
4653 }
4654
4655 static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
4656         LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
4657         for (size_t i = 0; i < ret.datalen; i++) {
4658                 ret.data[i] = TxOut_clone(&orig->data[i]);
4659         }
4660         return ret;
4661 }
4662 static inline struct LDKTransaction CResult_TransactionNoneZ_get_ok(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
4663 CHECK(owner->result_ok);
4664         return *owner->contents.result;
4665 }
4666 int8_tArray  __attribute__((export_name("TS_CResult_TransactionNoneZ_get_ok"))) TS_CResult_TransactionNoneZ_get_ok(uint32_t owner) {
4667         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)(owner & ~1);
4668         LDKTransaction ret_var = CResult_TransactionNoneZ_get_ok(owner_conv);
4669         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
4670         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
4671         return ret_arr;
4672 }
4673
4674 static inline void CResult_TransactionNoneZ_get_err(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
4675 CHECK(!owner->result_ok);
4676         return *owner->contents.err;
4677 }
4678 void  __attribute__((export_name("TS_CResult_TransactionNoneZ_get_err"))) TS_CResult_TransactionNoneZ_get_err(uint32_t owner) {
4679         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)(owner & ~1);
4680         CResult_TransactionNoneZ_get_err(owner_conv);
4681 }
4682
4683 uint32_t __attribute__((export_name("TS_LDKCOption_u16Z_ty_from_ptr"))) TS_LDKCOption_u16Z_ty_from_ptr(uint32_t ptr) {
4684         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)(ptr & ~1);
4685         switch(obj->tag) {
4686                 case LDKCOption_u16Z_Some: return 0;
4687                 case LDKCOption_u16Z_None: return 1;
4688                 default: abort();
4689         }
4690 }
4691 int16_t __attribute__((export_name("TS_LDKCOption_u16Z_Some_get_some"))) TS_LDKCOption_u16Z_Some_get_some(uint32_t ptr) {
4692         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)(ptr & ~1);
4693         assert(obj->tag == LDKCOption_u16Z_Some);
4694                         int16_t some_conv = obj->some;
4695         return some_conv;
4696 }
4697 uint32_t __attribute__((export_name("TS_LDKAPIError_ty_from_ptr"))) TS_LDKAPIError_ty_from_ptr(uint32_t ptr) {
4698         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
4699         switch(obj->tag) {
4700                 case LDKAPIError_APIMisuseError: return 0;
4701                 case LDKAPIError_FeeRateTooHigh: return 1;
4702                 case LDKAPIError_RouteError: return 2;
4703                 case LDKAPIError_ChannelUnavailable: return 3;
4704                 case LDKAPIError_MonitorUpdateFailed: return 4;
4705                 case LDKAPIError_IncompatibleShutdownScript: return 5;
4706                 default: abort();
4707         }
4708 }
4709 jstring __attribute__((export_name("TS_LDKAPIError_APIMisuseError_get_err"))) TS_LDKAPIError_APIMisuseError_get_err(uint32_t ptr) {
4710         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
4711         assert(obj->tag == LDKAPIError_APIMisuseError);
4712                         LDKStr err_str = obj->api_misuse_error.err;
4713                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
4714         return err_conv;
4715 }
4716 jstring __attribute__((export_name("TS_LDKAPIError_FeeRateTooHigh_get_err"))) TS_LDKAPIError_FeeRateTooHigh_get_err(uint32_t ptr) {
4717         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
4718         assert(obj->tag == LDKAPIError_FeeRateTooHigh);
4719                         LDKStr err_str = obj->fee_rate_too_high.err;
4720                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
4721         return err_conv;
4722 }
4723 int32_t __attribute__((export_name("TS_LDKAPIError_FeeRateTooHigh_get_feerate"))) TS_LDKAPIError_FeeRateTooHigh_get_feerate(uint32_t ptr) {
4724         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
4725         assert(obj->tag == LDKAPIError_FeeRateTooHigh);
4726                         int32_t feerate_conv = obj->fee_rate_too_high.feerate;
4727         return feerate_conv;
4728 }
4729 jstring __attribute__((export_name("TS_LDKAPIError_RouteError_get_err"))) TS_LDKAPIError_RouteError_get_err(uint32_t ptr) {
4730         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
4731         assert(obj->tag == LDKAPIError_RouteError);
4732                         LDKStr err_str = obj->route_error.err;
4733                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
4734         return err_conv;
4735 }
4736 jstring __attribute__((export_name("TS_LDKAPIError_ChannelUnavailable_get_err"))) TS_LDKAPIError_ChannelUnavailable_get_err(uint32_t ptr) {
4737         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
4738         assert(obj->tag == LDKAPIError_ChannelUnavailable);
4739                         LDKStr err_str = obj->channel_unavailable.err;
4740                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
4741         return err_conv;
4742 }
4743 uint32_t __attribute__((export_name("TS_LDKAPIError_IncompatibleShutdownScript_get_script"))) TS_LDKAPIError_IncompatibleShutdownScript_get_script(uint32_t ptr) {
4744         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
4745         assert(obj->tag == LDKAPIError_IncompatibleShutdownScript);
4746                         LDKShutdownScript script_var = obj->incompatible_shutdown_script.script;
4747                         uint32_t script_ref = 0;
4748                         CHECK((((uintptr_t)script_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4749                         CHECK((((uintptr_t)&script_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4750                         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_var);
4751                         script_ref = (uintptr_t)script_var.inner & ~1;
4752         return script_ref;
4753 }
4754 static inline void CResult_NoneAPIErrorZ_get_ok(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
4755 CHECK(owner->result_ok);
4756         return *owner->contents.result;
4757 }
4758 void  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_get_ok"))) TS_CResult_NoneAPIErrorZ_get_ok(uint32_t owner) {
4759         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)(owner & ~1);
4760         CResult_NoneAPIErrorZ_get_ok(owner_conv);
4761 }
4762
4763 static inline struct LDKAPIError CResult_NoneAPIErrorZ_get_err(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
4764 CHECK(!owner->result_ok);
4765         return APIError_clone(&*owner->contents.err);
4766 }
4767 uint32_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_get_err"))) TS_CResult_NoneAPIErrorZ_get_err(uint32_t owner) {
4768         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)(owner & ~1);
4769         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
4770         *ret_copy = CResult_NoneAPIErrorZ_get_err(owner_conv);
4771         uint32_t ret_ref = (uintptr_t)ret_copy;
4772         return ret_ref;
4773 }
4774
4775 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
4776         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
4777         for (size_t i = 0; i < ret.datalen; i++) {
4778                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
4779         }
4780         return ret;
4781 }
4782 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
4783         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
4784         for (size_t i = 0; i < ret.datalen; i++) {
4785                 ret.data[i] = APIError_clone(&orig->data[i]);
4786         }
4787         return ret;
4788 }
4789 static inline struct LDKThirtyTwoBytes CResult__u832APIErrorZ_get_ok(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
4790 CHECK(owner->result_ok);
4791         return ThirtyTwoBytes_clone(&*owner->contents.result);
4792 }
4793 int8_tArray  __attribute__((export_name("TS_CResult__u832APIErrorZ_get_ok"))) TS_CResult__u832APIErrorZ_get_ok(uint32_t owner) {
4794         LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)(owner & ~1);
4795         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4796         memcpy(ret_arr->elems, CResult__u832APIErrorZ_get_ok(owner_conv).data, 32);
4797         return ret_arr;
4798 }
4799
4800 static inline struct LDKAPIError CResult__u832APIErrorZ_get_err(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
4801 CHECK(!owner->result_ok);
4802         return APIError_clone(&*owner->contents.err);
4803 }
4804 uint32_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_get_err"))) TS_CResult__u832APIErrorZ_get_err(uint32_t owner) {
4805         LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)(owner & ~1);
4806         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
4807         *ret_copy = CResult__u832APIErrorZ_get_err(owner_conv);
4808         uint32_t ret_ref = (uintptr_t)ret_copy;
4809         return ret_ref;
4810 }
4811
4812 uint32_t __attribute__((export_name("TS_LDKPaymentSendFailure_ty_from_ptr"))) TS_LDKPaymentSendFailure_ty_from_ptr(uint32_t ptr) {
4813         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
4814         switch(obj->tag) {
4815                 case LDKPaymentSendFailure_ParameterError: return 0;
4816                 case LDKPaymentSendFailure_PathParameterError: return 1;
4817                 case LDKPaymentSendFailure_AllFailedRetrySafe: return 2;
4818                 case LDKPaymentSendFailure_PartialFailure: return 3;
4819                 default: abort();
4820         }
4821 }
4822 uint32_t __attribute__((export_name("TS_LDKPaymentSendFailure_ParameterError_get_parameter_error"))) TS_LDKPaymentSendFailure_ParameterError_get_parameter_error(uint32_t ptr) {
4823         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
4824         assert(obj->tag == LDKPaymentSendFailure_ParameterError);
4825                         uint32_t parameter_error_ref = ((uintptr_t)&obj->parameter_error) | 1;
4826         return parameter_error_ref;
4827 }
4828 uint32_tArray __attribute__((export_name("TS_LDKPaymentSendFailure_PathParameterError_get_path_parameter_error"))) TS_LDKPaymentSendFailure_PathParameterError_get_path_parameter_error(uint32_t ptr) {
4829         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
4830         assert(obj->tag == LDKPaymentSendFailure_PathParameterError);
4831                         LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
4832                         uint32_tArray path_parameter_error_arr = NULL;
4833                         path_parameter_error_arr = init_uint32_tArray(path_parameter_error_var.datalen, __LINE__);
4834                         uint32_t *path_parameter_error_arr_ptr = (uint32_t*)(((uint8_t*)path_parameter_error_arr) + 8);
4835                         for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
4836                                 LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
4837                                 *path_parameter_error_conv_22_conv = path_parameter_error_var.data[w];
4838                                 *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
4839                                 path_parameter_error_arr_ptr[w] = (uint32_t)path_parameter_error_conv_22_conv;
4840                         }
4841                         
4842         return path_parameter_error_arr;
4843 }
4844 uint32_tArray __attribute__((export_name("TS_LDKPaymentSendFailure_AllFailedRetrySafe_get_all_failed_retry_safe"))) TS_LDKPaymentSendFailure_AllFailedRetrySafe_get_all_failed_retry_safe(uint32_t ptr) {
4845         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
4846         assert(obj->tag == LDKPaymentSendFailure_AllFailedRetrySafe);
4847                         LDKCVec_APIErrorZ all_failed_retry_safe_var = obj->all_failed_retry_safe;
4848                         uint32_tArray all_failed_retry_safe_arr = NULL;
4849                         all_failed_retry_safe_arr = init_uint32_tArray(all_failed_retry_safe_var.datalen, __LINE__);
4850                         uint32_t *all_failed_retry_safe_arr_ptr = (uint32_t*)(((uint8_t*)all_failed_retry_safe_arr) + 8);
4851                         for (size_t k = 0; k < all_failed_retry_safe_var.datalen; k++) {
4852                                 uint32_t all_failed_retry_safe_conv_10_ref = ((uintptr_t)&all_failed_retry_safe_var.data[k]) | 1;
4853                                 all_failed_retry_safe_arr_ptr[k] = all_failed_retry_safe_conv_10_ref;
4854                         }
4855                         
4856         return all_failed_retry_safe_arr;
4857 }
4858 uint32_tArray __attribute__((export_name("TS_LDKPaymentSendFailure_PartialFailure_get_results"))) TS_LDKPaymentSendFailure_PartialFailure_get_results(uint32_t ptr) {
4859         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
4860         assert(obj->tag == LDKPaymentSendFailure_PartialFailure);
4861                         LDKCVec_CResult_NoneAPIErrorZZ results_var = obj->partial_failure.results;
4862                         uint32_tArray results_arr = NULL;
4863                         results_arr = init_uint32_tArray(results_var.datalen, __LINE__);
4864                         uint32_t *results_arr_ptr = (uint32_t*)(((uint8_t*)results_arr) + 8);
4865                         for (size_t w = 0; w < results_var.datalen; w++) {
4866                                 LDKCResult_NoneAPIErrorZ* results_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
4867                                 *results_conv_22_conv = results_var.data[w];
4868                                 *results_conv_22_conv = CResult_NoneAPIErrorZ_clone(results_conv_22_conv);
4869                                 results_arr_ptr[w] = (uint32_t)results_conv_22_conv;
4870                         }
4871                         
4872         return results_arr;
4873 }
4874 uint32_t __attribute__((export_name("TS_LDKPaymentSendFailure_PartialFailure_get_failed_paths_retry"))) TS_LDKPaymentSendFailure_PartialFailure_get_failed_paths_retry(uint32_t ptr) {
4875         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
4876         assert(obj->tag == LDKPaymentSendFailure_PartialFailure);
4877                         LDKRouteParameters failed_paths_retry_var = obj->partial_failure.failed_paths_retry;
4878                         uint32_t failed_paths_retry_ref = 0;
4879                         if ((uintptr_t)failed_paths_retry_var.inner > 4096) {
4880                                 CHECK((((uintptr_t)failed_paths_retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4881                                 CHECK((((uintptr_t)&failed_paths_retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4882                         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_var);
4883                                 failed_paths_retry_ref = (uintptr_t)failed_paths_retry_var.inner & ~1;
4884                         }
4885         return failed_paths_retry_ref;
4886 }
4887 int8_tArray __attribute__((export_name("TS_LDKPaymentSendFailure_PartialFailure_get_payment_id"))) TS_LDKPaymentSendFailure_PartialFailure_get_payment_id(uint32_t ptr) {
4888         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
4889         assert(obj->tag == LDKPaymentSendFailure_PartialFailure);
4890                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
4891                         memcpy(payment_id_arr->elems, obj->partial_failure.payment_id.data, 32);
4892         return payment_id_arr;
4893 }
4894 static inline struct LDKThirtyTwoBytes CResult_PaymentIdPaymentSendFailureZ_get_ok(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR owner){
4895 CHECK(owner->result_ok);
4896         return ThirtyTwoBytes_clone(&*owner->contents.result);
4897 }
4898 int8_tArray  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_get_ok"))) TS_CResult_PaymentIdPaymentSendFailureZ_get_ok(uint32_t owner) {
4899         LDKCResult_PaymentIdPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(owner & ~1);
4900         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4901         memcpy(ret_arr->elems, CResult_PaymentIdPaymentSendFailureZ_get_ok(owner_conv).data, 32);
4902         return ret_arr;
4903 }
4904
4905 static inline struct LDKPaymentSendFailure CResult_PaymentIdPaymentSendFailureZ_get_err(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR owner){
4906 CHECK(!owner->result_ok);
4907         return PaymentSendFailure_clone(&*owner->contents.err);
4908 }
4909 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_get_err"))) TS_CResult_PaymentIdPaymentSendFailureZ_get_err(uint32_t owner) {
4910         LDKCResult_PaymentIdPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(owner & ~1);
4911         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
4912         *ret_copy = CResult_PaymentIdPaymentSendFailureZ_get_err(owner_conv);
4913         uint32_t ret_ref = (uintptr_t)ret_copy;
4914         return ret_ref;
4915 }
4916
4917 static inline void CResult_NonePaymentSendFailureZ_get_ok(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
4918 CHECK(owner->result_ok);
4919         return *owner->contents.result;
4920 }
4921 void  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_get_ok"))) TS_CResult_NonePaymentSendFailureZ_get_ok(uint32_t owner) {
4922         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)(owner & ~1);
4923         CResult_NonePaymentSendFailureZ_get_ok(owner_conv);
4924 }
4925
4926 static inline struct LDKPaymentSendFailure CResult_NonePaymentSendFailureZ_get_err(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
4927 CHECK(!owner->result_ok);
4928         return PaymentSendFailure_clone(&*owner->contents.err);
4929 }
4930 uint32_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_get_err"))) TS_CResult_NonePaymentSendFailureZ_get_err(uint32_t owner) {
4931         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)(owner & ~1);
4932         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
4933         *ret_copy = CResult_NonePaymentSendFailureZ_get_err(owner_conv);
4934         uint32_t ret_ref = (uintptr_t)ret_copy;
4935         return ret_ref;
4936 }
4937
4938 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_a(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
4939         return ThirtyTwoBytes_clone(&owner->a);
4940 }
4941 int8_tArray  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_get_a"))) TS_C2Tuple_PaymentHashPaymentIdZ_get_a(uint32_t owner) {
4942         LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(owner & ~1);
4943         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4944         memcpy(ret_arr->elems, C2Tuple_PaymentHashPaymentIdZ_get_a(owner_conv).data, 32);
4945         return ret_arr;
4946 }
4947
4948 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_b(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
4949         return ThirtyTwoBytes_clone(&owner->b);
4950 }
4951 int8_tArray  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_get_b"))) TS_C2Tuple_PaymentHashPaymentIdZ_get_b(uint32_t owner) {
4952         LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(owner & ~1);
4953         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4954         memcpy(ret_arr->elems, C2Tuple_PaymentHashPaymentIdZ_get_b(owner_conv).data, 32);
4955         return ret_arr;
4956 }
4957
4958 static inline struct LDKC2Tuple_PaymentHashPaymentIdZ CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
4959 CHECK(owner->result_ok);
4960         return C2Tuple_PaymentHashPaymentIdZ_clone(&*owner->contents.result);
4961 }
4962 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(uint32_t owner) {
4963         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(owner & ~1);
4964         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
4965         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(owner_conv);
4966         return ((uint32_t)ret_conv);
4967 }
4968
4969 static inline struct LDKPaymentSendFailure CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
4970 CHECK(!owner->result_ok);
4971         return PaymentSendFailure_clone(&*owner->contents.err);
4972 }
4973 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(uint32_t owner) {
4974         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(owner & ~1);
4975         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
4976         *ret_copy = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(owner_conv);
4977         uint32_t ret_ref = (uintptr_t)ret_copy;
4978         return ret_ref;
4979 }
4980
4981 static inline LDKCVec_ThirtyTwoBytesZ CVec_ThirtyTwoBytesZ_clone(const LDKCVec_ThirtyTwoBytesZ *orig) {
4982         LDKCVec_ThirtyTwoBytesZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_ThirtyTwoBytesZ clone bytes"), .datalen = orig->datalen };
4983         for (size_t i = 0; i < ret.datalen; i++) {
4984                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
4985         }
4986         return ret;
4987 }
4988 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_a(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
4989         return ThirtyTwoBytes_clone(&owner->a);
4990 }
4991 int8_tArray  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_get_a"))) TS_C2Tuple_PaymentHashPaymentSecretZ_get_a(uint32_t owner) {
4992         LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(owner & ~1);
4993         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4994         memcpy(ret_arr->elems, C2Tuple_PaymentHashPaymentSecretZ_get_a(owner_conv).data, 32);
4995         return ret_arr;
4996 }
4997
4998 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_b(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
4999         return ThirtyTwoBytes_clone(&owner->b);
5000 }
5001 int8_tArray  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_get_b"))) TS_C2Tuple_PaymentHashPaymentSecretZ_get_b(uint32_t owner) {
5002         LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(owner & ~1);
5003         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5004         memcpy(ret_arr->elems, C2Tuple_PaymentHashPaymentSecretZ_get_b(owner_conv).data, 32);
5005         return ret_arr;
5006 }
5007
5008 static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
5009 CHECK(owner->result_ok);
5010         return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
5011 }
5012 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(uint32_t owner) {
5013         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(owner & ~1);
5014         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
5015         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(owner_conv);
5016         return ((uint32_t)ret_conv);
5017 }
5018
5019 static inline void CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
5020 CHECK(!owner->result_ok);
5021         return *owner->contents.err;
5022 }
5023 void  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(uint32_t owner) {
5024         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(owner & ~1);
5025         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(owner_conv);
5026 }
5027
5028 static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
5029 CHECK(owner->result_ok);
5030         return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
5031 }
5032 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(uint32_t owner) {
5033         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(owner & ~1);
5034         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
5035         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(owner_conv);
5036         return ((uint32_t)ret_conv);
5037 }
5038
5039 static inline struct LDKAPIError CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
5040 CHECK(!owner->result_ok);
5041         return APIError_clone(&*owner->contents.err);
5042 }
5043 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(uint32_t owner) {
5044         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(owner & ~1);
5045         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
5046         *ret_copy = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(owner_conv);
5047         uint32_t ret_ref = (uintptr_t)ret_copy;
5048         return ret_ref;
5049 }
5050
5051 static inline struct LDKThirtyTwoBytes CResult_PaymentSecretNoneZ_get_ok(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
5052 CHECK(owner->result_ok);
5053         return ThirtyTwoBytes_clone(&*owner->contents.result);
5054 }
5055 int8_tArray  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_get_ok"))) TS_CResult_PaymentSecretNoneZ_get_ok(uint32_t owner) {
5056         LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)(owner & ~1);
5057         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5058         memcpy(ret_arr->elems, CResult_PaymentSecretNoneZ_get_ok(owner_conv).data, 32);
5059         return ret_arr;
5060 }
5061
5062 static inline void CResult_PaymentSecretNoneZ_get_err(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
5063 CHECK(!owner->result_ok);
5064         return *owner->contents.err;
5065 }
5066 void  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_get_err"))) TS_CResult_PaymentSecretNoneZ_get_err(uint32_t owner) {
5067         LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)(owner & ~1);
5068         CResult_PaymentSecretNoneZ_get_err(owner_conv);
5069 }
5070
5071 static inline struct LDKThirtyTwoBytes CResult_PaymentSecretAPIErrorZ_get_ok(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
5072 CHECK(owner->result_ok);
5073         return ThirtyTwoBytes_clone(&*owner->contents.result);
5074 }
5075 int8_tArray  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_get_ok"))) TS_CResult_PaymentSecretAPIErrorZ_get_ok(uint32_t owner) {
5076         LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(owner & ~1);
5077         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5078         memcpy(ret_arr->elems, CResult_PaymentSecretAPIErrorZ_get_ok(owner_conv).data, 32);
5079         return ret_arr;
5080 }
5081
5082 static inline struct LDKAPIError CResult_PaymentSecretAPIErrorZ_get_err(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
5083 CHECK(!owner->result_ok);
5084         return APIError_clone(&*owner->contents.err);
5085 }
5086 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_get_err"))) TS_CResult_PaymentSecretAPIErrorZ_get_err(uint32_t owner) {
5087         LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(owner & ~1);
5088         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
5089         *ret_copy = CResult_PaymentSecretAPIErrorZ_get_err(owner_conv);
5090         uint32_t ret_ref = (uintptr_t)ret_copy;
5091         return ret_ref;
5092 }
5093
5094 static inline struct LDKThirtyTwoBytes CResult_PaymentPreimageAPIErrorZ_get_ok(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
5095 CHECK(owner->result_ok);
5096         return ThirtyTwoBytes_clone(&*owner->contents.result);
5097 }
5098 int8_tArray  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_get_ok"))) TS_CResult_PaymentPreimageAPIErrorZ_get_ok(uint32_t owner) {
5099         LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(owner & ~1);
5100         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5101         memcpy(ret_arr->elems, CResult_PaymentPreimageAPIErrorZ_get_ok(owner_conv).data, 32);
5102         return ret_arr;
5103 }
5104
5105 static inline struct LDKAPIError CResult_PaymentPreimageAPIErrorZ_get_err(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
5106 CHECK(!owner->result_ok);
5107         return APIError_clone(&*owner->contents.err);
5108 }
5109 uint32_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_get_err"))) TS_CResult_PaymentPreimageAPIErrorZ_get_err(uint32_t owner) {
5110         LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(owner & ~1);
5111         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
5112         *ret_copy = CResult_PaymentPreimageAPIErrorZ_get_err(owner_conv);
5113         uint32_t ret_ref = (uintptr_t)ret_copy;
5114         return ret_ref;
5115 }
5116
5117 static inline struct LDKCounterpartyForwardingInfo CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR owner){
5118 CHECK(owner->result_ok);
5119         return CounterpartyForwardingInfo_clone(&*owner->contents.result);
5120 }
5121 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(uint32_t owner) {
5122         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(owner & ~1);
5123         LDKCounterpartyForwardingInfo ret_var = CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(owner_conv);
5124         uint32_t ret_ref = 0;
5125         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5126         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5127         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5128         ret_ref = (uintptr_t)ret_var.inner;
5129         if (ret_var.is_owned) {
5130                 ret_ref |= 1;
5131         }
5132         return ret_ref;
5133 }
5134
5135 static inline struct LDKDecodeError CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR owner){
5136 CHECK(!owner->result_ok);
5137         return DecodeError_clone(&*owner->contents.err);
5138 }
5139 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(uint32_t owner) {
5140         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(owner & ~1);
5141         LDKDecodeError ret_var = CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(owner_conv);
5142         uint32_t ret_ref = 0;
5143         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5144         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5145         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5146         ret_ref = (uintptr_t)ret_var.inner;
5147         if (ret_var.is_owned) {
5148                 ret_ref |= 1;
5149         }
5150         return ret_ref;
5151 }
5152
5153 static inline struct LDKChannelCounterparty CResult_ChannelCounterpartyDecodeErrorZ_get_ok(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR owner){
5154 CHECK(owner->result_ok);
5155         return ChannelCounterparty_clone(&*owner->contents.result);
5156 }
5157 uint32_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_get_ok"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_get_ok(uint32_t owner) {
5158         LDKCResult_ChannelCounterpartyDecodeErrorZ* owner_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(owner & ~1);
5159         LDKChannelCounterparty ret_var = CResult_ChannelCounterpartyDecodeErrorZ_get_ok(owner_conv);
5160         uint32_t ret_ref = 0;
5161         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5162         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5163         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5164         ret_ref = (uintptr_t)ret_var.inner;
5165         if (ret_var.is_owned) {
5166                 ret_ref |= 1;
5167         }
5168         return ret_ref;
5169 }
5170
5171 static inline struct LDKDecodeError CResult_ChannelCounterpartyDecodeErrorZ_get_err(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR owner){
5172 CHECK(!owner->result_ok);
5173         return DecodeError_clone(&*owner->contents.err);
5174 }
5175 uint32_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_get_err"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_get_err(uint32_t owner) {
5176         LDKCResult_ChannelCounterpartyDecodeErrorZ* owner_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(owner & ~1);
5177         LDKDecodeError ret_var = CResult_ChannelCounterpartyDecodeErrorZ_get_err(owner_conv);
5178         uint32_t ret_ref = 0;
5179         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5180         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5181         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5182         ret_ref = (uintptr_t)ret_var.inner;
5183         if (ret_var.is_owned) {
5184                 ret_ref |= 1;
5185         }
5186         return ret_ref;
5187 }
5188
5189 static inline struct LDKChannelDetails CResult_ChannelDetailsDecodeErrorZ_get_ok(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR owner){
5190 CHECK(owner->result_ok);
5191         return ChannelDetails_clone(&*owner->contents.result);
5192 }
5193 uint32_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_get_ok"))) TS_CResult_ChannelDetailsDecodeErrorZ_get_ok(uint32_t owner) {
5194         LDKCResult_ChannelDetailsDecodeErrorZ* owner_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(owner & ~1);
5195         LDKChannelDetails ret_var = CResult_ChannelDetailsDecodeErrorZ_get_ok(owner_conv);
5196         uint32_t ret_ref = 0;
5197         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5198         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5199         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5200         ret_ref = (uintptr_t)ret_var.inner;
5201         if (ret_var.is_owned) {
5202                 ret_ref |= 1;
5203         }
5204         return ret_ref;
5205 }
5206
5207 static inline struct LDKDecodeError CResult_ChannelDetailsDecodeErrorZ_get_err(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR owner){
5208 CHECK(!owner->result_ok);
5209         return DecodeError_clone(&*owner->contents.err);
5210 }
5211 uint32_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_get_err"))) TS_CResult_ChannelDetailsDecodeErrorZ_get_err(uint32_t owner) {
5212         LDKCResult_ChannelDetailsDecodeErrorZ* owner_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(owner & ~1);
5213         LDKDecodeError ret_var = CResult_ChannelDetailsDecodeErrorZ_get_err(owner_conv);
5214         uint32_t ret_ref = 0;
5215         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5216         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5217         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5218         ret_ref = (uintptr_t)ret_var.inner;
5219         if (ret_var.is_owned) {
5220                 ret_ref |= 1;
5221         }
5222         return ret_ref;
5223 }
5224
5225 static inline struct LDKPhantomRouteHints CResult_PhantomRouteHintsDecodeErrorZ_get_ok(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR owner){
5226 CHECK(owner->result_ok);
5227         return PhantomRouteHints_clone(&*owner->contents.result);
5228 }
5229 uint32_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_get_ok"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_get_ok(uint32_t owner) {
5230         LDKCResult_PhantomRouteHintsDecodeErrorZ* owner_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(owner & ~1);
5231         LDKPhantomRouteHints ret_var = CResult_PhantomRouteHintsDecodeErrorZ_get_ok(owner_conv);
5232         uint32_t ret_ref = 0;
5233         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5234         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5235         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5236         ret_ref = (uintptr_t)ret_var.inner;
5237         if (ret_var.is_owned) {
5238                 ret_ref |= 1;
5239         }
5240         return ret_ref;
5241 }
5242
5243 static inline struct LDKDecodeError CResult_PhantomRouteHintsDecodeErrorZ_get_err(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR owner){
5244 CHECK(!owner->result_ok);
5245         return DecodeError_clone(&*owner->contents.err);
5246 }
5247 uint32_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_get_err"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_get_err(uint32_t owner) {
5248         LDKCResult_PhantomRouteHintsDecodeErrorZ* owner_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(owner & ~1);
5249         LDKDecodeError ret_var = CResult_PhantomRouteHintsDecodeErrorZ_get_err(owner_conv);
5250         uint32_t ret_ref = 0;
5251         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5252         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5253         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5254         ret_ref = (uintptr_t)ret_var.inner;
5255         if (ret_var.is_owned) {
5256                 ret_ref |= 1;
5257         }
5258         return ret_ref;
5259 }
5260
5261 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
5262         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
5263         for (size_t i = 0; i < ret.datalen; i++) {
5264                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
5265         }
5266         return ret;
5267 }
5268 typedef struct LDKWatch_JCalls {
5269         atomic_size_t refcnt;
5270         uint32_t instance_ptr;
5271 } LDKWatch_JCalls;
5272 static void LDKWatch_JCalls_free(void* this_arg) {
5273         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
5274         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5275                 FREE(j_calls);
5276         }
5277 }
5278 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
5279         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
5280         LDKOutPoint funding_txo_var = funding_txo;
5281         uint32_t funding_txo_ref = 0;
5282         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5283         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5284         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
5285         funding_txo_ref = (uintptr_t)funding_txo_var.inner;
5286         if (funding_txo_var.is_owned) {
5287                 funding_txo_ref |= 1;
5288         }
5289         LDKChannelMonitor monitor_var = monitor;
5290         uint32_t monitor_ref = 0;
5291         CHECK((((uintptr_t)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5292         CHECK((((uintptr_t)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5293         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_var);
5294         monitor_ref = (uintptr_t)monitor_var.inner;
5295         if (monitor_var.is_owned) {
5296                 monitor_ref |= 1;
5297         }
5298         uint32_t ret = js_invoke_function_uuuuuu(j_calls->instance_ptr, 16, (uint32_t)funding_txo_ref, (uint32_t)monitor_ref, 0, 0, 0, 0);
5299         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5300         CHECK_ACCESS(ret_ptr);
5301         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
5302         FREE((void*)ret);
5303         return ret_conv;
5304 }
5305 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
5306         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
5307         LDKOutPoint funding_txo_var = funding_txo;
5308         uint32_t funding_txo_ref = 0;
5309         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5310         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5311         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
5312         funding_txo_ref = (uintptr_t)funding_txo_var.inner;
5313         if (funding_txo_var.is_owned) {
5314                 funding_txo_ref |= 1;
5315         }
5316         LDKChannelMonitorUpdate update_var = update;
5317         uint32_t update_ref = 0;
5318         CHECK((((uintptr_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5319         CHECK((((uintptr_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5320         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
5321         update_ref = (uintptr_t)update_var.inner;
5322         if (update_var.is_owned) {
5323                 update_ref |= 1;
5324         }
5325         uint32_t ret = js_invoke_function_uuuuuu(j_calls->instance_ptr, 17, (uint32_t)funding_txo_ref, (uint32_t)update_ref, 0, 0, 0, 0);
5326         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5327         CHECK_ACCESS(ret_ptr);
5328         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
5329         FREE((void*)ret);
5330         return ret_conv;
5331 }
5332 LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ release_pending_monitor_events_LDKWatch_jcall(const void* this_arg) {
5333         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
5334         uint32_tArray ret = (uint32_tArray)js_invoke_function_uuuuuu(j_calls->instance_ptr, 18, 0, 0, 0, 0, 0, 0);
5335         LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ ret_constr;
5336         ret_constr.datalen = ret->arr_len;
5337         if (ret_constr.datalen > 0)
5338                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ Elements");
5339         else
5340                 ret_constr.data = NULL;
5341         uint32_t* ret_vals = ret->elems;
5342         for (size_t x = 0; x < ret_constr.datalen; x++) {
5343                 uint32_t ret_conv_49 = ret_vals[x];
5344                 void* ret_conv_49_ptr = (void*)(((uintptr_t)ret_conv_49) & ~1);
5345                 CHECK_ACCESS(ret_conv_49_ptr);
5346                 LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ ret_conv_49_conv = *(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(ret_conv_49_ptr);
5347                 FREE((void*)ret_conv_49);
5348                 ret_constr.data[x] = ret_conv_49_conv;
5349         }
5350         FREE(ret);
5351         return ret_constr;
5352 }
5353 static void LDKWatch_JCalls_cloned(LDKWatch* new_obj) {
5354         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) new_obj->this_arg;
5355         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5356 }
5357 static inline LDKWatch LDKWatch_init (JSValue o) {
5358         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
5359         atomic_init(&calls->refcnt, 1);
5360         calls->instance_ptr = o;
5361
5362         LDKWatch ret = {
5363                 .this_arg = (void*) calls,
5364                 .watch_channel = watch_channel_LDKWatch_jcall,
5365                 .update_channel = update_channel_LDKWatch_jcall,
5366                 .release_pending_monitor_events = release_pending_monitor_events_LDKWatch_jcall,
5367                 .free = LDKWatch_JCalls_free,
5368         };
5369         return ret;
5370 }
5371 long  __attribute__((export_name("TS_LDKWatch_new"))) TS_LDKWatch_new(JSValue o) {
5372         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
5373         *res_ptr = LDKWatch_init(o);
5374         return (long)res_ptr;
5375 }
5376 uint32_t  __attribute__((export_name("TS_Watch_watch_channel"))) TS_Watch_watch_channel(uint32_t this_arg, uint32_t funding_txo, uint32_t monitor) {
5377         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5378         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5379         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
5380         LDKOutPoint funding_txo_conv;
5381         funding_txo_conv.inner = (void*)(funding_txo & (~1));
5382         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
5383         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
5384         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
5385         LDKChannelMonitor monitor_conv;
5386         monitor_conv.inner = (void*)(monitor & (~1));
5387         monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
5388         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_conv);
5389         monitor_conv = ChannelMonitor_clone(&monitor_conv);
5390         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
5391         *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
5392         return (uint32_t)ret_conv;
5393 }
5394
5395 uint32_t  __attribute__((export_name("TS_Watch_update_channel"))) TS_Watch_update_channel(uint32_t this_arg, uint32_t funding_txo, uint32_t update) {
5396         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5397         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5398         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
5399         LDKOutPoint funding_txo_conv;
5400         funding_txo_conv.inner = (void*)(funding_txo & (~1));
5401         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
5402         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
5403         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
5404         LDKChannelMonitorUpdate update_conv;
5405         update_conv.inner = (void*)(update & (~1));
5406         update_conv.is_owned = (update & 1) || (update == 0);
5407         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
5408         update_conv = ChannelMonitorUpdate_clone(&update_conv);
5409         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
5410         *ret_conv = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
5411         return (uint32_t)ret_conv;
5412 }
5413
5414 uint32_tArray  __attribute__((export_name("TS_Watch_release_pending_monitor_events"))) TS_Watch_release_pending_monitor_events(uint32_t this_arg) {
5415         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5416         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5417         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
5418         LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
5419         uint32_tArray ret_arr = NULL;
5420         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
5421         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 8);
5422         for (size_t x = 0; x < ret_var.datalen; x++) {
5423                 LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* ret_conv_49_conv = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ");
5424                 *ret_conv_49_conv = ret_var.data[x];
5425                 ret_arr_ptr[x] = ((uint32_t)ret_conv_49_conv);
5426         }
5427         
5428         FREE(ret_var.data);
5429         return ret_arr;
5430 }
5431
5432 typedef struct LDKBroadcasterInterface_JCalls {
5433         atomic_size_t refcnt;
5434         uint32_t instance_ptr;
5435 } LDKBroadcasterInterface_JCalls;
5436 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
5437         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
5438         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5439                 FREE(j_calls);
5440         }
5441 }
5442 void broadcast_transaction_LDKBroadcasterInterface_jcall(const void* this_arg, LDKTransaction tx) {
5443         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
5444         LDKTransaction tx_var = tx;
5445         int8_tArray tx_arr = init_int8_tArray(tx_var.datalen, __LINE__);
5446         memcpy(tx_arr->elems, tx_var.data, tx_var.datalen);
5447         Transaction_free(tx_var);
5448         js_invoke_function_uuuuuu(j_calls->instance_ptr, 19, (uint32_t)tx_arr, 0, 0, 0, 0, 0);
5449 }
5450 static void LDKBroadcasterInterface_JCalls_cloned(LDKBroadcasterInterface* new_obj) {
5451         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) new_obj->this_arg;
5452         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5453 }
5454 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (JSValue o) {
5455         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
5456         atomic_init(&calls->refcnt, 1);
5457         calls->instance_ptr = o;
5458
5459         LDKBroadcasterInterface ret = {
5460                 .this_arg = (void*) calls,
5461                 .broadcast_transaction = broadcast_transaction_LDKBroadcasterInterface_jcall,
5462                 .free = LDKBroadcasterInterface_JCalls_free,
5463         };
5464         return ret;
5465 }
5466 long  __attribute__((export_name("TS_LDKBroadcasterInterface_new"))) TS_LDKBroadcasterInterface_new(JSValue o) {
5467         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
5468         *res_ptr = LDKBroadcasterInterface_init(o);
5469         return (long)res_ptr;
5470 }
5471 void  __attribute__((export_name("TS_BroadcasterInterface_broadcast_transaction"))) TS_BroadcasterInterface_broadcast_transaction(uint32_t this_arg, int8_tArray tx) {
5472         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5473         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5474         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)this_arg_ptr;
5475         LDKTransaction tx_ref;
5476         tx_ref.datalen = tx->arr_len;
5477         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
5478         memcpy(tx_ref.data, tx->elems, tx_ref.datalen); FREE(tx);
5479         tx_ref.data_is_owned = true;
5480         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
5481 }
5482
5483 typedef struct LDKKeysInterface_JCalls {
5484         atomic_size_t refcnt;
5485         uint32_t instance_ptr;
5486 } LDKKeysInterface_JCalls;
5487 static void LDKKeysInterface_JCalls_free(void* this_arg) {
5488         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5489         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5490                 FREE(j_calls);
5491         }
5492 }
5493 LDKCResult_SecretKeyNoneZ get_node_secret_LDKKeysInterface_jcall(const void* this_arg, LDKRecipient recipient) {
5494         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5495         uint32_t recipient_conv = LDKRecipient_to_js(recipient);
5496         uint32_t ret = js_invoke_function_uuuuuu(j_calls->instance_ptr, 20, (uint32_t)recipient_conv, 0, 0, 0, 0, 0);
5497         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5498         CHECK_ACCESS(ret_ptr);
5499         LDKCResult_SecretKeyNoneZ ret_conv = *(LDKCResult_SecretKeyNoneZ*)(ret_ptr);
5500         FREE((void*)ret);
5501         return ret_conv;
5502 }
5503 LDKCVec_u8Z get_destination_script_LDKKeysInterface_jcall(const void* this_arg) {
5504         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5505         int8_tArray ret = (int8_tArray)js_invoke_function_uuuuuu(j_calls->instance_ptr, 21, 0, 0, 0, 0, 0, 0);
5506         LDKCVec_u8Z ret_ref;
5507         ret_ref.datalen = ret->arr_len;
5508         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
5509         memcpy(ret_ref.data, ret->elems, ret_ref.datalen); FREE(ret);
5510         return ret_ref;
5511 }
5512 LDKShutdownScript get_shutdown_scriptpubkey_LDKKeysInterface_jcall(const void* this_arg) {
5513         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5514         uint32_t ret = js_invoke_function_uuuuuu(j_calls->instance_ptr, 22, 0, 0, 0, 0, 0, 0);
5515         LDKShutdownScript ret_conv;
5516         ret_conv.inner = (void*)(ret & (~1));
5517         ret_conv.is_owned = (ret & 1) || (ret == 0);
5518         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
5519         return ret_conv;
5520 }
5521 LDKSign get_channel_signer_LDKKeysInterface_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
5522         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5523         jboolean inbound_conv = inbound;
5524         int64_t channel_value_satoshis_conv = channel_value_satoshis;
5525         uint32_t ret = js_invoke_function_ubuuuu(j_calls->instance_ptr, 23, (uint32_t)inbound_conv, (uint32_t)channel_value_satoshis_conv, 0, 0, 0, 0);
5526         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5527         CHECK_ACCESS(ret_ptr);
5528         LDKSign ret_conv = *(LDKSign*)(ret_ptr);
5529         FREE((void*)ret);
5530         return ret_conv;
5531 }
5532 LDKThirtyTwoBytes get_secure_random_bytes_LDKKeysInterface_jcall(const void* this_arg) {
5533         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5534         int8_tArray ret = (int8_tArray)js_invoke_function_uuuuuu(j_calls->instance_ptr, 24, 0, 0, 0, 0, 0, 0);
5535         LDKThirtyTwoBytes ret_ref;
5536         CHECK(ret->arr_len == 32);
5537         memcpy(ret_ref.data, ret->elems, 32); FREE(ret);
5538         return ret_ref;
5539 }
5540 LDKCResult_SignDecodeErrorZ read_chan_signer_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice reader) {
5541         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5542         LDKu8slice reader_var = reader;
5543         int8_tArray reader_arr = init_int8_tArray(reader_var.datalen, __LINE__);
5544         memcpy(reader_arr->elems, reader_var.data, reader_var.datalen);
5545         uint32_t ret = js_invoke_function_uuuuuu(j_calls->instance_ptr, 25, (uint32_t)reader_arr, 0, 0, 0, 0, 0);
5546         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5547         CHECK_ACCESS(ret_ptr);
5548         LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(ret_ptr);
5549         FREE((void*)ret);
5550         return ret_conv;
5551 }
5552 LDKCResult_RecoverableSignatureNoneZ sign_invoice_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice hrp_bytes, LDKCVec_u5Z invoice_data, LDKRecipient receipient) {
5553         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5554         LDKu8slice hrp_bytes_var = hrp_bytes;
5555         int8_tArray hrp_bytes_arr = init_int8_tArray(hrp_bytes_var.datalen, __LINE__);
5556         memcpy(hrp_bytes_arr->elems, hrp_bytes_var.data, hrp_bytes_var.datalen);
5557         LDKCVec_u5Z invoice_data_var = invoice_data;
5558         ptrArray invoice_data_arr = NULL;
5559         invoice_data_arr = init_ptrArray(invoice_data_var.datalen, __LINE__);
5560         int8_t *invoice_data_arr_ptr = (int8_t*)(((uint8_t*)invoice_data_arr) + 8);
5561         for (size_t h = 0; h < invoice_data_var.datalen; h++) {
5562                 uint8_t invoice_data_conv_7_val = invoice_data_var.data[h]._0;
5563                 invoice_data_arr_ptr[h] = invoice_data_conv_7_val;
5564         }
5565         
5566         FREE(invoice_data_var.data);
5567         uint32_t receipient_conv = LDKRecipient_to_js(receipient);
5568         uint32_t ret = js_invoke_function_uuuuuu(j_calls->instance_ptr, 26, (uint32_t)hrp_bytes_arr, (uint32_t)invoice_data_arr, (uint32_t)receipient_conv, 0, 0, 0);
5569         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5570         CHECK_ACCESS(ret_ptr);
5571         LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(ret_ptr);
5572         FREE((void*)ret);
5573         return ret_conv;
5574 }
5575 LDKThirtyTwoBytes get_inbound_payment_key_material_LDKKeysInterface_jcall(const void* this_arg) {
5576         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5577         int8_tArray ret = (int8_tArray)js_invoke_function_uuuuuu(j_calls->instance_ptr, 27, 0, 0, 0, 0, 0, 0);
5578         LDKThirtyTwoBytes ret_ref;
5579         CHECK(ret->arr_len == 32);
5580         memcpy(ret_ref.data, ret->elems, 32); FREE(ret);
5581         return ret_ref;
5582 }
5583 static void LDKKeysInterface_JCalls_cloned(LDKKeysInterface* new_obj) {
5584         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) new_obj->this_arg;
5585         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5586 }
5587 static inline LDKKeysInterface LDKKeysInterface_init (JSValue o) {
5588         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
5589         atomic_init(&calls->refcnt, 1);
5590         calls->instance_ptr = o;
5591
5592         LDKKeysInterface ret = {
5593                 .this_arg = (void*) calls,
5594                 .get_node_secret = get_node_secret_LDKKeysInterface_jcall,
5595                 .get_destination_script = get_destination_script_LDKKeysInterface_jcall,
5596                 .get_shutdown_scriptpubkey = get_shutdown_scriptpubkey_LDKKeysInterface_jcall,
5597                 .get_channel_signer = get_channel_signer_LDKKeysInterface_jcall,
5598                 .get_secure_random_bytes = get_secure_random_bytes_LDKKeysInterface_jcall,
5599                 .read_chan_signer = read_chan_signer_LDKKeysInterface_jcall,
5600                 .sign_invoice = sign_invoice_LDKKeysInterface_jcall,
5601                 .get_inbound_payment_key_material = get_inbound_payment_key_material_LDKKeysInterface_jcall,
5602                 .free = LDKKeysInterface_JCalls_free,
5603         };
5604         return ret;
5605 }
5606 long  __attribute__((export_name("TS_LDKKeysInterface_new"))) TS_LDKKeysInterface_new(JSValue o) {
5607         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
5608         *res_ptr = LDKKeysInterface_init(o);
5609         return (long)res_ptr;
5610 }
5611 uint32_t  __attribute__((export_name("TS_KeysInterface_get_node_secret"))) TS_KeysInterface_get_node_secret(uint32_t this_arg, uint32_t recipient) {
5612         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5613         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5614         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
5615         LDKRecipient recipient_conv = LDKRecipient_from_js(recipient);
5616         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
5617         *ret_conv = (this_arg_conv->get_node_secret)(this_arg_conv->this_arg, recipient_conv);
5618         return (uint32_t)ret_conv;
5619 }
5620
5621 int8_tArray  __attribute__((export_name("TS_KeysInterface_get_destination_script"))) TS_KeysInterface_get_destination_script(uint32_t this_arg) {
5622         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5623         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5624         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
5625         LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
5626         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
5627         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
5628         CVec_u8Z_free(ret_var);
5629         return ret_arr;
5630 }
5631
5632 uint32_t  __attribute__((export_name("TS_KeysInterface_get_shutdown_scriptpubkey"))) TS_KeysInterface_get_shutdown_scriptpubkey(uint32_t this_arg) {
5633         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5634         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5635         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
5636         LDKShutdownScript ret_var = (this_arg_conv->get_shutdown_scriptpubkey)(this_arg_conv->this_arg);
5637         uint32_t ret_ref = 0;
5638         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5639         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5640         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5641         ret_ref = (uintptr_t)ret_var.inner;
5642         if (ret_var.is_owned) {
5643                 ret_ref |= 1;
5644         }
5645         return ret_ref;
5646 }
5647
5648 uint32_t  __attribute__((export_name("TS_KeysInterface_get_channel_signer"))) TS_KeysInterface_get_channel_signer(uint32_t this_arg, jboolean inbound, int64_t channel_value_satoshis) {
5649         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5650         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5651         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
5652         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
5653         *ret_ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
5654         return (uint32_t)ret_ret;
5655 }
5656
5657 int8_tArray  __attribute__((export_name("TS_KeysInterface_get_secure_random_bytes"))) TS_KeysInterface_get_secure_random_bytes(uint32_t this_arg) {
5658         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5659         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5660         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
5661         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5662         memcpy(ret_arr->elems, (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data, 32);
5663         return ret_arr;
5664 }
5665
5666 uint32_t  __attribute__((export_name("TS_KeysInterface_read_chan_signer"))) TS_KeysInterface_read_chan_signer(uint32_t this_arg, int8_tArray reader) {
5667         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5668         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5669         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
5670         LDKu8slice reader_ref;
5671         reader_ref.datalen = reader->arr_len;
5672         reader_ref.data = reader->elems;
5673         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
5674         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
5675         FREE(reader);
5676         return (uint32_t)ret_conv;
5677 }
5678
5679 uint32_t  __attribute__((export_name("TS_KeysInterface_sign_invoice"))) TS_KeysInterface_sign_invoice(uint32_t this_arg, int8_tArray hrp_bytes, ptrArray invoice_data, uint32_t receipient) {
5680         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5681         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5682         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
5683         LDKu8slice hrp_bytes_ref;
5684         hrp_bytes_ref.datalen = hrp_bytes->arr_len;
5685         hrp_bytes_ref.data = hrp_bytes->elems;
5686         LDKCVec_u5Z invoice_data_constr;
5687         invoice_data_constr.datalen = invoice_data->arr_len;
5688         if (invoice_data_constr.datalen > 0)
5689                 invoice_data_constr.data = MALLOC(invoice_data_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
5690         else
5691                 invoice_data_constr.data = NULL;
5692         int8_t* invoice_data_vals = (void*) invoice_data->elems;
5693         for (size_t h = 0; h < invoice_data_constr.datalen; h++) {
5694                 int8_t invoice_data_conv_7 = invoice_data_vals[h];
5695                 
5696                 invoice_data_constr.data[h] = (LDKu5){ ._0 = invoice_data_conv_7 };
5697         }
5698         FREE(invoice_data);
5699         LDKRecipient receipient_conv = LDKRecipient_from_js(receipient);
5700         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
5701         *ret_conv = (this_arg_conv->sign_invoice)(this_arg_conv->this_arg, hrp_bytes_ref, invoice_data_constr, receipient_conv);
5702         FREE(hrp_bytes);
5703         return (uint32_t)ret_conv;
5704 }
5705
5706 int8_tArray  __attribute__((export_name("TS_KeysInterface_get_inbound_payment_key_material"))) TS_KeysInterface_get_inbound_payment_key_material(uint32_t this_arg) {
5707         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5708         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5709         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
5710         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5711         memcpy(ret_arr->elems, (this_arg_conv->get_inbound_payment_key_material)(this_arg_conv->this_arg).data, 32);
5712         return ret_arr;
5713 }
5714
5715 typedef struct LDKFeeEstimator_JCalls {
5716         atomic_size_t refcnt;
5717         uint32_t instance_ptr;
5718 } LDKFeeEstimator_JCalls;
5719 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
5720         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
5721         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5722                 FREE(j_calls);
5723         }
5724 }
5725 uint32_t get_est_sat_per_1000_weight_LDKFeeEstimator_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
5726         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
5727         uint32_t confirmation_target_conv = LDKConfirmationTarget_to_js(confirmation_target);
5728         return js_invoke_function_uuuuuu(j_calls->instance_ptr, 28, (uint32_t)confirmation_target_conv, 0, 0, 0, 0, 0);
5729 }
5730 static void LDKFeeEstimator_JCalls_cloned(LDKFeeEstimator* new_obj) {
5731         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) new_obj->this_arg;
5732         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5733 }
5734 static inline LDKFeeEstimator LDKFeeEstimator_init (JSValue o) {
5735         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
5736         atomic_init(&calls->refcnt, 1);
5737         calls->instance_ptr = o;
5738
5739         LDKFeeEstimator ret = {
5740                 .this_arg = (void*) calls,
5741                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_LDKFeeEstimator_jcall,
5742                 .free = LDKFeeEstimator_JCalls_free,
5743         };
5744         return ret;
5745 }
5746 long  __attribute__((export_name("TS_LDKFeeEstimator_new"))) TS_LDKFeeEstimator_new(JSValue o) {
5747         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
5748         *res_ptr = LDKFeeEstimator_init(o);
5749         return (long)res_ptr;
5750 }
5751 int32_t  __attribute__((export_name("TS_FeeEstimator_get_est_sat_per_1000_weight"))) TS_FeeEstimator_get_est_sat_per_1000_weight(uint32_t this_arg, uint32_t confirmation_target) {
5752         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5753         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5754         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)this_arg_ptr;
5755         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_js(confirmation_target);
5756         int32_t ret_conv = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
5757         return ret_conv;
5758 }
5759
5760 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelManagerZ_get_a(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
5761         return ThirtyTwoBytes_clone(&owner->a);
5762 }
5763 int8_tArray  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_get_a"))) TS_C2Tuple_BlockHashChannelManagerZ_get_a(uint32_t owner) {
5764         LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(owner & ~1);
5765         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5766         memcpy(ret_arr->elems, C2Tuple_BlockHashChannelManagerZ_get_a(owner_conv).data, 32);
5767         return ret_arr;
5768 }
5769
5770 static inline struct LDKChannelManager *C2Tuple_BlockHashChannelManagerZ_get_b(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
5771         return &owner->b;
5772 }
5773 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_get_b"))) TS_C2Tuple_BlockHashChannelManagerZ_get_b(uint32_t owner) {
5774         LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(owner & ~1);
5775         LDKChannelManager ret_var = *C2Tuple_BlockHashChannelManagerZ_get_b(owner_conv);
5776         uint32_t ret_ref = 0;
5777         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5778         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5779         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5780         ret_ref = (uintptr_t)ret_var.inner & ~1;
5781         return ret_ref;
5782 }
5783
5784 static inline struct LDKC2Tuple_BlockHashChannelManagerZ *CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
5785 CHECK(owner->result_ok);
5786         return &*owner->contents.result;
5787 }
5788 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(uint32_t owner) {
5789         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(owner & ~1);
5790         uint32_t ret_ret = (uintptr_t)CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(owner_conv) | 1;
5791         return ret_ret;
5792 }
5793
5794 static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
5795 CHECK(!owner->result_ok);
5796         return DecodeError_clone(&*owner->contents.err);
5797 }
5798 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(uint32_t owner) {
5799         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(owner & ~1);
5800         LDKDecodeError ret_var = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(owner_conv);
5801         uint32_t ret_ref = 0;
5802         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5803         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5804         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5805         ret_ref = (uintptr_t)ret_var.inner;
5806         if (ret_var.is_owned) {
5807                 ret_ref |= 1;
5808         }
5809         return ret_ref;
5810 }
5811
5812 static inline struct LDKChannelConfig CResult_ChannelConfigDecodeErrorZ_get_ok(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
5813 CHECK(owner->result_ok);
5814         return ChannelConfig_clone(&*owner->contents.result);
5815 }
5816 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_get_ok"))) TS_CResult_ChannelConfigDecodeErrorZ_get_ok(uint32_t owner) {
5817         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(owner & ~1);
5818         LDKChannelConfig ret_var = CResult_ChannelConfigDecodeErrorZ_get_ok(owner_conv);
5819         uint32_t ret_ref = 0;
5820         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5821         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5822         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5823         ret_ref = (uintptr_t)ret_var.inner;
5824         if (ret_var.is_owned) {
5825                 ret_ref |= 1;
5826         }
5827         return ret_ref;
5828 }
5829
5830 static inline struct LDKDecodeError CResult_ChannelConfigDecodeErrorZ_get_err(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
5831 CHECK(!owner->result_ok);
5832         return DecodeError_clone(&*owner->contents.err);
5833 }
5834 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_get_err"))) TS_CResult_ChannelConfigDecodeErrorZ_get_err(uint32_t owner) {
5835         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(owner & ~1);
5836         LDKDecodeError ret_var = CResult_ChannelConfigDecodeErrorZ_get_err(owner_conv);
5837         uint32_t ret_ref = 0;
5838         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5839         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5840         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5841         ret_ref = (uintptr_t)ret_var.inner;
5842         if (ret_var.is_owned) {
5843                 ret_ref |= 1;
5844         }
5845         return ret_ref;
5846 }
5847
5848 static inline struct LDKOutPoint CResult_OutPointDecodeErrorZ_get_ok(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
5849 CHECK(owner->result_ok);
5850         return OutPoint_clone(&*owner->contents.result);
5851 }
5852 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_get_ok"))) TS_CResult_OutPointDecodeErrorZ_get_ok(uint32_t owner) {
5853         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)(owner & ~1);
5854         LDKOutPoint ret_var = CResult_OutPointDecodeErrorZ_get_ok(owner_conv);
5855         uint32_t ret_ref = 0;
5856         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5857         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5858         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5859         ret_ref = (uintptr_t)ret_var.inner;
5860         if (ret_var.is_owned) {
5861                 ret_ref |= 1;
5862         }
5863         return ret_ref;
5864 }
5865
5866 static inline struct LDKDecodeError CResult_OutPointDecodeErrorZ_get_err(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
5867 CHECK(!owner->result_ok);
5868         return DecodeError_clone(&*owner->contents.err);
5869 }
5870 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_get_err"))) TS_CResult_OutPointDecodeErrorZ_get_err(uint32_t owner) {
5871         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)(owner & ~1);
5872         LDKDecodeError ret_var = CResult_OutPointDecodeErrorZ_get_err(owner_conv);
5873         uint32_t ret_ref = 0;
5874         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5875         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5876         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5877         ret_ref = (uintptr_t)ret_var.inner;
5878         if (ret_var.is_owned) {
5879                 ret_ref |= 1;
5880         }
5881         return ret_ref;
5882 }
5883
5884 typedef struct LDKType_JCalls {
5885         atomic_size_t refcnt;
5886         uint32_t instance_ptr;
5887 } LDKType_JCalls;
5888 static void LDKType_JCalls_free(void* this_arg) {
5889         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
5890         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5891                 FREE(j_calls);
5892         }
5893 }
5894 uint16_t type_id_LDKType_jcall(const void* this_arg) {
5895         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
5896         return js_invoke_function_uuuuuu(j_calls->instance_ptr, 29, 0, 0, 0, 0, 0, 0);
5897 }
5898 LDKStr debug_str_LDKType_jcall(const void* this_arg) {
5899         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
5900         jstring ret = (jstring)js_invoke_function_uuuuuu(j_calls->instance_ptr, 30, 0, 0, 0, 0, 0, 0);
5901         LDKStr ret_conv = str_ref_to_owned_c(ret);
5902         return ret_conv;
5903 }
5904 LDKCVec_u8Z write_LDKType_jcall(const void* this_arg) {
5905         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
5906         int8_tArray ret = (int8_tArray)js_invoke_function_uuuuuu(j_calls->instance_ptr, 31, 0, 0, 0, 0, 0, 0);
5907         LDKCVec_u8Z ret_ref;
5908         ret_ref.datalen = ret->arr_len;
5909         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
5910         memcpy(ret_ref.data, ret->elems, ret_ref.datalen); FREE(ret);
5911         return ret_ref;
5912 }
5913 static void LDKType_JCalls_cloned(LDKType* new_obj) {
5914         LDKType_JCalls *j_calls = (LDKType_JCalls*) new_obj->this_arg;
5915         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5916 }
5917 static inline LDKType LDKType_init (JSValue o) {
5918         LDKType_JCalls *calls = MALLOC(sizeof(LDKType_JCalls), "LDKType_JCalls");
5919         atomic_init(&calls->refcnt, 1);
5920         calls->instance_ptr = o;
5921
5922         LDKType ret = {
5923                 .this_arg = (void*) calls,
5924                 .type_id = type_id_LDKType_jcall,
5925                 .debug_str = debug_str_LDKType_jcall,
5926                 .write = write_LDKType_jcall,
5927                 .cloned = LDKType_JCalls_cloned,
5928                 .free = LDKType_JCalls_free,
5929         };
5930         return ret;
5931 }
5932 long  __attribute__((export_name("TS_LDKType_new"))) TS_LDKType_new(JSValue o) {
5933         LDKType *res_ptr = MALLOC(sizeof(LDKType), "LDKType");
5934         *res_ptr = LDKType_init(o);
5935         return (long)res_ptr;
5936 }
5937 int16_t  __attribute__((export_name("TS_Type_type_id"))) TS_Type_type_id(uint32_t this_arg) {
5938         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5939         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5940         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
5941         int16_t ret_conv = (this_arg_conv->type_id)(this_arg_conv->this_arg);
5942         return ret_conv;
5943 }
5944
5945 jstring  __attribute__((export_name("TS_Type_debug_str"))) TS_Type_debug_str(uint32_t this_arg) {
5946         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5947         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5948         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
5949         LDKStr ret_str = (this_arg_conv->debug_str)(this_arg_conv->this_arg);
5950         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
5951         Str_free(ret_str);
5952         return ret_conv;
5953 }
5954
5955 int8_tArray  __attribute__((export_name("TS_Type_write"))) TS_Type_write(uint32_t this_arg) {
5956         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5957         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5958         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
5959         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
5960         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
5961         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
5962         CVec_u8Z_free(ret_var);
5963         return ret_arr;
5964 }
5965
5966 uint32_t __attribute__((export_name("TS_LDKCOption_TypeZ_ty_from_ptr"))) TS_LDKCOption_TypeZ_ty_from_ptr(uint32_t ptr) {
5967         LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)(ptr & ~1);
5968         switch(obj->tag) {
5969                 case LDKCOption_TypeZ_Some: return 0;
5970                 case LDKCOption_TypeZ_None: return 1;
5971                 default: abort();
5972         }
5973 }
5974 uint32_t __attribute__((export_name("TS_LDKCOption_TypeZ_Some_get_some"))) TS_LDKCOption_TypeZ_Some_get_some(uint32_t ptr) {
5975         LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)(ptr & ~1);
5976         assert(obj->tag == LDKCOption_TypeZ_Some);
5977                         LDKType* some_ret = MALLOC(sizeof(LDKType), "LDKType");
5978                         *some_ret = Type_clone(&obj->some);
5979         return (uint32_t)some_ret;
5980 }
5981 static inline struct LDKCOption_TypeZ CResult_COption_TypeZDecodeErrorZ_get_ok(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
5982 CHECK(owner->result_ok);
5983         return COption_TypeZ_clone(&*owner->contents.result);
5984 }
5985 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_get_ok"))) TS_CResult_COption_TypeZDecodeErrorZ_get_ok(uint32_t owner) {
5986         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(owner & ~1);
5987         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
5988         *ret_copy = CResult_COption_TypeZDecodeErrorZ_get_ok(owner_conv);
5989         uint32_t ret_ref = (uintptr_t)ret_copy;
5990         return ret_ref;
5991 }
5992
5993 static inline struct LDKDecodeError CResult_COption_TypeZDecodeErrorZ_get_err(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
5994 CHECK(!owner->result_ok);
5995         return DecodeError_clone(&*owner->contents.err);
5996 }
5997 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_get_err"))) TS_CResult_COption_TypeZDecodeErrorZ_get_err(uint32_t owner) {
5998         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(owner & ~1);
5999         LDKDecodeError ret_var = CResult_COption_TypeZDecodeErrorZ_get_err(owner_conv);
6000         uint32_t ret_ref = 0;
6001         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6002         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6003         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6004         ret_ref = (uintptr_t)ret_var.inner;
6005         if (ret_var.is_owned) {
6006                 ret_ref |= 1;
6007         }
6008         return ret_ref;
6009 }
6010
6011 uint32_t __attribute__((export_name("TS_LDKPaymentError_ty_from_ptr"))) TS_LDKPaymentError_ty_from_ptr(uint32_t ptr) {
6012         LDKPaymentError *obj = (LDKPaymentError*)(ptr & ~1);
6013         switch(obj->tag) {
6014                 case LDKPaymentError_Invoice: return 0;
6015                 case LDKPaymentError_Routing: return 1;
6016                 case LDKPaymentError_Sending: return 2;
6017                 default: abort();
6018         }
6019 }
6020 jstring __attribute__((export_name("TS_LDKPaymentError_Invoice_get_invoice"))) TS_LDKPaymentError_Invoice_get_invoice(uint32_t ptr) {
6021         LDKPaymentError *obj = (LDKPaymentError*)(ptr & ~1);
6022         assert(obj->tag == LDKPaymentError_Invoice);
6023                         LDKStr invoice_str = obj->invoice;
6024                         jstring invoice_conv = str_ref_to_ts(invoice_str.chars, invoice_str.len);
6025         return invoice_conv;
6026 }
6027 uint32_t __attribute__((export_name("TS_LDKPaymentError_Routing_get_routing"))) TS_LDKPaymentError_Routing_get_routing(uint32_t ptr) {
6028         LDKPaymentError *obj = (LDKPaymentError*)(ptr & ~1);
6029         assert(obj->tag == LDKPaymentError_Routing);
6030                         LDKLightningError routing_var = obj->routing;
6031                         uint32_t routing_ref = 0;
6032                         CHECK((((uintptr_t)routing_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6033                         CHECK((((uintptr_t)&routing_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6034                         CHECK_INNER_FIELD_ACCESS_OR_NULL(routing_var);
6035                         routing_ref = (uintptr_t)routing_var.inner & ~1;
6036         return routing_ref;
6037 }
6038 uint32_t __attribute__((export_name("TS_LDKPaymentError_Sending_get_sending"))) TS_LDKPaymentError_Sending_get_sending(uint32_t ptr) {
6039         LDKPaymentError *obj = (LDKPaymentError*)(ptr & ~1);
6040         assert(obj->tag == LDKPaymentError_Sending);
6041                         uint32_t sending_ref = ((uintptr_t)&obj->sending) | 1;
6042         return sending_ref;
6043 }
6044 static inline struct LDKThirtyTwoBytes CResult_PaymentIdPaymentErrorZ_get_ok(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR owner){
6045 CHECK(owner->result_ok);
6046         return ThirtyTwoBytes_clone(&*owner->contents.result);
6047 }
6048 int8_tArray  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_get_ok"))) TS_CResult_PaymentIdPaymentErrorZ_get_ok(uint32_t owner) {
6049         LDKCResult_PaymentIdPaymentErrorZ* owner_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(owner & ~1);
6050         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
6051         memcpy(ret_arr->elems, CResult_PaymentIdPaymentErrorZ_get_ok(owner_conv).data, 32);
6052         return ret_arr;
6053 }
6054
6055 static inline struct LDKPaymentError CResult_PaymentIdPaymentErrorZ_get_err(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR owner){
6056 CHECK(!owner->result_ok);
6057         return PaymentError_clone(&*owner->contents.err);
6058 }
6059 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_get_err"))) TS_CResult_PaymentIdPaymentErrorZ_get_err(uint32_t owner) {
6060         LDKCResult_PaymentIdPaymentErrorZ* owner_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(owner & ~1);
6061         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
6062         *ret_copy = CResult_PaymentIdPaymentErrorZ_get_err(owner_conv);
6063         uint32_t ret_ref = (uintptr_t)ret_copy;
6064         return ret_ref;
6065 }
6066
6067 uint32_t __attribute__((export_name("TS_LDKParseError_ty_from_ptr"))) TS_LDKParseError_ty_from_ptr(uint32_t ptr) {
6068         LDKParseError *obj = (LDKParseError*)(ptr & ~1);
6069         switch(obj->tag) {
6070                 case LDKParseError_Bech32Error: return 0;
6071                 case LDKParseError_ParseAmountError: return 1;
6072                 case LDKParseError_MalformedSignature: return 2;
6073                 case LDKParseError_BadPrefix: return 3;
6074                 case LDKParseError_UnknownCurrency: return 4;
6075                 case LDKParseError_UnknownSiPrefix: return 5;
6076                 case LDKParseError_MalformedHRP: return 6;
6077                 case LDKParseError_TooShortDataPart: return 7;
6078                 case LDKParseError_UnexpectedEndOfTaggedFields: return 8;
6079                 case LDKParseError_DescriptionDecodeError: return 9;
6080                 case LDKParseError_PaddingError: return 10;
6081                 case LDKParseError_IntegerOverflowError: return 11;
6082                 case LDKParseError_InvalidSegWitProgramLength: return 12;
6083                 case LDKParseError_InvalidPubKeyHashLength: return 13;
6084                 case LDKParseError_InvalidScriptHashLength: return 14;
6085                 case LDKParseError_InvalidRecoveryId: return 15;
6086                 case LDKParseError_InvalidSliceLength: return 16;
6087                 case LDKParseError_Skip: return 17;
6088                 default: abort();
6089         }
6090 }
6091 uint32_t __attribute__((export_name("TS_LDKParseError_Bech32Error_get_bech32_error"))) TS_LDKParseError_Bech32Error_get_bech32_error(uint32_t ptr) {
6092         LDKParseError *obj = (LDKParseError*)(ptr & ~1);
6093         assert(obj->tag == LDKParseError_Bech32Error);
6094                         uint32_t bech32_error_ref = ((uintptr_t)&obj->bech32_error) | 1;
6095         return bech32_error_ref;
6096 }
6097 int32_t __attribute__((export_name("TS_LDKParseError_ParseAmountError_get_parse_amount_error"))) TS_LDKParseError_ParseAmountError_get_parse_amount_error(uint32_t ptr) {
6098         LDKParseError *obj = (LDKParseError*)(ptr & ~1);
6099         assert(obj->tag == LDKParseError_ParseAmountError);
6100                         /*obj->parse_amount_error*/
6101         return 0;
6102 }
6103 uint32_t __attribute__((export_name("TS_LDKParseError_MalformedSignature_get_malformed_signature"))) TS_LDKParseError_MalformedSignature_get_malformed_signature(uint32_t ptr) {
6104         LDKParseError *obj = (LDKParseError*)(ptr & ~1);
6105         assert(obj->tag == LDKParseError_MalformedSignature);
6106                         uint32_t malformed_signature_conv = LDKSecp256k1Error_to_js(obj->malformed_signature);
6107         return malformed_signature_conv;
6108 }
6109 int32_t __attribute__((export_name("TS_LDKParseError_DescriptionDecodeError_get_description_decode_error"))) TS_LDKParseError_DescriptionDecodeError_get_description_decode_error(uint32_t ptr) {
6110         LDKParseError *obj = (LDKParseError*)(ptr & ~1);
6111         assert(obj->tag == LDKParseError_DescriptionDecodeError);
6112                         /*obj->description_decode_error*/
6113         return 0;
6114 }
6115 jstring __attribute__((export_name("TS_LDKParseError_InvalidSliceLength_get_invalid_slice_length"))) TS_LDKParseError_InvalidSliceLength_get_invalid_slice_length(uint32_t ptr) {
6116         LDKParseError *obj = (LDKParseError*)(ptr & ~1);
6117         assert(obj->tag == LDKParseError_InvalidSliceLength);
6118                         LDKStr invalid_slice_length_str = obj->invalid_slice_length;
6119                         jstring invalid_slice_length_conv = str_ref_to_ts(invalid_slice_length_str.chars, invalid_slice_length_str.len);
6120         return invalid_slice_length_conv;
6121 }
6122 static inline enum LDKSiPrefix CResult_SiPrefixParseErrorZ_get_ok(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR owner){
6123 CHECK(owner->result_ok);
6124         return SiPrefix_clone(&*owner->contents.result);
6125 }
6126 uint32_t  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_get_ok"))) TS_CResult_SiPrefixParseErrorZ_get_ok(uint32_t owner) {
6127         LDKCResult_SiPrefixParseErrorZ* owner_conv = (LDKCResult_SiPrefixParseErrorZ*)(owner & ~1);
6128         uint32_t ret_conv = LDKSiPrefix_to_js(CResult_SiPrefixParseErrorZ_get_ok(owner_conv));
6129         return ret_conv;
6130 }
6131
6132 static inline struct LDKParseError CResult_SiPrefixParseErrorZ_get_err(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR owner){
6133 CHECK(!owner->result_ok);
6134         return ParseError_clone(&*owner->contents.err);
6135 }
6136 uint32_t  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_get_err"))) TS_CResult_SiPrefixParseErrorZ_get_err(uint32_t owner) {
6137         LDKCResult_SiPrefixParseErrorZ* owner_conv = (LDKCResult_SiPrefixParseErrorZ*)(owner & ~1);
6138         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
6139         *ret_copy = CResult_SiPrefixParseErrorZ_get_err(owner_conv);
6140         uint32_t ret_ref = (uintptr_t)ret_copy;
6141         return ret_ref;
6142 }
6143
6144 uint32_t __attribute__((export_name("TS_LDKParseOrSemanticError_ty_from_ptr"))) TS_LDKParseOrSemanticError_ty_from_ptr(uint32_t ptr) {
6145         LDKParseOrSemanticError *obj = (LDKParseOrSemanticError*)(ptr & ~1);
6146         switch(obj->tag) {
6147                 case LDKParseOrSemanticError_ParseError: return 0;
6148                 case LDKParseOrSemanticError_SemanticError: return 1;
6149                 default: abort();
6150         }
6151 }
6152 uint32_t __attribute__((export_name("TS_LDKParseOrSemanticError_ParseError_get_parse_error"))) TS_LDKParseOrSemanticError_ParseError_get_parse_error(uint32_t ptr) {
6153         LDKParseOrSemanticError *obj = (LDKParseOrSemanticError*)(ptr & ~1);
6154         assert(obj->tag == LDKParseOrSemanticError_ParseError);
6155                         uint32_t parse_error_ref = ((uintptr_t)&obj->parse_error) | 1;
6156         return parse_error_ref;
6157 }
6158 uint32_t __attribute__((export_name("TS_LDKParseOrSemanticError_SemanticError_get_semantic_error"))) TS_LDKParseOrSemanticError_SemanticError_get_semantic_error(uint32_t ptr) {
6159         LDKParseOrSemanticError *obj = (LDKParseOrSemanticError*)(ptr & ~1);
6160         assert(obj->tag == LDKParseOrSemanticError_SemanticError);
6161                         uint32_t semantic_error_conv = LDKSemanticError_to_js(obj->semantic_error);
6162         return semantic_error_conv;
6163 }
6164 static inline struct LDKInvoice CResult_InvoiceParseOrSemanticErrorZ_get_ok(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR owner){
6165 CHECK(owner->result_ok);
6166         return Invoice_clone(&*owner->contents.result);
6167 }
6168 uint32_t  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_get_ok"))) TS_CResult_InvoiceParseOrSemanticErrorZ_get_ok(uint32_t owner) {
6169         LDKCResult_InvoiceParseOrSemanticErrorZ* owner_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(owner & ~1);
6170         LDKInvoice ret_var = CResult_InvoiceParseOrSemanticErrorZ_get_ok(owner_conv);
6171         uint32_t ret_ref = 0;
6172         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6173         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6174         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6175         ret_ref = (uintptr_t)ret_var.inner;
6176         if (ret_var.is_owned) {
6177                 ret_ref |= 1;
6178         }
6179         return ret_ref;
6180 }
6181
6182 static inline struct LDKParseOrSemanticError CResult_InvoiceParseOrSemanticErrorZ_get_err(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR owner){
6183 CHECK(!owner->result_ok);
6184         return ParseOrSemanticError_clone(&*owner->contents.err);
6185 }
6186 uint32_t  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_get_err"))) TS_CResult_InvoiceParseOrSemanticErrorZ_get_err(uint32_t owner) {
6187         LDKCResult_InvoiceParseOrSemanticErrorZ* owner_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(owner & ~1);
6188         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
6189         *ret_copy = CResult_InvoiceParseOrSemanticErrorZ_get_err(owner_conv);
6190         uint32_t ret_ref = (uintptr_t)ret_copy;
6191         return ret_ref;
6192 }
6193
6194 static inline struct LDKSignedRawInvoice CResult_SignedRawInvoiceParseErrorZ_get_ok(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR owner){
6195 CHECK(owner->result_ok);
6196         return SignedRawInvoice_clone(&*owner->contents.result);
6197 }
6198 uint32_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_get_ok"))) TS_CResult_SignedRawInvoiceParseErrorZ_get_ok(uint32_t owner) {
6199         LDKCResult_SignedRawInvoiceParseErrorZ* owner_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(owner & ~1);
6200         LDKSignedRawInvoice ret_var = CResult_SignedRawInvoiceParseErrorZ_get_ok(owner_conv);
6201         uint32_t ret_ref = 0;
6202         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6203         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6204         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6205         ret_ref = (uintptr_t)ret_var.inner;
6206         if (ret_var.is_owned) {
6207                 ret_ref |= 1;
6208         }
6209         return ret_ref;
6210 }
6211
6212 static inline struct LDKParseError CResult_SignedRawInvoiceParseErrorZ_get_err(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR owner){
6213 CHECK(!owner->result_ok);
6214         return ParseError_clone(&*owner->contents.err);
6215 }
6216 uint32_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_get_err"))) TS_CResult_SignedRawInvoiceParseErrorZ_get_err(uint32_t owner) {
6217         LDKCResult_SignedRawInvoiceParseErrorZ* owner_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(owner & ~1);
6218         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
6219         *ret_copy = CResult_SignedRawInvoiceParseErrorZ_get_err(owner_conv);
6220         uint32_t ret_ref = (uintptr_t)ret_copy;
6221         return ret_ref;
6222 }
6223
6224 static inline struct LDKRawInvoice C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
6225         return RawInvoice_clone(&owner->a);
6226 }
6227 uint32_t  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(uint32_t owner) {
6228         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
6229         LDKRawInvoice ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(owner_conv);
6230         uint32_t ret_ref = 0;
6231         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6232         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6233         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6234         ret_ref = (uintptr_t)ret_var.inner;
6235         if (ret_var.is_owned) {
6236                 ret_ref |= 1;
6237         }
6238         return ret_ref;
6239 }
6240
6241 static inline struct LDKThirtyTwoBytes C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
6242         return ThirtyTwoBytes_clone(&owner->b);
6243 }
6244 int8_tArray  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(uint32_t owner) {
6245         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
6246         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
6247         memcpy(ret_arr->elems, C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(owner_conv).data, 32);
6248         return ret_arr;
6249 }
6250
6251 static inline struct LDKInvoiceSignature C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
6252         return InvoiceSignature_clone(&owner->c);
6253 }
6254 uint32_t  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(uint32_t owner) {
6255         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
6256         LDKInvoiceSignature ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(owner_conv);
6257         uint32_t ret_ref = 0;
6258         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6259         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6260         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6261         ret_ref = (uintptr_t)ret_var.inner;
6262         if (ret_var.is_owned) {
6263                 ret_ref |= 1;
6264         }
6265         return ret_ref;
6266 }
6267
6268 static inline struct LDKPayeePubKey CResult_PayeePubKeyErrorZ_get_ok(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR owner){
6269 CHECK(owner->result_ok);
6270         return PayeePubKey_clone(&*owner->contents.result);
6271 }
6272 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_get_ok"))) TS_CResult_PayeePubKeyErrorZ_get_ok(uint32_t owner) {
6273         LDKCResult_PayeePubKeyErrorZ* owner_conv = (LDKCResult_PayeePubKeyErrorZ*)(owner & ~1);
6274         LDKPayeePubKey ret_var = CResult_PayeePubKeyErrorZ_get_ok(owner_conv);
6275         uint32_t ret_ref = 0;
6276         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6277         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6278         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6279         ret_ref = (uintptr_t)ret_var.inner;
6280         if (ret_var.is_owned) {
6281                 ret_ref |= 1;
6282         }
6283         return ret_ref;
6284 }
6285
6286 static inline enum LDKSecp256k1Error CResult_PayeePubKeyErrorZ_get_err(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR owner){
6287 CHECK(!owner->result_ok);
6288         return *owner->contents.err;
6289 }
6290 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_get_err"))) TS_CResult_PayeePubKeyErrorZ_get_err(uint32_t owner) {
6291         LDKCResult_PayeePubKeyErrorZ* owner_conv = (LDKCResult_PayeePubKeyErrorZ*)(owner & ~1);
6292         uint32_t ret_conv = LDKSecp256k1Error_to_js(CResult_PayeePubKeyErrorZ_get_err(owner_conv));
6293         return ret_conv;
6294 }
6295
6296 static inline LDKCVec_PrivateRouteZ CVec_PrivateRouteZ_clone(const LDKCVec_PrivateRouteZ *orig) {
6297         LDKCVec_PrivateRouteZ ret = { .data = MALLOC(sizeof(LDKPrivateRoute) * orig->datalen, "LDKCVec_PrivateRouteZ clone bytes"), .datalen = orig->datalen };
6298         for (size_t i = 0; i < ret.datalen; i++) {
6299                 ret.data[i] = PrivateRoute_clone(&orig->data[i]);
6300         }
6301         return ret;
6302 }
6303 static inline struct LDKPositiveTimestamp CResult_PositiveTimestampCreationErrorZ_get_ok(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR owner){
6304 CHECK(owner->result_ok);
6305         return PositiveTimestamp_clone(&*owner->contents.result);
6306 }
6307 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_get_ok"))) TS_CResult_PositiveTimestampCreationErrorZ_get_ok(uint32_t owner) {
6308         LDKCResult_PositiveTimestampCreationErrorZ* owner_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(owner & ~1);
6309         LDKPositiveTimestamp ret_var = CResult_PositiveTimestampCreationErrorZ_get_ok(owner_conv);
6310         uint32_t ret_ref = 0;
6311         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6312         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6313         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6314         ret_ref = (uintptr_t)ret_var.inner;
6315         if (ret_var.is_owned) {
6316                 ret_ref |= 1;
6317         }
6318         return ret_ref;
6319 }
6320
6321 static inline enum LDKCreationError CResult_PositiveTimestampCreationErrorZ_get_err(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR owner){
6322 CHECK(!owner->result_ok);
6323         return CreationError_clone(&*owner->contents.err);
6324 }
6325 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_get_err"))) TS_CResult_PositiveTimestampCreationErrorZ_get_err(uint32_t owner) {
6326         LDKCResult_PositiveTimestampCreationErrorZ* owner_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(owner & ~1);
6327         uint32_t ret_conv = LDKCreationError_to_js(CResult_PositiveTimestampCreationErrorZ_get_err(owner_conv));
6328         return ret_conv;
6329 }
6330
6331 static inline void CResult_NoneSemanticErrorZ_get_ok(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR owner){
6332 CHECK(owner->result_ok);
6333         return *owner->contents.result;
6334 }
6335 void  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_get_ok"))) TS_CResult_NoneSemanticErrorZ_get_ok(uint32_t owner) {
6336         LDKCResult_NoneSemanticErrorZ* owner_conv = (LDKCResult_NoneSemanticErrorZ*)(owner & ~1);
6337         CResult_NoneSemanticErrorZ_get_ok(owner_conv);
6338 }
6339
6340 static inline enum LDKSemanticError CResult_NoneSemanticErrorZ_get_err(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR owner){
6341 CHECK(!owner->result_ok);
6342         return SemanticError_clone(&*owner->contents.err);
6343 }
6344 uint32_t  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_get_err"))) TS_CResult_NoneSemanticErrorZ_get_err(uint32_t owner) {
6345         LDKCResult_NoneSemanticErrorZ* owner_conv = (LDKCResult_NoneSemanticErrorZ*)(owner & ~1);
6346         uint32_t ret_conv = LDKSemanticError_to_js(CResult_NoneSemanticErrorZ_get_err(owner_conv));
6347         return ret_conv;
6348 }
6349
6350 static inline struct LDKInvoice CResult_InvoiceSemanticErrorZ_get_ok(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR owner){
6351 CHECK(owner->result_ok);
6352         return Invoice_clone(&*owner->contents.result);
6353 }
6354 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_get_ok"))) TS_CResult_InvoiceSemanticErrorZ_get_ok(uint32_t owner) {
6355         LDKCResult_InvoiceSemanticErrorZ* owner_conv = (LDKCResult_InvoiceSemanticErrorZ*)(owner & ~1);
6356         LDKInvoice ret_var = CResult_InvoiceSemanticErrorZ_get_ok(owner_conv);
6357         uint32_t ret_ref = 0;
6358         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6359         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6360         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6361         ret_ref = (uintptr_t)ret_var.inner;
6362         if (ret_var.is_owned) {
6363                 ret_ref |= 1;
6364         }
6365         return ret_ref;
6366 }
6367
6368 static inline enum LDKSemanticError CResult_InvoiceSemanticErrorZ_get_err(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR owner){
6369 CHECK(!owner->result_ok);
6370         return SemanticError_clone(&*owner->contents.err);
6371 }
6372 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_get_err"))) TS_CResult_InvoiceSemanticErrorZ_get_err(uint32_t owner) {
6373         LDKCResult_InvoiceSemanticErrorZ* owner_conv = (LDKCResult_InvoiceSemanticErrorZ*)(owner & ~1);
6374         uint32_t ret_conv = LDKSemanticError_to_js(CResult_InvoiceSemanticErrorZ_get_err(owner_conv));
6375         return ret_conv;
6376 }
6377
6378 static inline struct LDKDescription CResult_DescriptionCreationErrorZ_get_ok(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR owner){
6379 CHECK(owner->result_ok);
6380         return Description_clone(&*owner->contents.result);
6381 }
6382 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_get_ok"))) TS_CResult_DescriptionCreationErrorZ_get_ok(uint32_t owner) {
6383         LDKCResult_DescriptionCreationErrorZ* owner_conv = (LDKCResult_DescriptionCreationErrorZ*)(owner & ~1);
6384         LDKDescription ret_var = CResult_DescriptionCreationErrorZ_get_ok(owner_conv);
6385         uint32_t ret_ref = 0;
6386         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6387         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6388         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6389         ret_ref = (uintptr_t)ret_var.inner;
6390         if (ret_var.is_owned) {
6391                 ret_ref |= 1;
6392         }
6393         return ret_ref;
6394 }
6395
6396 static inline enum LDKCreationError CResult_DescriptionCreationErrorZ_get_err(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR owner){
6397 CHECK(!owner->result_ok);
6398         return CreationError_clone(&*owner->contents.err);
6399 }
6400 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_get_err"))) TS_CResult_DescriptionCreationErrorZ_get_err(uint32_t owner) {
6401         LDKCResult_DescriptionCreationErrorZ* owner_conv = (LDKCResult_DescriptionCreationErrorZ*)(owner & ~1);
6402         uint32_t ret_conv = LDKCreationError_to_js(CResult_DescriptionCreationErrorZ_get_err(owner_conv));
6403         return ret_conv;
6404 }
6405
6406 static inline struct LDKPrivateRoute CResult_PrivateRouteCreationErrorZ_get_ok(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR owner){
6407 CHECK(owner->result_ok);
6408         return PrivateRoute_clone(&*owner->contents.result);
6409 }
6410 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_get_ok"))) TS_CResult_PrivateRouteCreationErrorZ_get_ok(uint32_t owner) {
6411         LDKCResult_PrivateRouteCreationErrorZ* owner_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(owner & ~1);
6412         LDKPrivateRoute ret_var = CResult_PrivateRouteCreationErrorZ_get_ok(owner_conv);
6413         uint32_t ret_ref = 0;
6414         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6415         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6416         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6417         ret_ref = (uintptr_t)ret_var.inner;
6418         if (ret_var.is_owned) {
6419                 ret_ref |= 1;
6420         }
6421         return ret_ref;
6422 }
6423
6424 static inline enum LDKCreationError CResult_PrivateRouteCreationErrorZ_get_err(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR owner){
6425 CHECK(!owner->result_ok);
6426         return CreationError_clone(&*owner->contents.err);
6427 }
6428 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_get_err"))) TS_CResult_PrivateRouteCreationErrorZ_get_err(uint32_t owner) {
6429         LDKCResult_PrivateRouteCreationErrorZ* owner_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(owner & ~1);
6430         uint32_t ret_conv = LDKCreationError_to_js(CResult_PrivateRouteCreationErrorZ_get_err(owner_conv));
6431         return ret_conv;
6432 }
6433
6434 static inline struct LDKStr CResult_StringErrorZ_get_ok(LDKCResult_StringErrorZ *NONNULL_PTR owner){
6435 CHECK(owner->result_ok);
6436         return *owner->contents.result;
6437 }
6438 jstring  __attribute__((export_name("TS_CResult_StringErrorZ_get_ok"))) TS_CResult_StringErrorZ_get_ok(uint32_t owner) {
6439         LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)(owner & ~1);
6440         LDKStr ret_str = CResult_StringErrorZ_get_ok(owner_conv);
6441         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
6442         return ret_conv;
6443 }
6444
6445 static inline enum LDKSecp256k1Error CResult_StringErrorZ_get_err(LDKCResult_StringErrorZ *NONNULL_PTR owner){
6446 CHECK(!owner->result_ok);
6447         return *owner->contents.err;
6448 }
6449 uint32_t  __attribute__((export_name("TS_CResult_StringErrorZ_get_err"))) TS_CResult_StringErrorZ_get_err(uint32_t owner) {
6450         LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)(owner & ~1);
6451         uint32_t ret_conv = LDKSecp256k1Error_to_js(CResult_StringErrorZ_get_err(owner_conv));
6452         return ret_conv;
6453 }
6454
6455 static inline struct LDKChannelMonitorUpdate CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
6456 CHECK(owner->result_ok);
6457         return ChannelMonitorUpdate_clone(&*owner->contents.result);
6458 }
6459 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(uint32_t owner) {
6460         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(owner & ~1);
6461         LDKChannelMonitorUpdate ret_var = CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(owner_conv);
6462         uint32_t ret_ref = 0;
6463         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6464         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6465         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6466         ret_ref = (uintptr_t)ret_var.inner;
6467         if (ret_var.is_owned) {
6468                 ret_ref |= 1;
6469         }
6470         return ret_ref;
6471 }
6472
6473 static inline struct LDKDecodeError CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
6474 CHECK(!owner->result_ok);
6475         return DecodeError_clone(&*owner->contents.err);
6476 }
6477 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_get_err"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(uint32_t owner) {
6478         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(owner & ~1);
6479         LDKDecodeError ret_var = CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(owner_conv);
6480         uint32_t ret_ref = 0;
6481         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6482         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6483         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6484         ret_ref = (uintptr_t)ret_var.inner;
6485         if (ret_var.is_owned) {
6486                 ret_ref |= 1;
6487         }
6488         return ret_ref;
6489 }
6490
6491 uint32_t __attribute__((export_name("TS_LDKCOption_MonitorEventZ_ty_from_ptr"))) TS_LDKCOption_MonitorEventZ_ty_from_ptr(uint32_t ptr) {
6492         LDKCOption_MonitorEventZ *obj = (LDKCOption_MonitorEventZ*)(ptr & ~1);
6493         switch(obj->tag) {
6494                 case LDKCOption_MonitorEventZ_Some: return 0;
6495                 case LDKCOption_MonitorEventZ_None: return 1;
6496                 default: abort();
6497         }
6498 }
6499 uint32_t __attribute__((export_name("TS_LDKCOption_MonitorEventZ_Some_get_some"))) TS_LDKCOption_MonitorEventZ_Some_get_some(uint32_t ptr) {
6500         LDKCOption_MonitorEventZ *obj = (LDKCOption_MonitorEventZ*)(ptr & ~1);
6501         assert(obj->tag == LDKCOption_MonitorEventZ_Some);
6502                         uint32_t some_ref = ((uintptr_t)&obj->some) | 1;
6503         return some_ref;
6504 }
6505 static inline struct LDKCOption_MonitorEventZ CResult_COption_MonitorEventZDecodeErrorZ_get_ok(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
6506 CHECK(owner->result_ok);
6507         return COption_MonitorEventZ_clone(&*owner->contents.result);
6508 }
6509 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_get_ok"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_get_ok(uint32_t owner) {
6510         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(owner & ~1);
6511         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
6512         *ret_copy = CResult_COption_MonitorEventZDecodeErrorZ_get_ok(owner_conv);
6513         uint32_t ret_ref = (uintptr_t)ret_copy;
6514         return ret_ref;
6515 }
6516
6517 static inline struct LDKDecodeError CResult_COption_MonitorEventZDecodeErrorZ_get_err(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
6518 CHECK(!owner->result_ok);
6519         return DecodeError_clone(&*owner->contents.err);
6520 }
6521 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_get_err"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_get_err(uint32_t owner) {
6522         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(owner & ~1);
6523         LDKDecodeError ret_var = CResult_COption_MonitorEventZDecodeErrorZ_get_err(owner_conv);
6524         uint32_t ret_ref = 0;
6525         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6526         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6527         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6528         ret_ref = (uintptr_t)ret_var.inner;
6529         if (ret_var.is_owned) {
6530                 ret_ref |= 1;
6531         }
6532         return ret_ref;
6533 }
6534
6535 static inline struct LDKHTLCUpdate CResult_HTLCUpdateDecodeErrorZ_get_ok(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
6536 CHECK(owner->result_ok);
6537         return HTLCUpdate_clone(&*owner->contents.result);
6538 }
6539 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_get_ok"))) TS_CResult_HTLCUpdateDecodeErrorZ_get_ok(uint32_t owner) {
6540         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(owner & ~1);
6541         LDKHTLCUpdate ret_var = CResult_HTLCUpdateDecodeErrorZ_get_ok(owner_conv);
6542         uint32_t ret_ref = 0;
6543         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6544         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6545         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6546         ret_ref = (uintptr_t)ret_var.inner;
6547         if (ret_var.is_owned) {
6548                 ret_ref |= 1;
6549         }
6550         return ret_ref;
6551 }
6552
6553 static inline struct LDKDecodeError CResult_HTLCUpdateDecodeErrorZ_get_err(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
6554 CHECK(!owner->result_ok);
6555         return DecodeError_clone(&*owner->contents.err);
6556 }
6557 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_get_err"))) TS_CResult_HTLCUpdateDecodeErrorZ_get_err(uint32_t owner) {
6558         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(owner & ~1);
6559         LDKDecodeError ret_var = CResult_HTLCUpdateDecodeErrorZ_get_err(owner_conv);
6560         uint32_t ret_ref = 0;
6561         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6562         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6563         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6564         ret_ref = (uintptr_t)ret_var.inner;
6565         if (ret_var.is_owned) {
6566                 ret_ref |= 1;
6567         }
6568         return ret_ref;
6569 }
6570
6571 static inline struct LDKOutPoint C2Tuple_OutPointScriptZ_get_a(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
6572         return OutPoint_clone(&owner->a);
6573 }
6574 uint32_t  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_get_a"))) TS_C2Tuple_OutPointScriptZ_get_a(uint32_t owner) {
6575         LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)(owner & ~1);
6576         LDKOutPoint ret_var = C2Tuple_OutPointScriptZ_get_a(owner_conv);
6577         uint32_t ret_ref = 0;
6578         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6579         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6580         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6581         ret_ref = (uintptr_t)ret_var.inner;
6582         if (ret_var.is_owned) {
6583                 ret_ref |= 1;
6584         }
6585         return ret_ref;
6586 }
6587
6588 static inline struct LDKCVec_u8Z C2Tuple_OutPointScriptZ_get_b(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
6589         return CVec_u8Z_clone(&owner->b);
6590 }
6591 int8_tArray  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_get_b"))) TS_C2Tuple_OutPointScriptZ_get_b(uint32_t owner) {
6592         LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)(owner & ~1);
6593         LDKCVec_u8Z ret_var = C2Tuple_OutPointScriptZ_get_b(owner_conv);
6594         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
6595         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
6596         CVec_u8Z_free(ret_var);
6597         return ret_arr;
6598 }
6599
6600 static inline uint32_t C2Tuple_u32ScriptZ_get_a(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
6601         return owner->a;
6602 }
6603 int32_t  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_get_a"))) TS_C2Tuple_u32ScriptZ_get_a(uint32_t owner) {
6604         LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)(owner & ~1);
6605         int32_t ret_conv = C2Tuple_u32ScriptZ_get_a(owner_conv);
6606         return ret_conv;
6607 }
6608
6609 static inline struct LDKCVec_u8Z C2Tuple_u32ScriptZ_get_b(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
6610         return CVec_u8Z_clone(&owner->b);
6611 }
6612 int8_tArray  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_get_b"))) TS_C2Tuple_u32ScriptZ_get_b(uint32_t owner) {
6613         LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)(owner & ~1);
6614         LDKCVec_u8Z ret_var = C2Tuple_u32ScriptZ_get_b(owner_conv);
6615         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
6616         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
6617         CVec_u8Z_free(ret_var);
6618         return ret_arr;
6619 }
6620
6621 static inline LDKCVec_C2Tuple_u32ScriptZZ CVec_C2Tuple_u32ScriptZZ_clone(const LDKCVec_C2Tuple_u32ScriptZZ *orig) {
6622         LDKCVec_C2Tuple_u32ScriptZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * orig->datalen, "LDKCVec_C2Tuple_u32ScriptZZ clone bytes"), .datalen = orig->datalen };
6623         for (size_t i = 0; i < ret.datalen; i++) {
6624                 ret.data[i] = C2Tuple_u32ScriptZ_clone(&orig->data[i]);
6625         }
6626         return ret;
6627 }
6628 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
6629         return ThirtyTwoBytes_clone(&owner->a);
6630 }
6631 int8_tArray  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(uint32_t owner) {
6632         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(owner & ~1);
6633         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
6634         memcpy(ret_arr->elems, C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(owner_conv).data, 32);
6635         return ret_arr;
6636 }
6637
6638 static inline struct LDKCVec_C2Tuple_u32ScriptZZ C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
6639         return CVec_C2Tuple_u32ScriptZZ_clone(&owner->b);
6640 }
6641 uint32_tArray  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(uint32_t owner) {
6642         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(owner & ~1);
6643         LDKCVec_C2Tuple_u32ScriptZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(owner_conv);
6644         uint32_tArray ret_arr = NULL;
6645         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
6646         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 8);
6647         for (size_t v = 0; v < ret_var.datalen; v++) {
6648                 LDKC2Tuple_u32ScriptZ* ret_conv_21_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
6649                 *ret_conv_21_conv = ret_var.data[v];
6650                 ret_arr_ptr[v] = ((uint32_t)ret_conv_21_conv);
6651         }
6652         
6653         FREE(ret_var.data);
6654         return ret_arr;
6655 }
6656
6657 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *orig) {
6658         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 };
6659         for (size_t i = 0; i < ret.datalen; i++) {
6660                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(&orig->data[i]);
6661         }
6662         return ret;
6663 }
6664 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
6665         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
6666         for (size_t i = 0; i < ret.datalen; i++) {
6667                 ret.data[i] = Event_clone(&orig->data[i]);
6668         }
6669         return ret;
6670 }
6671 static inline uint32_t C2Tuple_u32TxOutZ_get_a(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
6672         return owner->a;
6673 }
6674 int32_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_get_a"))) TS_C2Tuple_u32TxOutZ_get_a(uint32_t owner) {
6675         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)(owner & ~1);
6676         int32_t ret_conv = C2Tuple_u32TxOutZ_get_a(owner_conv);
6677         return ret_conv;
6678 }
6679
6680 static inline struct LDKTxOut C2Tuple_u32TxOutZ_get_b(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
6681         return TxOut_clone(&owner->b);
6682 }
6683 uint32_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_get_b"))) TS_C2Tuple_u32TxOutZ_get_b(uint32_t owner) {
6684         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)(owner & ~1);
6685         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
6686         *ret_ref = C2Tuple_u32TxOutZ_get_b(owner_conv);
6687         return (uint32_t)ret_ref;
6688 }
6689
6690 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
6691         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
6692         for (size_t i = 0; i < ret.datalen; i++) {
6693                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
6694         }
6695         return ret;
6696 }
6697 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
6698         return ThirtyTwoBytes_clone(&owner->a);
6699 }
6700 int8_tArray  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(uint32_t owner) {
6701         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(owner & ~1);
6702         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
6703         memcpy(ret_arr->elems, C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(owner_conv).data, 32);
6704         return ret_arr;
6705 }
6706
6707 static inline struct LDKCVec_C2Tuple_u32TxOutZZ C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
6708         return CVec_C2Tuple_u32TxOutZZ_clone(&owner->b);
6709 }
6710 uint32_tArray  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(uint32_t owner) {
6711         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(owner & ~1);
6712         LDKCVec_C2Tuple_u32TxOutZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(owner_conv);
6713         uint32_tArray ret_arr = NULL;
6714         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
6715         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 8);
6716         for (size_t u = 0; u < ret_var.datalen; u++) {
6717                 LDKC2Tuple_u32TxOutZ* ret_conv_20_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
6718                 *ret_conv_20_conv = ret_var.data[u];
6719                 ret_arr_ptr[u] = ((uint32_t)ret_conv_20_conv);
6720         }
6721         
6722         FREE(ret_var.data);
6723         return ret_arr;
6724 }
6725
6726 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *orig) {
6727         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 };
6728         for (size_t i = 0; i < ret.datalen; i++) {
6729                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(&orig->data[i]);
6730         }
6731         return ret;
6732 }
6733 uint32_t __attribute__((export_name("TS_LDKBalance_ty_from_ptr"))) TS_LDKBalance_ty_from_ptr(uint32_t ptr) {
6734         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
6735         switch(obj->tag) {
6736                 case LDKBalance_ClaimableOnChannelClose: return 0;
6737                 case LDKBalance_ClaimableAwaitingConfirmations: return 1;
6738                 case LDKBalance_ContentiousClaimable: return 2;
6739                 case LDKBalance_MaybeClaimableHTLCAwaitingTimeout: return 3;
6740                 default: abort();
6741         }
6742 }
6743 int64_t __attribute__((export_name("TS_LDKBalance_ClaimableOnChannelClose_get_claimable_amount_satoshis"))) TS_LDKBalance_ClaimableOnChannelClose_get_claimable_amount_satoshis(uint32_t ptr) {
6744         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
6745         assert(obj->tag == LDKBalance_ClaimableOnChannelClose);
6746                         int64_t claimable_amount_satoshis_conv = obj->claimable_on_channel_close.claimable_amount_satoshis;
6747         return claimable_amount_satoshis_conv;
6748 }
6749 int64_t __attribute__((export_name("TS_LDKBalance_ClaimableAwaitingConfirmations_get_claimable_amount_satoshis"))) TS_LDKBalance_ClaimableAwaitingConfirmations_get_claimable_amount_satoshis(uint32_t ptr) {
6750         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
6751         assert(obj->tag == LDKBalance_ClaimableAwaitingConfirmations);
6752                         int64_t claimable_amount_satoshis_conv = obj->claimable_awaiting_confirmations.claimable_amount_satoshis;
6753         return claimable_amount_satoshis_conv;
6754 }
6755 int32_t __attribute__((export_name("TS_LDKBalance_ClaimableAwaitingConfirmations_get_confirmation_height"))) TS_LDKBalance_ClaimableAwaitingConfirmations_get_confirmation_height(uint32_t ptr) {
6756         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
6757         assert(obj->tag == LDKBalance_ClaimableAwaitingConfirmations);
6758                         int32_t confirmation_height_conv = obj->claimable_awaiting_confirmations.confirmation_height;
6759         return confirmation_height_conv;
6760 }
6761 int64_t __attribute__((export_name("TS_LDKBalance_ContentiousClaimable_get_claimable_amount_satoshis"))) TS_LDKBalance_ContentiousClaimable_get_claimable_amount_satoshis(uint32_t ptr) {
6762         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
6763         assert(obj->tag == LDKBalance_ContentiousClaimable);
6764                         int64_t claimable_amount_satoshis_conv = obj->contentious_claimable.claimable_amount_satoshis;
6765         return claimable_amount_satoshis_conv;
6766 }
6767 int32_t __attribute__((export_name("TS_LDKBalance_ContentiousClaimable_get_timeout_height"))) TS_LDKBalance_ContentiousClaimable_get_timeout_height(uint32_t ptr) {
6768         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
6769         assert(obj->tag == LDKBalance_ContentiousClaimable);
6770                         int32_t timeout_height_conv = obj->contentious_claimable.timeout_height;
6771         return timeout_height_conv;
6772 }
6773 int64_t __attribute__((export_name("TS_LDKBalance_MaybeClaimableHTLCAwaitingTimeout_get_claimable_amount_satoshis"))) TS_LDKBalance_MaybeClaimableHTLCAwaitingTimeout_get_claimable_amount_satoshis(uint32_t ptr) {
6774         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
6775         assert(obj->tag == LDKBalance_MaybeClaimableHTLCAwaitingTimeout);
6776                         int64_t claimable_amount_satoshis_conv = obj->maybe_claimable_htlc_awaiting_timeout.claimable_amount_satoshis;
6777         return claimable_amount_satoshis_conv;
6778 }
6779 int32_t __attribute__((export_name("TS_LDKBalance_MaybeClaimableHTLCAwaitingTimeout_get_claimable_height"))) TS_LDKBalance_MaybeClaimableHTLCAwaitingTimeout_get_claimable_height(uint32_t ptr) {
6780         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
6781         assert(obj->tag == LDKBalance_MaybeClaimableHTLCAwaitingTimeout);
6782                         int32_t claimable_height_conv = obj->maybe_claimable_htlc_awaiting_timeout.claimable_height;
6783         return claimable_height_conv;
6784 }
6785 static inline LDKCVec_BalanceZ CVec_BalanceZ_clone(const LDKCVec_BalanceZ *orig) {
6786         LDKCVec_BalanceZ ret = { .data = MALLOC(sizeof(LDKBalance) * orig->datalen, "LDKCVec_BalanceZ clone bytes"), .datalen = orig->datalen };
6787         for (size_t i = 0; i < ret.datalen; i++) {
6788                 ret.data[i] = Balance_clone(&orig->data[i]);
6789         }
6790         return ret;
6791 }
6792 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelMonitorZ_get_a(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
6793         return ThirtyTwoBytes_clone(&owner->a);
6794 }
6795 int8_tArray  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_get_a"))) TS_C2Tuple_BlockHashChannelMonitorZ_get_a(uint32_t owner) {
6796         LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(owner & ~1);
6797         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
6798         memcpy(ret_arr->elems, C2Tuple_BlockHashChannelMonitorZ_get_a(owner_conv).data, 32);
6799         return ret_arr;
6800 }
6801
6802 static inline struct LDKChannelMonitor C2Tuple_BlockHashChannelMonitorZ_get_b(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
6803         return ChannelMonitor_clone(&owner->b);
6804 }
6805 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_get_b"))) TS_C2Tuple_BlockHashChannelMonitorZ_get_b(uint32_t owner) {
6806         LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(owner & ~1);
6807         LDKChannelMonitor ret_var = C2Tuple_BlockHashChannelMonitorZ_get_b(owner_conv);
6808         uint32_t ret_ref = 0;
6809         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6810         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6811         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6812         ret_ref = (uintptr_t)ret_var.inner;
6813         if (ret_var.is_owned) {
6814                 ret_ref |= 1;
6815         }
6816         return ret_ref;
6817 }
6818
6819 static inline struct LDKC2Tuple_BlockHashChannelMonitorZ CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
6820 CHECK(owner->result_ok);
6821         return C2Tuple_BlockHashChannelMonitorZ_clone(&*owner->contents.result);
6822 }
6823 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(uint32_t owner) {
6824         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(owner & ~1);
6825         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
6826         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(owner_conv);
6827         return ((uint32_t)ret_conv);
6828 }
6829
6830 static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
6831 CHECK(!owner->result_ok);
6832         return DecodeError_clone(&*owner->contents.err);
6833 }
6834 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(uint32_t owner) {
6835         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(owner & ~1);
6836         LDKDecodeError ret_var = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(owner_conv);
6837         uint32_t ret_ref = 0;
6838         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6839         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6840         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6841         ret_ref = (uintptr_t)ret_var.inner;
6842         if (ret_var.is_owned) {
6843                 ret_ref |= 1;
6844         }
6845         return ret_ref;
6846 }
6847
6848 static inline struct LDKPublicKey C2Tuple_PublicKeyTypeZ_get_a(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
6849         return owner->a;
6850 }
6851 int8_tArray  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_get_a"))) TS_C2Tuple_PublicKeyTypeZ_get_a(uint32_t owner) {
6852         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)(owner & ~1);
6853         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
6854         memcpy(ret_arr->elems, C2Tuple_PublicKeyTypeZ_get_a(owner_conv).compressed_form, 33);
6855         return ret_arr;
6856 }
6857
6858 static inline struct LDKType C2Tuple_PublicKeyTypeZ_get_b(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
6859         return Type_clone(&owner->b);
6860 }
6861 uint32_t  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_get_b"))) TS_C2Tuple_PublicKeyTypeZ_get_b(uint32_t owner) {
6862         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)(owner & ~1);
6863         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
6864         *ret_ret = C2Tuple_PublicKeyTypeZ_get_b(owner_conv);
6865         return (uint32_t)ret_ret;
6866 }
6867
6868 static inline LDKCVec_C2Tuple_PublicKeyTypeZZ CVec_C2Tuple_PublicKeyTypeZZ_clone(const LDKCVec_C2Tuple_PublicKeyTypeZZ *orig) {
6869         LDKCVec_C2Tuple_PublicKeyTypeZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ) * orig->datalen, "LDKCVec_C2Tuple_PublicKeyTypeZZ clone bytes"), .datalen = orig->datalen };
6870         for (size_t i = 0; i < ret.datalen; i++) {
6871                 ret.data[i] = C2Tuple_PublicKeyTypeZ_clone(&orig->data[i]);
6872         }
6873         return ret;
6874 }
6875 uint32_t __attribute__((export_name("TS_LDKCOption_NetAddressZ_ty_from_ptr"))) TS_LDKCOption_NetAddressZ_ty_from_ptr(uint32_t ptr) {
6876         LDKCOption_NetAddressZ *obj = (LDKCOption_NetAddressZ*)(ptr & ~1);
6877         switch(obj->tag) {
6878                 case LDKCOption_NetAddressZ_Some: return 0;
6879                 case LDKCOption_NetAddressZ_None: return 1;
6880                 default: abort();
6881         }
6882 }
6883 uint32_t __attribute__((export_name("TS_LDKCOption_NetAddressZ_Some_get_some"))) TS_LDKCOption_NetAddressZ_Some_get_some(uint32_t ptr) {
6884         LDKCOption_NetAddressZ *obj = (LDKCOption_NetAddressZ*)(ptr & ~1);
6885         assert(obj->tag == LDKCOption_NetAddressZ_Some);
6886                         uint32_t some_ref = ((uintptr_t)&obj->some) | 1;
6887         return some_ref;
6888 }
6889 static inline struct LDKCVec_u8Z CResult_CVec_u8ZPeerHandleErrorZ_get_ok(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
6890 CHECK(owner->result_ok);
6891         return CVec_u8Z_clone(&*owner->contents.result);
6892 }
6893 int8_tArray  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_get_ok"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_get_ok(uint32_t owner) {
6894         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(owner & ~1);
6895         LDKCVec_u8Z ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_ok(owner_conv);
6896         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
6897         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
6898         CVec_u8Z_free(ret_var);
6899         return ret_arr;
6900 }
6901
6902 static inline struct LDKPeerHandleError CResult_CVec_u8ZPeerHandleErrorZ_get_err(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
6903 CHECK(!owner->result_ok);
6904         return PeerHandleError_clone(&*owner->contents.err);
6905 }
6906 uint32_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_get_err"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_get_err(uint32_t owner) {
6907         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(owner & ~1);
6908         LDKPeerHandleError ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_err(owner_conv);
6909         uint32_t ret_ref = 0;
6910         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6911         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6912         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6913         ret_ref = (uintptr_t)ret_var.inner;
6914         if (ret_var.is_owned) {
6915                 ret_ref |= 1;
6916         }
6917         return ret_ref;
6918 }
6919
6920 static inline void CResult_NonePeerHandleErrorZ_get_ok(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
6921 CHECK(owner->result_ok);
6922         return *owner->contents.result;
6923 }
6924 void  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_get_ok"))) TS_CResult_NonePeerHandleErrorZ_get_ok(uint32_t owner) {
6925         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)(owner & ~1);
6926         CResult_NonePeerHandleErrorZ_get_ok(owner_conv);
6927 }
6928
6929 static inline struct LDKPeerHandleError CResult_NonePeerHandleErrorZ_get_err(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
6930 CHECK(!owner->result_ok);
6931         return PeerHandleError_clone(&*owner->contents.err);
6932 }
6933 uint32_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_get_err"))) TS_CResult_NonePeerHandleErrorZ_get_err(uint32_t owner) {
6934         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)(owner & ~1);
6935         LDKPeerHandleError ret_var = CResult_NonePeerHandleErrorZ_get_err(owner_conv);
6936         uint32_t ret_ref = 0;
6937         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6938         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6939         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6940         ret_ref = (uintptr_t)ret_var.inner;
6941         if (ret_var.is_owned) {
6942                 ret_ref |= 1;
6943         }
6944         return ret_ref;
6945 }
6946
6947 static inline bool CResult_boolPeerHandleErrorZ_get_ok(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
6948 CHECK(owner->result_ok);
6949         return *owner->contents.result;
6950 }
6951 jboolean  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_get_ok"))) TS_CResult_boolPeerHandleErrorZ_get_ok(uint32_t owner) {
6952         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)(owner & ~1);
6953         jboolean ret_conv = CResult_boolPeerHandleErrorZ_get_ok(owner_conv);
6954         return ret_conv;
6955 }
6956
6957 static inline struct LDKPeerHandleError CResult_boolPeerHandleErrorZ_get_err(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
6958 CHECK(!owner->result_ok);
6959         return PeerHandleError_clone(&*owner->contents.err);
6960 }
6961 uint32_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_get_err"))) TS_CResult_boolPeerHandleErrorZ_get_err(uint32_t owner) {
6962         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)(owner & ~1);
6963         LDKPeerHandleError ret_var = CResult_boolPeerHandleErrorZ_get_err(owner_conv);
6964         uint32_t ret_ref = 0;
6965         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6966         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6967         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6968         ret_ref = (uintptr_t)ret_var.inner;
6969         if (ret_var.is_owned) {
6970                 ret_ref |= 1;
6971         }
6972         return ret_ref;
6973 }
6974
6975 static inline void CResult_NoneErrorZ_get_ok(LDKCResult_NoneErrorZ *NONNULL_PTR owner){
6976 CHECK(owner->result_ok);
6977         return *owner->contents.result;
6978 }
6979 void  __attribute__((export_name("TS_CResult_NoneErrorZ_get_ok"))) TS_CResult_NoneErrorZ_get_ok(uint32_t owner) {
6980         LDKCResult_NoneErrorZ* owner_conv = (LDKCResult_NoneErrorZ*)(owner & ~1);
6981         CResult_NoneErrorZ_get_ok(owner_conv);
6982 }
6983
6984 static inline enum LDKIOError CResult_NoneErrorZ_get_err(LDKCResult_NoneErrorZ *NONNULL_PTR owner){
6985 CHECK(!owner->result_ok);
6986         return *owner->contents.err;
6987 }
6988 uint32_t  __attribute__((export_name("TS_CResult_NoneErrorZ_get_err"))) TS_CResult_NoneErrorZ_get_err(uint32_t owner) {
6989         LDKCResult_NoneErrorZ* owner_conv = (LDKCResult_NoneErrorZ*)(owner & ~1);
6990         uint32_t ret_conv = LDKIOError_to_js(CResult_NoneErrorZ_get_err(owner_conv));
6991         return ret_conv;
6992 }
6993
6994 static inline struct LDKNetAddress CResult_NetAddressDecodeErrorZ_get_ok(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
6995 CHECK(owner->result_ok);
6996         return NetAddress_clone(&*owner->contents.result);
6997 }
6998 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_get_ok"))) TS_CResult_NetAddressDecodeErrorZ_get_ok(uint32_t owner) {
6999         LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)(owner & ~1);
7000         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
7001         *ret_copy = CResult_NetAddressDecodeErrorZ_get_ok(owner_conv);
7002         uint32_t ret_ref = (uintptr_t)ret_copy;
7003         return ret_ref;
7004 }
7005
7006 static inline struct LDKDecodeError CResult_NetAddressDecodeErrorZ_get_err(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
7007 CHECK(!owner->result_ok);
7008         return DecodeError_clone(&*owner->contents.err);
7009 }
7010 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_get_err"))) TS_CResult_NetAddressDecodeErrorZ_get_err(uint32_t owner) {
7011         LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)(owner & ~1);
7012         LDKDecodeError ret_var = CResult_NetAddressDecodeErrorZ_get_err(owner_conv);
7013         uint32_t ret_ref = 0;
7014         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7015         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7016         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7017         ret_ref = (uintptr_t)ret_var.inner;
7018         if (ret_var.is_owned) {
7019                 ret_ref |= 1;
7020         }
7021         return ret_ref;
7022 }
7023
7024 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
7025         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
7026         for (size_t i = 0; i < ret.datalen; i++) {
7027                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
7028         }
7029         return ret;
7030 }
7031 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
7032         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
7033         for (size_t i = 0; i < ret.datalen; i++) {
7034                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
7035         }
7036         return ret;
7037 }
7038 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
7039         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
7040         for (size_t i = 0; i < ret.datalen; i++) {
7041                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
7042         }
7043         return ret;
7044 }
7045 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
7046         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
7047         for (size_t i = 0; i < ret.datalen; i++) {
7048                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
7049         }
7050         return ret;
7051 }
7052 static inline struct LDKAcceptChannel CResult_AcceptChannelDecodeErrorZ_get_ok(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
7053 CHECK(owner->result_ok);
7054         return AcceptChannel_clone(&*owner->contents.result);
7055 }
7056 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_get_ok"))) TS_CResult_AcceptChannelDecodeErrorZ_get_ok(uint32_t owner) {
7057         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(owner & ~1);
7058         LDKAcceptChannel ret_var = CResult_AcceptChannelDecodeErrorZ_get_ok(owner_conv);
7059         uint32_t ret_ref = 0;
7060         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7061         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7062         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7063         ret_ref = (uintptr_t)ret_var.inner;
7064         if (ret_var.is_owned) {
7065                 ret_ref |= 1;
7066         }
7067         return ret_ref;
7068 }
7069
7070 static inline struct LDKDecodeError CResult_AcceptChannelDecodeErrorZ_get_err(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
7071 CHECK(!owner->result_ok);
7072         return DecodeError_clone(&*owner->contents.err);
7073 }
7074 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_get_err"))) TS_CResult_AcceptChannelDecodeErrorZ_get_err(uint32_t owner) {
7075         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(owner & ~1);
7076         LDKDecodeError ret_var = CResult_AcceptChannelDecodeErrorZ_get_err(owner_conv);
7077         uint32_t ret_ref = 0;
7078         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7079         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7080         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7081         ret_ref = (uintptr_t)ret_var.inner;
7082         if (ret_var.is_owned) {
7083                 ret_ref |= 1;
7084         }
7085         return ret_ref;
7086 }
7087
7088 static inline struct LDKAnnouncementSignatures CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
7089 CHECK(owner->result_ok);
7090         return AnnouncementSignatures_clone(&*owner->contents.result);
7091 }
7092 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_get_ok"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(uint32_t owner) {
7093         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(owner & ~1);
7094         LDKAnnouncementSignatures ret_var = CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(owner_conv);
7095         uint32_t ret_ref = 0;
7096         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7097         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7098         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7099         ret_ref = (uintptr_t)ret_var.inner;
7100         if (ret_var.is_owned) {
7101                 ret_ref |= 1;
7102         }
7103         return ret_ref;
7104 }
7105
7106 static inline struct LDKDecodeError CResult_AnnouncementSignaturesDecodeErrorZ_get_err(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
7107 CHECK(!owner->result_ok);
7108         return DecodeError_clone(&*owner->contents.err);
7109 }
7110 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_get_err"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_get_err(uint32_t owner) {
7111         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(owner & ~1);
7112         LDKDecodeError ret_var = CResult_AnnouncementSignaturesDecodeErrorZ_get_err(owner_conv);
7113         uint32_t ret_ref = 0;
7114         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7115         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7116         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7117         ret_ref = (uintptr_t)ret_var.inner;
7118         if (ret_var.is_owned) {
7119                 ret_ref |= 1;
7120         }
7121         return ret_ref;
7122 }
7123
7124 static inline struct LDKChannelReestablish CResult_ChannelReestablishDecodeErrorZ_get_ok(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
7125 CHECK(owner->result_ok);
7126         return ChannelReestablish_clone(&*owner->contents.result);
7127 }
7128 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_get_ok"))) TS_CResult_ChannelReestablishDecodeErrorZ_get_ok(uint32_t owner) {
7129         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(owner & ~1);
7130         LDKChannelReestablish ret_var = CResult_ChannelReestablishDecodeErrorZ_get_ok(owner_conv);
7131         uint32_t ret_ref = 0;
7132         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7133         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7134         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7135         ret_ref = (uintptr_t)ret_var.inner;
7136         if (ret_var.is_owned) {
7137                 ret_ref |= 1;
7138         }
7139         return ret_ref;
7140 }
7141
7142 static inline struct LDKDecodeError CResult_ChannelReestablishDecodeErrorZ_get_err(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
7143 CHECK(!owner->result_ok);
7144         return DecodeError_clone(&*owner->contents.err);
7145 }
7146 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_get_err"))) TS_CResult_ChannelReestablishDecodeErrorZ_get_err(uint32_t owner) {
7147         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(owner & ~1);
7148         LDKDecodeError ret_var = CResult_ChannelReestablishDecodeErrorZ_get_err(owner_conv);
7149         uint32_t ret_ref = 0;
7150         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7151         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7152         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7153         ret_ref = (uintptr_t)ret_var.inner;
7154         if (ret_var.is_owned) {
7155                 ret_ref |= 1;
7156         }
7157         return ret_ref;
7158 }
7159
7160 static inline struct LDKClosingSigned CResult_ClosingSignedDecodeErrorZ_get_ok(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
7161 CHECK(owner->result_ok);
7162         return ClosingSigned_clone(&*owner->contents.result);
7163 }
7164 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_get_ok"))) TS_CResult_ClosingSignedDecodeErrorZ_get_ok(uint32_t owner) {
7165         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(owner & ~1);
7166         LDKClosingSigned ret_var = CResult_ClosingSignedDecodeErrorZ_get_ok(owner_conv);
7167         uint32_t ret_ref = 0;
7168         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7169         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7170         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7171         ret_ref = (uintptr_t)ret_var.inner;
7172         if (ret_var.is_owned) {
7173                 ret_ref |= 1;
7174         }
7175         return ret_ref;
7176 }
7177
7178 static inline struct LDKDecodeError CResult_ClosingSignedDecodeErrorZ_get_err(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
7179 CHECK(!owner->result_ok);
7180         return DecodeError_clone(&*owner->contents.err);
7181 }
7182 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_get_err"))) TS_CResult_ClosingSignedDecodeErrorZ_get_err(uint32_t owner) {
7183         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(owner & ~1);
7184         LDKDecodeError ret_var = CResult_ClosingSignedDecodeErrorZ_get_err(owner_conv);
7185         uint32_t ret_ref = 0;
7186         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7187         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7188         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7189         ret_ref = (uintptr_t)ret_var.inner;
7190         if (ret_var.is_owned) {
7191                 ret_ref |= 1;
7192         }
7193         return ret_ref;
7194 }
7195
7196 static inline struct LDKClosingSignedFeeRange CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
7197 CHECK(owner->result_ok);
7198         return ClosingSignedFeeRange_clone(&*owner->contents.result);
7199 }
7200 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(uint32_t owner) {
7201         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(owner & ~1);
7202         LDKClosingSignedFeeRange ret_var = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(owner_conv);
7203         uint32_t ret_ref = 0;
7204         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7205         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7206         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7207         ret_ref = (uintptr_t)ret_var.inner;
7208         if (ret_var.is_owned) {
7209                 ret_ref |= 1;
7210         }
7211         return ret_ref;
7212 }
7213
7214 static inline struct LDKDecodeError CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
7215 CHECK(!owner->result_ok);
7216         return DecodeError_clone(&*owner->contents.err);
7217 }
7218 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(uint32_t owner) {
7219         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(owner & ~1);
7220         LDKDecodeError ret_var = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(owner_conv);
7221         uint32_t ret_ref = 0;
7222         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7223         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7224         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7225         ret_ref = (uintptr_t)ret_var.inner;
7226         if (ret_var.is_owned) {
7227                 ret_ref |= 1;
7228         }
7229         return ret_ref;
7230 }
7231
7232 static inline struct LDKCommitmentSigned CResult_CommitmentSignedDecodeErrorZ_get_ok(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
7233 CHECK(owner->result_ok);
7234         return CommitmentSigned_clone(&*owner->contents.result);
7235 }
7236 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_get_ok"))) TS_CResult_CommitmentSignedDecodeErrorZ_get_ok(uint32_t owner) {
7237         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(owner & ~1);
7238         LDKCommitmentSigned ret_var = CResult_CommitmentSignedDecodeErrorZ_get_ok(owner_conv);
7239         uint32_t ret_ref = 0;
7240         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7241         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7242         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7243         ret_ref = (uintptr_t)ret_var.inner;
7244         if (ret_var.is_owned) {
7245                 ret_ref |= 1;
7246         }
7247         return ret_ref;
7248 }
7249
7250 static inline struct LDKDecodeError CResult_CommitmentSignedDecodeErrorZ_get_err(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
7251 CHECK(!owner->result_ok);
7252         return DecodeError_clone(&*owner->contents.err);
7253 }
7254 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_get_err"))) TS_CResult_CommitmentSignedDecodeErrorZ_get_err(uint32_t owner) {
7255         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(owner & ~1);
7256         LDKDecodeError ret_var = CResult_CommitmentSignedDecodeErrorZ_get_err(owner_conv);
7257         uint32_t ret_ref = 0;
7258         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7259         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7260         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7261         ret_ref = (uintptr_t)ret_var.inner;
7262         if (ret_var.is_owned) {
7263                 ret_ref |= 1;
7264         }
7265         return ret_ref;
7266 }
7267
7268 static inline struct LDKFundingCreated CResult_FundingCreatedDecodeErrorZ_get_ok(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
7269 CHECK(owner->result_ok);
7270         return FundingCreated_clone(&*owner->contents.result);
7271 }
7272 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_get_ok"))) TS_CResult_FundingCreatedDecodeErrorZ_get_ok(uint32_t owner) {
7273         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(owner & ~1);
7274         LDKFundingCreated ret_var = CResult_FundingCreatedDecodeErrorZ_get_ok(owner_conv);
7275         uint32_t ret_ref = 0;
7276         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7277         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7278         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7279         ret_ref = (uintptr_t)ret_var.inner;
7280         if (ret_var.is_owned) {
7281                 ret_ref |= 1;
7282         }
7283         return ret_ref;
7284 }
7285
7286 static inline struct LDKDecodeError CResult_FundingCreatedDecodeErrorZ_get_err(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
7287 CHECK(!owner->result_ok);
7288         return DecodeError_clone(&*owner->contents.err);
7289 }
7290 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_get_err"))) TS_CResult_FundingCreatedDecodeErrorZ_get_err(uint32_t owner) {
7291         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(owner & ~1);
7292         LDKDecodeError ret_var = CResult_FundingCreatedDecodeErrorZ_get_err(owner_conv);
7293         uint32_t ret_ref = 0;
7294         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7295         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7296         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7297         ret_ref = (uintptr_t)ret_var.inner;
7298         if (ret_var.is_owned) {
7299                 ret_ref |= 1;
7300         }
7301         return ret_ref;
7302 }
7303
7304 static inline struct LDKFundingSigned CResult_FundingSignedDecodeErrorZ_get_ok(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
7305 CHECK(owner->result_ok);
7306         return FundingSigned_clone(&*owner->contents.result);
7307 }
7308 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_get_ok"))) TS_CResult_FundingSignedDecodeErrorZ_get_ok(uint32_t owner) {
7309         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(owner & ~1);
7310         LDKFundingSigned ret_var = CResult_FundingSignedDecodeErrorZ_get_ok(owner_conv);
7311         uint32_t ret_ref = 0;
7312         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7313         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7314         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7315         ret_ref = (uintptr_t)ret_var.inner;
7316         if (ret_var.is_owned) {
7317                 ret_ref |= 1;
7318         }
7319         return ret_ref;
7320 }
7321
7322 static inline struct LDKDecodeError CResult_FundingSignedDecodeErrorZ_get_err(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
7323 CHECK(!owner->result_ok);
7324         return DecodeError_clone(&*owner->contents.err);
7325 }
7326 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_get_err"))) TS_CResult_FundingSignedDecodeErrorZ_get_err(uint32_t owner) {
7327         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(owner & ~1);
7328         LDKDecodeError ret_var = CResult_FundingSignedDecodeErrorZ_get_err(owner_conv);
7329         uint32_t ret_ref = 0;
7330         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7331         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7332         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7333         ret_ref = (uintptr_t)ret_var.inner;
7334         if (ret_var.is_owned) {
7335                 ret_ref |= 1;
7336         }
7337         return ret_ref;
7338 }
7339
7340 static inline struct LDKChannelReady CResult_ChannelReadyDecodeErrorZ_get_ok(LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR owner){
7341 CHECK(owner->result_ok);
7342         return ChannelReady_clone(&*owner->contents.result);
7343 }
7344 uint32_t  __attribute__((export_name("TS_CResult_ChannelReadyDecodeErrorZ_get_ok"))) TS_CResult_ChannelReadyDecodeErrorZ_get_ok(uint32_t owner) {
7345         LDKCResult_ChannelReadyDecodeErrorZ* owner_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)(owner & ~1);
7346         LDKChannelReady ret_var = CResult_ChannelReadyDecodeErrorZ_get_ok(owner_conv);
7347         uint32_t ret_ref = 0;
7348         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7349         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7350         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7351         ret_ref = (uintptr_t)ret_var.inner;
7352         if (ret_var.is_owned) {
7353                 ret_ref |= 1;
7354         }
7355         return ret_ref;
7356 }
7357
7358 static inline struct LDKDecodeError CResult_ChannelReadyDecodeErrorZ_get_err(LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR owner){
7359 CHECK(!owner->result_ok);
7360         return DecodeError_clone(&*owner->contents.err);
7361 }
7362 uint32_t  __attribute__((export_name("TS_CResult_ChannelReadyDecodeErrorZ_get_err"))) TS_CResult_ChannelReadyDecodeErrorZ_get_err(uint32_t owner) {
7363         LDKCResult_ChannelReadyDecodeErrorZ* owner_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)(owner & ~1);
7364         LDKDecodeError ret_var = CResult_ChannelReadyDecodeErrorZ_get_err(owner_conv);
7365         uint32_t ret_ref = 0;
7366         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7367         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7368         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7369         ret_ref = (uintptr_t)ret_var.inner;
7370         if (ret_var.is_owned) {
7371                 ret_ref |= 1;
7372         }
7373         return ret_ref;
7374 }
7375
7376 static inline struct LDKInit CResult_InitDecodeErrorZ_get_ok(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
7377 CHECK(owner->result_ok);
7378         return Init_clone(&*owner->contents.result);
7379 }
7380 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_get_ok"))) TS_CResult_InitDecodeErrorZ_get_ok(uint32_t owner) {
7381         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)(owner & ~1);
7382         LDKInit ret_var = CResult_InitDecodeErrorZ_get_ok(owner_conv);
7383         uint32_t ret_ref = 0;
7384         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7385         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7386         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7387         ret_ref = (uintptr_t)ret_var.inner;
7388         if (ret_var.is_owned) {
7389                 ret_ref |= 1;
7390         }
7391         return ret_ref;
7392 }
7393
7394 static inline struct LDKDecodeError CResult_InitDecodeErrorZ_get_err(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
7395 CHECK(!owner->result_ok);
7396         return DecodeError_clone(&*owner->contents.err);
7397 }
7398 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_get_err"))) TS_CResult_InitDecodeErrorZ_get_err(uint32_t owner) {
7399         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)(owner & ~1);
7400         LDKDecodeError ret_var = CResult_InitDecodeErrorZ_get_err(owner_conv);
7401         uint32_t ret_ref = 0;
7402         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7403         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7404         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7405         ret_ref = (uintptr_t)ret_var.inner;
7406         if (ret_var.is_owned) {
7407                 ret_ref |= 1;
7408         }
7409         return ret_ref;
7410 }
7411
7412 static inline struct LDKOpenChannel CResult_OpenChannelDecodeErrorZ_get_ok(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
7413 CHECK(owner->result_ok);
7414         return OpenChannel_clone(&*owner->contents.result);
7415 }
7416 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_get_ok"))) TS_CResult_OpenChannelDecodeErrorZ_get_ok(uint32_t owner) {
7417         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(owner & ~1);
7418         LDKOpenChannel ret_var = CResult_OpenChannelDecodeErrorZ_get_ok(owner_conv);
7419         uint32_t ret_ref = 0;
7420         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7421         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7422         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7423         ret_ref = (uintptr_t)ret_var.inner;
7424         if (ret_var.is_owned) {
7425                 ret_ref |= 1;
7426         }
7427         return ret_ref;
7428 }
7429
7430 static inline struct LDKDecodeError CResult_OpenChannelDecodeErrorZ_get_err(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
7431 CHECK(!owner->result_ok);
7432         return DecodeError_clone(&*owner->contents.err);
7433 }
7434 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_get_err"))) TS_CResult_OpenChannelDecodeErrorZ_get_err(uint32_t owner) {
7435         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(owner & ~1);
7436         LDKDecodeError ret_var = CResult_OpenChannelDecodeErrorZ_get_err(owner_conv);
7437         uint32_t ret_ref = 0;
7438         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7439         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7440         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7441         ret_ref = (uintptr_t)ret_var.inner;
7442         if (ret_var.is_owned) {
7443                 ret_ref |= 1;
7444         }
7445         return ret_ref;
7446 }
7447
7448 static inline struct LDKRevokeAndACK CResult_RevokeAndACKDecodeErrorZ_get_ok(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
7449 CHECK(owner->result_ok);
7450         return RevokeAndACK_clone(&*owner->contents.result);
7451 }
7452 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_get_ok"))) TS_CResult_RevokeAndACKDecodeErrorZ_get_ok(uint32_t owner) {
7453         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(owner & ~1);
7454         LDKRevokeAndACK ret_var = CResult_RevokeAndACKDecodeErrorZ_get_ok(owner_conv);
7455         uint32_t ret_ref = 0;
7456         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7457         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7458         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7459         ret_ref = (uintptr_t)ret_var.inner;
7460         if (ret_var.is_owned) {
7461                 ret_ref |= 1;
7462         }
7463         return ret_ref;
7464 }
7465
7466 static inline struct LDKDecodeError CResult_RevokeAndACKDecodeErrorZ_get_err(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
7467 CHECK(!owner->result_ok);
7468         return DecodeError_clone(&*owner->contents.err);
7469 }
7470 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_get_err"))) TS_CResult_RevokeAndACKDecodeErrorZ_get_err(uint32_t owner) {
7471         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(owner & ~1);
7472         LDKDecodeError ret_var = CResult_RevokeAndACKDecodeErrorZ_get_err(owner_conv);
7473         uint32_t ret_ref = 0;
7474         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7475         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7476         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7477         ret_ref = (uintptr_t)ret_var.inner;
7478         if (ret_var.is_owned) {
7479                 ret_ref |= 1;
7480         }
7481         return ret_ref;
7482 }
7483
7484 static inline struct LDKShutdown CResult_ShutdownDecodeErrorZ_get_ok(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
7485 CHECK(owner->result_ok);
7486         return Shutdown_clone(&*owner->contents.result);
7487 }
7488 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_get_ok"))) TS_CResult_ShutdownDecodeErrorZ_get_ok(uint32_t owner) {
7489         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)(owner & ~1);
7490         LDKShutdown ret_var = CResult_ShutdownDecodeErrorZ_get_ok(owner_conv);
7491         uint32_t ret_ref = 0;
7492         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7493         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7494         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7495         ret_ref = (uintptr_t)ret_var.inner;
7496         if (ret_var.is_owned) {
7497                 ret_ref |= 1;
7498         }
7499         return ret_ref;
7500 }
7501
7502 static inline struct LDKDecodeError CResult_ShutdownDecodeErrorZ_get_err(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
7503 CHECK(!owner->result_ok);
7504         return DecodeError_clone(&*owner->contents.err);
7505 }
7506 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_get_err"))) TS_CResult_ShutdownDecodeErrorZ_get_err(uint32_t owner) {
7507         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)(owner & ~1);
7508         LDKDecodeError ret_var = CResult_ShutdownDecodeErrorZ_get_err(owner_conv);
7509         uint32_t ret_ref = 0;
7510         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7511         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7512         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7513         ret_ref = (uintptr_t)ret_var.inner;
7514         if (ret_var.is_owned) {
7515                 ret_ref |= 1;
7516         }
7517         return ret_ref;
7518 }
7519
7520 static inline struct LDKUpdateFailHTLC CResult_UpdateFailHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
7521 CHECK(owner->result_ok);
7522         return UpdateFailHTLC_clone(&*owner->contents.result);
7523 }
7524 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_get_ok"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_get_ok(uint32_t owner) {
7525         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(owner & ~1);
7526         LDKUpdateFailHTLC ret_var = CResult_UpdateFailHTLCDecodeErrorZ_get_ok(owner_conv);
7527         uint32_t ret_ref = 0;
7528         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7529         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7530         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7531         ret_ref = (uintptr_t)ret_var.inner;
7532         if (ret_var.is_owned) {
7533                 ret_ref |= 1;
7534         }
7535         return ret_ref;
7536 }
7537
7538 static inline struct LDKDecodeError CResult_UpdateFailHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
7539 CHECK(!owner->result_ok);
7540         return DecodeError_clone(&*owner->contents.err);
7541 }
7542 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_get_err"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_get_err(uint32_t owner) {
7543         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(owner & ~1);
7544         LDKDecodeError ret_var = CResult_UpdateFailHTLCDecodeErrorZ_get_err(owner_conv);
7545         uint32_t ret_ref = 0;
7546         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7547         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7548         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7549         ret_ref = (uintptr_t)ret_var.inner;
7550         if (ret_var.is_owned) {
7551                 ret_ref |= 1;
7552         }
7553         return ret_ref;
7554 }
7555
7556 static inline struct LDKUpdateFailMalformedHTLC CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
7557 CHECK(owner->result_ok);
7558         return UpdateFailMalformedHTLC_clone(&*owner->contents.result);
7559 }
7560 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(uint32_t owner) {
7561         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(owner & ~1);
7562         LDKUpdateFailMalformedHTLC ret_var = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(owner_conv);
7563         uint32_t ret_ref = 0;
7564         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7565         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7566         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7567         ret_ref = (uintptr_t)ret_var.inner;
7568         if (ret_var.is_owned) {
7569                 ret_ref |= 1;
7570         }
7571         return ret_ref;
7572 }
7573
7574 static inline struct LDKDecodeError CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
7575 CHECK(!owner->result_ok);
7576         return DecodeError_clone(&*owner->contents.err);
7577 }
7578 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(uint32_t owner) {
7579         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(owner & ~1);
7580         LDKDecodeError ret_var = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(owner_conv);
7581         uint32_t ret_ref = 0;
7582         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7583         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7584         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7585         ret_ref = (uintptr_t)ret_var.inner;
7586         if (ret_var.is_owned) {
7587                 ret_ref |= 1;
7588         }
7589         return ret_ref;
7590 }
7591
7592 static inline struct LDKUpdateFee CResult_UpdateFeeDecodeErrorZ_get_ok(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
7593 CHECK(owner->result_ok);
7594         return UpdateFee_clone(&*owner->contents.result);
7595 }
7596 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_get_ok"))) TS_CResult_UpdateFeeDecodeErrorZ_get_ok(uint32_t owner) {
7597         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(owner & ~1);
7598         LDKUpdateFee ret_var = CResult_UpdateFeeDecodeErrorZ_get_ok(owner_conv);
7599         uint32_t ret_ref = 0;
7600         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7601         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7602         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7603         ret_ref = (uintptr_t)ret_var.inner;
7604         if (ret_var.is_owned) {
7605                 ret_ref |= 1;
7606         }
7607         return ret_ref;
7608 }
7609
7610 static inline struct LDKDecodeError CResult_UpdateFeeDecodeErrorZ_get_err(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
7611 CHECK(!owner->result_ok);
7612         return DecodeError_clone(&*owner->contents.err);
7613 }
7614 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_get_err"))) TS_CResult_UpdateFeeDecodeErrorZ_get_err(uint32_t owner) {
7615         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(owner & ~1);
7616         LDKDecodeError ret_var = CResult_UpdateFeeDecodeErrorZ_get_err(owner_conv);
7617         uint32_t ret_ref = 0;
7618         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7619         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7620         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7621         ret_ref = (uintptr_t)ret_var.inner;
7622         if (ret_var.is_owned) {
7623                 ret_ref |= 1;
7624         }
7625         return ret_ref;
7626 }
7627
7628 static inline struct LDKUpdateFulfillHTLC CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
7629 CHECK(owner->result_ok);
7630         return UpdateFulfillHTLC_clone(&*owner->contents.result);
7631 }
7632 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(uint32_t owner) {
7633         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(owner & ~1);
7634         LDKUpdateFulfillHTLC ret_var = CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(owner_conv);
7635         uint32_t ret_ref = 0;
7636         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7637         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7638         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7639         ret_ref = (uintptr_t)ret_var.inner;
7640         if (ret_var.is_owned) {
7641                 ret_ref |= 1;
7642         }
7643         return ret_ref;
7644 }
7645
7646 static inline struct LDKDecodeError CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
7647 CHECK(!owner->result_ok);
7648         return DecodeError_clone(&*owner->contents.err);
7649 }
7650 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_get_err"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(uint32_t owner) {
7651         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(owner & ~1);
7652         LDKDecodeError ret_var = CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(owner_conv);
7653         uint32_t ret_ref = 0;
7654         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7655         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7656         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7657         ret_ref = (uintptr_t)ret_var.inner;
7658         if (ret_var.is_owned) {
7659                 ret_ref |= 1;
7660         }
7661         return ret_ref;
7662 }
7663
7664 static inline struct LDKUpdateAddHTLC CResult_UpdateAddHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
7665 CHECK(owner->result_ok);
7666         return UpdateAddHTLC_clone(&*owner->contents.result);
7667 }
7668 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_get_ok"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_get_ok(uint32_t owner) {
7669         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(owner & ~1);
7670         LDKUpdateAddHTLC ret_var = CResult_UpdateAddHTLCDecodeErrorZ_get_ok(owner_conv);
7671         uint32_t ret_ref = 0;
7672         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7673         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7674         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7675         ret_ref = (uintptr_t)ret_var.inner;
7676         if (ret_var.is_owned) {
7677                 ret_ref |= 1;
7678         }
7679         return ret_ref;
7680 }
7681
7682 static inline struct LDKDecodeError CResult_UpdateAddHTLCDecodeErrorZ_get_err(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
7683 CHECK(!owner->result_ok);
7684         return DecodeError_clone(&*owner->contents.err);
7685 }
7686 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_get_err"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_get_err(uint32_t owner) {
7687         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(owner & ~1);
7688         LDKDecodeError ret_var = CResult_UpdateAddHTLCDecodeErrorZ_get_err(owner_conv);
7689         uint32_t ret_ref = 0;
7690         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7691         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7692         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7693         ret_ref = (uintptr_t)ret_var.inner;
7694         if (ret_var.is_owned) {
7695                 ret_ref |= 1;
7696         }
7697         return ret_ref;
7698 }
7699
7700 static inline struct LDKPing CResult_PingDecodeErrorZ_get_ok(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
7701 CHECK(owner->result_ok);
7702         return Ping_clone(&*owner->contents.result);
7703 }
7704 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_get_ok"))) TS_CResult_PingDecodeErrorZ_get_ok(uint32_t owner) {
7705         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)(owner & ~1);
7706         LDKPing ret_var = CResult_PingDecodeErrorZ_get_ok(owner_conv);
7707         uint32_t ret_ref = 0;
7708         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7709         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7710         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7711         ret_ref = (uintptr_t)ret_var.inner;
7712         if (ret_var.is_owned) {
7713                 ret_ref |= 1;
7714         }
7715         return ret_ref;
7716 }
7717
7718 static inline struct LDKDecodeError CResult_PingDecodeErrorZ_get_err(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
7719 CHECK(!owner->result_ok);
7720         return DecodeError_clone(&*owner->contents.err);
7721 }
7722 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_get_err"))) TS_CResult_PingDecodeErrorZ_get_err(uint32_t owner) {
7723         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)(owner & ~1);
7724         LDKDecodeError ret_var = CResult_PingDecodeErrorZ_get_err(owner_conv);
7725         uint32_t ret_ref = 0;
7726         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7727         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7728         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7729         ret_ref = (uintptr_t)ret_var.inner;
7730         if (ret_var.is_owned) {
7731                 ret_ref |= 1;
7732         }
7733         return ret_ref;
7734 }
7735
7736 static inline struct LDKPong CResult_PongDecodeErrorZ_get_ok(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
7737 CHECK(owner->result_ok);
7738         return Pong_clone(&*owner->contents.result);
7739 }
7740 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_get_ok"))) TS_CResult_PongDecodeErrorZ_get_ok(uint32_t owner) {
7741         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)(owner & ~1);
7742         LDKPong ret_var = CResult_PongDecodeErrorZ_get_ok(owner_conv);
7743         uint32_t ret_ref = 0;
7744         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7745         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7746         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7747         ret_ref = (uintptr_t)ret_var.inner;
7748         if (ret_var.is_owned) {
7749                 ret_ref |= 1;
7750         }
7751         return ret_ref;
7752 }
7753
7754 static inline struct LDKDecodeError CResult_PongDecodeErrorZ_get_err(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
7755 CHECK(!owner->result_ok);
7756         return DecodeError_clone(&*owner->contents.err);
7757 }
7758 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_get_err"))) TS_CResult_PongDecodeErrorZ_get_err(uint32_t owner) {
7759         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)(owner & ~1);
7760         LDKDecodeError ret_var = CResult_PongDecodeErrorZ_get_err(owner_conv);
7761         uint32_t ret_ref = 0;
7762         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7763         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7764         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7765         ret_ref = (uintptr_t)ret_var.inner;
7766         if (ret_var.is_owned) {
7767                 ret_ref |= 1;
7768         }
7769         return ret_ref;
7770 }
7771
7772 static inline struct LDKUnsignedChannelAnnouncement CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7773 CHECK(owner->result_ok);
7774         return UnsignedChannelAnnouncement_clone(&*owner->contents.result);
7775 }
7776 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(uint32_t owner) {
7777         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(owner & ~1);
7778         LDKUnsignedChannelAnnouncement ret_var = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
7779         uint32_t ret_ref = 0;
7780         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7781         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7782         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7783         ret_ref = (uintptr_t)ret_var.inner;
7784         if (ret_var.is_owned) {
7785                 ret_ref |= 1;
7786         }
7787         return ret_ref;
7788 }
7789
7790 static inline struct LDKDecodeError CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7791 CHECK(!owner->result_ok);
7792         return DecodeError_clone(&*owner->contents.err);
7793 }
7794 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(uint32_t owner) {
7795         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(owner & ~1);
7796         LDKDecodeError ret_var = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
7797         uint32_t ret_ref = 0;
7798         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7799         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7800         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7801         ret_ref = (uintptr_t)ret_var.inner;
7802         if (ret_var.is_owned) {
7803                 ret_ref |= 1;
7804         }
7805         return ret_ref;
7806 }
7807
7808 static inline struct LDKChannelAnnouncement CResult_ChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7809 CHECK(owner->result_ok);
7810         return ChannelAnnouncement_clone(&*owner->contents.result);
7811 }
7812 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_get_ok"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_get_ok(uint32_t owner) {
7813         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(owner & ~1);
7814         LDKChannelAnnouncement ret_var = CResult_ChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
7815         uint32_t ret_ref = 0;
7816         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7817         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7818         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7819         ret_ref = (uintptr_t)ret_var.inner;
7820         if (ret_var.is_owned) {
7821                 ret_ref |= 1;
7822         }
7823         return ret_ref;
7824 }
7825
7826 static inline struct LDKDecodeError CResult_ChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7827 CHECK(!owner->result_ok);
7828         return DecodeError_clone(&*owner->contents.err);
7829 }
7830 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_get_err"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_get_err(uint32_t owner) {
7831         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(owner & ~1);
7832         LDKDecodeError ret_var = CResult_ChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
7833         uint32_t ret_ref = 0;
7834         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7835         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7836         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7837         ret_ref = (uintptr_t)ret_var.inner;
7838         if (ret_var.is_owned) {
7839                 ret_ref |= 1;
7840         }
7841         return ret_ref;
7842 }
7843
7844 static inline struct LDKUnsignedChannelUpdate CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
7845 CHECK(owner->result_ok);
7846         return UnsignedChannelUpdate_clone(&*owner->contents.result);
7847 }
7848 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(uint32_t owner) {
7849         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(owner & ~1);
7850         LDKUnsignedChannelUpdate ret_var = CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(owner_conv);
7851         uint32_t ret_ref = 0;
7852         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7853         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7854         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7855         ret_ref = (uintptr_t)ret_var.inner;
7856         if (ret_var.is_owned) {
7857                 ret_ref |= 1;
7858         }
7859         return ret_ref;
7860 }
7861
7862 static inline struct LDKDecodeError CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
7863 CHECK(!owner->result_ok);
7864         return DecodeError_clone(&*owner->contents.err);
7865 }
7866 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_get_err"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(uint32_t owner) {
7867         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(owner & ~1);
7868         LDKDecodeError ret_var = CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(owner_conv);
7869         uint32_t ret_ref = 0;
7870         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7871         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7872         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7873         ret_ref = (uintptr_t)ret_var.inner;
7874         if (ret_var.is_owned) {
7875                 ret_ref |= 1;
7876         }
7877         return ret_ref;
7878 }
7879
7880 static inline struct LDKChannelUpdate CResult_ChannelUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
7881 CHECK(owner->result_ok);
7882         return ChannelUpdate_clone(&*owner->contents.result);
7883 }
7884 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_get_ok"))) TS_CResult_ChannelUpdateDecodeErrorZ_get_ok(uint32_t owner) {
7885         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(owner & ~1);
7886         LDKChannelUpdate ret_var = CResult_ChannelUpdateDecodeErrorZ_get_ok(owner_conv);
7887         uint32_t ret_ref = 0;
7888         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7889         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7890         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7891         ret_ref = (uintptr_t)ret_var.inner;
7892         if (ret_var.is_owned) {
7893                 ret_ref |= 1;
7894         }
7895         return ret_ref;
7896 }
7897
7898 static inline struct LDKDecodeError CResult_ChannelUpdateDecodeErrorZ_get_err(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
7899 CHECK(!owner->result_ok);
7900         return DecodeError_clone(&*owner->contents.err);
7901 }
7902 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_get_err"))) TS_CResult_ChannelUpdateDecodeErrorZ_get_err(uint32_t owner) {
7903         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(owner & ~1);
7904         LDKDecodeError ret_var = CResult_ChannelUpdateDecodeErrorZ_get_err(owner_conv);
7905         uint32_t ret_ref = 0;
7906         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7907         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7908         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7909         ret_ref = (uintptr_t)ret_var.inner;
7910         if (ret_var.is_owned) {
7911                 ret_ref |= 1;
7912         }
7913         return ret_ref;
7914 }
7915
7916 static inline struct LDKErrorMessage CResult_ErrorMessageDecodeErrorZ_get_ok(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
7917 CHECK(owner->result_ok);
7918         return ErrorMessage_clone(&*owner->contents.result);
7919 }
7920 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_get_ok"))) TS_CResult_ErrorMessageDecodeErrorZ_get_ok(uint32_t owner) {
7921         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(owner & ~1);
7922         LDKErrorMessage ret_var = CResult_ErrorMessageDecodeErrorZ_get_ok(owner_conv);
7923         uint32_t ret_ref = 0;
7924         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7925         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7926         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7927         ret_ref = (uintptr_t)ret_var.inner;
7928         if (ret_var.is_owned) {
7929                 ret_ref |= 1;
7930         }
7931         return ret_ref;
7932 }
7933
7934 static inline struct LDKDecodeError CResult_ErrorMessageDecodeErrorZ_get_err(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
7935 CHECK(!owner->result_ok);
7936         return DecodeError_clone(&*owner->contents.err);
7937 }
7938 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_get_err"))) TS_CResult_ErrorMessageDecodeErrorZ_get_err(uint32_t owner) {
7939         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(owner & ~1);
7940         LDKDecodeError ret_var = CResult_ErrorMessageDecodeErrorZ_get_err(owner_conv);
7941         uint32_t ret_ref = 0;
7942         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7943         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7944         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7945         ret_ref = (uintptr_t)ret_var.inner;
7946         if (ret_var.is_owned) {
7947                 ret_ref |= 1;
7948         }
7949         return ret_ref;
7950 }
7951
7952 static inline struct LDKWarningMessage CResult_WarningMessageDecodeErrorZ_get_ok(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR owner){
7953 CHECK(owner->result_ok);
7954         return WarningMessage_clone(&*owner->contents.result);
7955 }
7956 uint32_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_get_ok"))) TS_CResult_WarningMessageDecodeErrorZ_get_ok(uint32_t owner) {
7957         LDKCResult_WarningMessageDecodeErrorZ* owner_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(owner & ~1);
7958         LDKWarningMessage ret_var = CResult_WarningMessageDecodeErrorZ_get_ok(owner_conv);
7959         uint32_t ret_ref = 0;
7960         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7961         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7962         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7963         ret_ref = (uintptr_t)ret_var.inner;
7964         if (ret_var.is_owned) {
7965                 ret_ref |= 1;
7966         }
7967         return ret_ref;
7968 }
7969
7970 static inline struct LDKDecodeError CResult_WarningMessageDecodeErrorZ_get_err(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR owner){
7971 CHECK(!owner->result_ok);
7972         return DecodeError_clone(&*owner->contents.err);
7973 }
7974 uint32_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_get_err"))) TS_CResult_WarningMessageDecodeErrorZ_get_err(uint32_t owner) {
7975         LDKCResult_WarningMessageDecodeErrorZ* owner_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(owner & ~1);
7976         LDKDecodeError ret_var = CResult_WarningMessageDecodeErrorZ_get_err(owner_conv);
7977         uint32_t ret_ref = 0;
7978         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7979         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7980         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7981         ret_ref = (uintptr_t)ret_var.inner;
7982         if (ret_var.is_owned) {
7983                 ret_ref |= 1;
7984         }
7985         return ret_ref;
7986 }
7987
7988 static inline struct LDKUnsignedNodeAnnouncement CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7989 CHECK(owner->result_ok);
7990         return UnsignedNodeAnnouncement_clone(&*owner->contents.result);
7991 }
7992 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(uint32_t owner) {
7993         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(owner & ~1);
7994         LDKUnsignedNodeAnnouncement ret_var = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
7995         uint32_t ret_ref = 0;
7996         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7997         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7998         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7999         ret_ref = (uintptr_t)ret_var.inner;
8000         if (ret_var.is_owned) {
8001                 ret_ref |= 1;
8002         }
8003         return ret_ref;
8004 }
8005
8006 static inline struct LDKDecodeError CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
8007 CHECK(!owner->result_ok);
8008         return DecodeError_clone(&*owner->contents.err);
8009 }
8010 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(uint32_t owner) {
8011         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(owner & ~1);
8012         LDKDecodeError ret_var = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(owner_conv);
8013         uint32_t ret_ref = 0;
8014         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8015         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8016         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8017         ret_ref = (uintptr_t)ret_var.inner;
8018         if (ret_var.is_owned) {
8019                 ret_ref |= 1;
8020         }
8021         return ret_ref;
8022 }
8023
8024 static inline struct LDKNodeAnnouncement CResult_NodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
8025 CHECK(owner->result_ok);
8026         return NodeAnnouncement_clone(&*owner->contents.result);
8027 }
8028 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_get_ok"))) TS_CResult_NodeAnnouncementDecodeErrorZ_get_ok(uint32_t owner) {
8029         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(owner & ~1);
8030         LDKNodeAnnouncement ret_var = CResult_NodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
8031         uint32_t ret_ref = 0;
8032         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8033         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8034         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8035         ret_ref = (uintptr_t)ret_var.inner;
8036         if (ret_var.is_owned) {
8037                 ret_ref |= 1;
8038         }
8039         return ret_ref;
8040 }
8041
8042 static inline struct LDKDecodeError CResult_NodeAnnouncementDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
8043 CHECK(!owner->result_ok);
8044         return DecodeError_clone(&*owner->contents.err);
8045 }
8046 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_get_err"))) TS_CResult_NodeAnnouncementDecodeErrorZ_get_err(uint32_t owner) {
8047         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(owner & ~1);
8048         LDKDecodeError ret_var = CResult_NodeAnnouncementDecodeErrorZ_get_err(owner_conv);
8049         uint32_t ret_ref = 0;
8050         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8051         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8052         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8053         ret_ref = (uintptr_t)ret_var.inner;
8054         if (ret_var.is_owned) {
8055                 ret_ref |= 1;
8056         }
8057         return ret_ref;
8058 }
8059
8060 static inline struct LDKQueryShortChannelIds CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
8061 CHECK(owner->result_ok);
8062         return QueryShortChannelIds_clone(&*owner->contents.result);
8063 }
8064 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_get_ok"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(uint32_t owner) {
8065         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(owner & ~1);
8066         LDKQueryShortChannelIds ret_var = CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(owner_conv);
8067         uint32_t ret_ref = 0;
8068         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8069         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8070         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8071         ret_ref = (uintptr_t)ret_var.inner;
8072         if (ret_var.is_owned) {
8073                 ret_ref |= 1;
8074         }
8075         return ret_ref;
8076 }
8077
8078 static inline struct LDKDecodeError CResult_QueryShortChannelIdsDecodeErrorZ_get_err(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
8079 CHECK(!owner->result_ok);
8080         return DecodeError_clone(&*owner->contents.err);
8081 }
8082 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_get_err"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_get_err(uint32_t owner) {
8083         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(owner & ~1);
8084         LDKDecodeError ret_var = CResult_QueryShortChannelIdsDecodeErrorZ_get_err(owner_conv);
8085         uint32_t ret_ref = 0;
8086         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8087         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8088         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8089         ret_ref = (uintptr_t)ret_var.inner;
8090         if (ret_var.is_owned) {
8091                 ret_ref |= 1;
8092         }
8093         return ret_ref;
8094 }
8095
8096 static inline struct LDKReplyShortChannelIdsEnd CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
8097 CHECK(owner->result_ok);
8098         return ReplyShortChannelIdsEnd_clone(&*owner->contents.result);
8099 }
8100 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(uint32_t owner) {
8101         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(owner & ~1);
8102         LDKReplyShortChannelIdsEnd ret_var = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(owner_conv);
8103         uint32_t ret_ref = 0;
8104         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8105         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8106         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8107         ret_ref = (uintptr_t)ret_var.inner;
8108         if (ret_var.is_owned) {
8109                 ret_ref |= 1;
8110         }
8111         return ret_ref;
8112 }
8113
8114 static inline struct LDKDecodeError CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
8115 CHECK(!owner->result_ok);
8116         return DecodeError_clone(&*owner->contents.err);
8117 }
8118 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(uint32_t owner) {
8119         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(owner & ~1);
8120         LDKDecodeError ret_var = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(owner_conv);
8121         uint32_t ret_ref = 0;
8122         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8123         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8124         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8125         ret_ref = (uintptr_t)ret_var.inner;
8126         if (ret_var.is_owned) {
8127                 ret_ref |= 1;
8128         }
8129         return ret_ref;
8130 }
8131
8132 static inline struct LDKQueryChannelRange CResult_QueryChannelRangeDecodeErrorZ_get_ok(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
8133 CHECK(owner->result_ok);
8134         return QueryChannelRange_clone(&*owner->contents.result);
8135 }
8136 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_get_ok"))) TS_CResult_QueryChannelRangeDecodeErrorZ_get_ok(uint32_t owner) {
8137         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(owner & ~1);
8138         LDKQueryChannelRange ret_var = CResult_QueryChannelRangeDecodeErrorZ_get_ok(owner_conv);
8139         uint32_t ret_ref = 0;
8140         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8141         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8142         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8143         ret_ref = (uintptr_t)ret_var.inner;
8144         if (ret_var.is_owned) {
8145                 ret_ref |= 1;
8146         }
8147         return ret_ref;
8148 }
8149
8150 static inline struct LDKDecodeError CResult_QueryChannelRangeDecodeErrorZ_get_err(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
8151 CHECK(!owner->result_ok);
8152         return DecodeError_clone(&*owner->contents.err);
8153 }
8154 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_get_err"))) TS_CResult_QueryChannelRangeDecodeErrorZ_get_err(uint32_t owner) {
8155         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(owner & ~1);
8156         LDKDecodeError ret_var = CResult_QueryChannelRangeDecodeErrorZ_get_err(owner_conv);
8157         uint32_t ret_ref = 0;
8158         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8159         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8160         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8161         ret_ref = (uintptr_t)ret_var.inner;
8162         if (ret_var.is_owned) {
8163                 ret_ref |= 1;
8164         }
8165         return ret_ref;
8166 }
8167
8168 static inline struct LDKReplyChannelRange CResult_ReplyChannelRangeDecodeErrorZ_get_ok(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
8169 CHECK(owner->result_ok);
8170         return ReplyChannelRange_clone(&*owner->contents.result);
8171 }
8172 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_get_ok"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_get_ok(uint32_t owner) {
8173         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(owner & ~1);
8174         LDKReplyChannelRange ret_var = CResult_ReplyChannelRangeDecodeErrorZ_get_ok(owner_conv);
8175         uint32_t ret_ref = 0;
8176         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8177         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8178         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8179         ret_ref = (uintptr_t)ret_var.inner;
8180         if (ret_var.is_owned) {
8181                 ret_ref |= 1;
8182         }
8183         return ret_ref;
8184 }
8185
8186 static inline struct LDKDecodeError CResult_ReplyChannelRangeDecodeErrorZ_get_err(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
8187 CHECK(!owner->result_ok);
8188         return DecodeError_clone(&*owner->contents.err);
8189 }
8190 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_get_err"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_get_err(uint32_t owner) {
8191         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(owner & ~1);
8192         LDKDecodeError ret_var = CResult_ReplyChannelRangeDecodeErrorZ_get_err(owner_conv);
8193         uint32_t ret_ref = 0;
8194         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8195         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8196         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8197         ret_ref = (uintptr_t)ret_var.inner;
8198         if (ret_var.is_owned) {
8199                 ret_ref |= 1;
8200         }
8201         return ret_ref;
8202 }
8203
8204 static inline struct LDKGossipTimestampFilter CResult_GossipTimestampFilterDecodeErrorZ_get_ok(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
8205 CHECK(owner->result_ok);
8206         return GossipTimestampFilter_clone(&*owner->contents.result);
8207 }
8208 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_get_ok"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_get_ok(uint32_t owner) {
8209         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(owner & ~1);
8210         LDKGossipTimestampFilter ret_var = CResult_GossipTimestampFilterDecodeErrorZ_get_ok(owner_conv);
8211         uint32_t ret_ref = 0;
8212         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8213         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8214         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8215         ret_ref = (uintptr_t)ret_var.inner;
8216         if (ret_var.is_owned) {
8217                 ret_ref |= 1;
8218         }
8219         return ret_ref;
8220 }
8221
8222 static inline struct LDKDecodeError CResult_GossipTimestampFilterDecodeErrorZ_get_err(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
8223 CHECK(!owner->result_ok);
8224         return DecodeError_clone(&*owner->contents.err);
8225 }
8226 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_get_err"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_get_err(uint32_t owner) {
8227         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(owner & ~1);
8228         LDKDecodeError ret_var = CResult_GossipTimestampFilterDecodeErrorZ_get_err(owner_conv);
8229         uint32_t ret_ref = 0;
8230         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8231         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8232         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8233         ret_ref = (uintptr_t)ret_var.inner;
8234         if (ret_var.is_owned) {
8235                 ret_ref |= 1;
8236         }
8237         return ret_ref;
8238 }
8239
8240 uint32_t __attribute__((export_name("TS_LDKSignOrCreationError_ty_from_ptr"))) TS_LDKSignOrCreationError_ty_from_ptr(uint32_t ptr) {
8241         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)(ptr & ~1);
8242         switch(obj->tag) {
8243                 case LDKSignOrCreationError_SignError: return 0;
8244                 case LDKSignOrCreationError_CreationError: return 1;
8245                 default: abort();
8246         }
8247 }
8248 uint32_t __attribute__((export_name("TS_LDKSignOrCreationError_CreationError_get_creation_error"))) TS_LDKSignOrCreationError_CreationError_get_creation_error(uint32_t ptr) {
8249         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)(ptr & ~1);
8250         assert(obj->tag == LDKSignOrCreationError_CreationError);
8251                         uint32_t creation_error_conv = LDKCreationError_to_js(obj->creation_error);
8252         return creation_error_conv;
8253 }
8254 static inline struct LDKInvoice CResult_InvoiceSignOrCreationErrorZ_get_ok(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR owner){
8255 CHECK(owner->result_ok);
8256         return Invoice_clone(&*owner->contents.result);
8257 }
8258 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_get_ok"))) TS_CResult_InvoiceSignOrCreationErrorZ_get_ok(uint32_t owner) {
8259         LDKCResult_InvoiceSignOrCreationErrorZ* owner_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(owner & ~1);
8260         LDKInvoice ret_var = CResult_InvoiceSignOrCreationErrorZ_get_ok(owner_conv);
8261         uint32_t ret_ref = 0;
8262         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8263         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8264         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8265         ret_ref = (uintptr_t)ret_var.inner;
8266         if (ret_var.is_owned) {
8267                 ret_ref |= 1;
8268         }
8269         return ret_ref;
8270 }
8271
8272 static inline struct LDKSignOrCreationError CResult_InvoiceSignOrCreationErrorZ_get_err(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR owner){
8273 CHECK(!owner->result_ok);
8274         return SignOrCreationError_clone(&*owner->contents.err);
8275 }
8276 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_get_err"))) TS_CResult_InvoiceSignOrCreationErrorZ_get_err(uint32_t owner) {
8277         LDKCResult_InvoiceSignOrCreationErrorZ* owner_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(owner & ~1);
8278         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
8279         *ret_copy = CResult_InvoiceSignOrCreationErrorZ_get_err(owner_conv);
8280         uint32_t ret_ref = (uintptr_t)ret_copy;
8281         return ret_ref;
8282 }
8283
8284 typedef struct LDKFilter_JCalls {
8285         atomic_size_t refcnt;
8286         uint32_t instance_ptr;
8287 } LDKFilter_JCalls;
8288 static void LDKFilter_JCalls_free(void* this_arg) {
8289         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
8290         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8291                 FREE(j_calls);
8292         }
8293 }
8294 void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
8295         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
8296         int8_tArray txid_arr = init_int8_tArray(32, __LINE__);
8297         memcpy(txid_arr->elems, *txid, 32);
8298         LDKu8slice script_pubkey_var = script_pubkey;
8299         int8_tArray script_pubkey_arr = init_int8_tArray(script_pubkey_var.datalen, __LINE__);
8300         memcpy(script_pubkey_arr->elems, script_pubkey_var.data, script_pubkey_var.datalen);
8301         js_invoke_function_uuuuuu(j_calls->instance_ptr, 32, (uint32_t)txid_arr, (uint32_t)script_pubkey_arr, 0, 0, 0, 0);
8302 }
8303 LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) {
8304         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
8305         LDKWatchedOutput output_var = output;
8306         uint32_t output_ref = 0;
8307         CHECK((((uintptr_t)output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8308         CHECK((((uintptr_t)&output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8309         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_var);
8310         output_ref = (uintptr_t)output_var.inner;
8311         if (output_var.is_owned) {
8312                 output_ref |= 1;
8313         }
8314         uint32_t ret = js_invoke_function_uuuuuu(j_calls->instance_ptr, 33, (uint32_t)output_ref, 0, 0, 0, 0, 0);
8315         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
8316         CHECK_ACCESS(ret_ptr);
8317         LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(ret_ptr);
8318         FREE((void*)ret);
8319         return ret_conv;
8320 }
8321 static void LDKFilter_JCalls_cloned(LDKFilter* new_obj) {
8322         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) new_obj->this_arg;
8323         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8324 }
8325 static inline LDKFilter LDKFilter_init (JSValue o) {
8326         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
8327         atomic_init(&calls->refcnt, 1);
8328         calls->instance_ptr = o;
8329
8330         LDKFilter ret = {
8331                 .this_arg = (void*) calls,
8332                 .register_tx = register_tx_LDKFilter_jcall,
8333                 .register_output = register_output_LDKFilter_jcall,
8334                 .free = LDKFilter_JCalls_free,
8335         };
8336         return ret;
8337 }
8338 long  __attribute__((export_name("TS_LDKFilter_new"))) TS_LDKFilter_new(JSValue o) {
8339         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
8340         *res_ptr = LDKFilter_init(o);
8341         return (long)res_ptr;
8342 }
8343 void  __attribute__((export_name("TS_Filter_register_tx"))) TS_Filter_register_tx(uint32_t this_arg, int8_tArray txid, int8_tArray script_pubkey) {
8344         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8345         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8346         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
8347         unsigned char txid_arr[32];
8348         CHECK(txid->arr_len == 32);
8349         memcpy(txid_arr, txid->elems, 32); FREE(txid);
8350         unsigned char (*txid_ref)[32] = &txid_arr;
8351         LDKu8slice script_pubkey_ref;
8352         script_pubkey_ref.datalen = script_pubkey->arr_len;
8353         script_pubkey_ref.data = script_pubkey->elems;
8354         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
8355         FREE(script_pubkey);
8356 }
8357
8358 uint32_t  __attribute__((export_name("TS_Filter_register_output"))) TS_Filter_register_output(uint32_t this_arg, uint32_t output) {
8359         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8360         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8361         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
8362         LDKWatchedOutput output_conv;
8363         output_conv.inner = (void*)(output & (~1));
8364         output_conv.is_owned = (output & 1) || (output == 0);
8365         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_conv);
8366         output_conv = WatchedOutput_clone(&output_conv);
8367         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
8368         *ret_copy = (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv);
8369         uint32_t ret_ref = (uintptr_t)ret_copy;
8370         return ret_ref;
8371 }
8372
8373 uint32_t __attribute__((export_name("TS_LDKCOption_FilterZ_ty_from_ptr"))) TS_LDKCOption_FilterZ_ty_from_ptr(uint32_t ptr) {
8374         LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)(ptr & ~1);
8375         switch(obj->tag) {
8376                 case LDKCOption_FilterZ_Some: return 0;
8377                 case LDKCOption_FilterZ_None: return 1;
8378                 default: abort();
8379         }
8380 }
8381 uint32_t __attribute__((export_name("TS_LDKCOption_FilterZ_Some_get_some"))) TS_LDKCOption_FilterZ_Some_get_some(uint32_t ptr) {
8382         LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)(ptr & ~1);
8383         assert(obj->tag == LDKCOption_FilterZ_Some);
8384                         LDKFilter* some_ret = MALLOC(sizeof(LDKFilter), "LDKFilter");
8385                         *some_ret = obj->some;
8386                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
8387                         if ((*some_ret).free == LDKFilter_JCalls_free) {
8388                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
8389                                 LDKFilter_JCalls_cloned(&(*some_ret));
8390                         }
8391         return (uint32_t)some_ret;
8392 }
8393 static inline struct LDKLockedChannelMonitor *CResult_LockedChannelMonitorNoneZ_get_ok(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
8394 CHECK(owner->result_ok);
8395         return &*owner->contents.result;
8396 }
8397 uint32_t  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_get_ok"))) TS_CResult_LockedChannelMonitorNoneZ_get_ok(uint32_t owner) {
8398         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(owner & ~1);
8399         LDKLockedChannelMonitor ret_var = *CResult_LockedChannelMonitorNoneZ_get_ok(owner_conv);
8400         uint32_t ret_ref = 0;
8401         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8402         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8403         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8404         ret_ref = (uintptr_t)ret_var.inner & ~1;
8405         return ret_ref;
8406 }
8407
8408 static inline void CResult_LockedChannelMonitorNoneZ_get_err(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
8409 CHECK(!owner->result_ok);
8410         return *owner->contents.err;
8411 }
8412 void  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_get_err"))) TS_CResult_LockedChannelMonitorNoneZ_get_err(uint32_t owner) {
8413         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(owner & ~1);
8414         CResult_LockedChannelMonitorNoneZ_get_err(owner_conv);
8415 }
8416
8417 static inline LDKCVec_OutPointZ CVec_OutPointZ_clone(const LDKCVec_OutPointZ *orig) {
8418         LDKCVec_OutPointZ ret = { .data = MALLOC(sizeof(LDKOutPoint) * orig->datalen, "LDKCVec_OutPointZ clone bytes"), .datalen = orig->datalen };
8419         for (size_t i = 0; i < ret.datalen; i++) {
8420                 ret.data[i] = OutPoint_clone(&orig->data[i]);
8421         }
8422         return ret;
8423 }
8424 typedef struct LDKMessageSendEventsProvider_JCalls {
8425         atomic_size_t refcnt;
8426         uint32_t instance_ptr;
8427 } LDKMessageSendEventsProvider_JCalls;
8428 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
8429         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
8430         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8431                 FREE(j_calls);
8432         }
8433 }
8434 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) {
8435         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
8436         uint32_tArray ret = (uint32_tArray)js_invoke_function_uuuuuu(j_calls->instance_ptr, 34, 0, 0, 0, 0, 0, 0);
8437         LDKCVec_MessageSendEventZ ret_constr;
8438         ret_constr.datalen = ret->arr_len;
8439         if (ret_constr.datalen > 0)
8440                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
8441         else
8442                 ret_constr.data = NULL;
8443         uint32_t* ret_vals = ret->elems;
8444         for (size_t s = 0; s < ret_constr.datalen; s++) {
8445                 uint32_t ret_conv_18 = ret_vals[s];
8446                 void* ret_conv_18_ptr = (void*)(((uintptr_t)ret_conv_18) & ~1);
8447                 CHECK_ACCESS(ret_conv_18_ptr);
8448                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(ret_conv_18_ptr);
8449                 FREE((void*)ret_conv_18);
8450                 ret_constr.data[s] = ret_conv_18_conv;
8451         }
8452         FREE(ret);
8453         return ret_constr;
8454 }
8455 static void LDKMessageSendEventsProvider_JCalls_cloned(LDKMessageSendEventsProvider* new_obj) {
8456         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) new_obj->this_arg;
8457         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8458 }
8459 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (JSValue o) {
8460         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
8461         atomic_init(&calls->refcnt, 1);
8462         calls->instance_ptr = o;
8463
8464         LDKMessageSendEventsProvider ret = {
8465                 .this_arg = (void*) calls,
8466                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall,
8467                 .free = LDKMessageSendEventsProvider_JCalls_free,
8468         };
8469         return ret;
8470 }
8471 long  __attribute__((export_name("TS_LDKMessageSendEventsProvider_new"))) TS_LDKMessageSendEventsProvider_new(JSValue o) {
8472         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
8473         *res_ptr = LDKMessageSendEventsProvider_init(o);
8474         return (long)res_ptr;
8475 }
8476 uint32_tArray  __attribute__((export_name("TS_MessageSendEventsProvider_get_and_clear_pending_msg_events"))) TS_MessageSendEventsProvider_get_and_clear_pending_msg_events(uint32_t this_arg) {
8477         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8478         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8479         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)this_arg_ptr;
8480         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
8481         uint32_tArray ret_arr = NULL;
8482         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
8483         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 8);
8484         for (size_t s = 0; s < ret_var.datalen; s++) {
8485                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
8486                 *ret_conv_18_copy = ret_var.data[s];
8487                 uint32_t ret_conv_18_ref = (uintptr_t)ret_conv_18_copy;
8488                 ret_arr_ptr[s] = ret_conv_18_ref;
8489         }
8490         
8491         FREE(ret_var.data);
8492         return ret_arr;
8493 }
8494
8495 typedef struct LDKEventHandler_JCalls {
8496         atomic_size_t refcnt;
8497         uint32_t instance_ptr;
8498 } LDKEventHandler_JCalls;
8499 static void LDKEventHandler_JCalls_free(void* this_arg) {
8500         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
8501         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8502                 FREE(j_calls);
8503         }
8504 }
8505 void handle_event_LDKEventHandler_jcall(const void* this_arg, const LDKEvent * event) {
8506         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
8507         LDKEvent *ret_event = MALLOC(sizeof(LDKEvent), "LDKEvent ret conversion");
8508         *ret_event = Event_clone(event);
8509         js_invoke_function_uuuuuu(j_calls->instance_ptr, 35, (uint32_t)(uint32_t)ret_event, 0, 0, 0, 0, 0);
8510 }
8511 static void LDKEventHandler_JCalls_cloned(LDKEventHandler* new_obj) {
8512         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) new_obj->this_arg;
8513         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8514 }
8515 static inline LDKEventHandler LDKEventHandler_init (JSValue o) {
8516         LDKEventHandler_JCalls *calls = MALLOC(sizeof(LDKEventHandler_JCalls), "LDKEventHandler_JCalls");
8517         atomic_init(&calls->refcnt, 1);
8518         calls->instance_ptr = o;
8519
8520         LDKEventHandler ret = {
8521                 .this_arg = (void*) calls,
8522                 .handle_event = handle_event_LDKEventHandler_jcall,
8523                 .free = LDKEventHandler_JCalls_free,
8524         };
8525         return ret;
8526 }
8527 long  __attribute__((export_name("TS_LDKEventHandler_new"))) TS_LDKEventHandler_new(JSValue o) {
8528         LDKEventHandler *res_ptr = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
8529         *res_ptr = LDKEventHandler_init(o);
8530         return (long)res_ptr;
8531 }
8532 void  __attribute__((export_name("TS_EventHandler_handle_event"))) TS_EventHandler_handle_event(uint32_t this_arg, uint32_t event) {
8533         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8534         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8535         LDKEventHandler* this_arg_conv = (LDKEventHandler*)this_arg_ptr;
8536         LDKEvent* event_conv = (LDKEvent*)event;
8537         (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv);
8538 }
8539
8540 typedef struct LDKEventsProvider_JCalls {
8541         atomic_size_t refcnt;
8542         uint32_t instance_ptr;
8543 } LDKEventsProvider_JCalls;
8544 static void LDKEventsProvider_JCalls_free(void* this_arg) {
8545         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
8546         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8547                 FREE(j_calls);
8548         }
8549 }
8550 void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEventHandler handler) {
8551         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
8552         LDKEventHandler* handler_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
8553         *handler_ret = handler;
8554         js_invoke_function_uuuuuu(j_calls->instance_ptr, 36, (uint32_t)(uint32_t)handler_ret, 0, 0, 0, 0, 0);
8555 }
8556 static void LDKEventsProvider_JCalls_cloned(LDKEventsProvider* new_obj) {
8557         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) new_obj->this_arg;
8558         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8559 }
8560 static inline LDKEventsProvider LDKEventsProvider_init (JSValue o) {
8561         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
8562         atomic_init(&calls->refcnt, 1);
8563         calls->instance_ptr = o;
8564
8565         LDKEventsProvider ret = {
8566                 .this_arg = (void*) calls,
8567                 .process_pending_events = process_pending_events_LDKEventsProvider_jcall,
8568                 .free = LDKEventsProvider_JCalls_free,
8569         };
8570         return ret;
8571 }
8572 long  __attribute__((export_name("TS_LDKEventsProvider_new"))) TS_LDKEventsProvider_new(JSValue o) {
8573         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
8574         *res_ptr = LDKEventsProvider_init(o);
8575         return (long)res_ptr;
8576 }
8577 void  __attribute__((export_name("TS_EventsProvider_process_pending_events"))) TS_EventsProvider_process_pending_events(uint32_t this_arg, uint32_t handler) {
8578         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8579         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8580         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)this_arg_ptr;
8581         void* handler_ptr = (void*)(((uintptr_t)handler) & ~1);
8582         CHECK_ACCESS(handler_ptr);
8583         LDKEventHandler handler_conv = *(LDKEventHandler*)(handler_ptr);
8584         if (handler_conv.free == LDKEventHandler_JCalls_free) {
8585                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
8586                 LDKEventHandler_JCalls_cloned(&handler_conv);
8587         }
8588         (this_arg_conv->process_pending_events)(this_arg_conv->this_arg, handler_conv);
8589 }
8590
8591 typedef struct LDKScore_JCalls {
8592         atomic_size_t refcnt;
8593         uint32_t instance_ptr;
8594 } LDKScore_JCalls;
8595 static void LDKScore_JCalls_free(void* this_arg) {
8596         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
8597         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8598                 FREE(j_calls);
8599         }
8600 }
8601 uint64_t channel_penalty_msat_LDKScore_jcall(const void* this_arg, uint64_t short_channel_id, const LDKNodeId * source, const LDKNodeId * target, LDKChannelUsage usage) {
8602         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
8603         int64_t short_channel_id_conv = short_channel_id;
8604         LDKNodeId source_var = *source;
8605         uint32_t source_ref = 0;
8606         source_var = NodeId_clone(&source_var);
8607         CHECK((((uintptr_t)source_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8608         CHECK((((uintptr_t)&source_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8609         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_var);
8610         source_ref = (uintptr_t)source_var.inner;
8611         if (source_var.is_owned) {
8612                 source_ref |= 1;
8613         }
8614         LDKNodeId target_var = *target;
8615         uint32_t target_ref = 0;
8616         target_var = NodeId_clone(&target_var);
8617         CHECK((((uintptr_t)target_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8618         CHECK((((uintptr_t)&target_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8619         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_var);
8620         target_ref = (uintptr_t)target_var.inner;
8621         if (target_var.is_owned) {
8622                 target_ref |= 1;
8623         }
8624         LDKChannelUsage usage_var = usage;
8625         uint32_t usage_ref = 0;
8626         CHECK((((uintptr_t)usage_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8627         CHECK((((uintptr_t)&usage_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8628         CHECK_INNER_FIELD_ACCESS_OR_NULL(usage_var);
8629         usage_ref = (uintptr_t)usage_var.inner;
8630         if (usage_var.is_owned) {
8631                 usage_ref |= 1;
8632         }
8633         return js_invoke_function_buuuuu(j_calls->instance_ptr, 37, (uint32_t)short_channel_id_conv, (uint32_t)source_ref, (uint32_t)target_ref, (uint32_t)usage_ref, 0, 0);
8634 }
8635 void payment_path_failed_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
8636         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
8637         LDKCVec_RouteHopZ path_var = path;
8638         uint32_tArray path_arr = NULL;
8639         path_arr = init_uint32_tArray(path_var.datalen, __LINE__);
8640         uint32_t *path_arr_ptr = (uint32_t*)(((uint8_t*)path_arr) + 8);
8641         for (size_t k = 0; k < path_var.datalen; k++) {
8642                 LDKRouteHop path_conv_10_var = path_var.data[k];
8643                 uint32_t path_conv_10_ref = 0;
8644                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8645                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8646                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
8647                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner;
8648                 if (path_conv_10_var.is_owned) {
8649                         path_conv_10_ref |= 1;
8650                 }
8651                 path_arr_ptr[k] = path_conv_10_ref;
8652         }
8653         
8654         FREE(path_var.data);
8655         int64_t short_channel_id_conv = short_channel_id;
8656         js_invoke_function_ubuuuu(j_calls->instance_ptr, 38, (uint32_t)path_arr, (uint32_t)short_channel_id_conv, 0, 0, 0, 0);
8657 }
8658 void payment_path_successful_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path) {
8659         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
8660         LDKCVec_RouteHopZ path_var = path;
8661         uint32_tArray path_arr = NULL;
8662         path_arr = init_uint32_tArray(path_var.datalen, __LINE__);
8663         uint32_t *path_arr_ptr = (uint32_t*)(((uint8_t*)path_arr) + 8);
8664         for (size_t k = 0; k < path_var.datalen; k++) {
8665                 LDKRouteHop path_conv_10_var = path_var.data[k];
8666                 uint32_t path_conv_10_ref = 0;
8667                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8668                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8669                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
8670                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner;
8671                 if (path_conv_10_var.is_owned) {
8672                         path_conv_10_ref |= 1;
8673                 }
8674                 path_arr_ptr[k] = path_conv_10_ref;
8675         }
8676         
8677         FREE(path_var.data);
8678         js_invoke_function_uuuuuu(j_calls->instance_ptr, 39, (uint32_t)path_arr, 0, 0, 0, 0, 0);
8679 }
8680 void probe_failed_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
8681         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
8682         LDKCVec_RouteHopZ path_var = path;
8683         uint32_tArray path_arr = NULL;
8684         path_arr = init_uint32_tArray(path_var.datalen, __LINE__);
8685         uint32_t *path_arr_ptr = (uint32_t*)(((uint8_t*)path_arr) + 8);
8686         for (size_t k = 0; k < path_var.datalen; k++) {
8687                 LDKRouteHop path_conv_10_var = path_var.data[k];
8688                 uint32_t path_conv_10_ref = 0;
8689                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8690                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8691                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
8692                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner;
8693                 if (path_conv_10_var.is_owned) {
8694                         path_conv_10_ref |= 1;
8695                 }
8696                 path_arr_ptr[k] = path_conv_10_ref;
8697         }
8698         
8699         FREE(path_var.data);
8700         int64_t short_channel_id_conv = short_channel_id;
8701         js_invoke_function_ubuuuu(j_calls->instance_ptr, 40, (uint32_t)path_arr, (uint32_t)short_channel_id_conv, 0, 0, 0, 0);
8702 }
8703 void probe_successful_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path) {
8704         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
8705         LDKCVec_RouteHopZ path_var = path;
8706         uint32_tArray path_arr = NULL;
8707         path_arr = init_uint32_tArray(path_var.datalen, __LINE__);
8708         uint32_t *path_arr_ptr = (uint32_t*)(((uint8_t*)path_arr) + 8);
8709         for (size_t k = 0; k < path_var.datalen; k++) {
8710                 LDKRouteHop path_conv_10_var = path_var.data[k];
8711                 uint32_t path_conv_10_ref = 0;
8712                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8713                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8714                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
8715                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner;
8716                 if (path_conv_10_var.is_owned) {
8717                         path_conv_10_ref |= 1;
8718                 }
8719                 path_arr_ptr[k] = path_conv_10_ref;
8720         }
8721         
8722         FREE(path_var.data);
8723         js_invoke_function_uuuuuu(j_calls->instance_ptr, 41, (uint32_t)path_arr, 0, 0, 0, 0, 0);
8724 }
8725 LDKCVec_u8Z write_LDKScore_jcall(const void* this_arg) {
8726         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
8727         int8_tArray ret = (int8_tArray)js_invoke_function_uuuuuu(j_calls->instance_ptr, 42, 0, 0, 0, 0, 0, 0);
8728         LDKCVec_u8Z ret_ref;
8729         ret_ref.datalen = ret->arr_len;
8730         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
8731         memcpy(ret_ref.data, ret->elems, ret_ref.datalen); FREE(ret);
8732         return ret_ref;
8733 }
8734 static void LDKScore_JCalls_cloned(LDKScore* new_obj) {
8735         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) new_obj->this_arg;
8736         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8737 }
8738 static inline LDKScore LDKScore_init (JSValue o) {
8739         LDKScore_JCalls *calls = MALLOC(sizeof(LDKScore_JCalls), "LDKScore_JCalls");
8740         atomic_init(&calls->refcnt, 1);
8741         calls->instance_ptr = o;
8742
8743         LDKScore ret = {
8744                 .this_arg = (void*) calls,
8745                 .channel_penalty_msat = channel_penalty_msat_LDKScore_jcall,
8746                 .payment_path_failed = payment_path_failed_LDKScore_jcall,
8747                 .payment_path_successful = payment_path_successful_LDKScore_jcall,
8748                 .probe_failed = probe_failed_LDKScore_jcall,
8749                 .probe_successful = probe_successful_LDKScore_jcall,
8750                 .write = write_LDKScore_jcall,
8751                 .free = LDKScore_JCalls_free,
8752         };
8753         return ret;
8754 }
8755 long  __attribute__((export_name("TS_LDKScore_new"))) TS_LDKScore_new(JSValue o) {
8756         LDKScore *res_ptr = MALLOC(sizeof(LDKScore), "LDKScore");
8757         *res_ptr = LDKScore_init(o);
8758         return (long)res_ptr;
8759 }
8760 int64_t  __attribute__((export_name("TS_Score_channel_penalty_msat"))) TS_Score_channel_penalty_msat(uint32_t this_arg, int64_t short_channel_id, uint32_t source, uint32_t target, uint32_t usage) {
8761         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8762         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8763         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
8764         LDKNodeId source_conv;
8765         source_conv.inner = (void*)(source & (~1));
8766         source_conv.is_owned = false;
8767         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_conv);
8768         LDKNodeId target_conv;
8769         target_conv.inner = (void*)(target & (~1));
8770         target_conv.is_owned = false;
8771         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
8772         LDKChannelUsage usage_conv;
8773         usage_conv.inner = (void*)(usage & (~1));
8774         usage_conv.is_owned = (usage & 1) || (usage == 0);
8775         CHECK_INNER_FIELD_ACCESS_OR_NULL(usage_conv);
8776         usage_conv = ChannelUsage_clone(&usage_conv);
8777         int64_t ret_conv = (this_arg_conv->channel_penalty_msat)(this_arg_conv->this_arg, short_channel_id, &source_conv, &target_conv, usage_conv);
8778         return ret_conv;
8779 }
8780
8781 void  __attribute__((export_name("TS_Score_payment_path_failed"))) TS_Score_payment_path_failed(uint32_t this_arg, uint32_tArray path, int64_t short_channel_id) {
8782         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8783         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8784         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
8785         LDKCVec_RouteHopZ path_constr;
8786         path_constr.datalen = path->arr_len;
8787         if (path_constr.datalen > 0)
8788                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
8789         else
8790                 path_constr.data = NULL;
8791         uint32_t* path_vals = path->elems;
8792         for (size_t k = 0; k < path_constr.datalen; k++) {
8793                 uint32_t path_conv_10 = path_vals[k];
8794                 LDKRouteHop path_conv_10_conv;
8795                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
8796                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
8797                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
8798                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
8799                 path_constr.data[k] = path_conv_10_conv;
8800         }
8801         FREE(path);
8802         (this_arg_conv->payment_path_failed)(this_arg_conv->this_arg, path_constr, short_channel_id);
8803 }
8804
8805 void  __attribute__((export_name("TS_Score_payment_path_successful"))) TS_Score_payment_path_successful(uint32_t this_arg, uint32_tArray path) {
8806         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8807         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8808         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
8809         LDKCVec_RouteHopZ path_constr;
8810         path_constr.datalen = path->arr_len;
8811         if (path_constr.datalen > 0)
8812                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
8813         else
8814                 path_constr.data = NULL;
8815         uint32_t* path_vals = path->elems;
8816         for (size_t k = 0; k < path_constr.datalen; k++) {
8817                 uint32_t path_conv_10 = path_vals[k];
8818                 LDKRouteHop path_conv_10_conv;
8819                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
8820                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
8821                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
8822                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
8823                 path_constr.data[k] = path_conv_10_conv;
8824         }
8825         FREE(path);
8826         (this_arg_conv->payment_path_successful)(this_arg_conv->this_arg, path_constr);
8827 }
8828
8829 void  __attribute__((export_name("TS_Score_probe_failed"))) TS_Score_probe_failed(uint32_t this_arg, uint32_tArray path, int64_t short_channel_id) {
8830         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8831         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8832         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
8833         LDKCVec_RouteHopZ path_constr;
8834         path_constr.datalen = path->arr_len;
8835         if (path_constr.datalen > 0)
8836                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
8837         else
8838                 path_constr.data = NULL;
8839         uint32_t* path_vals = path->elems;
8840         for (size_t k = 0; k < path_constr.datalen; k++) {
8841                 uint32_t path_conv_10 = path_vals[k];
8842                 LDKRouteHop path_conv_10_conv;
8843                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
8844                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
8845                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
8846                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
8847                 path_constr.data[k] = path_conv_10_conv;
8848         }
8849         FREE(path);
8850         (this_arg_conv->probe_failed)(this_arg_conv->this_arg, path_constr, short_channel_id);
8851 }
8852
8853 void  __attribute__((export_name("TS_Score_probe_successful"))) TS_Score_probe_successful(uint32_t this_arg, uint32_tArray path) {
8854         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8855         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8856         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
8857         LDKCVec_RouteHopZ path_constr;
8858         path_constr.datalen = path->arr_len;
8859         if (path_constr.datalen > 0)
8860                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
8861         else
8862                 path_constr.data = NULL;
8863         uint32_t* path_vals = path->elems;
8864         for (size_t k = 0; k < path_constr.datalen; k++) {
8865                 uint32_t path_conv_10 = path_vals[k];
8866                 LDKRouteHop path_conv_10_conv;
8867                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
8868                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
8869                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
8870                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
8871                 path_constr.data[k] = path_conv_10_conv;
8872         }
8873         FREE(path);
8874         (this_arg_conv->probe_successful)(this_arg_conv->this_arg, path_constr);
8875 }
8876
8877 int8_tArray  __attribute__((export_name("TS_Score_write"))) TS_Score_write(uint32_t this_arg) {
8878         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8879         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8880         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
8881         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
8882         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
8883         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
8884         CVec_u8Z_free(ret_var);
8885         return ret_arr;
8886 }
8887
8888 typedef struct LDKPersister_JCalls {
8889         atomic_size_t refcnt;
8890         uint32_t instance_ptr;
8891 } LDKPersister_JCalls;
8892 static void LDKPersister_JCalls_free(void* this_arg) {
8893         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
8894         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8895                 FREE(j_calls);
8896         }
8897 }
8898 LDKCResult_NoneErrorZ persist_manager_LDKPersister_jcall(const void* this_arg, const LDKChannelManager * channel_manager) {
8899         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
8900         LDKChannelManager channel_manager_var = *channel_manager;
8901         uint32_t channel_manager_ref = 0;
8902         // WARNING: we may need a move here but no clone is available for LDKChannelManager
8903         CHECK((((uintptr_t)channel_manager_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8904         CHECK((((uintptr_t)&channel_manager_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8905         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_var);
8906         channel_manager_ref = (uintptr_t)channel_manager_var.inner;
8907         if (channel_manager_var.is_owned) {
8908                 channel_manager_ref |= 1;
8909         }
8910         uint32_t ret = js_invoke_function_uuuuuu(j_calls->instance_ptr, 43, (uint32_t)channel_manager_ref, 0, 0, 0, 0, 0);
8911         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
8912         CHECK_ACCESS(ret_ptr);
8913         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
8914         FREE((void*)ret);
8915         return ret_conv;
8916 }
8917 LDKCResult_NoneErrorZ persist_graph_LDKPersister_jcall(const void* this_arg, const LDKNetworkGraph * network_graph) {
8918         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
8919         LDKNetworkGraph network_graph_var = *network_graph;
8920         uint32_t network_graph_ref = 0;
8921         // WARNING: we may need a move here but no clone is available for LDKNetworkGraph
8922         CHECK((((uintptr_t)network_graph_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8923         CHECK((((uintptr_t)&network_graph_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8924         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_var);
8925         network_graph_ref = (uintptr_t)network_graph_var.inner;
8926         if (network_graph_var.is_owned) {
8927                 network_graph_ref |= 1;
8928         }
8929         uint32_t ret = js_invoke_function_uuuuuu(j_calls->instance_ptr, 44, (uint32_t)network_graph_ref, 0, 0, 0, 0, 0);
8930         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
8931         CHECK_ACCESS(ret_ptr);
8932         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
8933         FREE((void*)ret);
8934         return ret_conv;
8935 }
8936 LDKCResult_NoneErrorZ persist_scorer_LDKPersister_jcall(const void* this_arg, const LDKMultiThreadedLockableScore * scorer) {
8937         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
8938         LDKMultiThreadedLockableScore scorer_var = *scorer;
8939         uint32_t scorer_ref = 0;
8940         // WARNING: we may need a move here but no clone is available for LDKMultiThreadedLockableScore
8941         CHECK((((uintptr_t)scorer_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8942         CHECK((((uintptr_t)&scorer_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8943         CHECK_INNER_FIELD_ACCESS_OR_NULL(scorer_var);
8944         scorer_ref = (uintptr_t)scorer_var.inner;
8945         if (scorer_var.is_owned) {
8946                 scorer_ref |= 1;
8947         }
8948         uint32_t ret = js_invoke_function_uuuuuu(j_calls->instance_ptr, 45, (uint32_t)scorer_ref, 0, 0, 0, 0, 0);
8949         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
8950         CHECK_ACCESS(ret_ptr);
8951         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
8952         FREE((void*)ret);
8953         return ret_conv;
8954 }
8955 static void LDKPersister_JCalls_cloned(LDKPersister* new_obj) {
8956         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) new_obj->this_arg;
8957         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8958 }
8959 static inline LDKPersister LDKPersister_init (JSValue o) {
8960         LDKPersister_JCalls *calls = MALLOC(sizeof(LDKPersister_JCalls), "LDKPersister_JCalls");
8961         atomic_init(&calls->refcnt, 1);
8962         calls->instance_ptr = o;
8963
8964         LDKPersister ret = {
8965                 .this_arg = (void*) calls,
8966                 .persist_manager = persist_manager_LDKPersister_jcall,
8967                 .persist_graph = persist_graph_LDKPersister_jcall,
8968                 .persist_scorer = persist_scorer_LDKPersister_jcall,
8969                 .free = LDKPersister_JCalls_free,
8970         };
8971         return ret;
8972 }
8973 long  __attribute__((export_name("TS_LDKPersister_new"))) TS_LDKPersister_new(JSValue o) {
8974         LDKPersister *res_ptr = MALLOC(sizeof(LDKPersister), "LDKPersister");
8975         *res_ptr = LDKPersister_init(o);
8976         return (long)res_ptr;
8977 }
8978 uint32_t  __attribute__((export_name("TS_Persister_persist_manager"))) TS_Persister_persist_manager(uint32_t this_arg, uint32_t channel_manager) {
8979         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8980         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8981         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
8982         LDKChannelManager channel_manager_conv;
8983         channel_manager_conv.inner = (void*)(channel_manager & (~1));
8984         channel_manager_conv.is_owned = false;
8985         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_conv);
8986         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
8987         *ret_conv = (this_arg_conv->persist_manager)(this_arg_conv->this_arg, &channel_manager_conv);
8988         return (uint32_t)ret_conv;
8989 }
8990
8991 uint32_t  __attribute__((export_name("TS_Persister_persist_graph"))) TS_Persister_persist_graph(uint32_t this_arg, uint32_t network_graph) {
8992         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8993         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8994         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
8995         LDKNetworkGraph network_graph_conv;
8996         network_graph_conv.inner = (void*)(network_graph & (~1));
8997         network_graph_conv.is_owned = false;
8998         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
8999         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
9000         *ret_conv = (this_arg_conv->persist_graph)(this_arg_conv->this_arg, &network_graph_conv);
9001         return (uint32_t)ret_conv;
9002 }
9003
9004 uint32_t  __attribute__((export_name("TS_Persister_persist_scorer"))) TS_Persister_persist_scorer(uint32_t this_arg, uint32_t scorer) {
9005         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9006         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9007         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
9008         LDKMultiThreadedLockableScore scorer_conv;
9009         scorer_conv.inner = (void*)(scorer & (~1));
9010         scorer_conv.is_owned = false;
9011         CHECK_INNER_FIELD_ACCESS_OR_NULL(scorer_conv);
9012         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
9013         *ret_conv = (this_arg_conv->persist_scorer)(this_arg_conv->this_arg, &scorer_conv);
9014         return (uint32_t)ret_conv;
9015 }
9016
9017 typedef struct LDKListen_JCalls {
9018         atomic_size_t refcnt;
9019         uint32_t instance_ptr;
9020 } LDKListen_JCalls;
9021 static void LDKListen_JCalls_free(void* this_arg) {
9022         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
9023         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9024                 FREE(j_calls);
9025         }
9026 }
9027 void filtered_block_connected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
9028         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
9029         int8_tArray header_arr = init_int8_tArray(80, __LINE__);
9030         memcpy(header_arr->elems, *header, 80);
9031         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
9032         uint32_tArray txdata_arr = NULL;
9033         txdata_arr = init_uint32_tArray(txdata_var.datalen, __LINE__);
9034         uint32_t *txdata_arr_ptr = (uint32_t*)(((uint8_t*)txdata_arr) + 8);
9035         for (size_t c = 0; c < txdata_var.datalen; c++) {
9036                 LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
9037                 *txdata_conv_28_conv = txdata_var.data[c];
9038                 txdata_arr_ptr[c] = ((uint32_t)txdata_conv_28_conv);
9039         }
9040         
9041         FREE(txdata_var.data);
9042         int32_t height_conv = height;
9043         js_invoke_function_uuuuuu(j_calls->instance_ptr, 46, (uint32_t)header_arr, (uint32_t)txdata_arr, (uint32_t)height_conv, 0, 0, 0);
9044 }
9045 void block_connected_LDKListen_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
9046         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
9047         LDKu8slice block_var = block;
9048         int8_tArray block_arr = init_int8_tArray(block_var.datalen, __LINE__);
9049         memcpy(block_arr->elems, block_var.data, block_var.datalen);
9050         int32_t height_conv = height;
9051         js_invoke_function_uuuuuu(j_calls->instance_ptr, 47, (uint32_t)block_arr, (uint32_t)height_conv, 0, 0, 0, 0);
9052 }
9053 void block_disconnected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
9054         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
9055         int8_tArray header_arr = init_int8_tArray(80, __LINE__);
9056         memcpy(header_arr->elems, *header, 80);
9057         int32_t height_conv = height;
9058         js_invoke_function_uuuuuu(j_calls->instance_ptr, 48, (uint32_t)header_arr, (uint32_t)height_conv, 0, 0, 0, 0);
9059 }
9060 static void LDKListen_JCalls_cloned(LDKListen* new_obj) {
9061         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) new_obj->this_arg;
9062         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9063 }
9064 static inline LDKListen LDKListen_init (JSValue o) {
9065         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
9066         atomic_init(&calls->refcnt, 1);
9067         calls->instance_ptr = o;
9068
9069         LDKListen ret = {
9070                 .this_arg = (void*) calls,
9071                 .filtered_block_connected = filtered_block_connected_LDKListen_jcall,
9072                 .block_connected = block_connected_LDKListen_jcall,
9073                 .block_disconnected = block_disconnected_LDKListen_jcall,
9074                 .free = LDKListen_JCalls_free,
9075         };
9076         return ret;
9077 }
9078 long  __attribute__((export_name("TS_LDKListen_new"))) TS_LDKListen_new(JSValue o) {
9079         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
9080         *res_ptr = LDKListen_init(o);
9081         return (long)res_ptr;
9082 }
9083 void  __attribute__((export_name("TS_Listen_filtered_block_connected"))) TS_Listen_filtered_block_connected(uint32_t this_arg, int8_tArray header, uint32_tArray txdata, int32_t height) {
9084         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9085         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9086         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
9087         unsigned char header_arr[80];
9088         CHECK(header->arr_len == 80);
9089         memcpy(header_arr, header->elems, 80); FREE(header);
9090         unsigned char (*header_ref)[80] = &header_arr;
9091         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
9092         txdata_constr.datalen = txdata->arr_len;
9093         if (txdata_constr.datalen > 0)
9094                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
9095         else
9096                 txdata_constr.data = NULL;
9097         uint32_t* txdata_vals = txdata->elems;
9098         for (size_t c = 0; c < txdata_constr.datalen; c++) {
9099                 uint32_t txdata_conv_28 = txdata_vals[c];
9100                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
9101                 CHECK_ACCESS(txdata_conv_28_ptr);
9102                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
9103                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
9104                 txdata_constr.data[c] = txdata_conv_28_conv;
9105         }
9106         FREE(txdata);
9107         (this_arg_conv->filtered_block_connected)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
9108 }
9109
9110 void  __attribute__((export_name("TS_Listen_block_connected"))) TS_Listen_block_connected(uint32_t this_arg, int8_tArray block, int32_t height) {
9111         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9112         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9113         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
9114         LDKu8slice block_ref;
9115         block_ref.datalen = block->arr_len;
9116         block_ref.data = block->elems;
9117         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
9118         FREE(block);
9119 }
9120
9121 void  __attribute__((export_name("TS_Listen_block_disconnected"))) TS_Listen_block_disconnected(uint32_t this_arg, int8_tArray header, int32_t height) {
9122         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9123         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9124         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
9125         unsigned char header_arr[80];
9126         CHECK(header->arr_len == 80);
9127         memcpy(header_arr, header->elems, 80); FREE(header);
9128         unsigned char (*header_ref)[80] = &header_arr;
9129         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
9130 }
9131
9132 typedef struct LDKConfirm_JCalls {
9133         atomic_size_t refcnt;
9134         uint32_t instance_ptr;
9135 } LDKConfirm_JCalls;
9136 static void LDKConfirm_JCalls_free(void* this_arg) {
9137         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
9138         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9139                 FREE(j_calls);
9140         }
9141 }
9142 void transactions_confirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
9143         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
9144         int8_tArray header_arr = init_int8_tArray(80, __LINE__);
9145         memcpy(header_arr->elems, *header, 80);
9146         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
9147         uint32_tArray txdata_arr = NULL;
9148         txdata_arr = init_uint32_tArray(txdata_var.datalen, __LINE__);
9149         uint32_t *txdata_arr_ptr = (uint32_t*)(((uint8_t*)txdata_arr) + 8);
9150         for (size_t c = 0; c < txdata_var.datalen; c++) {
9151                 LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
9152                 *txdata_conv_28_conv = txdata_var.data[c];
9153                 txdata_arr_ptr[c] = ((uint32_t)txdata_conv_28_conv);
9154         }
9155         
9156         FREE(txdata_var.data);
9157         int32_t height_conv = height;
9158         js_invoke_function_uuuuuu(j_calls->instance_ptr, 49, (uint32_t)header_arr, (uint32_t)txdata_arr, (uint32_t)height_conv, 0, 0, 0);
9159 }
9160 void transaction_unconfirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* txid)[32]) {
9161         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
9162         int8_tArray txid_arr = init_int8_tArray(32, __LINE__);
9163         memcpy(txid_arr->elems, *txid, 32);
9164         js_invoke_function_uuuuuu(j_calls->instance_ptr, 50, (uint32_t)txid_arr, 0, 0, 0, 0, 0);
9165 }
9166 void best_block_updated_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
9167         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
9168         int8_tArray header_arr = init_int8_tArray(80, __LINE__);
9169         memcpy(header_arr->elems, *header, 80);
9170         int32_t height_conv = height;
9171         js_invoke_function_uuuuuu(j_calls->instance_ptr, 51, (uint32_t)header_arr, (uint32_t)height_conv, 0, 0, 0, 0);
9172 }
9173 LDKCVec_TxidZ get_relevant_txids_LDKConfirm_jcall(const void* this_arg) {
9174         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
9175         ptrArray ret = (ptrArray)js_invoke_function_uuuuuu(j_calls->instance_ptr, 52, 0, 0, 0, 0, 0, 0);
9176         LDKCVec_TxidZ ret_constr;
9177         ret_constr.datalen = ret->arr_len;
9178         if (ret_constr.datalen > 0)
9179                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
9180         else
9181                 ret_constr.data = NULL;
9182         int8_tArray* ret_vals = (void*) ret->elems;
9183         for (size_t m = 0; m < ret_constr.datalen; m++) {
9184                 int8_tArray ret_conv_12 = ret_vals[m];
9185                 LDKThirtyTwoBytes ret_conv_12_ref;
9186                 CHECK(ret_conv_12->arr_len == 32);
9187                 memcpy(ret_conv_12_ref.data, ret_conv_12->elems, 32); FREE(ret_conv_12);
9188                 ret_constr.data[m] = ret_conv_12_ref;
9189         }
9190         FREE(ret);
9191         return ret_constr;
9192 }
9193 static void LDKConfirm_JCalls_cloned(LDKConfirm* new_obj) {
9194         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) new_obj->this_arg;
9195         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9196 }
9197 static inline LDKConfirm LDKConfirm_init (JSValue o) {
9198         LDKConfirm_JCalls *calls = MALLOC(sizeof(LDKConfirm_JCalls), "LDKConfirm_JCalls");
9199         atomic_init(&calls->refcnt, 1);
9200         calls->instance_ptr = o;
9201
9202         LDKConfirm ret = {
9203                 .this_arg = (void*) calls,
9204                 .transactions_confirmed = transactions_confirmed_LDKConfirm_jcall,
9205                 .transaction_unconfirmed = transaction_unconfirmed_LDKConfirm_jcall,
9206                 .best_block_updated = best_block_updated_LDKConfirm_jcall,
9207                 .get_relevant_txids = get_relevant_txids_LDKConfirm_jcall,
9208                 .free = LDKConfirm_JCalls_free,
9209         };
9210         return ret;
9211 }
9212 long  __attribute__((export_name("TS_LDKConfirm_new"))) TS_LDKConfirm_new(JSValue o) {
9213         LDKConfirm *res_ptr = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
9214         *res_ptr = LDKConfirm_init(o);
9215         return (long)res_ptr;
9216 }
9217 void  __attribute__((export_name("TS_Confirm_transactions_confirmed"))) TS_Confirm_transactions_confirmed(uint32_t this_arg, int8_tArray header, uint32_tArray txdata, int32_t height) {
9218         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9219         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9220         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
9221         unsigned char header_arr[80];
9222         CHECK(header->arr_len == 80);
9223         memcpy(header_arr, header->elems, 80); FREE(header);
9224         unsigned char (*header_ref)[80] = &header_arr;
9225         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
9226         txdata_constr.datalen = txdata->arr_len;
9227         if (txdata_constr.datalen > 0)
9228                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
9229         else
9230                 txdata_constr.data = NULL;
9231         uint32_t* txdata_vals = txdata->elems;
9232         for (size_t c = 0; c < txdata_constr.datalen; c++) {
9233                 uint32_t txdata_conv_28 = txdata_vals[c];
9234                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
9235                 CHECK_ACCESS(txdata_conv_28_ptr);
9236                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
9237                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
9238                 txdata_constr.data[c] = txdata_conv_28_conv;
9239         }
9240         FREE(txdata);
9241         (this_arg_conv->transactions_confirmed)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
9242 }
9243
9244 void  __attribute__((export_name("TS_Confirm_transaction_unconfirmed"))) TS_Confirm_transaction_unconfirmed(uint32_t this_arg, int8_tArray txid) {
9245         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9246         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9247         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
9248         unsigned char txid_arr[32];
9249         CHECK(txid->arr_len == 32);
9250         memcpy(txid_arr, txid->elems, 32); FREE(txid);
9251         unsigned char (*txid_ref)[32] = &txid_arr;
9252         (this_arg_conv->transaction_unconfirmed)(this_arg_conv->this_arg, txid_ref);
9253 }
9254
9255 void  __attribute__((export_name("TS_Confirm_best_block_updated"))) TS_Confirm_best_block_updated(uint32_t this_arg, int8_tArray header, int32_t height) {
9256         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9257         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9258         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
9259         unsigned char header_arr[80];
9260         CHECK(header->arr_len == 80);
9261         memcpy(header_arr, header->elems, 80); FREE(header);
9262         unsigned char (*header_ref)[80] = &header_arr;
9263         (this_arg_conv->best_block_updated)(this_arg_conv->this_arg, header_ref, height);
9264 }
9265
9266 ptrArray  __attribute__((export_name("TS_Confirm_get_relevant_txids"))) TS_Confirm_get_relevant_txids(uint32_t this_arg) {
9267         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9268         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9269         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
9270         LDKCVec_TxidZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg);
9271         ptrArray ret_arr = NULL;
9272         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
9273         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 8);
9274         for (size_t m = 0; m < ret_var.datalen; m++) {
9275                 int8_tArray ret_conv_12_arr = init_int8_tArray(32, __LINE__);
9276                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].data, 32);
9277                 ret_arr_ptr[m] = ret_conv_12_arr;
9278         }
9279         
9280         FREE(ret_var.data);
9281         return ret_arr;
9282 }
9283
9284 typedef struct LDKPersist_JCalls {
9285         atomic_size_t refcnt;
9286         uint32_t instance_ptr;
9287 } LDKPersist_JCalls;
9288 static void LDKPersist_JCalls_free(void* this_arg) {
9289         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
9290         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9291                 FREE(j_calls);
9292         }
9293 }
9294 LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
9295         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
9296         LDKOutPoint channel_id_var = channel_id;
9297         uint32_t channel_id_ref = 0;
9298         CHECK((((uintptr_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9299         CHECK((((uintptr_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9300         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
9301         channel_id_ref = (uintptr_t)channel_id_var.inner;
9302         if (channel_id_var.is_owned) {
9303                 channel_id_ref |= 1;
9304         }
9305         LDKChannelMonitor data_var = *data;
9306         uint32_t data_ref = 0;
9307         data_var = ChannelMonitor_clone(&data_var);
9308         CHECK((((uintptr_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9309         CHECK((((uintptr_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9310         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
9311         data_ref = (uintptr_t)data_var.inner;
9312         if (data_var.is_owned) {
9313                 data_ref |= 1;
9314         }
9315         LDKMonitorUpdateId update_id_var = update_id;
9316         uint32_t update_id_ref = 0;
9317         CHECK((((uintptr_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9318         CHECK((((uintptr_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9319         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
9320         update_id_ref = (uintptr_t)update_id_var.inner;
9321         if (update_id_var.is_owned) {
9322                 update_id_ref |= 1;
9323         }
9324         uint32_t ret = js_invoke_function_uuuuuu(j_calls->instance_ptr, 53, (uint32_t)channel_id_ref, (uint32_t)data_ref, (uint32_t)update_id_ref, 0, 0, 0);
9325         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9326         CHECK_ACCESS(ret_ptr);
9327         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
9328         FREE((void*)ret);
9329         return ret_conv;
9330 }
9331 LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
9332         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
9333         LDKOutPoint channel_id_var = channel_id;
9334         uint32_t channel_id_ref = 0;
9335         CHECK((((uintptr_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9336         CHECK((((uintptr_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9337         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
9338         channel_id_ref = (uintptr_t)channel_id_var.inner;
9339         if (channel_id_var.is_owned) {
9340                 channel_id_ref |= 1;
9341         }
9342         LDKChannelMonitorUpdate update_var = *update;
9343         uint32_t update_ref = 0;
9344         if ((uintptr_t)update_var.inner > 4096) {
9345                 update_var = ChannelMonitorUpdate_clone(&update_var);
9346                 CHECK((((uintptr_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9347                 CHECK((((uintptr_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9348         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
9349                 update_ref = (uintptr_t)update_var.inner;
9350                 if (update_var.is_owned) {
9351                         update_ref |= 1;
9352                 }
9353         }
9354         LDKChannelMonitor data_var = *data;
9355         uint32_t data_ref = 0;
9356         data_var = ChannelMonitor_clone(&data_var);
9357         CHECK((((uintptr_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9358         CHECK((((uintptr_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9359         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
9360         data_ref = (uintptr_t)data_var.inner;
9361         if (data_var.is_owned) {
9362                 data_ref |= 1;
9363         }
9364         LDKMonitorUpdateId update_id_var = update_id;
9365         uint32_t update_id_ref = 0;
9366         CHECK((((uintptr_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9367         CHECK((((uintptr_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9368         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
9369         update_id_ref = (uintptr_t)update_id_var.inner;
9370         if (update_id_var.is_owned) {
9371                 update_id_ref |= 1;
9372         }
9373         uint32_t ret = js_invoke_function_uuuuuu(j_calls->instance_ptr, 54, (uint32_t)channel_id_ref, (uint32_t)update_ref, (uint32_t)data_ref, (uint32_t)update_id_ref, 0, 0);
9374         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9375         CHECK_ACCESS(ret_ptr);
9376         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
9377         FREE((void*)ret);
9378         return ret_conv;
9379 }
9380 static void LDKPersist_JCalls_cloned(LDKPersist* new_obj) {
9381         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) new_obj->this_arg;
9382         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9383 }
9384 static inline LDKPersist LDKPersist_init (JSValue o) {
9385         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
9386         atomic_init(&calls->refcnt, 1);
9387         calls->instance_ptr = o;
9388
9389         LDKPersist ret = {
9390                 .this_arg = (void*) calls,
9391                 .persist_new_channel = persist_new_channel_LDKPersist_jcall,
9392                 .update_persisted_channel = update_persisted_channel_LDKPersist_jcall,
9393                 .free = LDKPersist_JCalls_free,
9394         };
9395         return ret;
9396 }
9397 long  __attribute__((export_name("TS_LDKPersist_new"))) TS_LDKPersist_new(JSValue o) {
9398         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
9399         *res_ptr = LDKPersist_init(o);
9400         return (long)res_ptr;
9401 }
9402 uint32_t  __attribute__((export_name("TS_Persist_persist_new_channel"))) TS_Persist_persist_new_channel(uint32_t this_arg, uint32_t channel_id, uint32_t data, uint32_t update_id) {
9403         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9404         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9405         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
9406         LDKOutPoint channel_id_conv;
9407         channel_id_conv.inner = (void*)(channel_id & (~1));
9408         channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
9409         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
9410         channel_id_conv = OutPoint_clone(&channel_id_conv);
9411         LDKChannelMonitor data_conv;
9412         data_conv.inner = (void*)(data & (~1));
9413         data_conv.is_owned = false;
9414         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
9415         LDKMonitorUpdateId update_id_conv;
9416         update_id_conv.inner = (void*)(update_id & (~1));
9417         update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
9418         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
9419         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
9420         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
9421         *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, channel_id_conv, &data_conv, update_id_conv);
9422         return (uint32_t)ret_conv;
9423 }
9424
9425 uint32_t  __attribute__((export_name("TS_Persist_update_persisted_channel"))) TS_Persist_update_persisted_channel(uint32_t this_arg, uint32_t channel_id, uint32_t update, uint32_t data, uint32_t update_id) {
9426         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9427         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9428         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
9429         LDKOutPoint channel_id_conv;
9430         channel_id_conv.inner = (void*)(channel_id & (~1));
9431         channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
9432         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
9433         channel_id_conv = OutPoint_clone(&channel_id_conv);
9434         LDKChannelMonitorUpdate update_conv;
9435         update_conv.inner = (void*)(update & (~1));
9436         update_conv.is_owned = false;
9437         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
9438         LDKChannelMonitor data_conv;
9439         data_conv.inner = (void*)(data & (~1));
9440         data_conv.is_owned = false;
9441         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
9442         LDKMonitorUpdateId update_id_conv;
9443         update_id_conv.inner = (void*)(update_id & (~1));
9444         update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
9445         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
9446         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
9447         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
9448         *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, channel_id_conv, &update_conv, &data_conv, update_id_conv);
9449         return (uint32_t)ret_conv;
9450 }
9451
9452 typedef struct LDKChannelMessageHandler_JCalls {
9453         atomic_size_t refcnt;
9454         uint32_t instance_ptr;
9455         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
9456 } LDKChannelMessageHandler_JCalls;
9457 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
9458         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9459         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9460                 FREE(j_calls);
9461         }
9462 }
9463 void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
9464         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9465         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9466         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9467         LDKInitFeatures their_features_var = their_features;
9468         uint32_t their_features_ref = 0;
9469         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9470         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9471         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
9472         their_features_ref = (uintptr_t)their_features_var.inner;
9473         if (their_features_var.is_owned) {
9474                 their_features_ref |= 1;
9475         }
9476         LDKOpenChannel msg_var = *msg;
9477         uint32_t msg_ref = 0;
9478         msg_var = OpenChannel_clone(&msg_var);
9479         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9480         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9481         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9482         msg_ref = (uintptr_t)msg_var.inner;
9483         if (msg_var.is_owned) {
9484                 msg_ref |= 1;
9485         }
9486         js_invoke_function_uuuuuu(j_calls->instance_ptr, 55, (uint32_t)their_node_id_arr, (uint32_t)their_features_ref, (uint32_t)msg_ref, 0, 0, 0);
9487 }
9488 void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
9489         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9490         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9491         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9492         LDKInitFeatures their_features_var = their_features;
9493         uint32_t their_features_ref = 0;
9494         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9495         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9496         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
9497         their_features_ref = (uintptr_t)their_features_var.inner;
9498         if (their_features_var.is_owned) {
9499                 their_features_ref |= 1;
9500         }
9501         LDKAcceptChannel msg_var = *msg;
9502         uint32_t msg_ref = 0;
9503         msg_var = AcceptChannel_clone(&msg_var);
9504         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9505         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9506         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9507         msg_ref = (uintptr_t)msg_var.inner;
9508         if (msg_var.is_owned) {
9509                 msg_ref |= 1;
9510         }
9511         js_invoke_function_uuuuuu(j_calls->instance_ptr, 56, (uint32_t)their_node_id_arr, (uint32_t)their_features_ref, (uint32_t)msg_ref, 0, 0, 0);
9512 }
9513 void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
9514         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9515         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9516         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9517         LDKFundingCreated msg_var = *msg;
9518         uint32_t msg_ref = 0;
9519         msg_var = FundingCreated_clone(&msg_var);
9520         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9521         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9522         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9523         msg_ref = (uintptr_t)msg_var.inner;
9524         if (msg_var.is_owned) {
9525                 msg_ref |= 1;
9526         }
9527         js_invoke_function_uuuuuu(j_calls->instance_ptr, 57, (uint32_t)their_node_id_arr, (uint32_t)msg_ref, 0, 0, 0, 0);
9528 }
9529 void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
9530         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9531         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9532         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9533         LDKFundingSigned msg_var = *msg;
9534         uint32_t msg_ref = 0;
9535         msg_var = FundingSigned_clone(&msg_var);
9536         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9537         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9538         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9539         msg_ref = (uintptr_t)msg_var.inner;
9540         if (msg_var.is_owned) {
9541                 msg_ref |= 1;
9542         }
9543         js_invoke_function_uuuuuu(j_calls->instance_ptr, 58, (uint32_t)their_node_id_arr, (uint32_t)msg_ref, 0, 0, 0, 0);
9544 }
9545 void handle_channel_ready_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReady * msg) {
9546         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9547         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9548         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9549         LDKChannelReady msg_var = *msg;
9550         uint32_t msg_ref = 0;
9551         msg_var = ChannelReady_clone(&msg_var);
9552         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9553         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9554         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9555         msg_ref = (uintptr_t)msg_var.inner;
9556         if (msg_var.is_owned) {
9557                 msg_ref |= 1;
9558         }
9559         js_invoke_function_uuuuuu(j_calls->instance_ptr, 59, (uint32_t)their_node_id_arr, (uint32_t)msg_ref, 0, 0, 0, 0);
9560 }
9561 void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInitFeatures * their_features, const LDKShutdown * msg) {
9562         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9563         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9564         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9565         LDKInitFeatures their_features_var = *their_features;
9566         uint32_t their_features_ref = 0;
9567         their_features_var = InitFeatures_clone(&their_features_var);
9568         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9569         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9570         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
9571         their_features_ref = (uintptr_t)their_features_var.inner;
9572         if (their_features_var.is_owned) {
9573                 their_features_ref |= 1;
9574         }
9575         LDKShutdown msg_var = *msg;
9576         uint32_t msg_ref = 0;
9577         msg_var = Shutdown_clone(&msg_var);
9578         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9579         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9580         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9581         msg_ref = (uintptr_t)msg_var.inner;
9582         if (msg_var.is_owned) {
9583                 msg_ref |= 1;
9584         }
9585         js_invoke_function_uuuuuu(j_calls->instance_ptr, 60, (uint32_t)their_node_id_arr, (uint32_t)their_features_ref, (uint32_t)msg_ref, 0, 0, 0);
9586 }
9587 void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
9588         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9589         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9590         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9591         LDKClosingSigned msg_var = *msg;
9592         uint32_t msg_ref = 0;
9593         msg_var = ClosingSigned_clone(&msg_var);
9594         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9595         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9596         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9597         msg_ref = (uintptr_t)msg_var.inner;
9598         if (msg_var.is_owned) {
9599                 msg_ref |= 1;
9600         }
9601         js_invoke_function_uuuuuu(j_calls->instance_ptr, 61, (uint32_t)their_node_id_arr, (uint32_t)msg_ref, 0, 0, 0, 0);
9602 }
9603 void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
9604         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9605         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9606         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9607         LDKUpdateAddHTLC msg_var = *msg;
9608         uint32_t msg_ref = 0;
9609         msg_var = UpdateAddHTLC_clone(&msg_var);
9610         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9611         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9612         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9613         msg_ref = (uintptr_t)msg_var.inner;
9614         if (msg_var.is_owned) {
9615                 msg_ref |= 1;
9616         }
9617         js_invoke_function_uuuuuu(j_calls->instance_ptr, 62, (uint32_t)their_node_id_arr, (uint32_t)msg_ref, 0, 0, 0, 0);
9618 }
9619 void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
9620         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9621         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9622         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9623         LDKUpdateFulfillHTLC msg_var = *msg;
9624         uint32_t msg_ref = 0;
9625         msg_var = UpdateFulfillHTLC_clone(&msg_var);
9626         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9627         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9628         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9629         msg_ref = (uintptr_t)msg_var.inner;
9630         if (msg_var.is_owned) {
9631                 msg_ref |= 1;
9632         }
9633         js_invoke_function_uuuuuu(j_calls->instance_ptr, 63, (uint32_t)their_node_id_arr, (uint32_t)msg_ref, 0, 0, 0, 0);
9634 }
9635 void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
9636         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9637         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9638         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9639         LDKUpdateFailHTLC msg_var = *msg;
9640         uint32_t msg_ref = 0;
9641         msg_var = UpdateFailHTLC_clone(&msg_var);
9642         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9643         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9644         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9645         msg_ref = (uintptr_t)msg_var.inner;
9646         if (msg_var.is_owned) {
9647                 msg_ref |= 1;
9648         }
9649         js_invoke_function_uuuuuu(j_calls->instance_ptr, 64, (uint32_t)their_node_id_arr, (uint32_t)msg_ref, 0, 0, 0, 0);
9650 }
9651 void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
9652         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9653         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9654         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9655         LDKUpdateFailMalformedHTLC msg_var = *msg;
9656         uint32_t msg_ref = 0;
9657         msg_var = UpdateFailMalformedHTLC_clone(&msg_var);
9658         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9659         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9660         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9661         msg_ref = (uintptr_t)msg_var.inner;
9662         if (msg_var.is_owned) {
9663                 msg_ref |= 1;
9664         }
9665         js_invoke_function_uuuuuu(j_calls->instance_ptr, 65, (uint32_t)their_node_id_arr, (uint32_t)msg_ref, 0, 0, 0, 0);
9666 }
9667 void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
9668         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9669         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9670         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9671         LDKCommitmentSigned msg_var = *msg;
9672         uint32_t msg_ref = 0;
9673         msg_var = CommitmentSigned_clone(&msg_var);
9674         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9675         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9676         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9677         msg_ref = (uintptr_t)msg_var.inner;
9678         if (msg_var.is_owned) {
9679                 msg_ref |= 1;
9680         }
9681         js_invoke_function_uuuuuu(j_calls->instance_ptr, 66, (uint32_t)their_node_id_arr, (uint32_t)msg_ref, 0, 0, 0, 0);
9682 }
9683 void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
9684         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9685         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9686         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9687         LDKRevokeAndACK msg_var = *msg;
9688         uint32_t msg_ref = 0;
9689         msg_var = RevokeAndACK_clone(&msg_var);
9690         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9691         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9692         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9693         msg_ref = (uintptr_t)msg_var.inner;
9694         if (msg_var.is_owned) {
9695                 msg_ref |= 1;
9696         }
9697         js_invoke_function_uuuuuu(j_calls->instance_ptr, 67, (uint32_t)their_node_id_arr, (uint32_t)msg_ref, 0, 0, 0, 0);
9698 }
9699 void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
9700         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9701         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9702         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9703         LDKUpdateFee msg_var = *msg;
9704         uint32_t msg_ref = 0;
9705         msg_var = UpdateFee_clone(&msg_var);
9706         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9707         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9708         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9709         msg_ref = (uintptr_t)msg_var.inner;
9710         if (msg_var.is_owned) {
9711                 msg_ref |= 1;
9712         }
9713         js_invoke_function_uuuuuu(j_calls->instance_ptr, 68, (uint32_t)their_node_id_arr, (uint32_t)msg_ref, 0, 0, 0, 0);
9714 }
9715 void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
9716         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9717         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9718         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9719         LDKAnnouncementSignatures msg_var = *msg;
9720         uint32_t msg_ref = 0;
9721         msg_var = AnnouncementSignatures_clone(&msg_var);
9722         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9723         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9724         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9725         msg_ref = (uintptr_t)msg_var.inner;
9726         if (msg_var.is_owned) {
9727                 msg_ref |= 1;
9728         }
9729         js_invoke_function_uuuuuu(j_calls->instance_ptr, 69, (uint32_t)their_node_id_arr, (uint32_t)msg_ref, 0, 0, 0, 0);
9730 }
9731 void peer_disconnected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
9732         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9733         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9734         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9735         jboolean no_connection_possible_conv = no_connection_possible;
9736         js_invoke_function_uuuuuu(j_calls->instance_ptr, 70, (uint32_t)their_node_id_arr, (uint32_t)no_connection_possible_conv, 0, 0, 0, 0);
9737 }
9738 void peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
9739         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9740         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9741         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9742         LDKInit msg_var = *msg;
9743         uint32_t msg_ref = 0;
9744         msg_var = Init_clone(&msg_var);
9745         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9746         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9747         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9748         msg_ref = (uintptr_t)msg_var.inner;
9749         if (msg_var.is_owned) {
9750                 msg_ref |= 1;
9751         }
9752         js_invoke_function_uuuuuu(j_calls->instance_ptr, 71, (uint32_t)their_node_id_arr, (uint32_t)msg_ref, 0, 0, 0, 0);
9753 }
9754 void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
9755         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9756         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9757         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9758         LDKChannelReestablish msg_var = *msg;
9759         uint32_t msg_ref = 0;
9760         msg_var = ChannelReestablish_clone(&msg_var);
9761         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9762         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9763         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9764         msg_ref = (uintptr_t)msg_var.inner;
9765         if (msg_var.is_owned) {
9766                 msg_ref |= 1;
9767         }
9768         js_invoke_function_uuuuuu(j_calls->instance_ptr, 72, (uint32_t)their_node_id_arr, (uint32_t)msg_ref, 0, 0, 0, 0);
9769 }
9770 void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelUpdate * msg) {
9771         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9772         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9773         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9774         LDKChannelUpdate msg_var = *msg;
9775         uint32_t msg_ref = 0;
9776         msg_var = ChannelUpdate_clone(&msg_var);
9777         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9778         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9779         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9780         msg_ref = (uintptr_t)msg_var.inner;
9781         if (msg_var.is_owned) {
9782                 msg_ref |= 1;
9783         }
9784         js_invoke_function_uuuuuu(j_calls->instance_ptr, 73, (uint32_t)their_node_id_arr, (uint32_t)msg_ref, 0, 0, 0, 0);
9785 }
9786 void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
9787         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9788         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9789         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9790         LDKErrorMessage msg_var = *msg;
9791         uint32_t msg_ref = 0;
9792         msg_var = ErrorMessage_clone(&msg_var);
9793         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9794         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9795         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9796         msg_ref = (uintptr_t)msg_var.inner;
9797         if (msg_var.is_owned) {
9798                 msg_ref |= 1;
9799         }
9800         js_invoke_function_uuuuuu(j_calls->instance_ptr, 74, (uint32_t)their_node_id_arr, (uint32_t)msg_ref, 0, 0, 0, 0);
9801 }
9802 static void LDKChannelMessageHandler_JCalls_cloned(LDKChannelMessageHandler* new_obj) {
9803         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) new_obj->this_arg;
9804         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9805         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
9806 }
9807 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (JSValue o, JSValue MessageSendEventsProvider) {
9808         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
9809         atomic_init(&calls->refcnt, 1);
9810         calls->instance_ptr = o;
9811
9812         LDKChannelMessageHandler ret = {
9813                 .this_arg = (void*) calls,
9814                 .handle_open_channel = handle_open_channel_LDKChannelMessageHandler_jcall,
9815                 .handle_accept_channel = handle_accept_channel_LDKChannelMessageHandler_jcall,
9816                 .handle_funding_created = handle_funding_created_LDKChannelMessageHandler_jcall,
9817                 .handle_funding_signed = handle_funding_signed_LDKChannelMessageHandler_jcall,
9818                 .handle_channel_ready = handle_channel_ready_LDKChannelMessageHandler_jcall,
9819                 .handle_shutdown = handle_shutdown_LDKChannelMessageHandler_jcall,
9820                 .handle_closing_signed = handle_closing_signed_LDKChannelMessageHandler_jcall,
9821                 .handle_update_add_htlc = handle_update_add_htlc_LDKChannelMessageHandler_jcall,
9822                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall,
9823                 .handle_update_fail_htlc = handle_update_fail_htlc_LDKChannelMessageHandler_jcall,
9824                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall,
9825                 .handle_commitment_signed = handle_commitment_signed_LDKChannelMessageHandler_jcall,
9826                 .handle_revoke_and_ack = handle_revoke_and_ack_LDKChannelMessageHandler_jcall,
9827                 .handle_update_fee = handle_update_fee_LDKChannelMessageHandler_jcall,
9828                 .handle_announcement_signatures = handle_announcement_signatures_LDKChannelMessageHandler_jcall,
9829                 .peer_disconnected = peer_disconnected_LDKChannelMessageHandler_jcall,
9830                 .peer_connected = peer_connected_LDKChannelMessageHandler_jcall,
9831                 .handle_channel_reestablish = handle_channel_reestablish_LDKChannelMessageHandler_jcall,
9832                 .handle_channel_update = handle_channel_update_LDKChannelMessageHandler_jcall,
9833                 .handle_error = handle_error_LDKChannelMessageHandler_jcall,
9834                 .free = LDKChannelMessageHandler_JCalls_free,
9835                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(MessageSendEventsProvider),
9836         };
9837         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
9838         return ret;
9839 }
9840 long  __attribute__((export_name("TS_LDKChannelMessageHandler_new"))) TS_LDKChannelMessageHandler_new(JSValue o, JSValue MessageSendEventsProvider) {
9841         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
9842         *res_ptr = LDKChannelMessageHandler_init(o, MessageSendEventsProvider);
9843         return (long)res_ptr;
9844 }
9845 void  __attribute__((export_name("TS_ChannelMessageHandler_handle_open_channel"))) TS_ChannelMessageHandler_handle_open_channel(uint32_t this_arg, int8_tArray their_node_id, uint32_t their_features, uint32_t msg) {
9846         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9847         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9848         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9849         LDKPublicKey their_node_id_ref;
9850         CHECK(their_node_id->arr_len == 33);
9851         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9852         LDKInitFeatures their_features_conv;
9853         their_features_conv.inner = (void*)(their_features & (~1));
9854         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
9855         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
9856         their_features_conv = InitFeatures_clone(&their_features_conv);
9857         LDKOpenChannel msg_conv;
9858         msg_conv.inner = (void*)(msg & (~1));
9859         msg_conv.is_owned = false;
9860         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9861         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
9862 }
9863
9864 void  __attribute__((export_name("TS_ChannelMessageHandler_handle_accept_channel"))) TS_ChannelMessageHandler_handle_accept_channel(uint32_t this_arg, int8_tArray their_node_id, uint32_t their_features, uint32_t msg) {
9865         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9866         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9867         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9868         LDKPublicKey their_node_id_ref;
9869         CHECK(their_node_id->arr_len == 33);
9870         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9871         LDKInitFeatures their_features_conv;
9872         their_features_conv.inner = (void*)(their_features & (~1));
9873         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
9874         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
9875         their_features_conv = InitFeatures_clone(&their_features_conv);
9876         LDKAcceptChannel msg_conv;
9877         msg_conv.inner = (void*)(msg & (~1));
9878         msg_conv.is_owned = false;
9879         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9880         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
9881 }
9882
9883 void  __attribute__((export_name("TS_ChannelMessageHandler_handle_funding_created"))) TS_ChannelMessageHandler_handle_funding_created(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
9884         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9885         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9886         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9887         LDKPublicKey their_node_id_ref;
9888         CHECK(their_node_id->arr_len == 33);
9889         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9890         LDKFundingCreated msg_conv;
9891         msg_conv.inner = (void*)(msg & (~1));
9892         msg_conv.is_owned = false;
9893         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9894         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9895 }
9896
9897 void  __attribute__((export_name("TS_ChannelMessageHandler_handle_funding_signed"))) TS_ChannelMessageHandler_handle_funding_signed(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
9898         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9899         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9900         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9901         LDKPublicKey their_node_id_ref;
9902         CHECK(their_node_id->arr_len == 33);
9903         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9904         LDKFundingSigned msg_conv;
9905         msg_conv.inner = (void*)(msg & (~1));
9906         msg_conv.is_owned = false;
9907         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9908         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9909 }
9910
9911 void  __attribute__((export_name("TS_ChannelMessageHandler_handle_channel_ready"))) TS_ChannelMessageHandler_handle_channel_ready(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
9912         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9913         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9914         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9915         LDKPublicKey their_node_id_ref;
9916         CHECK(their_node_id->arr_len == 33);
9917         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9918         LDKChannelReady msg_conv;
9919         msg_conv.inner = (void*)(msg & (~1));
9920         msg_conv.is_owned = false;
9921         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9922         (this_arg_conv->handle_channel_ready)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9923 }
9924
9925 void  __attribute__((export_name("TS_ChannelMessageHandler_handle_shutdown"))) TS_ChannelMessageHandler_handle_shutdown(uint32_t this_arg, int8_tArray their_node_id, uint32_t their_features, uint32_t msg) {
9926         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9927         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9928         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9929         LDKPublicKey their_node_id_ref;
9930         CHECK(their_node_id->arr_len == 33);
9931         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9932         LDKInitFeatures their_features_conv;
9933         their_features_conv.inner = (void*)(their_features & (~1));
9934         their_features_conv.is_owned = false;
9935         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
9936         LDKShutdown msg_conv;
9937         msg_conv.inner = (void*)(msg & (~1));
9938         msg_conv.is_owned = false;
9939         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9940         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &their_features_conv, &msg_conv);
9941 }
9942
9943 void  __attribute__((export_name("TS_ChannelMessageHandler_handle_closing_signed"))) TS_ChannelMessageHandler_handle_closing_signed(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
9944         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9945         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9946         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9947         LDKPublicKey their_node_id_ref;
9948         CHECK(their_node_id->arr_len == 33);
9949         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9950         LDKClosingSigned msg_conv;
9951         msg_conv.inner = (void*)(msg & (~1));
9952         msg_conv.is_owned = false;
9953         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9954         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9955 }
9956
9957 void  __attribute__((export_name("TS_ChannelMessageHandler_handle_update_add_htlc"))) TS_ChannelMessageHandler_handle_update_add_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
9958         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9959         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9960         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9961         LDKPublicKey their_node_id_ref;
9962         CHECK(their_node_id->arr_len == 33);
9963         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9964         LDKUpdateAddHTLC msg_conv;
9965         msg_conv.inner = (void*)(msg & (~1));
9966         msg_conv.is_owned = false;
9967         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9968         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9969 }
9970
9971 void  __attribute__((export_name("TS_ChannelMessageHandler_handle_update_fulfill_htlc"))) TS_ChannelMessageHandler_handle_update_fulfill_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
9972         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9973         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9974         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9975         LDKPublicKey their_node_id_ref;
9976         CHECK(their_node_id->arr_len == 33);
9977         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9978         LDKUpdateFulfillHTLC msg_conv;
9979         msg_conv.inner = (void*)(msg & (~1));
9980         msg_conv.is_owned = false;
9981         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9982         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9983 }
9984
9985 void  __attribute__((export_name("TS_ChannelMessageHandler_handle_update_fail_htlc"))) TS_ChannelMessageHandler_handle_update_fail_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
9986         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9987         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9988         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9989         LDKPublicKey their_node_id_ref;
9990         CHECK(their_node_id->arr_len == 33);
9991         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9992         LDKUpdateFailHTLC msg_conv;
9993         msg_conv.inner = (void*)(msg & (~1));
9994         msg_conv.is_owned = false;
9995         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9996         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9997 }
9998
9999 void  __attribute__((export_name("TS_ChannelMessageHandler_handle_update_fail_malformed_htlc"))) TS_ChannelMessageHandler_handle_update_fail_malformed_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
10000         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10001         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10002         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
10003         LDKPublicKey their_node_id_ref;
10004         CHECK(their_node_id->arr_len == 33);
10005         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
10006         LDKUpdateFailMalformedHTLC msg_conv;
10007         msg_conv.inner = (void*)(msg & (~1));
10008         msg_conv.is_owned = false;
10009         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10010         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
10011 }
10012
10013 void  __attribute__((export_name("TS_ChannelMessageHandler_handle_commitment_signed"))) TS_ChannelMessageHandler_handle_commitment_signed(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
10014         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10015         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10016         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
10017         LDKPublicKey their_node_id_ref;
10018         CHECK(their_node_id->arr_len == 33);
10019         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
10020         LDKCommitmentSigned msg_conv;
10021         msg_conv.inner = (void*)(msg & (~1));
10022         msg_conv.is_owned = false;
10023         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10024         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
10025 }
10026
10027 void  __attribute__((export_name("TS_ChannelMessageHandler_handle_revoke_and_ack"))) TS_ChannelMessageHandler_handle_revoke_and_ack(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
10028         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10029         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10030         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
10031         LDKPublicKey their_node_id_ref;
10032         CHECK(their_node_id->arr_len == 33);
10033         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
10034         LDKRevokeAndACK msg_conv;
10035         msg_conv.inner = (void*)(msg & (~1));
10036         msg_conv.is_owned = false;
10037         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10038         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
10039 }
10040
10041 void  __attribute__((export_name("TS_ChannelMessageHandler_handle_update_fee"))) TS_ChannelMessageHandler_handle_update_fee(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
10042         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10043         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10044         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
10045         LDKPublicKey their_node_id_ref;
10046         CHECK(their_node_id->arr_len == 33);
10047         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
10048         LDKUpdateFee msg_conv;
10049         msg_conv.inner = (void*)(msg & (~1));
10050         msg_conv.is_owned = false;
10051         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10052         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
10053 }
10054
10055 void  __attribute__((export_name("TS_ChannelMessageHandler_handle_announcement_signatures"))) TS_ChannelMessageHandler_handle_announcement_signatures(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
10056         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10057         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10058         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
10059         LDKPublicKey their_node_id_ref;
10060         CHECK(their_node_id->arr_len == 33);
10061         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
10062         LDKAnnouncementSignatures msg_conv;
10063         msg_conv.inner = (void*)(msg & (~1));
10064         msg_conv.is_owned = false;
10065         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10066         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
10067 }
10068
10069 void  __attribute__((export_name("TS_ChannelMessageHandler_peer_disconnected"))) TS_ChannelMessageHandler_peer_disconnected(uint32_t this_arg, int8_tArray their_node_id, jboolean no_connection_possible) {
10070         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10071         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10072         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
10073         LDKPublicKey their_node_id_ref;
10074         CHECK(their_node_id->arr_len == 33);
10075         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
10076         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
10077 }
10078
10079 void  __attribute__((export_name("TS_ChannelMessageHandler_peer_connected"))) TS_ChannelMessageHandler_peer_connected(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
10080         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10081         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10082         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
10083         LDKPublicKey their_node_id_ref;
10084         CHECK(their_node_id->arr_len == 33);
10085         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
10086         LDKInit msg_conv;
10087         msg_conv.inner = (void*)(msg & (~1));
10088         msg_conv.is_owned = false;
10089         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10090         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
10091 }
10092
10093 void  __attribute__((export_name("TS_ChannelMessageHandler_handle_channel_reestablish"))) TS_ChannelMessageHandler_handle_channel_reestablish(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
10094         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10095         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10096         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
10097         LDKPublicKey their_node_id_ref;
10098         CHECK(their_node_id->arr_len == 33);
10099         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
10100         LDKChannelReestablish msg_conv;
10101         msg_conv.inner = (void*)(msg & (~1));
10102         msg_conv.is_owned = false;
10103         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10104         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
10105 }
10106
10107 void  __attribute__((export_name("TS_ChannelMessageHandler_handle_channel_update"))) TS_ChannelMessageHandler_handle_channel_update(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
10108         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10109         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10110         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
10111         LDKPublicKey their_node_id_ref;
10112         CHECK(their_node_id->arr_len == 33);
10113         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
10114         LDKChannelUpdate msg_conv;
10115         msg_conv.inner = (void*)(msg & (~1));
10116         msg_conv.is_owned = false;
10117         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10118         (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
10119 }
10120
10121 void  __attribute__((export_name("TS_ChannelMessageHandler_handle_error"))) TS_ChannelMessageHandler_handle_error(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
10122         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10123         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10124         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
10125         LDKPublicKey their_node_id_ref;
10126         CHECK(their_node_id->arr_len == 33);
10127         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
10128         LDKErrorMessage msg_conv;
10129         msg_conv.inner = (void*)(msg & (~1));
10130         msg_conv.is_owned = false;
10131         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10132         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
10133 }
10134
10135 typedef struct LDKRoutingMessageHandler_JCalls {
10136         atomic_size_t refcnt;
10137         uint32_t instance_ptr;
10138         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
10139 } LDKRoutingMessageHandler_JCalls;
10140 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
10141         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
10142         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10143                 FREE(j_calls);
10144         }
10145 }
10146 LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
10147         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
10148         LDKNodeAnnouncement msg_var = *msg;
10149         uint32_t msg_ref = 0;
10150         msg_var = NodeAnnouncement_clone(&msg_var);
10151         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10152         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10153         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10154         msg_ref = (uintptr_t)msg_var.inner;
10155         if (msg_var.is_owned) {
10156                 msg_ref |= 1;
10157         }
10158         uint32_t ret = js_invoke_function_uuuuuu(j_calls->instance_ptr, 75, (uint32_t)msg_ref, 0, 0, 0, 0, 0);
10159         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10160         CHECK_ACCESS(ret_ptr);
10161         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
10162         FREE((void*)ret);
10163         return ret_conv;
10164 }
10165 LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
10166         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
10167         LDKChannelAnnouncement msg_var = *msg;
10168         uint32_t msg_ref = 0;
10169         msg_var = ChannelAnnouncement_clone(&msg_var);
10170         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10171         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10172         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10173         msg_ref = (uintptr_t)msg_var.inner;
10174         if (msg_var.is_owned) {
10175                 msg_ref |= 1;
10176         }
10177         uint32_t ret = js_invoke_function_uuuuuu(j_calls->instance_ptr, 76, (uint32_t)msg_ref, 0, 0, 0, 0, 0);
10178         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10179         CHECK_ACCESS(ret_ptr);
10180         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
10181         FREE((void*)ret);
10182         return ret_conv;
10183 }
10184 LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
10185         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
10186         LDKChannelUpdate msg_var = *msg;
10187         uint32_t msg_ref = 0;
10188         msg_var = ChannelUpdate_clone(&msg_var);
10189         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10190         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10191         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10192         msg_ref = (uintptr_t)msg_var.inner;
10193         if (msg_var.is_owned) {
10194                 msg_ref |= 1;
10195         }
10196         uint32_t ret = js_invoke_function_uuuuuu(j_calls->instance_ptr, 77, (uint32_t)msg_ref, 0, 0, 0, 0, 0);
10197         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10198         CHECK_ACCESS(ret_ptr);
10199         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
10200         FREE((void*)ret);
10201         return ret_conv;
10202 }
10203 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
10204         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
10205         int64_t starting_point_conv = starting_point;
10206         int8_t batch_amount_conv = batch_amount;
10207         uint32_tArray ret = (uint32_tArray)js_invoke_function_buuuuu(j_calls->instance_ptr, 78, (uint32_t)starting_point_conv, (uint32_t)batch_amount_conv, 0, 0, 0, 0);
10208         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_constr;
10209         ret_constr.datalen = ret->arr_len;
10210         if (ret_constr.datalen > 0)
10211                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
10212         else
10213                 ret_constr.data = NULL;
10214         uint32_t* ret_vals = ret->elems;
10215         for (size_t h = 0; h < ret_constr.datalen; h++) {
10216                 uint32_t ret_conv_59 = ret_vals[h];
10217                 void* ret_conv_59_ptr = (void*)(((uintptr_t)ret_conv_59) & ~1);
10218                 CHECK_ACCESS(ret_conv_59_ptr);
10219                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ret_conv_59_ptr);
10220                 FREE((void*)ret_conv_59);
10221                 ret_constr.data[h] = ret_conv_59_conv;
10222         }
10223         FREE(ret);
10224         return ret_constr;
10225 }
10226 LDKCVec_NodeAnnouncementZ get_next_node_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
10227         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
10228         int8_tArray starting_point_arr = init_int8_tArray(33, __LINE__);
10229         memcpy(starting_point_arr->elems, starting_point.compressed_form, 33);
10230         int8_t batch_amount_conv = batch_amount;
10231         uint32_tArray ret = (uint32_tArray)js_invoke_function_uuuuuu(j_calls->instance_ptr, 79, (uint32_t)starting_point_arr, (uint32_t)batch_amount_conv, 0, 0, 0, 0);
10232         LDKCVec_NodeAnnouncementZ ret_constr;
10233         ret_constr.datalen = ret->arr_len;
10234         if (ret_constr.datalen > 0)
10235                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
10236         else
10237                 ret_constr.data = NULL;
10238         uint32_t* ret_vals = ret->elems;
10239         for (size_t s = 0; s < ret_constr.datalen; s++) {
10240                 uint32_t ret_conv_18 = ret_vals[s];
10241                 LDKNodeAnnouncement ret_conv_18_conv;
10242                 ret_conv_18_conv.inner = (void*)(ret_conv_18 & (~1));
10243                 ret_conv_18_conv.is_owned = (ret_conv_18 & 1) || (ret_conv_18 == 0);
10244                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_18_conv);
10245                 ret_constr.data[s] = ret_conv_18_conv;
10246         }
10247         FREE(ret);
10248         return ret_constr;
10249 }
10250 void peer_connected_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
10251         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
10252         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
10253         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
10254         LDKInit init_var = *init;
10255         uint32_t init_ref = 0;
10256         init_var = Init_clone(&init_var);
10257         CHECK((((uintptr_t)init_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10258         CHECK((((uintptr_t)&init_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10259         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_var);
10260         init_ref = (uintptr_t)init_var.inner;
10261         if (init_var.is_owned) {
10262                 init_ref |= 1;
10263         }
10264         js_invoke_function_uuuuuu(j_calls->instance_ptr, 80, (uint32_t)their_node_id_arr, (uint32_t)init_ref, 0, 0, 0, 0);
10265 }
10266 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
10267         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
10268         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
10269         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
10270         LDKReplyChannelRange msg_var = msg;
10271         uint32_t msg_ref = 0;
10272         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10273         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10274         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10275         msg_ref = (uintptr_t)msg_var.inner;
10276         if (msg_var.is_owned) {
10277                 msg_ref |= 1;
10278         }
10279         uint32_t ret = js_invoke_function_uuuuuu(j_calls->instance_ptr, 81, (uint32_t)their_node_id_arr, (uint32_t)msg_ref, 0, 0, 0, 0);
10280         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10281         CHECK_ACCESS(ret_ptr);
10282         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
10283         FREE((void*)ret);
10284         return ret_conv;
10285 }
10286 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
10287         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
10288         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
10289         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
10290         LDKReplyShortChannelIdsEnd msg_var = msg;
10291         uint32_t msg_ref = 0;
10292         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10293         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10294         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10295         msg_ref = (uintptr_t)msg_var.inner;
10296         if (msg_var.is_owned) {
10297                 msg_ref |= 1;
10298         }
10299         uint32_t ret = js_invoke_function_uuuuuu(j_calls->instance_ptr, 82, (uint32_t)their_node_id_arr, (uint32_t)msg_ref, 0, 0, 0, 0);
10300         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10301         CHECK_ACCESS(ret_ptr);
10302         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
10303         FREE((void*)ret);
10304         return ret_conv;
10305 }
10306 LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
10307         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
10308         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
10309         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
10310         LDKQueryChannelRange msg_var = msg;
10311         uint32_t msg_ref = 0;
10312         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10313         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10314         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10315         msg_ref = (uintptr_t)msg_var.inner;
10316         if (msg_var.is_owned) {
10317                 msg_ref |= 1;
10318         }
10319         uint32_t ret = js_invoke_function_uuuuuu(j_calls->instance_ptr, 83, (uint32_t)their_node_id_arr, (uint32_t)msg_ref, 0, 0, 0, 0);
10320         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10321         CHECK_ACCESS(ret_ptr);
10322         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
10323         FREE((void*)ret);
10324         return ret_conv;
10325 }
10326 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
10327         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
10328         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
10329         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
10330         LDKQueryShortChannelIds msg_var = msg;
10331         uint32_t msg_ref = 0;
10332         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10333         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10334         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10335         msg_ref = (uintptr_t)msg_var.inner;
10336         if (msg_var.is_owned) {
10337                 msg_ref |= 1;
10338         }
10339         uint32_t ret = js_invoke_function_uuuuuu(j_calls->instance_ptr, 84, (uint32_t)their_node_id_arr, (uint32_t)msg_ref, 0, 0, 0, 0);
10340         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10341         CHECK_ACCESS(ret_ptr);
10342         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
10343         FREE((void*)ret);
10344         return ret_conv;
10345 }
10346 static void LDKRoutingMessageHandler_JCalls_cloned(LDKRoutingMessageHandler* new_obj) {
10347         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) new_obj->this_arg;
10348         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10349         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
10350 }
10351 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (JSValue o, JSValue MessageSendEventsProvider) {
10352         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
10353         atomic_init(&calls->refcnt, 1);
10354         calls->instance_ptr = o;
10355
10356         LDKRoutingMessageHandler ret = {
10357                 .this_arg = (void*) calls,
10358                 .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall,
10359                 .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall,
10360                 .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall,
10361                 .get_next_channel_announcements = get_next_channel_announcements_LDKRoutingMessageHandler_jcall,
10362                 .get_next_node_announcements = get_next_node_announcements_LDKRoutingMessageHandler_jcall,
10363                 .peer_connected = peer_connected_LDKRoutingMessageHandler_jcall,
10364                 .handle_reply_channel_range = handle_reply_channel_range_LDKRoutingMessageHandler_jcall,
10365                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall,
10366                 .handle_query_channel_range = handle_query_channel_range_LDKRoutingMessageHandler_jcall,
10367                 .handle_query_short_channel_ids = handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall,
10368                 .free = LDKRoutingMessageHandler_JCalls_free,
10369                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(MessageSendEventsProvider),
10370         };
10371         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
10372         return ret;
10373 }
10374 long  __attribute__((export_name("TS_LDKRoutingMessageHandler_new"))) TS_LDKRoutingMessageHandler_new(JSValue o, JSValue MessageSendEventsProvider) {
10375         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
10376         *res_ptr = LDKRoutingMessageHandler_init(o, MessageSendEventsProvider);
10377         return (long)res_ptr;
10378 }
10379 uint32_t  __attribute__((export_name("TS_RoutingMessageHandler_handle_node_announcement"))) TS_RoutingMessageHandler_handle_node_announcement(uint32_t this_arg, uint32_t msg) {
10380         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10381         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10382         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
10383         LDKNodeAnnouncement msg_conv;
10384         msg_conv.inner = (void*)(msg & (~1));
10385         msg_conv.is_owned = false;
10386         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10387         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
10388         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
10389         return (uint32_t)ret_conv;
10390 }
10391
10392 uint32_t  __attribute__((export_name("TS_RoutingMessageHandler_handle_channel_announcement"))) TS_RoutingMessageHandler_handle_channel_announcement(uint32_t this_arg, uint32_t msg) {
10393         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10394         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10395         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
10396         LDKChannelAnnouncement msg_conv;
10397         msg_conv.inner = (void*)(msg & (~1));
10398         msg_conv.is_owned = false;
10399         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10400         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
10401         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
10402         return (uint32_t)ret_conv;
10403 }
10404
10405 uint32_t  __attribute__((export_name("TS_RoutingMessageHandler_handle_channel_update"))) TS_RoutingMessageHandler_handle_channel_update(uint32_t this_arg, uint32_t msg) {
10406         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10407         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10408         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
10409         LDKChannelUpdate msg_conv;
10410         msg_conv.inner = (void*)(msg & (~1));
10411         msg_conv.is_owned = false;
10412         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10413         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
10414         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
10415         return (uint32_t)ret_conv;
10416 }
10417
10418 uint32_tArray  __attribute__((export_name("TS_RoutingMessageHandler_get_next_channel_announcements"))) TS_RoutingMessageHandler_get_next_channel_announcements(uint32_t this_arg, int64_t starting_point, int8_t batch_amount) {
10419         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10420         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10421         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
10422         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
10423         uint32_tArray ret_arr = NULL;
10424         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
10425         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 8);
10426         for (size_t h = 0; h < ret_var.datalen; h++) {
10427                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv_59_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
10428                 *ret_conv_59_conv = ret_var.data[h];
10429                 ret_arr_ptr[h] = ((uint32_t)ret_conv_59_conv);
10430         }
10431         
10432         FREE(ret_var.data);
10433         return ret_arr;
10434 }
10435
10436 uint32_tArray  __attribute__((export_name("TS_RoutingMessageHandler_get_next_node_announcements"))) TS_RoutingMessageHandler_get_next_node_announcements(uint32_t this_arg, int8_tArray starting_point, int8_t batch_amount) {
10437         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10438         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10439         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
10440         LDKPublicKey starting_point_ref;
10441         CHECK(starting_point->arr_len == 33);
10442         memcpy(starting_point_ref.compressed_form, starting_point->elems, 33); FREE(starting_point);
10443         LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
10444         uint32_tArray ret_arr = NULL;
10445         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
10446         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 8);
10447         for (size_t s = 0; s < ret_var.datalen; s++) {
10448                 LDKNodeAnnouncement ret_conv_18_var = ret_var.data[s];
10449                 uint32_t ret_conv_18_ref = 0;
10450                 CHECK((((uintptr_t)ret_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10451                 CHECK((((uintptr_t)&ret_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10452                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_18_var);
10453                 ret_conv_18_ref = (uintptr_t)ret_conv_18_var.inner;
10454                 if (ret_conv_18_var.is_owned) {
10455                         ret_conv_18_ref |= 1;
10456                 }
10457                 ret_arr_ptr[s] = ret_conv_18_ref;
10458         }
10459         
10460         FREE(ret_var.data);
10461         return ret_arr;
10462 }
10463
10464 void  __attribute__((export_name("TS_RoutingMessageHandler_peer_connected"))) TS_RoutingMessageHandler_peer_connected(uint32_t this_arg, int8_tArray their_node_id, uint32_t init) {
10465         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10466         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10467         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
10468         LDKPublicKey their_node_id_ref;
10469         CHECK(their_node_id->arr_len == 33);
10470         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
10471         LDKInit init_conv;
10472         init_conv.inner = (void*)(init & (~1));
10473         init_conv.is_owned = false;
10474         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_conv);
10475         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
10476 }
10477
10478 uint32_t  __attribute__((export_name("TS_RoutingMessageHandler_handle_reply_channel_range"))) TS_RoutingMessageHandler_handle_reply_channel_range(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
10479         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10480         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10481         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
10482         LDKPublicKey their_node_id_ref;
10483         CHECK(their_node_id->arr_len == 33);
10484         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
10485         LDKReplyChannelRange msg_conv;
10486         msg_conv.inner = (void*)(msg & (~1));
10487         msg_conv.is_owned = (msg & 1) || (msg == 0);
10488         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10489         msg_conv = ReplyChannelRange_clone(&msg_conv);
10490         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
10491         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
10492         return (uint32_t)ret_conv;
10493 }
10494
10495 uint32_t  __attribute__((export_name("TS_RoutingMessageHandler_handle_reply_short_channel_ids_end"))) TS_RoutingMessageHandler_handle_reply_short_channel_ids_end(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
10496         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10497         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10498         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
10499         LDKPublicKey their_node_id_ref;
10500         CHECK(their_node_id->arr_len == 33);
10501         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
10502         LDKReplyShortChannelIdsEnd msg_conv;
10503         msg_conv.inner = (void*)(msg & (~1));
10504         msg_conv.is_owned = (msg & 1) || (msg == 0);
10505         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10506         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
10507         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
10508         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
10509         return (uint32_t)ret_conv;
10510 }
10511
10512 uint32_t  __attribute__((export_name("TS_RoutingMessageHandler_handle_query_channel_range"))) TS_RoutingMessageHandler_handle_query_channel_range(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
10513         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10514         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10515         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
10516         LDKPublicKey their_node_id_ref;
10517         CHECK(their_node_id->arr_len == 33);
10518         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
10519         LDKQueryChannelRange msg_conv;
10520         msg_conv.inner = (void*)(msg & (~1));
10521         msg_conv.is_owned = (msg & 1) || (msg == 0);
10522         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10523         msg_conv = QueryChannelRange_clone(&msg_conv);
10524         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
10525         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
10526         return (uint32_t)ret_conv;
10527 }
10528
10529 uint32_t  __attribute__((export_name("TS_RoutingMessageHandler_handle_query_short_channel_ids"))) TS_RoutingMessageHandler_handle_query_short_channel_ids(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
10530         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10531         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10532         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
10533         LDKPublicKey their_node_id_ref;
10534         CHECK(their_node_id->arr_len == 33);
10535         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
10536         LDKQueryShortChannelIds msg_conv;
10537         msg_conv.inner = (void*)(msg & (~1));
10538         msg_conv.is_owned = (msg & 1) || (msg == 0);
10539         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10540         msg_conv = QueryShortChannelIds_clone(&msg_conv);
10541         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
10542         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
10543         return (uint32_t)ret_conv;
10544 }
10545
10546 typedef struct LDKCustomMessageReader_JCalls {
10547         atomic_size_t refcnt;
10548         uint32_t instance_ptr;
10549 } LDKCustomMessageReader_JCalls;
10550 static void LDKCustomMessageReader_JCalls_free(void* this_arg) {
10551         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
10552         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10553                 FREE(j_calls);
10554         }
10555 }
10556 LDKCResult_COption_TypeZDecodeErrorZ read_LDKCustomMessageReader_jcall(const void* this_arg, uint16_t message_type, LDKu8slice buffer) {
10557         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
10558         int16_t message_type_conv = message_type;
10559         LDKu8slice buffer_var = buffer;
10560         int8_tArray buffer_arr = init_int8_tArray(buffer_var.datalen, __LINE__);
10561         memcpy(buffer_arr->elems, buffer_var.data, buffer_var.datalen);
10562         uint32_t ret = js_invoke_function_uuuuuu(j_calls->instance_ptr, 85, (uint32_t)message_type_conv, (uint32_t)buffer_arr, 0, 0, 0, 0);
10563         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10564         CHECK_ACCESS(ret_ptr);
10565         LDKCResult_COption_TypeZDecodeErrorZ ret_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(ret_ptr);
10566         FREE((void*)ret);
10567         return ret_conv;
10568 }
10569 static void LDKCustomMessageReader_JCalls_cloned(LDKCustomMessageReader* new_obj) {
10570         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) new_obj->this_arg;
10571         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10572 }
10573 static inline LDKCustomMessageReader LDKCustomMessageReader_init (JSValue o) {
10574         LDKCustomMessageReader_JCalls *calls = MALLOC(sizeof(LDKCustomMessageReader_JCalls), "LDKCustomMessageReader_JCalls");
10575         atomic_init(&calls->refcnt, 1);
10576         calls->instance_ptr = o;
10577
10578         LDKCustomMessageReader ret = {
10579                 .this_arg = (void*) calls,
10580                 .read = read_LDKCustomMessageReader_jcall,
10581                 .free = LDKCustomMessageReader_JCalls_free,
10582         };
10583         return ret;
10584 }
10585 long  __attribute__((export_name("TS_LDKCustomMessageReader_new"))) TS_LDKCustomMessageReader_new(JSValue o) {
10586         LDKCustomMessageReader *res_ptr = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
10587         *res_ptr = LDKCustomMessageReader_init(o);
10588         return (long)res_ptr;
10589 }
10590 uint32_t  __attribute__((export_name("TS_CustomMessageReader_read"))) TS_CustomMessageReader_read(uint32_t this_arg, int16_t message_type, int8_tArray buffer) {
10591         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10592         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10593         LDKCustomMessageReader* this_arg_conv = (LDKCustomMessageReader*)this_arg_ptr;
10594         LDKu8slice buffer_ref;
10595         buffer_ref.datalen = buffer->arr_len;
10596         buffer_ref.data = buffer->elems;
10597         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
10598         *ret_conv = (this_arg_conv->read)(this_arg_conv->this_arg, message_type, buffer_ref);
10599         FREE(buffer);
10600         return (uint32_t)ret_conv;
10601 }
10602
10603 typedef struct LDKCustomMessageHandler_JCalls {
10604         atomic_size_t refcnt;
10605         uint32_t instance_ptr;
10606         LDKCustomMessageReader_JCalls* CustomMessageReader;
10607 } LDKCustomMessageHandler_JCalls;
10608 static void LDKCustomMessageHandler_JCalls_free(void* this_arg) {
10609         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
10610         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10611                 FREE(j_calls);
10612         }
10613 }
10614 LDKCResult_NoneLightningErrorZ handle_custom_message_LDKCustomMessageHandler_jcall(const void* this_arg, LDKType msg, LDKPublicKey sender_node_id) {
10615         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
10616         LDKType* msg_ret = MALLOC(sizeof(LDKType), "LDKType");
10617         *msg_ret = msg;
10618         int8_tArray sender_node_id_arr = init_int8_tArray(33, __LINE__);
10619         memcpy(sender_node_id_arr->elems, sender_node_id.compressed_form, 33);
10620         uint32_t ret = js_invoke_function_uuuuuu(j_calls->instance_ptr, 86, (uint32_t)(uint32_t)msg_ret, (uint32_t)sender_node_id_arr, 0, 0, 0, 0);
10621         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10622         CHECK_ACCESS(ret_ptr);
10623         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
10624         FREE((void*)ret);
10625         return ret_conv;
10626 }
10627 LDKCVec_C2Tuple_PublicKeyTypeZZ get_and_clear_pending_msg_LDKCustomMessageHandler_jcall(const void* this_arg) {
10628         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
10629         uint32_tArray ret = (uint32_tArray)js_invoke_function_uuuuuu(j_calls->instance_ptr, 87, 0, 0, 0, 0, 0, 0);
10630         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_constr;
10631         ret_constr.datalen = ret->arr_len;
10632         if (ret_constr.datalen > 0)
10633                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
10634         else
10635                 ret_constr.data = NULL;
10636         uint32_t* ret_vals = ret->elems;
10637         for (size_t z = 0; z < ret_constr.datalen; z++) {
10638                 uint32_t ret_conv_25 = ret_vals[z];
10639                 void* ret_conv_25_ptr = (void*)(((uintptr_t)ret_conv_25) & ~1);
10640                 CHECK_ACCESS(ret_conv_25_ptr);
10641                 LDKC2Tuple_PublicKeyTypeZ ret_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(ret_conv_25_ptr);
10642                 FREE((void*)ret_conv_25);
10643                 ret_constr.data[z] = ret_conv_25_conv;
10644         }
10645         FREE(ret);
10646         return ret_constr;
10647 }
10648 static void LDKCustomMessageHandler_JCalls_cloned(LDKCustomMessageHandler* new_obj) {
10649         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) new_obj->this_arg;
10650         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10651         atomic_fetch_add_explicit(&j_calls->CustomMessageReader->refcnt, 1, memory_order_release);
10652 }
10653 static inline LDKCustomMessageHandler LDKCustomMessageHandler_init (JSValue o, JSValue CustomMessageReader) {
10654         LDKCustomMessageHandler_JCalls *calls = MALLOC(sizeof(LDKCustomMessageHandler_JCalls), "LDKCustomMessageHandler_JCalls");
10655         atomic_init(&calls->refcnt, 1);
10656         calls->instance_ptr = o;
10657
10658         LDKCustomMessageHandler ret = {
10659                 .this_arg = (void*) calls,
10660                 .handle_custom_message = handle_custom_message_LDKCustomMessageHandler_jcall,
10661                 .get_and_clear_pending_msg = get_and_clear_pending_msg_LDKCustomMessageHandler_jcall,
10662                 .free = LDKCustomMessageHandler_JCalls_free,
10663                 .CustomMessageReader = LDKCustomMessageReader_init(CustomMessageReader),
10664         };
10665         calls->CustomMessageReader = ret.CustomMessageReader.this_arg;
10666         return ret;
10667 }
10668 long  __attribute__((export_name("TS_LDKCustomMessageHandler_new"))) TS_LDKCustomMessageHandler_new(JSValue o, JSValue CustomMessageReader) {
10669         LDKCustomMessageHandler *res_ptr = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
10670         *res_ptr = LDKCustomMessageHandler_init(o, CustomMessageReader);
10671         return (long)res_ptr;
10672 }
10673 uint32_t  __attribute__((export_name("TS_CustomMessageHandler_handle_custom_message"))) TS_CustomMessageHandler_handle_custom_message(uint32_t this_arg, uint32_t msg, int8_tArray sender_node_id) {
10674         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10675         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10676         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
10677         void* msg_ptr = (void*)(((uintptr_t)msg) & ~1);
10678         CHECK_ACCESS(msg_ptr);
10679         LDKType msg_conv = *(LDKType*)(msg_ptr);
10680         if (msg_conv.free == LDKType_JCalls_free) {
10681                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10682                 LDKType_JCalls_cloned(&msg_conv);
10683         }
10684         LDKPublicKey sender_node_id_ref;
10685         CHECK(sender_node_id->arr_len == 33);
10686         memcpy(sender_node_id_ref.compressed_form, sender_node_id->elems, 33); FREE(sender_node_id);
10687         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
10688         *ret_conv = (this_arg_conv->handle_custom_message)(this_arg_conv->this_arg, msg_conv, sender_node_id_ref);
10689         return (uint32_t)ret_conv;
10690 }
10691
10692 uint32_tArray  __attribute__((export_name("TS_CustomMessageHandler_get_and_clear_pending_msg"))) TS_CustomMessageHandler_get_and_clear_pending_msg(uint32_t this_arg) {
10693         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10694         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10695         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
10696         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_var = (this_arg_conv->get_and_clear_pending_msg)(this_arg_conv->this_arg);
10697         uint32_tArray ret_arr = NULL;
10698         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
10699         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 8);
10700         for (size_t z = 0; z < ret_var.datalen; z++) {
10701                 LDKC2Tuple_PublicKeyTypeZ* ret_conv_25_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
10702                 *ret_conv_25_conv = ret_var.data[z];
10703                 ret_arr_ptr[z] = ((uint32_t)ret_conv_25_conv);
10704         }
10705         
10706         FREE(ret_var.data);
10707         return ret_arr;
10708 }
10709
10710 typedef struct LDKSocketDescriptor_JCalls {
10711         atomic_size_t refcnt;
10712         uint32_t instance_ptr;
10713 } LDKSocketDescriptor_JCalls;
10714 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
10715         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
10716         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10717                 FREE(j_calls);
10718         }
10719 }
10720 uintptr_t send_data_LDKSocketDescriptor_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
10721         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
10722         LDKu8slice data_var = data;
10723         int8_tArray data_arr = init_int8_tArray(data_var.datalen, __LINE__);
10724         memcpy(data_arr->elems, data_var.data, data_var.datalen);
10725         jboolean resume_read_conv = resume_read;
10726         return js_invoke_function_uuuuuu(j_calls->instance_ptr, 88, (uint32_t)data_arr, (uint32_t)resume_read_conv, 0, 0, 0, 0);
10727 }
10728 void disconnect_socket_LDKSocketDescriptor_jcall(void* this_arg) {
10729         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
10730         js_invoke_function_uuuuuu(j_calls->instance_ptr, 89, 0, 0, 0, 0, 0, 0);
10731 }
10732 bool eq_LDKSocketDescriptor_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
10733         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
10734         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
10735         *other_arg_clone = SocketDescriptor_clone(other_arg);
10736         return js_invoke_function_uuuuuu(j_calls->instance_ptr, 90, (uint32_t)(uint32_t)other_arg_clone, 0, 0, 0, 0, 0);
10737 }
10738 uint64_t hash_LDKSocketDescriptor_jcall(const void* this_arg) {
10739         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
10740         return js_invoke_function_uuuuuu(j_calls->instance_ptr, 91, 0, 0, 0, 0, 0, 0);
10741 }
10742 static void LDKSocketDescriptor_JCalls_cloned(LDKSocketDescriptor* new_obj) {
10743         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) new_obj->this_arg;
10744         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10745 }
10746 static inline LDKSocketDescriptor LDKSocketDescriptor_init (JSValue o) {
10747         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
10748         atomic_init(&calls->refcnt, 1);
10749         calls->instance_ptr = o;
10750
10751         LDKSocketDescriptor ret = {
10752                 .this_arg = (void*) calls,
10753                 .send_data = send_data_LDKSocketDescriptor_jcall,
10754                 .disconnect_socket = disconnect_socket_LDKSocketDescriptor_jcall,
10755                 .eq = eq_LDKSocketDescriptor_jcall,
10756                 .hash = hash_LDKSocketDescriptor_jcall,
10757                 .cloned = LDKSocketDescriptor_JCalls_cloned,
10758                 .free = LDKSocketDescriptor_JCalls_free,
10759         };
10760         return ret;
10761 }
10762 long  __attribute__((export_name("TS_LDKSocketDescriptor_new"))) TS_LDKSocketDescriptor_new(JSValue o) {
10763         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
10764         *res_ptr = LDKSocketDescriptor_init(o);
10765         return (long)res_ptr;
10766 }
10767 uint32_t  __attribute__((export_name("TS_SocketDescriptor_send_data"))) TS_SocketDescriptor_send_data(uint32_t this_arg, int8_tArray data, jboolean resume_read) {
10768         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10769         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10770         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
10771         LDKu8slice data_ref;
10772         data_ref.datalen = data->arr_len;
10773         data_ref.data = data->elems;
10774         uint32_t ret_conv = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
10775         FREE(data);
10776         return ret_conv;
10777 }
10778
10779 void  __attribute__((export_name("TS_SocketDescriptor_disconnect_socket"))) TS_SocketDescriptor_disconnect_socket(uint32_t this_arg) {
10780         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10781         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10782         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
10783         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
10784 }
10785
10786 int64_t  __attribute__((export_name("TS_SocketDescriptor_hash"))) TS_SocketDescriptor_hash(uint32_t this_arg) {
10787         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10788         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10789         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
10790         int64_t ret_conv = (this_arg_conv->hash)(this_arg_conv->this_arg);
10791         return ret_conv;
10792 }
10793
10794 uint32_t __attribute__((export_name("TS_LDKEffectiveCapacity_ty_from_ptr"))) TS_LDKEffectiveCapacity_ty_from_ptr(uint32_t ptr) {
10795         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)(ptr & ~1);
10796         switch(obj->tag) {
10797                 case LDKEffectiveCapacity_ExactLiquidity: return 0;
10798                 case LDKEffectiveCapacity_MaximumHTLC: return 1;
10799                 case LDKEffectiveCapacity_Total: return 2;
10800                 case LDKEffectiveCapacity_Infinite: return 3;
10801                 case LDKEffectiveCapacity_Unknown: return 4;
10802                 default: abort();
10803         }
10804 }
10805 int64_t __attribute__((export_name("TS_LDKEffectiveCapacity_ExactLiquidity_get_liquidity_msat"))) TS_LDKEffectiveCapacity_ExactLiquidity_get_liquidity_msat(uint32_t ptr) {
10806         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)(ptr & ~1);
10807         assert(obj->tag == LDKEffectiveCapacity_ExactLiquidity);
10808                         int64_t liquidity_msat_conv = obj->exact_liquidity.liquidity_msat;
10809         return liquidity_msat_conv;
10810 }
10811 int64_t __attribute__((export_name("TS_LDKEffectiveCapacity_MaximumHTLC_get_amount_msat"))) TS_LDKEffectiveCapacity_MaximumHTLC_get_amount_msat(uint32_t ptr) {
10812         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)(ptr & ~1);
10813         assert(obj->tag == LDKEffectiveCapacity_MaximumHTLC);
10814                         int64_t amount_msat_conv = obj->maximum_htlc.amount_msat;
10815         return amount_msat_conv;
10816 }
10817 int64_t __attribute__((export_name("TS_LDKEffectiveCapacity_Total_get_capacity_msat"))) TS_LDKEffectiveCapacity_Total_get_capacity_msat(uint32_t ptr) {
10818         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)(ptr & ~1);
10819         assert(obj->tag == LDKEffectiveCapacity_Total);
10820                         int64_t capacity_msat_conv = obj->total.capacity_msat;
10821         return capacity_msat_conv;
10822 }
10823 uint32_t __attribute__((export_name("TS_LDKEffectiveCapacity_Total_get_htlc_maximum_msat"))) TS_LDKEffectiveCapacity_Total_get_htlc_maximum_msat(uint32_t ptr) {
10824         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)(ptr & ~1);
10825         assert(obj->tag == LDKEffectiveCapacity_Total);
10826                         uint32_t htlc_maximum_msat_ref = ((uintptr_t)&obj->total.htlc_maximum_msat) | 1;
10827         return htlc_maximum_msat_ref;
10828 }
10829 typedef struct LDKLockableScore_JCalls {
10830         atomic_size_t refcnt;
10831         uint32_t instance_ptr;
10832 } LDKLockableScore_JCalls;
10833 static void LDKLockableScore_JCalls_free(void* this_arg) {
10834         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
10835         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10836                 FREE(j_calls);
10837         }
10838 }
10839 LDKScore lock_LDKLockableScore_jcall(const void* this_arg) {
10840         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
10841         uint32_t ret = js_invoke_function_uuuuuu(j_calls->instance_ptr, 92, 0, 0, 0, 0, 0, 0);
10842         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10843         CHECK_ACCESS(ret_ptr);
10844         LDKScore ret_conv = *(LDKScore*)(ret_ptr);
10845         if (ret_conv.free == LDKScore_JCalls_free) {
10846                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10847                 LDKScore_JCalls_cloned(&ret_conv);
10848         }// WARNING: we may need a move here but no clone is available for LDKScore
10849         
10850         return ret_conv;
10851 }
10852 static void LDKLockableScore_JCalls_cloned(LDKLockableScore* new_obj) {
10853         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) new_obj->this_arg;
10854         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10855 }
10856 static inline LDKLockableScore LDKLockableScore_init (JSValue o) {
10857         LDKLockableScore_JCalls *calls = MALLOC(sizeof(LDKLockableScore_JCalls), "LDKLockableScore_JCalls");
10858         atomic_init(&calls->refcnt, 1);
10859         calls->instance_ptr = o;
10860
10861         LDKLockableScore ret = {
10862                 .this_arg = (void*) calls,
10863                 .lock = lock_LDKLockableScore_jcall,
10864                 .free = LDKLockableScore_JCalls_free,
10865         };
10866         return ret;
10867 }
10868 long  __attribute__((export_name("TS_LDKLockableScore_new"))) TS_LDKLockableScore_new(JSValue o) {
10869         LDKLockableScore *res_ptr = MALLOC(sizeof(LDKLockableScore), "LDKLockableScore");
10870         *res_ptr = LDKLockableScore_init(o);
10871         return (long)res_ptr;
10872 }
10873 uint32_t  __attribute__((export_name("TS_LockableScore_lock"))) TS_LockableScore_lock(uint32_t this_arg) {
10874         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10875         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10876         LDKLockableScore* this_arg_conv = (LDKLockableScore*)this_arg_ptr;
10877         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
10878         *ret_ret = (this_arg_conv->lock)(this_arg_conv->this_arg);
10879         return (uint32_t)ret_ret;
10880 }
10881
10882 uint32_t __attribute__((export_name("TS_LDKFallback_ty_from_ptr"))) TS_LDKFallback_ty_from_ptr(uint32_t ptr) {
10883         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
10884         switch(obj->tag) {
10885                 case LDKFallback_SegWitProgram: return 0;
10886                 case LDKFallback_PubKeyHash: return 1;
10887                 case LDKFallback_ScriptHash: return 2;
10888                 default: abort();
10889         }
10890 }
10891 int8_t __attribute__((export_name("TS_LDKFallback_SegWitProgram_get_version"))) TS_LDKFallback_SegWitProgram_get_version(uint32_t ptr) {
10892         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
10893         assert(obj->tag == LDKFallback_SegWitProgram);
10894                         uint8_t version_val = obj->seg_wit_program.version._0;
10895         return version_val;
10896 }
10897 int8_tArray __attribute__((export_name("TS_LDKFallback_SegWitProgram_get_program"))) TS_LDKFallback_SegWitProgram_get_program(uint32_t ptr) {
10898         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
10899         assert(obj->tag == LDKFallback_SegWitProgram);
10900                         LDKCVec_u8Z program_var = obj->seg_wit_program.program;
10901                         int8_tArray program_arr = init_int8_tArray(program_var.datalen, __LINE__);
10902                         memcpy(program_arr->elems, program_var.data, program_var.datalen);
10903         return program_arr;
10904 }
10905 int8_tArray __attribute__((export_name("TS_LDKFallback_PubKeyHash_get_pub_key_hash"))) TS_LDKFallback_PubKeyHash_get_pub_key_hash(uint32_t ptr) {
10906         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
10907         assert(obj->tag == LDKFallback_PubKeyHash);
10908                         int8_tArray pub_key_hash_arr = init_int8_tArray(20, __LINE__);
10909                         memcpy(pub_key_hash_arr->elems, obj->pub_key_hash.data, 20);
10910         return pub_key_hash_arr;
10911 }
10912 int8_tArray __attribute__((export_name("TS_LDKFallback_ScriptHash_get_script_hash"))) TS_LDKFallback_ScriptHash_get_script_hash(uint32_t ptr) {
10913         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
10914         assert(obj->tag == LDKFallback_ScriptHash);
10915                         int8_tArray script_hash_arr = init_int8_tArray(20, __LINE__);
10916                         memcpy(script_hash_arr->elems, obj->script_hash.data, 20);
10917         return script_hash_arr;
10918 }
10919 typedef struct LDKPayer_JCalls {
10920         atomic_size_t refcnt;
10921         uint32_t instance_ptr;
10922 } LDKPayer_JCalls;
10923 static void LDKPayer_JCalls_free(void* this_arg) {
10924         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10925         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10926                 FREE(j_calls);
10927         }
10928 }
10929 LDKPublicKey node_id_LDKPayer_jcall(const void* this_arg) {
10930         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10931         int8_tArray ret = (int8_tArray)js_invoke_function_uuuuuu(j_calls->instance_ptr, 93, 0, 0, 0, 0, 0, 0);
10932         LDKPublicKey ret_ref;
10933         CHECK(ret->arr_len == 33);
10934         memcpy(ret_ref.compressed_form, ret->elems, 33); FREE(ret);
10935         return ret_ref;
10936 }
10937 LDKCVec_ChannelDetailsZ first_hops_LDKPayer_jcall(const void* this_arg) {
10938         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10939         uint32_tArray ret = (uint32_tArray)js_invoke_function_uuuuuu(j_calls->instance_ptr, 94, 0, 0, 0, 0, 0, 0);
10940         LDKCVec_ChannelDetailsZ ret_constr;
10941         ret_constr.datalen = ret->arr_len;
10942         if (ret_constr.datalen > 0)
10943                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
10944         else
10945                 ret_constr.data = NULL;
10946         uint32_t* ret_vals = ret->elems;
10947         for (size_t q = 0; q < ret_constr.datalen; q++) {
10948                 uint32_t ret_conv_16 = ret_vals[q];
10949                 LDKChannelDetails ret_conv_16_conv;
10950                 ret_conv_16_conv.inner = (void*)(ret_conv_16 & (~1));
10951                 ret_conv_16_conv.is_owned = (ret_conv_16 & 1) || (ret_conv_16 == 0);
10952                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_conv);
10953                 ret_constr.data[q] = ret_conv_16_conv;
10954         }
10955         FREE(ret);
10956         return ret_constr;
10957 }
10958 LDKCResult_PaymentIdPaymentSendFailureZ send_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_hash, LDKThirtyTwoBytes payment_secret) {
10959         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10960         LDKRoute route_var = *route;
10961         uint32_t route_ref = 0;
10962         route_var = Route_clone(&route_var);
10963         CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10964         CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10965         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
10966         route_ref = (uintptr_t)route_var.inner;
10967         if (route_var.is_owned) {
10968                 route_ref |= 1;
10969         }
10970         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
10971         memcpy(payment_hash_arr->elems, payment_hash.data, 32);
10972         int8_tArray payment_secret_arr = init_int8_tArray(32, __LINE__);
10973         memcpy(payment_secret_arr->elems, payment_secret.data, 32);
10974         uint32_t ret = js_invoke_function_uuuuuu(j_calls->instance_ptr, 95, (uint32_t)route_ref, (uint32_t)payment_hash_arr, (uint32_t)payment_secret_arr, 0, 0, 0);
10975         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10976         CHECK_ACCESS(ret_ptr);
10977         LDKCResult_PaymentIdPaymentSendFailureZ ret_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(ret_ptr);
10978         FREE((void*)ret);
10979         return ret_conv;
10980 }
10981 LDKCResult_PaymentIdPaymentSendFailureZ send_spontaneous_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_preimage) {
10982         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10983         LDKRoute route_var = *route;
10984         uint32_t route_ref = 0;
10985         route_var = Route_clone(&route_var);
10986         CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10987         CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10988         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
10989         route_ref = (uintptr_t)route_var.inner;
10990         if (route_var.is_owned) {
10991                 route_ref |= 1;
10992         }
10993         int8_tArray payment_preimage_arr = init_int8_tArray(32, __LINE__);
10994         memcpy(payment_preimage_arr->elems, payment_preimage.data, 32);
10995         uint32_t ret = js_invoke_function_uuuuuu(j_calls->instance_ptr, 96, (uint32_t)route_ref, (uint32_t)payment_preimage_arr, 0, 0, 0, 0);
10996         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10997         CHECK_ACCESS(ret_ptr);
10998         LDKCResult_PaymentIdPaymentSendFailureZ ret_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(ret_ptr);
10999         FREE((void*)ret);
11000         return ret_conv;
11001 }
11002 LDKCResult_NonePaymentSendFailureZ retry_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_id) {
11003         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
11004         LDKRoute route_var = *route;
11005         uint32_t route_ref = 0;
11006         route_var = Route_clone(&route_var);
11007         CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11008         CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11009         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
11010         route_ref = (uintptr_t)route_var.inner;
11011         if (route_var.is_owned) {
11012                 route_ref |= 1;
11013         }
11014         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
11015         memcpy(payment_id_arr->elems, payment_id.data, 32);
11016         uint32_t ret = js_invoke_function_uuuuuu(j_calls->instance_ptr, 97, (uint32_t)route_ref, (uint32_t)payment_id_arr, 0, 0, 0, 0);
11017         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
11018         CHECK_ACCESS(ret_ptr);
11019         LDKCResult_NonePaymentSendFailureZ ret_conv = *(LDKCResult_NonePaymentSendFailureZ*)(ret_ptr);
11020         FREE((void*)ret);
11021         return ret_conv;
11022 }
11023 void abandon_payment_LDKPayer_jcall(const void* this_arg, LDKThirtyTwoBytes payment_id) {
11024         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
11025         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
11026         memcpy(payment_id_arr->elems, payment_id.data, 32);
11027         js_invoke_function_uuuuuu(j_calls->instance_ptr, 98, (uint32_t)payment_id_arr, 0, 0, 0, 0, 0);
11028 }
11029 static void LDKPayer_JCalls_cloned(LDKPayer* new_obj) {
11030         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) new_obj->this_arg;
11031         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11032 }
11033 static inline LDKPayer LDKPayer_init (JSValue o) {
11034         LDKPayer_JCalls *calls = MALLOC(sizeof(LDKPayer_JCalls), "LDKPayer_JCalls");
11035         atomic_init(&calls->refcnt, 1);
11036         calls->instance_ptr = o;
11037
11038         LDKPayer ret = {
11039                 .this_arg = (void*) calls,
11040                 .node_id = node_id_LDKPayer_jcall,
11041                 .first_hops = first_hops_LDKPayer_jcall,
11042                 .send_payment = send_payment_LDKPayer_jcall,
11043                 .send_spontaneous_payment = send_spontaneous_payment_LDKPayer_jcall,
11044                 .retry_payment = retry_payment_LDKPayer_jcall,
11045                 .abandon_payment = abandon_payment_LDKPayer_jcall,
11046                 .free = LDKPayer_JCalls_free,
11047         };
11048         return ret;
11049 }
11050 long  __attribute__((export_name("TS_LDKPayer_new"))) TS_LDKPayer_new(JSValue o) {
11051         LDKPayer *res_ptr = MALLOC(sizeof(LDKPayer), "LDKPayer");
11052         *res_ptr = LDKPayer_init(o);
11053         return (long)res_ptr;
11054 }
11055 int8_tArray  __attribute__((export_name("TS_Payer_node_id"))) TS_Payer_node_id(uint32_t this_arg) {
11056         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11057         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11058         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
11059         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
11060         memcpy(ret_arr->elems, (this_arg_conv->node_id)(this_arg_conv->this_arg).compressed_form, 33);
11061         return ret_arr;
11062 }
11063
11064 uint32_tArray  __attribute__((export_name("TS_Payer_first_hops"))) TS_Payer_first_hops(uint32_t this_arg) {
11065         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11066         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11067         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
11068         LDKCVec_ChannelDetailsZ ret_var = (this_arg_conv->first_hops)(this_arg_conv->this_arg);
11069         uint32_tArray ret_arr = NULL;
11070         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
11071         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 8);
11072         for (size_t q = 0; q < ret_var.datalen; q++) {
11073                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
11074                 uint32_t ret_conv_16_ref = 0;
11075                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11076                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11077                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
11078                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
11079                 if (ret_conv_16_var.is_owned) {
11080                         ret_conv_16_ref |= 1;
11081                 }
11082                 ret_arr_ptr[q] = ret_conv_16_ref;
11083         }
11084         
11085         FREE(ret_var.data);
11086         return ret_arr;
11087 }
11088
11089 uint32_t  __attribute__((export_name("TS_Payer_send_payment"))) TS_Payer_send_payment(uint32_t this_arg, uint32_t route, int8_tArray payment_hash, int8_tArray payment_secret) {
11090         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11091         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11092         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
11093         LDKRoute route_conv;
11094         route_conv.inner = (void*)(route & (~1));
11095         route_conv.is_owned = false;
11096         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
11097         LDKThirtyTwoBytes payment_hash_ref;
11098         CHECK(payment_hash->arr_len == 32);
11099         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
11100         LDKThirtyTwoBytes payment_secret_ref;
11101         CHECK(payment_secret->arr_len == 32);
11102         memcpy(payment_secret_ref.data, payment_secret->elems, 32); FREE(payment_secret);
11103         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
11104         *ret_conv = (this_arg_conv->send_payment)(this_arg_conv->this_arg, &route_conv, payment_hash_ref, payment_secret_ref);
11105         return (uint32_t)ret_conv;
11106 }
11107
11108 uint32_t  __attribute__((export_name("TS_Payer_send_spontaneous_payment"))) TS_Payer_send_spontaneous_payment(uint32_t this_arg, uint32_t route, int8_tArray payment_preimage) {
11109         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11110         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11111         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
11112         LDKRoute route_conv;
11113         route_conv.inner = (void*)(route & (~1));
11114         route_conv.is_owned = false;
11115         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
11116         LDKThirtyTwoBytes payment_preimage_ref;
11117         CHECK(payment_preimage->arr_len == 32);
11118         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
11119         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
11120         *ret_conv = (this_arg_conv->send_spontaneous_payment)(this_arg_conv->this_arg, &route_conv, payment_preimage_ref);
11121         return (uint32_t)ret_conv;
11122 }
11123
11124 uint32_t  __attribute__((export_name("TS_Payer_retry_payment"))) TS_Payer_retry_payment(uint32_t this_arg, uint32_t route, int8_tArray payment_id) {
11125         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11126         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11127         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
11128         LDKRoute route_conv;
11129         route_conv.inner = (void*)(route & (~1));
11130         route_conv.is_owned = false;
11131         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
11132         LDKThirtyTwoBytes payment_id_ref;
11133         CHECK(payment_id->arr_len == 32);
11134         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
11135         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
11136         *ret_conv = (this_arg_conv->retry_payment)(this_arg_conv->this_arg, &route_conv, payment_id_ref);
11137         return (uint32_t)ret_conv;
11138 }
11139
11140 void  __attribute__((export_name("TS_Payer_abandon_payment"))) TS_Payer_abandon_payment(uint32_t this_arg, int8_tArray payment_id) {
11141         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11142         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11143         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
11144         LDKThirtyTwoBytes payment_id_ref;
11145         CHECK(payment_id->arr_len == 32);
11146         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
11147         (this_arg_conv->abandon_payment)(this_arg_conv->this_arg, payment_id_ref);
11148 }
11149
11150 typedef struct LDKRouter_JCalls {
11151         atomic_size_t refcnt;
11152         uint32_t instance_ptr;
11153 } LDKRouter_JCalls;
11154 static void LDKRouter_JCalls_free(void* this_arg) {
11155         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
11156         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11157                 FREE(j_calls);
11158         }
11159 }
11160 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, const LDKScore * scorer) {
11161         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
11162         int8_tArray payer_arr = init_int8_tArray(33, __LINE__);
11163         memcpy(payer_arr->elems, payer.compressed_form, 33);
11164         LDKRouteParameters route_params_var = *route_params;
11165         uint32_t route_params_ref = 0;
11166         route_params_var = RouteParameters_clone(&route_params_var);
11167         CHECK((((uintptr_t)route_params_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11168         CHECK((((uintptr_t)&route_params_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11169         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_var);
11170         route_params_ref = (uintptr_t)route_params_var.inner;
11171         if (route_params_var.is_owned) {
11172                 route_params_ref |= 1;
11173         }
11174         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
11175         memcpy(payment_hash_arr->elems, *payment_hash, 32);
11176         LDKCVec_ChannelDetailsZ *first_hops_var_ptr = first_hops;
11177         uint32_tArray first_hops_arr = NULL;
11178         if (first_hops != NULL) {
11179                 LDKCVec_ChannelDetailsZ first_hops_var = *first_hops_var_ptr;
11180                 first_hops_arr = init_uint32_tArray(first_hops_var.datalen, __LINE__);
11181                 uint32_t *first_hops_arr_ptr = (uint32_t*)(((uint8_t*)first_hops_arr) + 8);
11182                 for (size_t q = 0; q < first_hops_var.datalen; q++) {
11183                         LDKChannelDetails first_hops_conv_16_var =      first_hops_var.data[q];
11184                         uint32_t first_hops_conv_16_ref = 0;
11185                         CHECK((((uintptr_t)first_hops_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11186                         CHECK((((uintptr_t)&first_hops_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11187                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_var);
11188                         first_hops_conv_16_ref = (uintptr_t)first_hops_conv_16_var.inner;
11189                         if (first_hops_conv_16_var.is_owned) {
11190                                 first_hops_conv_16_ref |= 1;
11191                         }
11192                         first_hops_arr_ptr[q] = first_hops_conv_16_ref;
11193                 }
11194         
11195         }
11196         // WARNING: This object doesn't live past this scope, needs clone!
11197         uint32_t ret_scorer = ((uintptr_t)scorer) | 1;
11198         uint32_t ret = js_invoke_function_uuuuuu(j_calls->instance_ptr, 99, (uint32_t)payer_arr, (uint32_t)route_params_ref, (uint32_t)payment_hash_arr, (uint32_t)first_hops_arr, (uint32_t)ret_scorer, 0);
11199         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
11200         CHECK_ACCESS(ret_ptr);
11201         LDKCResult_RouteLightningErrorZ ret_conv = *(LDKCResult_RouteLightningErrorZ*)(ret_ptr);
11202         FREE((void*)ret);
11203         return ret_conv;
11204 }
11205 static void LDKRouter_JCalls_cloned(LDKRouter* new_obj) {
11206         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) new_obj->this_arg;
11207         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11208 }
11209 static inline LDKRouter LDKRouter_init (JSValue o) {
11210         LDKRouter_JCalls *calls = MALLOC(sizeof(LDKRouter_JCalls), "LDKRouter_JCalls");
11211         atomic_init(&calls->refcnt, 1);
11212         calls->instance_ptr = o;
11213
11214         LDKRouter ret = {
11215                 .this_arg = (void*) calls,
11216                 .find_route = find_route_LDKRouter_jcall,
11217                 .free = LDKRouter_JCalls_free,
11218         };
11219         return ret;
11220 }
11221 long  __attribute__((export_name("TS_LDKRouter_new"))) TS_LDKRouter_new(JSValue o) {
11222         LDKRouter *res_ptr = MALLOC(sizeof(LDKRouter), "LDKRouter");
11223         *res_ptr = LDKRouter_init(o);
11224         return (long)res_ptr;
11225 }
11226 uint32_t  __attribute__((export_name("TS_Router_find_route"))) TS_Router_find_route(uint32_t this_arg, int8_tArray payer, uint32_t route_params, int8_tArray payment_hash, uint32_tArray first_hops, uint32_t scorer) {
11227         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11228         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11229         LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
11230         LDKPublicKey payer_ref;
11231         CHECK(payer->arr_len == 33);
11232         memcpy(payer_ref.compressed_form, payer->elems, 33); FREE(payer);
11233         LDKRouteParameters route_params_conv;
11234         route_params_conv.inner = (void*)(route_params & (~1));
11235         route_params_conv.is_owned = false;
11236         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
11237         unsigned char payment_hash_arr[32];
11238         CHECK(payment_hash->arr_len == 32);
11239         memcpy(payment_hash_arr, payment_hash->elems, 32); FREE(payment_hash);
11240         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
11241         LDKCVec_ChannelDetailsZ first_hops_constr;
11242         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
11243         if (first_hops != 0) {
11244                 first_hops_constr.datalen = first_hops->arr_len;
11245                 if (first_hops_constr.datalen > 0)
11246                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
11247                 else
11248                         first_hops_constr.data = NULL;
11249                 uint32_t* first_hops_vals = first_hops->elems;
11250                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
11251                         uint32_t first_hops_conv_16 = first_hops_vals[q];
11252                         LDKChannelDetails first_hops_conv_16_conv;
11253                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
11254                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
11255                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
11256                         first_hops_constr.data[q] = first_hops_conv_16_conv;
11257                 }
11258                 FREE(first_hops);
11259                 first_hops_ptr = &first_hops_constr;
11260         }
11261         void* scorer_ptr = (void*)(((uintptr_t)scorer) & ~1);
11262         if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
11263         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
11264         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
11265         *ret_conv = (this_arg_conv->find_route)(this_arg_conv->this_arg, payer_ref, &route_params_conv, payment_hash_ref, first_hops_ptr, scorer_conv);
11266         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
11267         return (uint32_t)ret_conv;
11268 }
11269
11270 uint32_t __attribute__((export_name("TS_LDKRetry_ty_from_ptr"))) TS_LDKRetry_ty_from_ptr(uint32_t ptr) {
11271         LDKRetry *obj = (LDKRetry*)(ptr & ~1);
11272         switch(obj->tag) {
11273                 case LDKRetry_Attempts: return 0;
11274                 default: abort();
11275         }
11276 }
11277 uint32_t __attribute__((export_name("TS_LDKRetry_Attempts_get_attempts"))) TS_LDKRetry_Attempts_get_attempts(uint32_t ptr) {
11278         LDKRetry *obj = (LDKRetry*)(ptr & ~1);
11279         assert(obj->tag == LDKRetry_Attempts);
11280                         uint32_t attempts_conv = obj->attempts;
11281         return attempts_conv;
11282 }
11283 jstring  __attribute__((export_name("TS__ldk_get_compiled_version"))) TS__ldk_get_compiled_version() {
11284         LDKStr ret_str = _ldk_get_compiled_version();
11285         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
11286         Str_free(ret_str);
11287         return ret_conv;
11288 }
11289
11290 jstring  __attribute__((export_name("TS__ldk_c_bindings_get_compiled_version"))) TS__ldk_c_bindings_get_compiled_version() {
11291         LDKStr ret_str = _ldk_c_bindings_get_compiled_version();
11292         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
11293         Str_free(ret_str);
11294         return ret_conv;
11295 }
11296
11297 static inline uintptr_t Bech32Error_clone_ptr(LDKBech32Error *NONNULL_PTR arg) {
11298         LDKBech32Error *ret_copy = MALLOC(sizeof(LDKBech32Error), "LDKBech32Error");
11299         *ret_copy = Bech32Error_clone(arg);
11300 uint32_t ret_ref = (uintptr_t)ret_copy;
11301         return ret_ref;
11302 }
11303 uint32_t  __attribute__((export_name("TS_Bech32Error_clone_ptr"))) TS_Bech32Error_clone_ptr(uint32_t arg) {
11304         LDKBech32Error* arg_conv = (LDKBech32Error*)arg;
11305         uint32_t ret_conv = Bech32Error_clone_ptr(arg_conv);
11306         return ret_conv;
11307 }
11308
11309 uint32_t  __attribute__((export_name("TS_Bech32Error_clone"))) TS_Bech32Error_clone(uint32_t orig) {
11310         LDKBech32Error* orig_conv = (LDKBech32Error*)orig;
11311         LDKBech32Error *ret_copy = MALLOC(sizeof(LDKBech32Error), "LDKBech32Error");
11312         *ret_copy = Bech32Error_clone(orig_conv);
11313         uint32_t ret_ref = (uintptr_t)ret_copy;
11314         return ret_ref;
11315 }
11316
11317 void  __attribute__((export_name("TS_Bech32Error_free"))) TS_Bech32Error_free(uint32_t o) {
11318         if ((o & 1) != 0) return;
11319         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
11320         CHECK_ACCESS(o_ptr);
11321         LDKBech32Error o_conv = *(LDKBech32Error*)(o_ptr);
11322         FREE((void*)o);
11323         Bech32Error_free(o_conv);
11324 }
11325
11326 void  __attribute__((export_name("TS_Transaction_free"))) TS_Transaction_free(int8_tArray _res) {
11327         LDKTransaction _res_ref;
11328         _res_ref.datalen = _res->arr_len;
11329         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
11330         memcpy(_res_ref.data, _res->elems, _res_ref.datalen); FREE(_res);
11331         _res_ref.data_is_owned = true;
11332         Transaction_free(_res_ref);
11333 }
11334
11335 uint32_t  __attribute__((export_name("TS_TxOut_new"))) TS_TxOut_new(int8_tArray script_pubkey, int64_t value) {
11336         LDKCVec_u8Z script_pubkey_ref;
11337         script_pubkey_ref.datalen = script_pubkey->arr_len;
11338         script_pubkey_ref.data = MALLOC(script_pubkey_ref.datalen, "LDKCVec_u8Z Bytes");
11339         memcpy(script_pubkey_ref.data, script_pubkey->elems, script_pubkey_ref.datalen); FREE(script_pubkey);
11340         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
11341         *ret_ref = TxOut_new(script_pubkey_ref, value);
11342         return (uint32_t)ret_ref;
11343 }
11344
11345 void  __attribute__((export_name("TS_TxOut_free"))) TS_TxOut_free(uint32_t _res) {
11346         if ((_res & 1) != 0) return;
11347         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11348         CHECK_ACCESS(_res_ptr);
11349         LDKTxOut _res_conv = *(LDKTxOut*)(_res_ptr);
11350         FREE((void*)_res);
11351         TxOut_free(_res_conv);
11352 }
11353
11354 static inline uintptr_t TxOut_clone_ptr(LDKTxOut *NONNULL_PTR arg) {
11355         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
11356         *ret_ref = TxOut_clone(arg);
11357         return (uint32_t)ret_ref;
11358 }
11359 uint32_t  __attribute__((export_name("TS_TxOut_clone_ptr"))) TS_TxOut_clone_ptr(uint32_t arg) {
11360         LDKTxOut* arg_conv = (LDKTxOut*)(arg & ~1);
11361         uint32_t ret_conv = TxOut_clone_ptr(arg_conv);
11362         return ret_conv;
11363 }
11364
11365 uint32_t  __attribute__((export_name("TS_TxOut_clone"))) TS_TxOut_clone(uint32_t orig) {
11366         LDKTxOut* orig_conv = (LDKTxOut*)(orig & ~1);
11367         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
11368         *ret_ref = TxOut_clone(orig_conv);
11369         return (uint32_t)ret_ref;
11370 }
11371
11372 void  __attribute__((export_name("TS_Str_free"))) TS_Str_free(jstring _res) {
11373         LDKStr dummy = { .chars = NULL, .len = 0, .chars_is_owned = false };
11374         Str_free(dummy);
11375 }
11376
11377 uint32_t  __attribute__((export_name("TS_CResult_NoneNoneZ_ok"))) TS_CResult_NoneNoneZ_ok() {
11378         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
11379         *ret_conv = CResult_NoneNoneZ_ok();
11380         return (uint32_t)ret_conv;
11381 }
11382
11383 uint32_t  __attribute__((export_name("TS_CResult_NoneNoneZ_err"))) TS_CResult_NoneNoneZ_err() {
11384         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
11385         *ret_conv = CResult_NoneNoneZ_err();
11386         return (uint32_t)ret_conv;
11387 }
11388
11389 jboolean  __attribute__((export_name("TS_CResult_NoneNoneZ_is_ok"))) TS_CResult_NoneNoneZ_is_ok(uint32_t o) {
11390         LDKCResult_NoneNoneZ* o_conv = (LDKCResult_NoneNoneZ*)(o & ~1);
11391         jboolean ret_conv = CResult_NoneNoneZ_is_ok(o_conv);
11392         return ret_conv;
11393 }
11394
11395 void  __attribute__((export_name("TS_CResult_NoneNoneZ_free"))) TS_CResult_NoneNoneZ_free(uint32_t _res) {
11396         if ((_res & 1) != 0) return;
11397         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11398         CHECK_ACCESS(_res_ptr);
11399         LDKCResult_NoneNoneZ _res_conv = *(LDKCResult_NoneNoneZ*)(_res_ptr);
11400         FREE((void*)_res);
11401         CResult_NoneNoneZ_free(_res_conv);
11402 }
11403
11404 static inline uintptr_t CResult_NoneNoneZ_clone_ptr(LDKCResult_NoneNoneZ *NONNULL_PTR arg) {
11405         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
11406         *ret_conv = CResult_NoneNoneZ_clone(arg);
11407         return (uint32_t)ret_conv;
11408 }
11409 uint32_t  __attribute__((export_name("TS_CResult_NoneNoneZ_clone_ptr"))) TS_CResult_NoneNoneZ_clone_ptr(uint32_t arg) {
11410         LDKCResult_NoneNoneZ* arg_conv = (LDKCResult_NoneNoneZ*)(arg & ~1);
11411         uint32_t ret_conv = CResult_NoneNoneZ_clone_ptr(arg_conv);
11412         return ret_conv;
11413 }
11414
11415 uint32_t  __attribute__((export_name("TS_CResult_NoneNoneZ_clone"))) TS_CResult_NoneNoneZ_clone(uint32_t orig) {
11416         LDKCResult_NoneNoneZ* orig_conv = (LDKCResult_NoneNoneZ*)(orig & ~1);
11417         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
11418         *ret_conv = CResult_NoneNoneZ_clone(orig_conv);
11419         return (uint32_t)ret_conv;
11420 }
11421
11422 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok(uint32_t o) {
11423         LDKCounterpartyCommitmentSecrets o_conv;
11424         o_conv.inner = (void*)(o & (~1));
11425         o_conv.is_owned = (o & 1) || (o == 0);
11426         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11427         o_conv = CounterpartyCommitmentSecrets_clone(&o_conv);
11428         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
11429         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok(o_conv);
11430         return (uint32_t)ret_conv;
11431 }
11432
11433 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err(uint32_t e) {
11434         LDKDecodeError e_conv;
11435         e_conv.inner = (void*)(e & (~1));
11436         e_conv.is_owned = (e & 1) || (e == 0);
11437         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11438         e_conv = DecodeError_clone(&e_conv);
11439         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
11440         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err(e_conv);
11441         return (uint32_t)ret_conv;
11442 }
11443
11444 jboolean  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok(uint32_t o) {
11445         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* o_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(o & ~1);
11446         jboolean ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok(o_conv);
11447         return ret_conv;
11448 }
11449
11450 void  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free(uint32_t _res) {
11451         if ((_res & 1) != 0) return;
11452         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11453         CHECK_ACCESS(_res_ptr);
11454         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(_res_ptr);
11455         FREE((void*)_res);
11456         CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free(_res_conv);
11457 }
11458
11459 static inline uintptr_t CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR arg) {
11460         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
11461         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(arg);
11462         return (uint32_t)ret_conv;
11463 }
11464 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(uint32_t arg) {
11465         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(arg & ~1);
11466         uint32_t ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(arg_conv);
11467         return ret_conv;
11468 }
11469
11470 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(uint32_t orig) {
11471         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(orig & ~1);
11472         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
11473         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(orig_conv);
11474         return (uint32_t)ret_conv;
11475 }
11476
11477 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_ok"))) TS_CResult_SecretKeyErrorZ_ok(int8_tArray o) {
11478         LDKSecretKey o_ref;
11479         CHECK(o->arr_len == 32);
11480         memcpy(o_ref.bytes, o->elems, 32); FREE(o);
11481         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
11482         *ret_conv = CResult_SecretKeyErrorZ_ok(o_ref);
11483         return (uint32_t)ret_conv;
11484 }
11485
11486 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_err"))) TS_CResult_SecretKeyErrorZ_err(uint32_t e) {
11487         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
11488         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
11489         *ret_conv = CResult_SecretKeyErrorZ_err(e_conv);
11490         return (uint32_t)ret_conv;
11491 }
11492
11493 jboolean  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_is_ok"))) TS_CResult_SecretKeyErrorZ_is_ok(uint32_t o) {
11494         LDKCResult_SecretKeyErrorZ* o_conv = (LDKCResult_SecretKeyErrorZ*)(o & ~1);
11495         jboolean ret_conv = CResult_SecretKeyErrorZ_is_ok(o_conv);
11496         return ret_conv;
11497 }
11498
11499 void  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_free"))) TS_CResult_SecretKeyErrorZ_free(uint32_t _res) {
11500         if ((_res & 1) != 0) return;
11501         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11502         CHECK_ACCESS(_res_ptr);
11503         LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(_res_ptr);
11504         FREE((void*)_res);
11505         CResult_SecretKeyErrorZ_free(_res_conv);
11506 }
11507
11508 static inline uintptr_t CResult_SecretKeyErrorZ_clone_ptr(LDKCResult_SecretKeyErrorZ *NONNULL_PTR arg) {
11509         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
11510         *ret_conv = CResult_SecretKeyErrorZ_clone(arg);
11511         return (uint32_t)ret_conv;
11512 }
11513 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_clone_ptr"))) TS_CResult_SecretKeyErrorZ_clone_ptr(uint32_t arg) {
11514         LDKCResult_SecretKeyErrorZ* arg_conv = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
11515         uint32_t ret_conv = CResult_SecretKeyErrorZ_clone_ptr(arg_conv);
11516         return ret_conv;
11517 }
11518
11519 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_clone"))) TS_CResult_SecretKeyErrorZ_clone(uint32_t orig) {
11520         LDKCResult_SecretKeyErrorZ* orig_conv = (LDKCResult_SecretKeyErrorZ*)(orig & ~1);
11521         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
11522         *ret_conv = CResult_SecretKeyErrorZ_clone(orig_conv);
11523         return (uint32_t)ret_conv;
11524 }
11525
11526 uint32_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_ok"))) TS_CResult_PublicKeyErrorZ_ok(int8_tArray o) {
11527         LDKPublicKey o_ref;
11528         CHECK(o->arr_len == 33);
11529         memcpy(o_ref.compressed_form, o->elems, 33); FREE(o);
11530         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
11531         *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
11532         return (uint32_t)ret_conv;
11533 }
11534
11535 uint32_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_err"))) TS_CResult_PublicKeyErrorZ_err(uint32_t e) {
11536         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
11537         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
11538         *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
11539         return (uint32_t)ret_conv;
11540 }
11541
11542 jboolean  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_is_ok"))) TS_CResult_PublicKeyErrorZ_is_ok(uint32_t o) {
11543         LDKCResult_PublicKeyErrorZ* o_conv = (LDKCResult_PublicKeyErrorZ*)(o & ~1);
11544         jboolean ret_conv = CResult_PublicKeyErrorZ_is_ok(o_conv);
11545         return ret_conv;
11546 }
11547
11548 void  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_free"))) TS_CResult_PublicKeyErrorZ_free(uint32_t _res) {
11549         if ((_res & 1) != 0) return;
11550         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11551         CHECK_ACCESS(_res_ptr);
11552         LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(_res_ptr);
11553         FREE((void*)_res);
11554         CResult_PublicKeyErrorZ_free(_res_conv);
11555 }
11556
11557 static inline uintptr_t CResult_PublicKeyErrorZ_clone_ptr(LDKCResult_PublicKeyErrorZ *NONNULL_PTR arg) {
11558         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
11559         *ret_conv = CResult_PublicKeyErrorZ_clone(arg);
11560         return (uint32_t)ret_conv;
11561 }
11562 uint32_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_clone_ptr"))) TS_CResult_PublicKeyErrorZ_clone_ptr(uint32_t arg) {
11563         LDKCResult_PublicKeyErrorZ* arg_conv = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
11564         uint32_t ret_conv = CResult_PublicKeyErrorZ_clone_ptr(arg_conv);
11565         return ret_conv;
11566 }
11567
11568 uint32_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_clone"))) TS_CResult_PublicKeyErrorZ_clone(uint32_t orig) {
11569         LDKCResult_PublicKeyErrorZ* orig_conv = (LDKCResult_PublicKeyErrorZ*)(orig & ~1);
11570         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
11571         *ret_conv = CResult_PublicKeyErrorZ_clone(orig_conv);
11572         return (uint32_t)ret_conv;
11573 }
11574
11575 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_ok"))) TS_CResult_TxCreationKeysDecodeErrorZ_ok(uint32_t o) {
11576         LDKTxCreationKeys o_conv;
11577         o_conv.inner = (void*)(o & (~1));
11578         o_conv.is_owned = (o & 1) || (o == 0);
11579         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11580         o_conv = TxCreationKeys_clone(&o_conv);
11581         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
11582         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
11583         return (uint32_t)ret_conv;
11584 }
11585
11586 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_err"))) TS_CResult_TxCreationKeysDecodeErrorZ_err(uint32_t e) {
11587         LDKDecodeError e_conv;
11588         e_conv.inner = (void*)(e & (~1));
11589         e_conv.is_owned = (e & 1) || (e == 0);
11590         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11591         e_conv = DecodeError_clone(&e_conv);
11592         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
11593         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
11594         return (uint32_t)ret_conv;
11595 }
11596
11597 jboolean  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_is_ok"))) TS_CResult_TxCreationKeysDecodeErrorZ_is_ok(uint32_t o) {
11598         LDKCResult_TxCreationKeysDecodeErrorZ* o_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(o & ~1);
11599         jboolean ret_conv = CResult_TxCreationKeysDecodeErrorZ_is_ok(o_conv);
11600         return ret_conv;
11601 }
11602
11603 void  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_free"))) TS_CResult_TxCreationKeysDecodeErrorZ_free(uint32_t _res) {
11604         if ((_res & 1) != 0) return;
11605         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11606         CHECK_ACCESS(_res_ptr);
11607         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(_res_ptr);
11608         FREE((void*)_res);
11609         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
11610 }
11611
11612 static inline uintptr_t CResult_TxCreationKeysDecodeErrorZ_clone_ptr(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR arg) {
11613         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
11614         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(arg);
11615         return (uint32_t)ret_conv;
11616 }
11617 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_clone_ptr"))) TS_CResult_TxCreationKeysDecodeErrorZ_clone_ptr(uint32_t arg) {
11618         LDKCResult_TxCreationKeysDecodeErrorZ* arg_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
11619         uint32_t ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone_ptr(arg_conv);
11620         return ret_conv;
11621 }
11622
11623 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_clone"))) TS_CResult_TxCreationKeysDecodeErrorZ_clone(uint32_t orig) {
11624         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(orig & ~1);
11625         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
11626         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
11627         return (uint32_t)ret_conv;
11628 }
11629
11630 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_ok"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_ok(uint32_t o) {
11631         LDKChannelPublicKeys o_conv;
11632         o_conv.inner = (void*)(o & (~1));
11633         o_conv.is_owned = (o & 1) || (o == 0);
11634         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11635         o_conv = ChannelPublicKeys_clone(&o_conv);
11636         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
11637         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
11638         return (uint32_t)ret_conv;
11639 }
11640
11641 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_err"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_err(uint32_t e) {
11642         LDKDecodeError e_conv;
11643         e_conv.inner = (void*)(e & (~1));
11644         e_conv.is_owned = (e & 1) || (e == 0);
11645         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11646         e_conv = DecodeError_clone(&e_conv);
11647         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
11648         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
11649         return (uint32_t)ret_conv;
11650 }
11651
11652 jboolean  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_is_ok"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_is_ok(uint32_t o) {
11653         LDKCResult_ChannelPublicKeysDecodeErrorZ* o_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(o & ~1);
11654         jboolean ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_is_ok(o_conv);
11655         return ret_conv;
11656 }
11657
11658 void  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_free"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_free(uint32_t _res) {
11659         if ((_res & 1) != 0) return;
11660         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11661         CHECK_ACCESS(_res_ptr);
11662         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(_res_ptr);
11663         FREE((void*)_res);
11664         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
11665 }
11666
11667 static inline uintptr_t CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR arg) {
11668         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
11669         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(arg);
11670         return (uint32_t)ret_conv;
11671 }
11672 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(uint32_t arg) {
11673         LDKCResult_ChannelPublicKeysDecodeErrorZ* arg_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
11674         uint32_t ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(arg_conv);
11675         return ret_conv;
11676 }
11677
11678 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_clone"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_clone(uint32_t orig) {
11679         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(orig & ~1);
11680         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
11681         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
11682         return (uint32_t)ret_conv;
11683 }
11684
11685 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_ok"))) TS_CResult_TxCreationKeysErrorZ_ok(uint32_t o) {
11686         LDKTxCreationKeys o_conv;
11687         o_conv.inner = (void*)(o & (~1));
11688         o_conv.is_owned = (o & 1) || (o == 0);
11689         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11690         o_conv = TxCreationKeys_clone(&o_conv);
11691         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
11692         *ret_conv = CResult_TxCreationKeysErrorZ_ok(o_conv);
11693         return (uint32_t)ret_conv;
11694 }
11695
11696 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_err"))) TS_CResult_TxCreationKeysErrorZ_err(uint32_t e) {
11697         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
11698         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
11699         *ret_conv = CResult_TxCreationKeysErrorZ_err(e_conv);
11700         return (uint32_t)ret_conv;
11701 }
11702
11703 jboolean  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_is_ok"))) TS_CResult_TxCreationKeysErrorZ_is_ok(uint32_t o) {
11704         LDKCResult_TxCreationKeysErrorZ* o_conv = (LDKCResult_TxCreationKeysErrorZ*)(o & ~1);
11705         jboolean ret_conv = CResult_TxCreationKeysErrorZ_is_ok(o_conv);
11706         return ret_conv;
11707 }
11708
11709 void  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_free"))) TS_CResult_TxCreationKeysErrorZ_free(uint32_t _res) {
11710         if ((_res & 1) != 0) return;
11711         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11712         CHECK_ACCESS(_res_ptr);
11713         LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(_res_ptr);
11714         FREE((void*)_res);
11715         CResult_TxCreationKeysErrorZ_free(_res_conv);
11716 }
11717
11718 static inline uintptr_t CResult_TxCreationKeysErrorZ_clone_ptr(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR arg) {
11719         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
11720         *ret_conv = CResult_TxCreationKeysErrorZ_clone(arg);
11721         return (uint32_t)ret_conv;
11722 }
11723 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_clone_ptr"))) TS_CResult_TxCreationKeysErrorZ_clone_ptr(uint32_t arg) {
11724         LDKCResult_TxCreationKeysErrorZ* arg_conv = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
11725         uint32_t ret_conv = CResult_TxCreationKeysErrorZ_clone_ptr(arg_conv);
11726         return ret_conv;
11727 }
11728
11729 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_clone"))) TS_CResult_TxCreationKeysErrorZ_clone(uint32_t orig) {
11730         LDKCResult_TxCreationKeysErrorZ* orig_conv = (LDKCResult_TxCreationKeysErrorZ*)(orig & ~1);
11731         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
11732         *ret_conv = CResult_TxCreationKeysErrorZ_clone(orig_conv);
11733         return (uint32_t)ret_conv;
11734 }
11735
11736 uint32_t  __attribute__((export_name("TS_COption_u32Z_some"))) TS_COption_u32Z_some(int32_t o) {
11737         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
11738         *ret_copy = COption_u32Z_some(o);
11739         uint32_t ret_ref = (uintptr_t)ret_copy;
11740         return ret_ref;
11741 }
11742
11743 uint32_t  __attribute__((export_name("TS_COption_u32Z_none"))) TS_COption_u32Z_none() {
11744         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
11745         *ret_copy = COption_u32Z_none();
11746         uint32_t ret_ref = (uintptr_t)ret_copy;
11747         return ret_ref;
11748 }
11749
11750 void  __attribute__((export_name("TS_COption_u32Z_free"))) TS_COption_u32Z_free(uint32_t _res) {
11751         if ((_res & 1) != 0) return;
11752         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11753         CHECK_ACCESS(_res_ptr);
11754         LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(_res_ptr);
11755         FREE((void*)_res);
11756         COption_u32Z_free(_res_conv);
11757 }
11758
11759 static inline uintptr_t COption_u32Z_clone_ptr(LDKCOption_u32Z *NONNULL_PTR arg) {
11760         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
11761         *ret_copy = COption_u32Z_clone(arg);
11762 uint32_t ret_ref = (uintptr_t)ret_copy;
11763         return ret_ref;
11764 }
11765 uint32_t  __attribute__((export_name("TS_COption_u32Z_clone_ptr"))) TS_COption_u32Z_clone_ptr(uint32_t arg) {
11766         LDKCOption_u32Z* arg_conv = (LDKCOption_u32Z*)arg;
11767         uint32_t ret_conv = COption_u32Z_clone_ptr(arg_conv);
11768         return ret_conv;
11769 }
11770
11771 uint32_t  __attribute__((export_name("TS_COption_u32Z_clone"))) TS_COption_u32Z_clone(uint32_t orig) {
11772         LDKCOption_u32Z* orig_conv = (LDKCOption_u32Z*)orig;
11773         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
11774         *ret_copy = COption_u32Z_clone(orig_conv);
11775         uint32_t ret_ref = (uintptr_t)ret_copy;
11776         return ret_ref;
11777 }
11778
11779 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_ok"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(uint32_t o) {
11780         LDKHTLCOutputInCommitment o_conv;
11781         o_conv.inner = (void*)(o & (~1));
11782         o_conv.is_owned = (o & 1) || (o == 0);
11783         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11784         o_conv = HTLCOutputInCommitment_clone(&o_conv);
11785         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
11786         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
11787         return (uint32_t)ret_conv;
11788 }
11789
11790 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_err"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_err(uint32_t e) {
11791         LDKDecodeError e_conv;
11792         e_conv.inner = (void*)(e & (~1));
11793         e_conv.is_owned = (e & 1) || (e == 0);
11794         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11795         e_conv = DecodeError_clone(&e_conv);
11796         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
11797         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
11798         return (uint32_t)ret_conv;
11799 }
11800
11801 jboolean  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(uint32_t o) {
11802         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* o_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(o & ~1);
11803         jboolean ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(o_conv);
11804         return ret_conv;
11805 }
11806
11807 void  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_free"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_free(uint32_t _res) {
11808         if ((_res & 1) != 0) return;
11809         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11810         CHECK_ACCESS(_res_ptr);
11811         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(_res_ptr);
11812         FREE((void*)_res);
11813         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
11814 }
11815
11816 static inline uintptr_t CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR arg) {
11817         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
11818         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(arg);
11819         return (uint32_t)ret_conv;
11820 }
11821 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(uint32_t arg) {
11822         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* arg_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
11823         uint32_t ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(arg_conv);
11824         return ret_conv;
11825 }
11826
11827 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(uint32_t orig) {
11828         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(orig & ~1);
11829         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
11830         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
11831         return (uint32_t)ret_conv;
11832 }
11833
11834 uint32_t  __attribute__((export_name("TS_COption_NoneZ_some"))) TS_COption_NoneZ_some() {
11835         uint32_t ret_conv = LDKCOption_NoneZ_to_js(COption_NoneZ_some());
11836         return ret_conv;
11837 }
11838
11839 uint32_t  __attribute__((export_name("TS_COption_NoneZ_none"))) TS_COption_NoneZ_none() {
11840         uint32_t ret_conv = LDKCOption_NoneZ_to_js(COption_NoneZ_none());
11841         return ret_conv;
11842 }
11843
11844 void  __attribute__((export_name("TS_COption_NoneZ_free"))) TS_COption_NoneZ_free(uint32_t _res) {
11845         LDKCOption_NoneZ _res_conv = LDKCOption_NoneZ_from_js(_res);
11846         COption_NoneZ_free(_res_conv);
11847 }
11848
11849 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(uint32_t o) {
11850         LDKCounterpartyChannelTransactionParameters o_conv;
11851         o_conv.inner = (void*)(o & (~1));
11852         o_conv.is_owned = (o & 1) || (o == 0);
11853         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11854         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
11855         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
11856         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
11857         return (uint32_t)ret_conv;
11858 }
11859
11860 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(uint32_t e) {
11861         LDKDecodeError e_conv;
11862         e_conv.inner = (void*)(e & (~1));
11863         e_conv.is_owned = (e & 1) || (e == 0);
11864         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11865         e_conv = DecodeError_clone(&e_conv);
11866         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
11867         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
11868         return (uint32_t)ret_conv;
11869 }
11870
11871 jboolean  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(uint32_t o) {
11872         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(o & ~1);
11873         jboolean ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
11874         return ret_conv;
11875 }
11876
11877 void  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(uint32_t _res) {
11878         if ((_res & 1) != 0) return;
11879         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11880         CHECK_ACCESS(_res_ptr);
11881         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
11882         FREE((void*)_res);
11883         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
11884 }
11885
11886 static inline uintptr_t CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
11887         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
11888         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(arg);
11889         return (uint32_t)ret_conv;
11890 }
11891 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(uint32_t arg) {
11892         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
11893         uint32_t ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
11894         return ret_conv;
11895 }
11896
11897 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(uint32_t orig) {
11898         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
11899         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
11900         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
11901         return (uint32_t)ret_conv;
11902 }
11903
11904 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_ok"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_ok(uint32_t o) {
11905         LDKChannelTransactionParameters o_conv;
11906         o_conv.inner = (void*)(o & (~1));
11907         o_conv.is_owned = (o & 1) || (o == 0);
11908         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11909         o_conv = ChannelTransactionParameters_clone(&o_conv);
11910         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
11911         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
11912         return (uint32_t)ret_conv;
11913 }
11914
11915 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_err"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_err(uint32_t e) {
11916         LDKDecodeError e_conv;
11917         e_conv.inner = (void*)(e & (~1));
11918         e_conv.is_owned = (e & 1) || (e == 0);
11919         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11920         e_conv = DecodeError_clone(&e_conv);
11921         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
11922         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
11923         return (uint32_t)ret_conv;
11924 }
11925
11926 jboolean  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_is_ok"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(uint32_t o) {
11927         LDKCResult_ChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(o & ~1);
11928         jboolean ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
11929         return ret_conv;
11930 }
11931
11932 void  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_free"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_free(uint32_t _res) {
11933         if ((_res & 1) != 0) return;
11934         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11935         CHECK_ACCESS(_res_ptr);
11936         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
11937         FREE((void*)_res);
11938         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
11939 }
11940
11941 static inline uintptr_t CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
11942         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
11943         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(arg);
11944         return (uint32_t)ret_conv;
11945 }
11946 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(uint32_t arg) {
11947         LDKCResult_ChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
11948         uint32_t ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
11949         return ret_conv;
11950 }
11951
11952 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone(uint32_t orig) {
11953         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
11954         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
11955         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
11956         return (uint32_t)ret_conv;
11957 }
11958
11959 void  __attribute__((export_name("TS_CVec_SignatureZ_free"))) TS_CVec_SignatureZ_free(ptrArray _res) {
11960         LDKCVec_SignatureZ _res_constr;
11961         _res_constr.datalen = _res->arr_len;
11962         if (_res_constr.datalen > 0)
11963                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
11964         else
11965                 _res_constr.data = NULL;
11966         int8_tArray* _res_vals = (void*) _res->elems;
11967         for (size_t m = 0; m < _res_constr.datalen; m++) {
11968                 int8_tArray _res_conv_12 = _res_vals[m];
11969                 LDKSignature _res_conv_12_ref;
11970                 CHECK(_res_conv_12->arr_len == 64);
11971                 memcpy(_res_conv_12_ref.compact_form, _res_conv_12->elems, 64); FREE(_res_conv_12);
11972                 _res_constr.data[m] = _res_conv_12_ref;
11973         }
11974         FREE(_res);
11975         CVec_SignatureZ_free(_res_constr);
11976 }
11977
11978 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_ok"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
11979         LDKHolderCommitmentTransaction o_conv;
11980         o_conv.inner = (void*)(o & (~1));
11981         o_conv.is_owned = (o & 1) || (o == 0);
11982         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11983         o_conv = HolderCommitmentTransaction_clone(&o_conv);
11984         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
11985         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
11986         return (uint32_t)ret_conv;
11987 }
11988
11989 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_err"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_err(uint32_t e) {
11990         LDKDecodeError e_conv;
11991         e_conv.inner = (void*)(e & (~1));
11992         e_conv.is_owned = (e & 1) || (e == 0);
11993         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11994         e_conv = DecodeError_clone(&e_conv);
11995         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
11996         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
11997         return (uint32_t)ret_conv;
11998 }
11999
12000 jboolean  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(uint32_t o) {
12001         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(o & ~1);
12002         jboolean ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
12003         return ret_conv;
12004 }
12005
12006 void  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_free"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
12007         if ((_res & 1) != 0) return;
12008         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12009         CHECK_ACCESS(_res_ptr);
12010         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(_res_ptr);
12011         FREE((void*)_res);
12012         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
12013 }
12014
12015 static inline uintptr_t CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
12016         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
12017         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(arg);
12018         return (uint32_t)ret_conv;
12019 }
12020 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(uint32_t arg) {
12021         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
12022         uint32_t ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
12023         return ret_conv;
12024 }
12025
12026 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
12027         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(orig & ~1);
12028         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
12029         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
12030         return (uint32_t)ret_conv;
12031 }
12032
12033 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_ok"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
12034         LDKBuiltCommitmentTransaction o_conv;
12035         o_conv.inner = (void*)(o & (~1));
12036         o_conv.is_owned = (o & 1) || (o == 0);
12037         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12038         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
12039         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
12040         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
12041         return (uint32_t)ret_conv;
12042 }
12043
12044 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_err"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_err(uint32_t e) {
12045         LDKDecodeError e_conv;
12046         e_conv.inner = (void*)(e & (~1));
12047         e_conv.is_owned = (e & 1) || (e == 0);
12048         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12049         e_conv = DecodeError_clone(&e_conv);
12050         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
12051         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
12052         return (uint32_t)ret_conv;
12053 }
12054
12055 jboolean  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(uint32_t o) {
12056         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(o & ~1);
12057         jboolean ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
12058         return ret_conv;
12059 }
12060
12061 void  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_free"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
12062         if ((_res & 1) != 0) return;
12063         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12064         CHECK_ACCESS(_res_ptr);
12065         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(_res_ptr);
12066         FREE((void*)_res);
12067         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
12068 }
12069
12070 static inline uintptr_t CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
12071         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
12072         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(arg);
12073         return (uint32_t)ret_conv;
12074 }
12075 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(uint32_t arg) {
12076         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
12077         uint32_t ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
12078         return ret_conv;
12079 }
12080
12081 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
12082         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(orig & ~1);
12083         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
12084         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
12085         return (uint32_t)ret_conv;
12086 }
12087
12088 uint32_t  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_ok"))) TS_CResult_TrustedClosingTransactionNoneZ_ok(uint32_t o) {
12089         LDKTrustedClosingTransaction o_conv;
12090         o_conv.inner = (void*)(o & (~1));
12091         o_conv.is_owned = (o & 1) || (o == 0);
12092         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12093         // WARNING: we need a move here but no clone is available for LDKTrustedClosingTransaction
12094         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
12095         *ret_conv = CResult_TrustedClosingTransactionNoneZ_ok(o_conv);
12096         return (uint32_t)ret_conv;
12097 }
12098
12099 uint32_t  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_err"))) TS_CResult_TrustedClosingTransactionNoneZ_err() {
12100         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
12101         *ret_conv = CResult_TrustedClosingTransactionNoneZ_err();
12102         return (uint32_t)ret_conv;
12103 }
12104
12105 jboolean  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_is_ok"))) TS_CResult_TrustedClosingTransactionNoneZ_is_ok(uint32_t o) {
12106         LDKCResult_TrustedClosingTransactionNoneZ* o_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(o & ~1);
12107         jboolean ret_conv = CResult_TrustedClosingTransactionNoneZ_is_ok(o_conv);
12108         return ret_conv;
12109 }
12110
12111 void  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_free"))) TS_CResult_TrustedClosingTransactionNoneZ_free(uint32_t _res) {
12112         if ((_res & 1) != 0) return;
12113         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12114         CHECK_ACCESS(_res_ptr);
12115         LDKCResult_TrustedClosingTransactionNoneZ _res_conv = *(LDKCResult_TrustedClosingTransactionNoneZ*)(_res_ptr);
12116         FREE((void*)_res);
12117         CResult_TrustedClosingTransactionNoneZ_free(_res_conv);
12118 }
12119
12120 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_ok"))) TS_CResult_CommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
12121         LDKCommitmentTransaction o_conv;
12122         o_conv.inner = (void*)(o & (~1));
12123         o_conv.is_owned = (o & 1) || (o == 0);
12124         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12125         o_conv = CommitmentTransaction_clone(&o_conv);
12126         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
12127         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
12128         return (uint32_t)ret_conv;
12129 }
12130
12131 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_err"))) TS_CResult_CommitmentTransactionDecodeErrorZ_err(uint32_t e) {
12132         LDKDecodeError e_conv;
12133         e_conv.inner = (void*)(e & (~1));
12134         e_conv.is_owned = (e & 1) || (e == 0);
12135         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12136         e_conv = DecodeError_clone(&e_conv);
12137         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
12138         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
12139         return (uint32_t)ret_conv;
12140 }
12141
12142 jboolean  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_is_ok"))) TS_CResult_CommitmentTransactionDecodeErrorZ_is_ok(uint32_t o) {
12143         LDKCResult_CommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(o & ~1);
12144         jboolean ret_conv = CResult_CommitmentTransactionDecodeErrorZ_is_ok(o_conv);
12145         return ret_conv;
12146 }
12147
12148 void  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_free"))) TS_CResult_CommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
12149         if ((_res & 1) != 0) return;
12150         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12151         CHECK_ACCESS(_res_ptr);
12152         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(_res_ptr);
12153         FREE((void*)_res);
12154         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
12155 }
12156
12157 static inline uintptr_t CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
12158         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
12159         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(arg);
12160         return (uint32_t)ret_conv;
12161 }
12162 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_clone_ptr"))) TS_CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(uint32_t arg) {
12163         LDKCResult_CommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
12164         uint32_t ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
12165         return ret_conv;
12166 }
12167
12168 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_clone"))) TS_CResult_CommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
12169         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(orig & ~1);
12170         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
12171         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
12172         return (uint32_t)ret_conv;
12173 }
12174
12175 uint32_t  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_ok"))) TS_CResult_TrustedCommitmentTransactionNoneZ_ok(uint32_t o) {
12176         LDKTrustedCommitmentTransaction o_conv;
12177         o_conv.inner = (void*)(o & (~1));
12178         o_conv.is_owned = (o & 1) || (o == 0);
12179         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12180         // WARNING: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
12181         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
12182         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
12183         return (uint32_t)ret_conv;
12184 }
12185
12186 uint32_t  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_err"))) TS_CResult_TrustedCommitmentTransactionNoneZ_err() {
12187         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
12188         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
12189         return (uint32_t)ret_conv;
12190 }
12191
12192 jboolean  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_is_ok"))) TS_CResult_TrustedCommitmentTransactionNoneZ_is_ok(uint32_t o) {
12193         LDKCResult_TrustedCommitmentTransactionNoneZ* o_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(o & ~1);
12194         jboolean ret_conv = CResult_TrustedCommitmentTransactionNoneZ_is_ok(o_conv);
12195         return ret_conv;
12196 }
12197
12198 void  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_free"))) TS_CResult_TrustedCommitmentTransactionNoneZ_free(uint32_t _res) {
12199         if ((_res & 1) != 0) return;
12200         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12201         CHECK_ACCESS(_res_ptr);
12202         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(_res_ptr);
12203         FREE((void*)_res);
12204         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
12205 }
12206
12207 uint32_t  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_ok"))) TS_CResult_CVec_SignatureZNoneZ_ok(ptrArray o) {
12208         LDKCVec_SignatureZ o_constr;
12209         o_constr.datalen = o->arr_len;
12210         if (o_constr.datalen > 0)
12211                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
12212         else
12213                 o_constr.data = NULL;
12214         int8_tArray* o_vals = (void*) o->elems;
12215         for (size_t m = 0; m < o_constr.datalen; m++) {
12216                 int8_tArray o_conv_12 = o_vals[m];
12217                 LDKSignature o_conv_12_ref;
12218                 CHECK(o_conv_12->arr_len == 64);
12219                 memcpy(o_conv_12_ref.compact_form, o_conv_12->elems, 64); FREE(o_conv_12);
12220                 o_constr.data[m] = o_conv_12_ref;
12221         }
12222         FREE(o);
12223         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
12224         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
12225         return (uint32_t)ret_conv;
12226 }
12227
12228 uint32_t  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_err"))) TS_CResult_CVec_SignatureZNoneZ_err() {
12229         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
12230         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
12231         return (uint32_t)ret_conv;
12232 }
12233
12234 jboolean  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_is_ok"))) TS_CResult_CVec_SignatureZNoneZ_is_ok(uint32_t o) {
12235         LDKCResult_CVec_SignatureZNoneZ* o_conv = (LDKCResult_CVec_SignatureZNoneZ*)(o & ~1);
12236         jboolean ret_conv = CResult_CVec_SignatureZNoneZ_is_ok(o_conv);
12237         return ret_conv;
12238 }
12239
12240 void  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_free"))) TS_CResult_CVec_SignatureZNoneZ_free(uint32_t _res) {
12241         if ((_res & 1) != 0) return;
12242         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12243         CHECK_ACCESS(_res_ptr);
12244         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(_res_ptr);
12245         FREE((void*)_res);
12246         CResult_CVec_SignatureZNoneZ_free(_res_conv);
12247 }
12248
12249 static inline uintptr_t CResult_CVec_SignatureZNoneZ_clone_ptr(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR arg) {
12250         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
12251         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(arg);
12252         return (uint32_t)ret_conv;
12253 }
12254 uint32_t  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_clone_ptr"))) TS_CResult_CVec_SignatureZNoneZ_clone_ptr(uint32_t arg) {
12255         LDKCResult_CVec_SignatureZNoneZ* arg_conv = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
12256         uint32_t ret_conv = CResult_CVec_SignatureZNoneZ_clone_ptr(arg_conv);
12257         return ret_conv;
12258 }
12259
12260 uint32_t  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_clone"))) TS_CResult_CVec_SignatureZNoneZ_clone(uint32_t orig) {
12261         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)(orig & ~1);
12262         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
12263         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
12264         return (uint32_t)ret_conv;
12265 }
12266
12267 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_ok"))) TS_CResult_ShutdownScriptDecodeErrorZ_ok(uint32_t o) {
12268         LDKShutdownScript o_conv;
12269         o_conv.inner = (void*)(o & (~1));
12270         o_conv.is_owned = (o & 1) || (o == 0);
12271         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12272         o_conv = ShutdownScript_clone(&o_conv);
12273         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
12274         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_ok(o_conv);
12275         return (uint32_t)ret_conv;
12276 }
12277
12278 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_err"))) TS_CResult_ShutdownScriptDecodeErrorZ_err(uint32_t e) {
12279         LDKDecodeError e_conv;
12280         e_conv.inner = (void*)(e & (~1));
12281         e_conv.is_owned = (e & 1) || (e == 0);
12282         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12283         e_conv = DecodeError_clone(&e_conv);
12284         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
12285         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_err(e_conv);
12286         return (uint32_t)ret_conv;
12287 }
12288
12289 jboolean  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_is_ok"))) TS_CResult_ShutdownScriptDecodeErrorZ_is_ok(uint32_t o) {
12290         LDKCResult_ShutdownScriptDecodeErrorZ* o_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(o & ~1);
12291         jboolean ret_conv = CResult_ShutdownScriptDecodeErrorZ_is_ok(o_conv);
12292         return ret_conv;
12293 }
12294
12295 void  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_free"))) TS_CResult_ShutdownScriptDecodeErrorZ_free(uint32_t _res) {
12296         if ((_res & 1) != 0) return;
12297         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12298         CHECK_ACCESS(_res_ptr);
12299         LDKCResult_ShutdownScriptDecodeErrorZ _res_conv = *(LDKCResult_ShutdownScriptDecodeErrorZ*)(_res_ptr);
12300         FREE((void*)_res);
12301         CResult_ShutdownScriptDecodeErrorZ_free(_res_conv);
12302 }
12303
12304 static inline uintptr_t CResult_ShutdownScriptDecodeErrorZ_clone_ptr(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR arg) {
12305         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
12306         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(arg);
12307         return (uint32_t)ret_conv;
12308 }
12309 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_clone_ptr"))) TS_CResult_ShutdownScriptDecodeErrorZ_clone_ptr(uint32_t arg) {
12310         LDKCResult_ShutdownScriptDecodeErrorZ* arg_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(arg & ~1);
12311         uint32_t ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone_ptr(arg_conv);
12312         return ret_conv;
12313 }
12314
12315 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_clone"))) TS_CResult_ShutdownScriptDecodeErrorZ_clone(uint32_t orig) {
12316         LDKCResult_ShutdownScriptDecodeErrorZ* orig_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(orig & ~1);
12317         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
12318         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(orig_conv);
12319         return (uint32_t)ret_conv;
12320 }
12321
12322 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_ok"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_ok(uint32_t o) {
12323         LDKShutdownScript o_conv;
12324         o_conv.inner = (void*)(o & (~1));
12325         o_conv.is_owned = (o & 1) || (o == 0);
12326         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12327         o_conv = ShutdownScript_clone(&o_conv);
12328         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
12329         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_ok(o_conv);
12330         return (uint32_t)ret_conv;
12331 }
12332
12333 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_err"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_err(uint32_t e) {
12334         LDKInvalidShutdownScript e_conv;
12335         e_conv.inner = (void*)(e & (~1));
12336         e_conv.is_owned = (e & 1) || (e == 0);
12337         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12338         e_conv = InvalidShutdownScript_clone(&e_conv);
12339         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
12340         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_err(e_conv);
12341         return (uint32_t)ret_conv;
12342 }
12343
12344 jboolean  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok(uint32_t o) {
12345         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* o_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(o & ~1);
12346         jboolean ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok(o_conv);
12347         return ret_conv;
12348 }
12349
12350 void  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_free"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_free(uint32_t _res) {
12351         if ((_res & 1) != 0) return;
12352         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12353         CHECK_ACCESS(_res_ptr);
12354         LDKCResult_ShutdownScriptInvalidShutdownScriptZ _res_conv = *(LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(_res_ptr);
12355         FREE((void*)_res);
12356         CResult_ShutdownScriptInvalidShutdownScriptZ_free(_res_conv);
12357 }
12358
12359 static inline uintptr_t CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR arg) {
12360         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
12361         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(arg);
12362         return (uint32_t)ret_conv;
12363 }
12364 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(uint32_t arg) {
12365         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* arg_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(arg & ~1);
12366         uint32_t ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(arg_conv);
12367         return ret_conv;
12368 }
12369
12370 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_clone"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_clone(uint32_t orig) {
12371         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* orig_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(orig & ~1);
12372         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
12373         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(orig_conv);
12374         return (uint32_t)ret_conv;
12375 }
12376
12377 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_ok"))) TS_CResult_RouteHopDecodeErrorZ_ok(uint32_t o) {
12378         LDKRouteHop o_conv;
12379         o_conv.inner = (void*)(o & (~1));
12380         o_conv.is_owned = (o & 1) || (o == 0);
12381         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12382         o_conv = RouteHop_clone(&o_conv);
12383         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
12384         *ret_conv = CResult_RouteHopDecodeErrorZ_ok(o_conv);
12385         return (uint32_t)ret_conv;
12386 }
12387
12388 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_err"))) TS_CResult_RouteHopDecodeErrorZ_err(uint32_t e) {
12389         LDKDecodeError e_conv;
12390         e_conv.inner = (void*)(e & (~1));
12391         e_conv.is_owned = (e & 1) || (e == 0);
12392         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12393         e_conv = DecodeError_clone(&e_conv);
12394         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
12395         *ret_conv = CResult_RouteHopDecodeErrorZ_err(e_conv);
12396         return (uint32_t)ret_conv;
12397 }
12398
12399 jboolean  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_is_ok"))) TS_CResult_RouteHopDecodeErrorZ_is_ok(uint32_t o) {
12400         LDKCResult_RouteHopDecodeErrorZ* o_conv = (LDKCResult_RouteHopDecodeErrorZ*)(o & ~1);
12401         jboolean ret_conv = CResult_RouteHopDecodeErrorZ_is_ok(o_conv);
12402         return ret_conv;
12403 }
12404
12405 void  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_free"))) TS_CResult_RouteHopDecodeErrorZ_free(uint32_t _res) {
12406         if ((_res & 1) != 0) return;
12407         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12408         CHECK_ACCESS(_res_ptr);
12409         LDKCResult_RouteHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHopDecodeErrorZ*)(_res_ptr);
12410         FREE((void*)_res);
12411         CResult_RouteHopDecodeErrorZ_free(_res_conv);
12412 }
12413
12414 static inline uintptr_t CResult_RouteHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR arg) {
12415         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
12416         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(arg);
12417         return (uint32_t)ret_conv;
12418 }
12419 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_clone_ptr"))) TS_CResult_RouteHopDecodeErrorZ_clone_ptr(uint32_t arg) {
12420         LDKCResult_RouteHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
12421         uint32_t ret_conv = CResult_RouteHopDecodeErrorZ_clone_ptr(arg_conv);
12422         return ret_conv;
12423 }
12424
12425 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_clone"))) TS_CResult_RouteHopDecodeErrorZ_clone(uint32_t orig) {
12426         LDKCResult_RouteHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHopDecodeErrorZ*)(orig & ~1);
12427         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
12428         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(orig_conv);
12429         return (uint32_t)ret_conv;
12430 }
12431
12432 void  __attribute__((export_name("TS_CVec_RouteHopZ_free"))) TS_CVec_RouteHopZ_free(uint32_tArray _res) {
12433         LDKCVec_RouteHopZ _res_constr;
12434         _res_constr.datalen = _res->arr_len;
12435         if (_res_constr.datalen > 0)
12436                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
12437         else
12438                 _res_constr.data = NULL;
12439         uint32_t* _res_vals = _res->elems;
12440         for (size_t k = 0; k < _res_constr.datalen; k++) {
12441                 uint32_t _res_conv_10 = _res_vals[k];
12442                 LDKRouteHop _res_conv_10_conv;
12443                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
12444                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
12445                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
12446                 _res_constr.data[k] = _res_conv_10_conv;
12447         }
12448         FREE(_res);
12449         CVec_RouteHopZ_free(_res_constr);
12450 }
12451
12452 void  __attribute__((export_name("TS_CVec_CVec_RouteHopZZ_free"))) TS_CVec_CVec_RouteHopZZ_free(ptrArray _res) {
12453         LDKCVec_CVec_RouteHopZZ _res_constr;
12454         _res_constr.datalen = _res->arr_len;
12455         if (_res_constr.datalen > 0)
12456                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
12457         else
12458                 _res_constr.data = NULL;
12459         uint32_tArray* _res_vals = (void*) _res->elems;
12460         for (size_t m = 0; m < _res_constr.datalen; m++) {
12461                 uint32_tArray _res_conv_12 = _res_vals[m];
12462                 LDKCVec_RouteHopZ _res_conv_12_constr;
12463                 _res_conv_12_constr.datalen = _res_conv_12->arr_len;
12464                 if (_res_conv_12_constr.datalen > 0)
12465                         _res_conv_12_constr.data = MALLOC(_res_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
12466                 else
12467                         _res_conv_12_constr.data = NULL;
12468                 uint32_t* _res_conv_12_vals = _res_conv_12->elems;
12469                 for (size_t k = 0; k < _res_conv_12_constr.datalen; k++) {
12470                         uint32_t _res_conv_12_conv_10 = _res_conv_12_vals[k];
12471                         LDKRouteHop _res_conv_12_conv_10_conv;
12472                         _res_conv_12_conv_10_conv.inner = (void*)(_res_conv_12_conv_10 & (~1));
12473                         _res_conv_12_conv_10_conv.is_owned = (_res_conv_12_conv_10 & 1) || (_res_conv_12_conv_10 == 0);
12474                         CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_12_conv_10_conv);
12475                         _res_conv_12_constr.data[k] = _res_conv_12_conv_10_conv;
12476                 }
12477                 FREE(_res_conv_12);
12478                 _res_constr.data[m] = _res_conv_12_constr;
12479         }
12480         FREE(_res);
12481         CVec_CVec_RouteHopZZ_free(_res_constr);
12482 }
12483
12484 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_ok"))) TS_CResult_RouteDecodeErrorZ_ok(uint32_t o) {
12485         LDKRoute o_conv;
12486         o_conv.inner = (void*)(o & (~1));
12487         o_conv.is_owned = (o & 1) || (o == 0);
12488         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12489         o_conv = Route_clone(&o_conv);
12490         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
12491         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
12492         return (uint32_t)ret_conv;
12493 }
12494
12495 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_err"))) TS_CResult_RouteDecodeErrorZ_err(uint32_t e) {
12496         LDKDecodeError e_conv;
12497         e_conv.inner = (void*)(e & (~1));
12498         e_conv.is_owned = (e & 1) || (e == 0);
12499         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12500         e_conv = DecodeError_clone(&e_conv);
12501         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
12502         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
12503         return (uint32_t)ret_conv;
12504 }
12505
12506 jboolean  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_is_ok"))) TS_CResult_RouteDecodeErrorZ_is_ok(uint32_t o) {
12507         LDKCResult_RouteDecodeErrorZ* o_conv = (LDKCResult_RouteDecodeErrorZ*)(o & ~1);
12508         jboolean ret_conv = CResult_RouteDecodeErrorZ_is_ok(o_conv);
12509         return ret_conv;
12510 }
12511
12512 void  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_free"))) TS_CResult_RouteDecodeErrorZ_free(uint32_t _res) {
12513         if ((_res & 1) != 0) return;
12514         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12515         CHECK_ACCESS(_res_ptr);
12516         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(_res_ptr);
12517         FREE((void*)_res);
12518         CResult_RouteDecodeErrorZ_free(_res_conv);
12519 }
12520
12521 static inline uintptr_t CResult_RouteDecodeErrorZ_clone_ptr(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR arg) {
12522         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
12523         *ret_conv = CResult_RouteDecodeErrorZ_clone(arg);
12524         return (uint32_t)ret_conv;
12525 }
12526 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_clone_ptr"))) TS_CResult_RouteDecodeErrorZ_clone_ptr(uint32_t arg) {
12527         LDKCResult_RouteDecodeErrorZ* arg_conv = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
12528         uint32_t ret_conv = CResult_RouteDecodeErrorZ_clone_ptr(arg_conv);
12529         return ret_conv;
12530 }
12531
12532 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_clone"))) TS_CResult_RouteDecodeErrorZ_clone(uint32_t orig) {
12533         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)(orig & ~1);
12534         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
12535         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
12536         return (uint32_t)ret_conv;
12537 }
12538
12539 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_ok"))) TS_CResult_RouteParametersDecodeErrorZ_ok(uint32_t o) {
12540         LDKRouteParameters o_conv;
12541         o_conv.inner = (void*)(o & (~1));
12542         o_conv.is_owned = (o & 1) || (o == 0);
12543         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12544         o_conv = RouteParameters_clone(&o_conv);
12545         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
12546         *ret_conv = CResult_RouteParametersDecodeErrorZ_ok(o_conv);
12547         return (uint32_t)ret_conv;
12548 }
12549
12550 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_err"))) TS_CResult_RouteParametersDecodeErrorZ_err(uint32_t e) {
12551         LDKDecodeError e_conv;
12552         e_conv.inner = (void*)(e & (~1));
12553         e_conv.is_owned = (e & 1) || (e == 0);
12554         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12555         e_conv = DecodeError_clone(&e_conv);
12556         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
12557         *ret_conv = CResult_RouteParametersDecodeErrorZ_err(e_conv);
12558         return (uint32_t)ret_conv;
12559 }
12560
12561 jboolean  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_is_ok"))) TS_CResult_RouteParametersDecodeErrorZ_is_ok(uint32_t o) {
12562         LDKCResult_RouteParametersDecodeErrorZ* o_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(o & ~1);
12563         jboolean ret_conv = CResult_RouteParametersDecodeErrorZ_is_ok(o_conv);
12564         return ret_conv;
12565 }
12566
12567 void  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_free"))) TS_CResult_RouteParametersDecodeErrorZ_free(uint32_t _res) {
12568         if ((_res & 1) != 0) return;
12569         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12570         CHECK_ACCESS(_res_ptr);
12571         LDKCResult_RouteParametersDecodeErrorZ _res_conv = *(LDKCResult_RouteParametersDecodeErrorZ*)(_res_ptr);
12572         FREE((void*)_res);
12573         CResult_RouteParametersDecodeErrorZ_free(_res_conv);
12574 }
12575
12576 static inline uintptr_t CResult_RouteParametersDecodeErrorZ_clone_ptr(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR arg) {
12577         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
12578         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(arg);
12579         return (uint32_t)ret_conv;
12580 }
12581 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_clone_ptr"))) TS_CResult_RouteParametersDecodeErrorZ_clone_ptr(uint32_t arg) {
12582         LDKCResult_RouteParametersDecodeErrorZ* arg_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(arg & ~1);
12583         uint32_t ret_conv = CResult_RouteParametersDecodeErrorZ_clone_ptr(arg_conv);
12584         return ret_conv;
12585 }
12586
12587 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_clone"))) TS_CResult_RouteParametersDecodeErrorZ_clone(uint32_t orig) {
12588         LDKCResult_RouteParametersDecodeErrorZ* orig_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(orig & ~1);
12589         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
12590         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(orig_conv);
12591         return (uint32_t)ret_conv;
12592 }
12593
12594 void  __attribute__((export_name("TS_CVec_RouteHintZ_free"))) TS_CVec_RouteHintZ_free(uint32_tArray _res) {
12595         LDKCVec_RouteHintZ _res_constr;
12596         _res_constr.datalen = _res->arr_len;
12597         if (_res_constr.datalen > 0)
12598                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
12599         else
12600                 _res_constr.data = NULL;
12601         uint32_t* _res_vals = _res->elems;
12602         for (size_t l = 0; l < _res_constr.datalen; l++) {
12603                 uint32_t _res_conv_11 = _res_vals[l];
12604                 LDKRouteHint _res_conv_11_conv;
12605                 _res_conv_11_conv.inner = (void*)(_res_conv_11 & (~1));
12606                 _res_conv_11_conv.is_owned = (_res_conv_11 & 1) || (_res_conv_11 == 0);
12607                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_11_conv);
12608                 _res_constr.data[l] = _res_conv_11_conv;
12609         }
12610         FREE(_res);
12611         CVec_RouteHintZ_free(_res_constr);
12612 }
12613
12614 uint32_t  __attribute__((export_name("TS_COption_u64Z_some"))) TS_COption_u64Z_some(int64_t o) {
12615         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
12616         *ret_copy = COption_u64Z_some(o);
12617         uint32_t ret_ref = (uintptr_t)ret_copy;
12618         return ret_ref;
12619 }
12620
12621 uint32_t  __attribute__((export_name("TS_COption_u64Z_none"))) TS_COption_u64Z_none() {
12622         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
12623         *ret_copy = COption_u64Z_none();
12624         uint32_t ret_ref = (uintptr_t)ret_copy;
12625         return ret_ref;
12626 }
12627
12628 void  __attribute__((export_name("TS_COption_u64Z_free"))) TS_COption_u64Z_free(uint32_t _res) {
12629         if ((_res & 1) != 0) return;
12630         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12631         CHECK_ACCESS(_res_ptr);
12632         LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(_res_ptr);
12633         FREE((void*)_res);
12634         COption_u64Z_free(_res_conv);
12635 }
12636
12637 static inline uintptr_t COption_u64Z_clone_ptr(LDKCOption_u64Z *NONNULL_PTR arg) {
12638         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
12639         *ret_copy = COption_u64Z_clone(arg);
12640 uint32_t ret_ref = (uintptr_t)ret_copy;
12641         return ret_ref;
12642 }
12643 uint32_t  __attribute__((export_name("TS_COption_u64Z_clone_ptr"))) TS_COption_u64Z_clone_ptr(uint32_t arg) {
12644         LDKCOption_u64Z* arg_conv = (LDKCOption_u64Z*)arg;
12645         uint32_t ret_conv = COption_u64Z_clone_ptr(arg_conv);
12646         return ret_conv;
12647 }
12648
12649 uint32_t  __attribute__((export_name("TS_COption_u64Z_clone"))) TS_COption_u64Z_clone(uint32_t orig) {
12650         LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)orig;
12651         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
12652         *ret_copy = COption_u64Z_clone(orig_conv);
12653         uint32_t ret_ref = (uintptr_t)ret_copy;
12654         return ret_ref;
12655 }
12656
12657 void  __attribute__((export_name("TS_CVec_u64Z_free"))) TS_CVec_u64Z_free(int64_tArray _res) {
12658         LDKCVec_u64Z _res_constr;
12659         _res_constr.datalen = _res->arr_len;
12660         if (_res_constr.datalen > 0)
12661                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
12662         else
12663                 _res_constr.data = NULL;
12664         int64_t* _res_vals = _res->elems;
12665         for (size_t i = 0; i < _res_constr.datalen; i++) {
12666                 int64_t _res_conv_8 = _res_vals[i];
12667                 _res_constr.data[i] = _res_conv_8;
12668         }
12669         FREE(_res);
12670         CVec_u64Z_free(_res_constr);
12671 }
12672
12673 uint32_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_ok"))) TS_CResult_PaymentParametersDecodeErrorZ_ok(uint32_t o) {
12674         LDKPaymentParameters o_conv;
12675         o_conv.inner = (void*)(o & (~1));
12676         o_conv.is_owned = (o & 1) || (o == 0);
12677         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12678         o_conv = PaymentParameters_clone(&o_conv);
12679         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
12680         *ret_conv = CResult_PaymentParametersDecodeErrorZ_ok(o_conv);
12681         return (uint32_t)ret_conv;
12682 }
12683
12684 uint32_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_err"))) TS_CResult_PaymentParametersDecodeErrorZ_err(uint32_t e) {
12685         LDKDecodeError e_conv;
12686         e_conv.inner = (void*)(e & (~1));
12687         e_conv.is_owned = (e & 1) || (e == 0);
12688         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12689         e_conv = DecodeError_clone(&e_conv);
12690         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
12691         *ret_conv = CResult_PaymentParametersDecodeErrorZ_err(e_conv);
12692         return (uint32_t)ret_conv;
12693 }
12694
12695 jboolean  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_is_ok"))) TS_CResult_PaymentParametersDecodeErrorZ_is_ok(uint32_t o) {
12696         LDKCResult_PaymentParametersDecodeErrorZ* o_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(o & ~1);
12697         jboolean ret_conv = CResult_PaymentParametersDecodeErrorZ_is_ok(o_conv);
12698         return ret_conv;
12699 }
12700
12701 void  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_free"))) TS_CResult_PaymentParametersDecodeErrorZ_free(uint32_t _res) {
12702         if ((_res & 1) != 0) return;
12703         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12704         CHECK_ACCESS(_res_ptr);
12705         LDKCResult_PaymentParametersDecodeErrorZ _res_conv = *(LDKCResult_PaymentParametersDecodeErrorZ*)(_res_ptr);
12706         FREE((void*)_res);
12707         CResult_PaymentParametersDecodeErrorZ_free(_res_conv);
12708 }
12709
12710 static inline uintptr_t CResult_PaymentParametersDecodeErrorZ_clone_ptr(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR arg) {
12711         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
12712         *ret_conv = CResult_PaymentParametersDecodeErrorZ_clone(arg);
12713         return (uint32_t)ret_conv;
12714 }
12715 uint32_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_clone_ptr"))) TS_CResult_PaymentParametersDecodeErrorZ_clone_ptr(uint32_t arg) {
12716         LDKCResult_PaymentParametersDecodeErrorZ* arg_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(arg & ~1);
12717         uint32_t ret_conv = CResult_PaymentParametersDecodeErrorZ_clone_ptr(arg_conv);
12718         return ret_conv;
12719 }
12720
12721 uint32_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_clone"))) TS_CResult_PaymentParametersDecodeErrorZ_clone(uint32_t orig) {
12722         LDKCResult_PaymentParametersDecodeErrorZ* orig_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(orig & ~1);
12723         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
12724         *ret_conv = CResult_PaymentParametersDecodeErrorZ_clone(orig_conv);
12725         return (uint32_t)ret_conv;
12726 }
12727
12728 void  __attribute__((export_name("TS_CVec_RouteHintHopZ_free"))) TS_CVec_RouteHintHopZ_free(uint32_tArray _res) {
12729         LDKCVec_RouteHintHopZ _res_constr;
12730         _res_constr.datalen = _res->arr_len;
12731         if (_res_constr.datalen > 0)
12732                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
12733         else
12734                 _res_constr.data = NULL;
12735         uint32_t* _res_vals = _res->elems;
12736         for (size_t o = 0; o < _res_constr.datalen; o++) {
12737                 uint32_t _res_conv_14 = _res_vals[o];
12738                 LDKRouteHintHop _res_conv_14_conv;
12739                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
12740                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
12741                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
12742                 _res_constr.data[o] = _res_conv_14_conv;
12743         }
12744         FREE(_res);
12745         CVec_RouteHintHopZ_free(_res_constr);
12746 }
12747
12748 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_ok"))) TS_CResult_RouteHintDecodeErrorZ_ok(uint32_t o) {
12749         LDKRouteHint o_conv;
12750         o_conv.inner = (void*)(o & (~1));
12751         o_conv.is_owned = (o & 1) || (o == 0);
12752         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12753         o_conv = RouteHint_clone(&o_conv);
12754         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
12755         *ret_conv = CResult_RouteHintDecodeErrorZ_ok(o_conv);
12756         return (uint32_t)ret_conv;
12757 }
12758
12759 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_err"))) TS_CResult_RouteHintDecodeErrorZ_err(uint32_t e) {
12760         LDKDecodeError e_conv;
12761         e_conv.inner = (void*)(e & (~1));
12762         e_conv.is_owned = (e & 1) || (e == 0);
12763         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12764         e_conv = DecodeError_clone(&e_conv);
12765         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
12766         *ret_conv = CResult_RouteHintDecodeErrorZ_err(e_conv);
12767         return (uint32_t)ret_conv;
12768 }
12769
12770 jboolean  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_is_ok"))) TS_CResult_RouteHintDecodeErrorZ_is_ok(uint32_t o) {
12771         LDKCResult_RouteHintDecodeErrorZ* o_conv = (LDKCResult_RouteHintDecodeErrorZ*)(o & ~1);
12772         jboolean ret_conv = CResult_RouteHintDecodeErrorZ_is_ok(o_conv);
12773         return ret_conv;
12774 }
12775
12776 void  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_free"))) TS_CResult_RouteHintDecodeErrorZ_free(uint32_t _res) {
12777         if ((_res & 1) != 0) return;
12778         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12779         CHECK_ACCESS(_res_ptr);
12780         LDKCResult_RouteHintDecodeErrorZ _res_conv = *(LDKCResult_RouteHintDecodeErrorZ*)(_res_ptr);
12781         FREE((void*)_res);
12782         CResult_RouteHintDecodeErrorZ_free(_res_conv);
12783 }
12784
12785 static inline uintptr_t CResult_RouteHintDecodeErrorZ_clone_ptr(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR arg) {
12786         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
12787         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(arg);
12788         return (uint32_t)ret_conv;
12789 }
12790 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_clone_ptr"))) TS_CResult_RouteHintDecodeErrorZ_clone_ptr(uint32_t arg) {
12791         LDKCResult_RouteHintDecodeErrorZ* arg_conv = (LDKCResult_RouteHintDecodeErrorZ*)(arg & ~1);
12792         uint32_t ret_conv = CResult_RouteHintDecodeErrorZ_clone_ptr(arg_conv);
12793         return ret_conv;
12794 }
12795
12796 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_clone"))) TS_CResult_RouteHintDecodeErrorZ_clone(uint32_t orig) {
12797         LDKCResult_RouteHintDecodeErrorZ* orig_conv = (LDKCResult_RouteHintDecodeErrorZ*)(orig & ~1);
12798         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
12799         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(orig_conv);
12800         return (uint32_t)ret_conv;
12801 }
12802
12803 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_ok"))) TS_CResult_RouteHintHopDecodeErrorZ_ok(uint32_t o) {
12804         LDKRouteHintHop o_conv;
12805         o_conv.inner = (void*)(o & (~1));
12806         o_conv.is_owned = (o & 1) || (o == 0);
12807         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12808         o_conv = RouteHintHop_clone(&o_conv);
12809         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
12810         *ret_conv = CResult_RouteHintHopDecodeErrorZ_ok(o_conv);
12811         return (uint32_t)ret_conv;
12812 }
12813
12814 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_err"))) TS_CResult_RouteHintHopDecodeErrorZ_err(uint32_t e) {
12815         LDKDecodeError e_conv;
12816         e_conv.inner = (void*)(e & (~1));
12817         e_conv.is_owned = (e & 1) || (e == 0);
12818         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12819         e_conv = DecodeError_clone(&e_conv);
12820         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
12821         *ret_conv = CResult_RouteHintHopDecodeErrorZ_err(e_conv);
12822         return (uint32_t)ret_conv;
12823 }
12824
12825 jboolean  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_is_ok"))) TS_CResult_RouteHintHopDecodeErrorZ_is_ok(uint32_t o) {
12826         LDKCResult_RouteHintHopDecodeErrorZ* o_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(o & ~1);
12827         jboolean ret_conv = CResult_RouteHintHopDecodeErrorZ_is_ok(o_conv);
12828         return ret_conv;
12829 }
12830
12831 void  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_free"))) TS_CResult_RouteHintHopDecodeErrorZ_free(uint32_t _res) {
12832         if ((_res & 1) != 0) return;
12833         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12834         CHECK_ACCESS(_res_ptr);
12835         LDKCResult_RouteHintHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHintHopDecodeErrorZ*)(_res_ptr);
12836         FREE((void*)_res);
12837         CResult_RouteHintHopDecodeErrorZ_free(_res_conv);
12838 }
12839
12840 static inline uintptr_t CResult_RouteHintHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR arg) {
12841         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
12842         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(arg);
12843         return (uint32_t)ret_conv;
12844 }
12845 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_clone_ptr"))) TS_CResult_RouteHintHopDecodeErrorZ_clone_ptr(uint32_t arg) {
12846         LDKCResult_RouteHintHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(arg & ~1);
12847         uint32_t ret_conv = CResult_RouteHintHopDecodeErrorZ_clone_ptr(arg_conv);
12848         return ret_conv;
12849 }
12850
12851 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_clone"))) TS_CResult_RouteHintHopDecodeErrorZ_clone(uint32_t orig) {
12852         LDKCResult_RouteHintHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(orig & ~1);
12853         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
12854         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(orig_conv);
12855         return (uint32_t)ret_conv;
12856 }
12857
12858 void  __attribute__((export_name("TS_CVec_ChannelDetailsZ_free"))) TS_CVec_ChannelDetailsZ_free(uint32_tArray _res) {
12859         LDKCVec_ChannelDetailsZ _res_constr;
12860         _res_constr.datalen = _res->arr_len;
12861         if (_res_constr.datalen > 0)
12862                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
12863         else
12864                 _res_constr.data = NULL;
12865         uint32_t* _res_vals = _res->elems;
12866         for (size_t q = 0; q < _res_constr.datalen; q++) {
12867                 uint32_t _res_conv_16 = _res_vals[q];
12868                 LDKChannelDetails _res_conv_16_conv;
12869                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
12870                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
12871                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
12872                 _res_constr.data[q] = _res_conv_16_conv;
12873         }
12874         FREE(_res);
12875         CVec_ChannelDetailsZ_free(_res_constr);
12876 }
12877
12878 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_ok"))) TS_CResult_RouteLightningErrorZ_ok(uint32_t o) {
12879         LDKRoute o_conv;
12880         o_conv.inner = (void*)(o & (~1));
12881         o_conv.is_owned = (o & 1) || (o == 0);
12882         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12883         o_conv = Route_clone(&o_conv);
12884         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
12885         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
12886         return (uint32_t)ret_conv;
12887 }
12888
12889 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_err"))) TS_CResult_RouteLightningErrorZ_err(uint32_t e) {
12890         LDKLightningError e_conv;
12891         e_conv.inner = (void*)(e & (~1));
12892         e_conv.is_owned = (e & 1) || (e == 0);
12893         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12894         e_conv = LightningError_clone(&e_conv);
12895         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
12896         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
12897         return (uint32_t)ret_conv;
12898 }
12899
12900 jboolean  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_is_ok"))) TS_CResult_RouteLightningErrorZ_is_ok(uint32_t o) {
12901         LDKCResult_RouteLightningErrorZ* o_conv = (LDKCResult_RouteLightningErrorZ*)(o & ~1);
12902         jboolean ret_conv = CResult_RouteLightningErrorZ_is_ok(o_conv);
12903         return ret_conv;
12904 }
12905
12906 void  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_free"))) TS_CResult_RouteLightningErrorZ_free(uint32_t _res) {
12907         if ((_res & 1) != 0) return;
12908         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12909         CHECK_ACCESS(_res_ptr);
12910         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(_res_ptr);
12911         FREE((void*)_res);
12912         CResult_RouteLightningErrorZ_free(_res_conv);
12913 }
12914
12915 static inline uintptr_t CResult_RouteLightningErrorZ_clone_ptr(LDKCResult_RouteLightningErrorZ *NONNULL_PTR arg) {
12916         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
12917         *ret_conv = CResult_RouteLightningErrorZ_clone(arg);
12918         return (uint32_t)ret_conv;
12919 }
12920 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_clone_ptr"))) TS_CResult_RouteLightningErrorZ_clone_ptr(uint32_t arg) {
12921         LDKCResult_RouteLightningErrorZ* arg_conv = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
12922         uint32_t ret_conv = CResult_RouteLightningErrorZ_clone_ptr(arg_conv);
12923         return ret_conv;
12924 }
12925
12926 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_clone"))) TS_CResult_RouteLightningErrorZ_clone(uint32_t orig) {
12927         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)(orig & ~1);
12928         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
12929         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
12930         return (uint32_t)ret_conv;
12931 }
12932
12933 void  __attribute__((export_name("TS_CVec_PublicKeyZ_free"))) TS_CVec_PublicKeyZ_free(ptrArray _res) {
12934         LDKCVec_PublicKeyZ _res_constr;
12935         _res_constr.datalen = _res->arr_len;
12936         if (_res_constr.datalen > 0)
12937                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
12938         else
12939                 _res_constr.data = NULL;
12940         int8_tArray* _res_vals = (void*) _res->elems;
12941         for (size_t m = 0; m < _res_constr.datalen; m++) {
12942                 int8_tArray _res_conv_12 = _res_vals[m];
12943                 LDKPublicKey _res_conv_12_ref;
12944                 CHECK(_res_conv_12->arr_len == 33);
12945                 memcpy(_res_conv_12_ref.compressed_form, _res_conv_12->elems, 33); FREE(_res_conv_12);
12946                 _res_constr.data[m] = _res_conv_12_ref;
12947         }
12948         FREE(_res);
12949         CVec_PublicKeyZ_free(_res_constr);
12950 }
12951
12952 uint32_t  __attribute__((export_name("TS_CResult_PaymentPurposeDecodeErrorZ_ok"))) TS_CResult_PaymentPurposeDecodeErrorZ_ok(uint32_t o) {
12953         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12954         CHECK_ACCESS(o_ptr);
12955         LDKPaymentPurpose o_conv = *(LDKPaymentPurpose*)(o_ptr);
12956         o_conv = PaymentPurpose_clone((LDKPaymentPurpose*)(((uintptr_t)o) & ~1));
12957         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
12958         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_ok(o_conv);
12959         return (uint32_t)ret_conv;
12960 }
12961
12962 uint32_t  __attribute__((export_name("TS_CResult_PaymentPurposeDecodeErrorZ_err"))) TS_CResult_PaymentPurposeDecodeErrorZ_err(uint32_t e) {
12963         LDKDecodeError e_conv;
12964         e_conv.inner = (void*)(e & (~1));
12965         e_conv.is_owned = (e & 1) || (e == 0);
12966         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12967         e_conv = DecodeError_clone(&e_conv);
12968         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
12969         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_err(e_conv);
12970         return (uint32_t)ret_conv;
12971 }
12972
12973 jboolean  __attribute__((export_name("TS_CResult_PaymentPurposeDecodeErrorZ_is_ok"))) TS_CResult_PaymentPurposeDecodeErrorZ_is_ok(uint32_t o) {
12974         LDKCResult_PaymentPurposeDecodeErrorZ* o_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)(o & ~1);
12975         jboolean ret_conv = CResult_PaymentPurposeDecodeErrorZ_is_ok(o_conv);
12976         return ret_conv;
12977 }
12978
12979 void  __attribute__((export_name("TS_CResult_PaymentPurposeDecodeErrorZ_free"))) TS_CResult_PaymentPurposeDecodeErrorZ_free(uint32_t _res) {
12980         if ((_res & 1) != 0) return;
12981         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12982         CHECK_ACCESS(_res_ptr);
12983         LDKCResult_PaymentPurposeDecodeErrorZ _res_conv = *(LDKCResult_PaymentPurposeDecodeErrorZ*)(_res_ptr);
12984         FREE((void*)_res);
12985         CResult_PaymentPurposeDecodeErrorZ_free(_res_conv);
12986 }
12987
12988 static inline uintptr_t CResult_PaymentPurposeDecodeErrorZ_clone_ptr(LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR arg) {
12989         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
12990         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_clone(arg);
12991         return (uint32_t)ret_conv;
12992 }
12993 uint32_t  __attribute__((export_name("TS_CResult_PaymentPurposeDecodeErrorZ_clone_ptr"))) TS_CResult_PaymentPurposeDecodeErrorZ_clone_ptr(uint32_t arg) {
12994         LDKCResult_PaymentPurposeDecodeErrorZ* arg_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)(arg & ~1);
12995         uint32_t ret_conv = CResult_PaymentPurposeDecodeErrorZ_clone_ptr(arg_conv);
12996         return ret_conv;
12997 }
12998
12999 uint32_t  __attribute__((export_name("TS_CResult_PaymentPurposeDecodeErrorZ_clone"))) TS_CResult_PaymentPurposeDecodeErrorZ_clone(uint32_t orig) {
13000         LDKCResult_PaymentPurposeDecodeErrorZ* orig_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)(orig & ~1);
13001         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
13002         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_clone(orig_conv);
13003         return (uint32_t)ret_conv;
13004 }
13005
13006 uint32_t  __attribute__((export_name("TS_COption_ClosureReasonZ_some"))) TS_COption_ClosureReasonZ_some(uint32_t o) {
13007         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
13008         CHECK_ACCESS(o_ptr);
13009         LDKClosureReason o_conv = *(LDKClosureReason*)(o_ptr);
13010         o_conv = ClosureReason_clone((LDKClosureReason*)(((uintptr_t)o) & ~1));
13011         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
13012         *ret_copy = COption_ClosureReasonZ_some(o_conv);
13013         uint32_t ret_ref = (uintptr_t)ret_copy;
13014         return ret_ref;
13015 }
13016
13017 uint32_t  __attribute__((export_name("TS_COption_ClosureReasonZ_none"))) TS_COption_ClosureReasonZ_none() {
13018         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
13019         *ret_copy = COption_ClosureReasonZ_none();
13020         uint32_t ret_ref = (uintptr_t)ret_copy;
13021         return ret_ref;
13022 }
13023
13024 void  __attribute__((export_name("TS_COption_ClosureReasonZ_free"))) TS_COption_ClosureReasonZ_free(uint32_t _res) {
13025         if ((_res & 1) != 0) return;
13026         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13027         CHECK_ACCESS(_res_ptr);
13028         LDKCOption_ClosureReasonZ _res_conv = *(LDKCOption_ClosureReasonZ*)(_res_ptr);
13029         FREE((void*)_res);
13030         COption_ClosureReasonZ_free(_res_conv);
13031 }
13032
13033 static inline uintptr_t COption_ClosureReasonZ_clone_ptr(LDKCOption_ClosureReasonZ *NONNULL_PTR arg) {
13034         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
13035         *ret_copy = COption_ClosureReasonZ_clone(arg);
13036 uint32_t ret_ref = (uintptr_t)ret_copy;
13037         return ret_ref;
13038 }
13039 uint32_t  __attribute__((export_name("TS_COption_ClosureReasonZ_clone_ptr"))) TS_COption_ClosureReasonZ_clone_ptr(uint32_t arg) {
13040         LDKCOption_ClosureReasonZ* arg_conv = (LDKCOption_ClosureReasonZ*)arg;
13041         uint32_t ret_conv = COption_ClosureReasonZ_clone_ptr(arg_conv);
13042         return ret_conv;
13043 }
13044
13045 uint32_t  __attribute__((export_name("TS_COption_ClosureReasonZ_clone"))) TS_COption_ClosureReasonZ_clone(uint32_t orig) {
13046         LDKCOption_ClosureReasonZ* orig_conv = (LDKCOption_ClosureReasonZ*)orig;
13047         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
13048         *ret_copy = COption_ClosureReasonZ_clone(orig_conv);
13049         uint32_t ret_ref = (uintptr_t)ret_copy;
13050         return ret_ref;
13051 }
13052
13053 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_ok"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_ok(uint32_t o) {
13054         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
13055         CHECK_ACCESS(o_ptr);
13056         LDKCOption_ClosureReasonZ o_conv = *(LDKCOption_ClosureReasonZ*)(o_ptr);
13057         o_conv = COption_ClosureReasonZ_clone((LDKCOption_ClosureReasonZ*)(((uintptr_t)o) & ~1));
13058         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
13059         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_ok(o_conv);
13060         return (uint32_t)ret_conv;
13061 }
13062
13063 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_err"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_err(uint32_t e) {
13064         LDKDecodeError e_conv;
13065         e_conv.inner = (void*)(e & (~1));
13066         e_conv.is_owned = (e & 1) || (e == 0);
13067         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13068         e_conv = DecodeError_clone(&e_conv);
13069         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
13070         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_err(e_conv);
13071         return (uint32_t)ret_conv;
13072 }
13073
13074 jboolean  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_is_ok"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(uint32_t o) {
13075         LDKCResult_COption_ClosureReasonZDecodeErrorZ* o_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(o & ~1);
13076         jboolean ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(o_conv);
13077         return ret_conv;
13078 }
13079
13080 void  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_free"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_free(uint32_t _res) {
13081         if ((_res & 1) != 0) return;
13082         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13083         CHECK_ACCESS(_res_ptr);
13084         LDKCResult_COption_ClosureReasonZDecodeErrorZ _res_conv = *(LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(_res_ptr);
13085         FREE((void*)_res);
13086         CResult_COption_ClosureReasonZDecodeErrorZ_free(_res_conv);
13087 }
13088
13089 static inline uintptr_t CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR arg) {
13090         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
13091         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(arg);
13092         return (uint32_t)ret_conv;
13093 }
13094 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(uint32_t arg) {
13095         LDKCResult_COption_ClosureReasonZDecodeErrorZ* arg_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(arg & ~1);
13096         uint32_t ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(arg_conv);
13097         return ret_conv;
13098 }
13099
13100 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_clone"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_clone(uint32_t orig) {
13101         LDKCResult_COption_ClosureReasonZDecodeErrorZ* orig_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(orig & ~1);
13102         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
13103         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(orig_conv);
13104         return (uint32_t)ret_conv;
13105 }
13106
13107 uint32_t  __attribute__((export_name("TS_COption_HTLCDestinationZ_some"))) TS_COption_HTLCDestinationZ_some(uint32_t o) {
13108         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
13109         CHECK_ACCESS(o_ptr);
13110         LDKHTLCDestination o_conv = *(LDKHTLCDestination*)(o_ptr);
13111         o_conv = HTLCDestination_clone((LDKHTLCDestination*)(((uintptr_t)o) & ~1));
13112         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
13113         *ret_copy = COption_HTLCDestinationZ_some(o_conv);
13114         uint32_t ret_ref = (uintptr_t)ret_copy;
13115         return ret_ref;
13116 }
13117
13118 uint32_t  __attribute__((export_name("TS_COption_HTLCDestinationZ_none"))) TS_COption_HTLCDestinationZ_none() {
13119         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
13120         *ret_copy = COption_HTLCDestinationZ_none();
13121         uint32_t ret_ref = (uintptr_t)ret_copy;
13122         return ret_ref;
13123 }
13124
13125 void  __attribute__((export_name("TS_COption_HTLCDestinationZ_free"))) TS_COption_HTLCDestinationZ_free(uint32_t _res) {
13126         if ((_res & 1) != 0) return;
13127         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13128         CHECK_ACCESS(_res_ptr);
13129         LDKCOption_HTLCDestinationZ _res_conv = *(LDKCOption_HTLCDestinationZ*)(_res_ptr);
13130         FREE((void*)_res);
13131         COption_HTLCDestinationZ_free(_res_conv);
13132 }
13133
13134 static inline uintptr_t COption_HTLCDestinationZ_clone_ptr(LDKCOption_HTLCDestinationZ *NONNULL_PTR arg) {
13135         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
13136         *ret_copy = COption_HTLCDestinationZ_clone(arg);
13137 uint32_t ret_ref = (uintptr_t)ret_copy;
13138         return ret_ref;
13139 }
13140 uint32_t  __attribute__((export_name("TS_COption_HTLCDestinationZ_clone_ptr"))) TS_COption_HTLCDestinationZ_clone_ptr(uint32_t arg) {
13141         LDKCOption_HTLCDestinationZ* arg_conv = (LDKCOption_HTLCDestinationZ*)arg;
13142         uint32_t ret_conv = COption_HTLCDestinationZ_clone_ptr(arg_conv);
13143         return ret_conv;
13144 }
13145
13146 uint32_t  __attribute__((export_name("TS_COption_HTLCDestinationZ_clone"))) TS_COption_HTLCDestinationZ_clone(uint32_t orig) {
13147         LDKCOption_HTLCDestinationZ* orig_conv = (LDKCOption_HTLCDestinationZ*)orig;
13148         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
13149         *ret_copy = COption_HTLCDestinationZ_clone(orig_conv);
13150         uint32_t ret_ref = (uintptr_t)ret_copy;
13151         return ret_ref;
13152 }
13153
13154 uint32_t  __attribute__((export_name("TS_CResult_COption_HTLCDestinationZDecodeErrorZ_ok"))) TS_CResult_COption_HTLCDestinationZDecodeErrorZ_ok(uint32_t o) {
13155         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
13156         CHECK_ACCESS(o_ptr);
13157         LDKCOption_HTLCDestinationZ o_conv = *(LDKCOption_HTLCDestinationZ*)(o_ptr);
13158         o_conv = COption_HTLCDestinationZ_clone((LDKCOption_HTLCDestinationZ*)(((uintptr_t)o) & ~1));
13159         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
13160         *ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_ok(o_conv);
13161         return (uint32_t)ret_conv;
13162 }
13163
13164 uint32_t  __attribute__((export_name("TS_CResult_COption_HTLCDestinationZDecodeErrorZ_err"))) TS_CResult_COption_HTLCDestinationZDecodeErrorZ_err(uint32_t e) {
13165         LDKDecodeError e_conv;
13166         e_conv.inner = (void*)(e & (~1));
13167         e_conv.is_owned = (e & 1) || (e == 0);
13168         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13169         e_conv = DecodeError_clone(&e_conv);
13170         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
13171         *ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_err(e_conv);
13172         return (uint32_t)ret_conv;
13173 }
13174
13175 jboolean  __attribute__((export_name("TS_CResult_COption_HTLCDestinationZDecodeErrorZ_is_ok"))) TS_CResult_COption_HTLCDestinationZDecodeErrorZ_is_ok(uint32_t o) {
13176         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* o_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)(o & ~1);
13177         jboolean ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_is_ok(o_conv);
13178         return ret_conv;
13179 }
13180
13181 void  __attribute__((export_name("TS_CResult_COption_HTLCDestinationZDecodeErrorZ_free"))) TS_CResult_COption_HTLCDestinationZDecodeErrorZ_free(uint32_t _res) {
13182         if ((_res & 1) != 0) return;
13183         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13184         CHECK_ACCESS(_res_ptr);
13185         LDKCResult_COption_HTLCDestinationZDecodeErrorZ _res_conv = *(LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)(_res_ptr);
13186         FREE((void*)_res);
13187         CResult_COption_HTLCDestinationZDecodeErrorZ_free(_res_conv);
13188 }
13189
13190 static inline uintptr_t CResult_COption_HTLCDestinationZDecodeErrorZ_clone_ptr(LDKCResult_COption_HTLCDestinationZDecodeErrorZ *NONNULL_PTR arg) {
13191         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
13192         *ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_clone(arg);
13193         return (uint32_t)ret_conv;
13194 }
13195 uint32_t  __attribute__((export_name("TS_CResult_COption_HTLCDestinationZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_HTLCDestinationZDecodeErrorZ_clone_ptr(uint32_t arg) {
13196         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* arg_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)(arg & ~1);
13197         uint32_t ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_clone_ptr(arg_conv);
13198         return ret_conv;
13199 }
13200
13201 uint32_t  __attribute__((export_name("TS_CResult_COption_HTLCDestinationZDecodeErrorZ_clone"))) TS_CResult_COption_HTLCDestinationZDecodeErrorZ_clone(uint32_t orig) {
13202         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* orig_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)(orig & ~1);
13203         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
13204         *ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_clone(orig_conv);
13205         return (uint32_t)ret_conv;
13206 }
13207
13208 uint32_t  __attribute__((export_name("TS_COption_NetworkUpdateZ_some"))) TS_COption_NetworkUpdateZ_some(uint32_t o) {
13209         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
13210         CHECK_ACCESS(o_ptr);
13211         LDKNetworkUpdate o_conv = *(LDKNetworkUpdate*)(o_ptr);
13212         o_conv = NetworkUpdate_clone((LDKNetworkUpdate*)(((uintptr_t)o) & ~1));
13213         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
13214         *ret_copy = COption_NetworkUpdateZ_some(o_conv);
13215         uint32_t ret_ref = (uintptr_t)ret_copy;
13216         return ret_ref;
13217 }
13218
13219 uint32_t  __attribute__((export_name("TS_COption_NetworkUpdateZ_none"))) TS_COption_NetworkUpdateZ_none() {
13220         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
13221         *ret_copy = COption_NetworkUpdateZ_none();
13222         uint32_t ret_ref = (uintptr_t)ret_copy;
13223         return ret_ref;
13224 }
13225
13226 void  __attribute__((export_name("TS_COption_NetworkUpdateZ_free"))) TS_COption_NetworkUpdateZ_free(uint32_t _res) {
13227         if ((_res & 1) != 0) return;
13228         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13229         CHECK_ACCESS(_res_ptr);
13230         LDKCOption_NetworkUpdateZ _res_conv = *(LDKCOption_NetworkUpdateZ*)(_res_ptr);
13231         FREE((void*)_res);
13232         COption_NetworkUpdateZ_free(_res_conv);
13233 }
13234
13235 static inline uintptr_t COption_NetworkUpdateZ_clone_ptr(LDKCOption_NetworkUpdateZ *NONNULL_PTR arg) {
13236         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
13237         *ret_copy = COption_NetworkUpdateZ_clone(arg);
13238 uint32_t ret_ref = (uintptr_t)ret_copy;
13239         return ret_ref;
13240 }
13241 uint32_t  __attribute__((export_name("TS_COption_NetworkUpdateZ_clone_ptr"))) TS_COption_NetworkUpdateZ_clone_ptr(uint32_t arg) {
13242         LDKCOption_NetworkUpdateZ* arg_conv = (LDKCOption_NetworkUpdateZ*)arg;
13243         uint32_t ret_conv = COption_NetworkUpdateZ_clone_ptr(arg_conv);
13244         return ret_conv;
13245 }
13246
13247 uint32_t  __attribute__((export_name("TS_COption_NetworkUpdateZ_clone"))) TS_COption_NetworkUpdateZ_clone(uint32_t orig) {
13248         LDKCOption_NetworkUpdateZ* orig_conv = (LDKCOption_NetworkUpdateZ*)orig;
13249         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
13250         *ret_copy = COption_NetworkUpdateZ_clone(orig_conv);
13251         uint32_t ret_ref = (uintptr_t)ret_copy;
13252         return ret_ref;
13253 }
13254
13255 void  __attribute__((export_name("TS_CVec_SpendableOutputDescriptorZ_free"))) TS_CVec_SpendableOutputDescriptorZ_free(uint32_tArray _res) {
13256         LDKCVec_SpendableOutputDescriptorZ _res_constr;
13257         _res_constr.datalen = _res->arr_len;
13258         if (_res_constr.datalen > 0)
13259                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
13260         else
13261                 _res_constr.data = NULL;
13262         uint32_t* _res_vals = _res->elems;
13263         for (size_t b = 0; b < _res_constr.datalen; b++) {
13264                 uint32_t _res_conv_27 = _res_vals[b];
13265                 void* _res_conv_27_ptr = (void*)(((uintptr_t)_res_conv_27) & ~1);
13266                 CHECK_ACCESS(_res_conv_27_ptr);
13267                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(_res_conv_27_ptr);
13268                 FREE((void*)_res_conv_27);
13269                 _res_constr.data[b] = _res_conv_27_conv;
13270         }
13271         FREE(_res);
13272         CVec_SpendableOutputDescriptorZ_free(_res_constr);
13273 }
13274
13275 uint32_t  __attribute__((export_name("TS_COption_EventZ_some"))) TS_COption_EventZ_some(uint32_t o) {
13276         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
13277         CHECK_ACCESS(o_ptr);
13278         LDKEvent o_conv = *(LDKEvent*)(o_ptr);
13279         o_conv = Event_clone((LDKEvent*)(((uintptr_t)o) & ~1));
13280         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
13281         *ret_copy = COption_EventZ_some(o_conv);
13282         uint32_t ret_ref = (uintptr_t)ret_copy;
13283         return ret_ref;
13284 }
13285
13286 uint32_t  __attribute__((export_name("TS_COption_EventZ_none"))) TS_COption_EventZ_none() {
13287         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
13288         *ret_copy = COption_EventZ_none();
13289         uint32_t ret_ref = (uintptr_t)ret_copy;
13290         return ret_ref;
13291 }
13292
13293 void  __attribute__((export_name("TS_COption_EventZ_free"))) TS_COption_EventZ_free(uint32_t _res) {
13294         if ((_res & 1) != 0) return;
13295         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13296         CHECK_ACCESS(_res_ptr);
13297         LDKCOption_EventZ _res_conv = *(LDKCOption_EventZ*)(_res_ptr);
13298         FREE((void*)_res);
13299         COption_EventZ_free(_res_conv);
13300 }
13301
13302 static inline uintptr_t COption_EventZ_clone_ptr(LDKCOption_EventZ *NONNULL_PTR arg) {
13303         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
13304         *ret_copy = COption_EventZ_clone(arg);
13305 uint32_t ret_ref = (uintptr_t)ret_copy;
13306         return ret_ref;
13307 }
13308 uint32_t  __attribute__((export_name("TS_COption_EventZ_clone_ptr"))) TS_COption_EventZ_clone_ptr(uint32_t arg) {
13309         LDKCOption_EventZ* arg_conv = (LDKCOption_EventZ*)arg;
13310         uint32_t ret_conv = COption_EventZ_clone_ptr(arg_conv);
13311         return ret_conv;
13312 }
13313
13314 uint32_t  __attribute__((export_name("TS_COption_EventZ_clone"))) TS_COption_EventZ_clone(uint32_t orig) {
13315         LDKCOption_EventZ* orig_conv = (LDKCOption_EventZ*)orig;
13316         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
13317         *ret_copy = COption_EventZ_clone(orig_conv);
13318         uint32_t ret_ref = (uintptr_t)ret_copy;
13319         return ret_ref;
13320 }
13321
13322 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_ok"))) TS_CResult_COption_EventZDecodeErrorZ_ok(uint32_t o) {
13323         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
13324         CHECK_ACCESS(o_ptr);
13325         LDKCOption_EventZ o_conv = *(LDKCOption_EventZ*)(o_ptr);
13326         o_conv = COption_EventZ_clone((LDKCOption_EventZ*)(((uintptr_t)o) & ~1));
13327         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
13328         *ret_conv = CResult_COption_EventZDecodeErrorZ_ok(o_conv);
13329         return (uint32_t)ret_conv;
13330 }
13331
13332 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_err"))) TS_CResult_COption_EventZDecodeErrorZ_err(uint32_t e) {
13333         LDKDecodeError e_conv;
13334         e_conv.inner = (void*)(e & (~1));
13335         e_conv.is_owned = (e & 1) || (e == 0);
13336         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13337         e_conv = DecodeError_clone(&e_conv);
13338         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
13339         *ret_conv = CResult_COption_EventZDecodeErrorZ_err(e_conv);
13340         return (uint32_t)ret_conv;
13341 }
13342
13343 jboolean  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_is_ok"))) TS_CResult_COption_EventZDecodeErrorZ_is_ok(uint32_t o) {
13344         LDKCResult_COption_EventZDecodeErrorZ* o_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(o & ~1);
13345         jboolean ret_conv = CResult_COption_EventZDecodeErrorZ_is_ok(o_conv);
13346         return ret_conv;
13347 }
13348
13349 void  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_free"))) TS_CResult_COption_EventZDecodeErrorZ_free(uint32_t _res) {
13350         if ((_res & 1) != 0) return;
13351         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13352         CHECK_ACCESS(_res_ptr);
13353         LDKCResult_COption_EventZDecodeErrorZ _res_conv = *(LDKCResult_COption_EventZDecodeErrorZ*)(_res_ptr);
13354         FREE((void*)_res);
13355         CResult_COption_EventZDecodeErrorZ_free(_res_conv);
13356 }
13357
13358 static inline uintptr_t CResult_COption_EventZDecodeErrorZ_clone_ptr(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR arg) {
13359         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
13360         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(arg);
13361         return (uint32_t)ret_conv;
13362 }
13363 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_EventZDecodeErrorZ_clone_ptr(uint32_t arg) {
13364         LDKCResult_COption_EventZDecodeErrorZ* arg_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(arg & ~1);
13365         uint32_t ret_conv = CResult_COption_EventZDecodeErrorZ_clone_ptr(arg_conv);
13366         return ret_conv;
13367 }
13368
13369 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_clone"))) TS_CResult_COption_EventZDecodeErrorZ_clone(uint32_t orig) {
13370         LDKCResult_COption_EventZDecodeErrorZ* orig_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(orig & ~1);
13371         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
13372         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(orig_conv);
13373         return (uint32_t)ret_conv;
13374 }
13375
13376 void  __attribute__((export_name("TS_CVec_MessageSendEventZ_free"))) TS_CVec_MessageSendEventZ_free(uint32_tArray _res) {
13377         LDKCVec_MessageSendEventZ _res_constr;
13378         _res_constr.datalen = _res->arr_len;
13379         if (_res_constr.datalen > 0)
13380                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
13381         else
13382                 _res_constr.data = NULL;
13383         uint32_t* _res_vals = _res->elems;
13384         for (size_t s = 0; s < _res_constr.datalen; s++) {
13385                 uint32_t _res_conv_18 = _res_vals[s];
13386                 void* _res_conv_18_ptr = (void*)(((uintptr_t)_res_conv_18) & ~1);
13387                 CHECK_ACCESS(_res_conv_18_ptr);
13388                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(_res_conv_18_ptr);
13389                 FREE((void*)_res_conv_18);
13390                 _res_constr.data[s] = _res_conv_18_conv;
13391         }
13392         FREE(_res);
13393         CVec_MessageSendEventZ_free(_res_constr);
13394 }
13395
13396 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_ok"))) TS_CResult_TxOutAccessErrorZ_ok(uint32_t o) {
13397         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
13398         CHECK_ACCESS(o_ptr);
13399         LDKTxOut o_conv = *(LDKTxOut*)(o_ptr);
13400         o_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)o) & ~1));
13401         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
13402         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
13403         return (uint32_t)ret_conv;
13404 }
13405
13406 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_err"))) TS_CResult_TxOutAccessErrorZ_err(uint32_t e) {
13407         LDKAccessError e_conv = LDKAccessError_from_js(e);
13408         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
13409         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
13410         return (uint32_t)ret_conv;
13411 }
13412
13413 jboolean  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_is_ok"))) TS_CResult_TxOutAccessErrorZ_is_ok(uint32_t o) {
13414         LDKCResult_TxOutAccessErrorZ* o_conv = (LDKCResult_TxOutAccessErrorZ*)(o & ~1);
13415         jboolean ret_conv = CResult_TxOutAccessErrorZ_is_ok(o_conv);
13416         return ret_conv;
13417 }
13418
13419 void  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_free"))) TS_CResult_TxOutAccessErrorZ_free(uint32_t _res) {
13420         if ((_res & 1) != 0) return;
13421         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13422         CHECK_ACCESS(_res_ptr);
13423         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(_res_ptr);
13424         FREE((void*)_res);
13425         CResult_TxOutAccessErrorZ_free(_res_conv);
13426 }
13427
13428 static inline uintptr_t CResult_TxOutAccessErrorZ_clone_ptr(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR arg) {
13429         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
13430         *ret_conv = CResult_TxOutAccessErrorZ_clone(arg);
13431         return (uint32_t)ret_conv;
13432 }
13433 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_clone_ptr"))) TS_CResult_TxOutAccessErrorZ_clone_ptr(uint32_t arg) {
13434         LDKCResult_TxOutAccessErrorZ* arg_conv = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
13435         uint32_t ret_conv = CResult_TxOutAccessErrorZ_clone_ptr(arg_conv);
13436         return ret_conv;
13437 }
13438
13439 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_clone"))) TS_CResult_TxOutAccessErrorZ_clone(uint32_t orig) {
13440         LDKCResult_TxOutAccessErrorZ* orig_conv = (LDKCResult_TxOutAccessErrorZ*)(orig & ~1);
13441         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
13442         *ret_conv = CResult_TxOutAccessErrorZ_clone(orig_conv);
13443         return (uint32_t)ret_conv;
13444 }
13445
13446 static inline uintptr_t C2Tuple_usizeTransactionZ_clone_ptr(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR arg) {
13447         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
13448         *ret_conv = C2Tuple_usizeTransactionZ_clone(arg);
13449         return ((uint32_t)ret_conv);
13450 }
13451 uint32_t  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_clone_ptr"))) TS_C2Tuple_usizeTransactionZ_clone_ptr(uint32_t arg) {
13452         LDKC2Tuple_usizeTransactionZ* arg_conv = (LDKC2Tuple_usizeTransactionZ*)(arg & ~1);
13453         uint32_t ret_conv = C2Tuple_usizeTransactionZ_clone_ptr(arg_conv);
13454         return ret_conv;
13455 }
13456
13457 uint32_t  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_clone"))) TS_C2Tuple_usizeTransactionZ_clone(uint32_t orig) {
13458         LDKC2Tuple_usizeTransactionZ* orig_conv = (LDKC2Tuple_usizeTransactionZ*)(orig & ~1);
13459         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
13460         *ret_conv = C2Tuple_usizeTransactionZ_clone(orig_conv);
13461         return ((uint32_t)ret_conv);
13462 }
13463
13464 uint32_t  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_new"))) TS_C2Tuple_usizeTransactionZ_new(uint32_t a, int8_tArray b) {
13465         LDKTransaction b_ref;
13466         b_ref.datalen = b->arr_len;
13467         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
13468         memcpy(b_ref.data, b->elems, b_ref.datalen); FREE(b);
13469         b_ref.data_is_owned = true;
13470         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
13471         *ret_conv = C2Tuple_usizeTransactionZ_new(a, b_ref);
13472         return ((uint32_t)ret_conv);
13473 }
13474
13475 void  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_free"))) TS_C2Tuple_usizeTransactionZ_free(uint32_t _res) {
13476         if ((_res & 1) != 0) return;
13477         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13478         CHECK_ACCESS(_res_ptr);
13479         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_ptr);
13480         FREE((void*)_res);
13481         C2Tuple_usizeTransactionZ_free(_res_conv);
13482 }
13483
13484 void  __attribute__((export_name("TS_CVec_C2Tuple_usizeTransactionZZ_free"))) TS_CVec_C2Tuple_usizeTransactionZZ_free(uint32_tArray _res) {
13485         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
13486         _res_constr.datalen = _res->arr_len;
13487         if (_res_constr.datalen > 0)
13488                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
13489         else
13490                 _res_constr.data = NULL;
13491         uint32_t* _res_vals = _res->elems;
13492         for (size_t c = 0; c < _res_constr.datalen; c++) {
13493                 uint32_t _res_conv_28 = _res_vals[c];
13494                 void* _res_conv_28_ptr = (void*)(((uintptr_t)_res_conv_28) & ~1);
13495                 CHECK_ACCESS(_res_conv_28_ptr);
13496                 LDKC2Tuple_usizeTransactionZ _res_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_conv_28_ptr);
13497                 FREE((void*)_res_conv_28);
13498                 _res_constr.data[c] = _res_conv_28_conv;
13499         }
13500         FREE(_res);
13501         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
13502 }
13503
13504 void  __attribute__((export_name("TS_CVec_TxidZ_free"))) TS_CVec_TxidZ_free(ptrArray _res) {
13505         LDKCVec_TxidZ _res_constr;
13506         _res_constr.datalen = _res->arr_len;
13507         if (_res_constr.datalen > 0)
13508                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
13509         else
13510                 _res_constr.data = NULL;
13511         int8_tArray* _res_vals = (void*) _res->elems;
13512         for (size_t m = 0; m < _res_constr.datalen; m++) {
13513                 int8_tArray _res_conv_12 = _res_vals[m];
13514                 LDKThirtyTwoBytes _res_conv_12_ref;
13515                 CHECK(_res_conv_12->arr_len == 32);
13516                 memcpy(_res_conv_12_ref.data, _res_conv_12->elems, 32); FREE(_res_conv_12);
13517                 _res_constr.data[m] = _res_conv_12_ref;
13518         }
13519         FREE(_res);
13520         CVec_TxidZ_free(_res_constr);
13521 }
13522
13523 uint32_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_ok"))) TS_CResult_NoneChannelMonitorUpdateErrZ_ok() {
13524         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
13525         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_ok();
13526         return (uint32_t)ret_conv;
13527 }
13528
13529 uint32_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_err"))) TS_CResult_NoneChannelMonitorUpdateErrZ_err(uint32_t e) {
13530         LDKChannelMonitorUpdateErr e_conv = LDKChannelMonitorUpdateErr_from_js(e);
13531         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
13532         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_err(e_conv);
13533         return (uint32_t)ret_conv;
13534 }
13535
13536 jboolean  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_is_ok"))) TS_CResult_NoneChannelMonitorUpdateErrZ_is_ok(uint32_t o) {
13537         LDKCResult_NoneChannelMonitorUpdateErrZ* o_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(o & ~1);
13538         jboolean ret_conv = CResult_NoneChannelMonitorUpdateErrZ_is_ok(o_conv);
13539         return ret_conv;
13540 }
13541
13542 void  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_free"))) TS_CResult_NoneChannelMonitorUpdateErrZ_free(uint32_t _res) {
13543         if ((_res & 1) != 0) return;
13544         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13545         CHECK_ACCESS(_res_ptr);
13546         LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(_res_ptr);
13547         FREE((void*)_res);
13548         CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
13549 }
13550
13551 static inline uintptr_t CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR arg) {
13552         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
13553         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(arg);
13554         return (uint32_t)ret_conv;
13555 }
13556 uint32_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_clone_ptr"))) TS_CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(uint32_t arg) {
13557         LDKCResult_NoneChannelMonitorUpdateErrZ* arg_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
13558         uint32_t ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(arg_conv);
13559         return ret_conv;
13560 }
13561
13562 uint32_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_clone"))) TS_CResult_NoneChannelMonitorUpdateErrZ_clone(uint32_t orig) {
13563         LDKCResult_NoneChannelMonitorUpdateErrZ* orig_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(orig & ~1);
13564         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
13565         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(orig_conv);
13566         return (uint32_t)ret_conv;
13567 }
13568
13569 void  __attribute__((export_name("TS_CVec_MonitorEventZ_free"))) TS_CVec_MonitorEventZ_free(uint32_tArray _res) {
13570         LDKCVec_MonitorEventZ _res_constr;
13571         _res_constr.datalen = _res->arr_len;
13572         if (_res_constr.datalen > 0)
13573                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
13574         else
13575                 _res_constr.data = NULL;
13576         uint32_t* _res_vals = _res->elems;
13577         for (size_t o = 0; o < _res_constr.datalen; o++) {
13578                 uint32_t _res_conv_14 = _res_vals[o];
13579                 void* _res_conv_14_ptr = (void*)(((uintptr_t)_res_conv_14) & ~1);
13580                 CHECK_ACCESS(_res_conv_14_ptr);
13581                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(_res_conv_14_ptr);
13582                 FREE((void*)_res_conv_14);
13583                 _res_constr.data[o] = _res_conv_14_conv;
13584         }
13585         FREE(_res);
13586         CVec_MonitorEventZ_free(_res_constr);
13587 }
13588
13589 static inline uintptr_t C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone_ptr(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *NONNULL_PTR arg) {
13590         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ");
13591         *ret_conv = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone(arg);
13592         return ((uint32_t)ret_conv);
13593 }
13594 uint32_t  __attribute__((export_name("TS_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone_ptr"))) TS_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone_ptr(uint32_t arg) {
13595         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* arg_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(arg & ~1);
13596         uint32_t ret_conv = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone_ptr(arg_conv);
13597         return ret_conv;
13598 }
13599
13600 uint32_t  __attribute__((export_name("TS_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone"))) TS_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone(uint32_t orig) {
13601         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* orig_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(orig & ~1);
13602         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ");
13603         *ret_conv = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone(orig_conv);
13604         return ((uint32_t)ret_conv);
13605 }
13606
13607 uint32_t  __attribute__((export_name("TS_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_new"))) TS_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_new(uint32_t a, uint32_tArray b, int8_tArray c) {
13608         LDKOutPoint a_conv;
13609         a_conv.inner = (void*)(a & (~1));
13610         a_conv.is_owned = (a & 1) || (a == 0);
13611         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
13612         a_conv = OutPoint_clone(&a_conv);
13613         LDKCVec_MonitorEventZ b_constr;
13614         b_constr.datalen = b->arr_len;
13615         if (b_constr.datalen > 0)
13616                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
13617         else
13618                 b_constr.data = NULL;
13619         uint32_t* b_vals = b->elems;
13620         for (size_t o = 0; o < b_constr.datalen; o++) {
13621                 uint32_t b_conv_14 = b_vals[o];
13622                 void* b_conv_14_ptr = (void*)(((uintptr_t)b_conv_14) & ~1);
13623                 CHECK_ACCESS(b_conv_14_ptr);
13624                 LDKMonitorEvent b_conv_14_conv = *(LDKMonitorEvent*)(b_conv_14_ptr);
13625                 b_conv_14_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uintptr_t)b_conv_14) & ~1));
13626                 b_constr.data[o] = b_conv_14_conv;
13627         }
13628         FREE(b);
13629         LDKPublicKey c_ref;
13630         CHECK(c->arr_len == 33);
13631         memcpy(c_ref.compressed_form, c->elems, 33); FREE(c);
13632         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ");
13633         *ret_conv = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_new(a_conv, b_constr, c_ref);
13634         return ((uint32_t)ret_conv);
13635 }
13636
13637 void  __attribute__((export_name("TS_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_free"))) TS_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_free(uint32_t _res) {
13638         if ((_res & 1) != 0) return;
13639         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13640         CHECK_ACCESS(_res_ptr);
13641         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ _res_conv = *(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(_res_ptr);
13642         FREE((void*)_res);
13643         C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_free(_res_conv);
13644 }
13645
13646 void  __attribute__((export_name("TS_CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ_free"))) TS_CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ_free(uint32_tArray _res) {
13647         LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ _res_constr;
13648         _res_constr.datalen = _res->arr_len;
13649         if (_res_constr.datalen > 0)
13650                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ Elements");
13651         else
13652                 _res_constr.data = NULL;
13653         uint32_t* _res_vals = _res->elems;
13654         for (size_t x = 0; x < _res_constr.datalen; x++) {
13655                 uint32_t _res_conv_49 = _res_vals[x];
13656                 void* _res_conv_49_ptr = (void*)(((uintptr_t)_res_conv_49) & ~1);
13657                 CHECK_ACCESS(_res_conv_49_ptr);
13658                 LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ _res_conv_49_conv = *(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(_res_conv_49_ptr);
13659                 FREE((void*)_res_conv_49);
13660                 _res_constr.data[x] = _res_conv_49_conv;
13661         }
13662         FREE(_res);
13663         CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ_free(_res_constr);
13664 }
13665
13666 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_some"))) TS_COption_C2Tuple_usizeTransactionZZ_some(uint32_t o) {
13667         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
13668         CHECK_ACCESS(o_ptr);
13669         LDKC2Tuple_usizeTransactionZ o_conv = *(LDKC2Tuple_usizeTransactionZ*)(o_ptr);
13670         o_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)o) & ~1));
13671         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
13672         *ret_copy = COption_C2Tuple_usizeTransactionZZ_some(o_conv);
13673         uint32_t ret_ref = (uintptr_t)ret_copy;
13674         return ret_ref;
13675 }
13676
13677 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_none"))) TS_COption_C2Tuple_usizeTransactionZZ_none() {
13678         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
13679         *ret_copy = COption_C2Tuple_usizeTransactionZZ_none();
13680         uint32_t ret_ref = (uintptr_t)ret_copy;
13681         return ret_ref;
13682 }
13683
13684 void  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_free"))) TS_COption_C2Tuple_usizeTransactionZZ_free(uint32_t _res) {
13685         if ((_res & 1) != 0) return;
13686         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13687         CHECK_ACCESS(_res_ptr);
13688         LDKCOption_C2Tuple_usizeTransactionZZ _res_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(_res_ptr);
13689         FREE((void*)_res);
13690         COption_C2Tuple_usizeTransactionZZ_free(_res_conv);
13691 }
13692
13693 static inline uintptr_t COption_C2Tuple_usizeTransactionZZ_clone_ptr(LDKCOption_C2Tuple_usizeTransactionZZ *NONNULL_PTR arg) {
13694         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
13695         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(arg);
13696 uint32_t ret_ref = (uintptr_t)ret_copy;
13697         return ret_ref;
13698 }
13699 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_clone_ptr"))) TS_COption_C2Tuple_usizeTransactionZZ_clone_ptr(uint32_t arg) {
13700         LDKCOption_C2Tuple_usizeTransactionZZ* arg_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)arg;
13701         uint32_t ret_conv = COption_C2Tuple_usizeTransactionZZ_clone_ptr(arg_conv);
13702         return ret_conv;
13703 }
13704
13705 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_clone"))) TS_COption_C2Tuple_usizeTransactionZZ_clone(uint32_t orig) {
13706         LDKCOption_C2Tuple_usizeTransactionZZ* orig_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)orig;
13707         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
13708         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(orig_conv);
13709         uint32_t ret_ref = (uintptr_t)ret_copy;
13710         return ret_ref;
13711 }
13712
13713 uint32_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_ok"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_ok(uint32_t o) {
13714         LDKFixedPenaltyScorer o_conv;
13715         o_conv.inner = (void*)(o & (~1));
13716         o_conv.is_owned = (o & 1) || (o == 0);
13717         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13718         o_conv = FixedPenaltyScorer_clone(&o_conv);
13719         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
13720         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_ok(o_conv);
13721         return (uint32_t)ret_conv;
13722 }
13723
13724 uint32_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_err"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_err(uint32_t e) {
13725         LDKDecodeError e_conv;
13726         e_conv.inner = (void*)(e & (~1));
13727         e_conv.is_owned = (e & 1) || (e == 0);
13728         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13729         e_conv = DecodeError_clone(&e_conv);
13730         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
13731         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_err(e_conv);
13732         return (uint32_t)ret_conv;
13733 }
13734
13735 jboolean  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_is_ok"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_is_ok(uint32_t o) {
13736         LDKCResult_FixedPenaltyScorerDecodeErrorZ* o_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(o & ~1);
13737         jboolean ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_is_ok(o_conv);
13738         return ret_conv;
13739 }
13740
13741 void  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_free"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_free(uint32_t _res) {
13742         if ((_res & 1) != 0) return;
13743         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13744         CHECK_ACCESS(_res_ptr);
13745         LDKCResult_FixedPenaltyScorerDecodeErrorZ _res_conv = *(LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(_res_ptr);
13746         FREE((void*)_res);
13747         CResult_FixedPenaltyScorerDecodeErrorZ_free(_res_conv);
13748 }
13749
13750 static inline uintptr_t CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR arg) {
13751         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
13752         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone(arg);
13753         return (uint32_t)ret_conv;
13754 }
13755 uint32_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(uint32_t arg) {
13756         LDKCResult_FixedPenaltyScorerDecodeErrorZ* arg_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(arg & ~1);
13757         uint32_t ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(arg_conv);
13758         return ret_conv;
13759 }
13760
13761 uint32_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_clone"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_clone(uint32_t orig) {
13762         LDKCResult_FixedPenaltyScorerDecodeErrorZ* orig_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(orig & ~1);
13763         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
13764         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone(orig_conv);
13765         return (uint32_t)ret_conv;
13766 }
13767
13768 static inline uintptr_t C2Tuple_u64u64Z_clone_ptr(LDKC2Tuple_u64u64Z *NONNULL_PTR arg) {
13769         LDKC2Tuple_u64u64Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
13770         *ret_conv = C2Tuple_u64u64Z_clone(arg);
13771         return ((uint32_t)ret_conv);
13772 }
13773 uint32_t  __attribute__((export_name("TS_C2Tuple_u64u64Z_clone_ptr"))) TS_C2Tuple_u64u64Z_clone_ptr(uint32_t arg) {
13774         LDKC2Tuple_u64u64Z* arg_conv = (LDKC2Tuple_u64u64Z*)(arg & ~1);
13775         uint32_t ret_conv = C2Tuple_u64u64Z_clone_ptr(arg_conv);
13776         return ret_conv;
13777 }
13778
13779 uint32_t  __attribute__((export_name("TS_C2Tuple_u64u64Z_clone"))) TS_C2Tuple_u64u64Z_clone(uint32_t orig) {
13780         LDKC2Tuple_u64u64Z* orig_conv = (LDKC2Tuple_u64u64Z*)(orig & ~1);
13781         LDKC2Tuple_u64u64Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
13782         *ret_conv = C2Tuple_u64u64Z_clone(orig_conv);
13783         return ((uint32_t)ret_conv);
13784 }
13785
13786 uint32_t  __attribute__((export_name("TS_C2Tuple_u64u64Z_new"))) TS_C2Tuple_u64u64Z_new(int64_t a, int64_t b) {
13787         LDKC2Tuple_u64u64Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
13788         *ret_conv = C2Tuple_u64u64Z_new(a, b);
13789         return ((uint32_t)ret_conv);
13790 }
13791
13792 void  __attribute__((export_name("TS_C2Tuple_u64u64Z_free"))) TS_C2Tuple_u64u64Z_free(uint32_t _res) {
13793         if ((_res & 1) != 0) return;
13794         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13795         CHECK_ACCESS(_res_ptr);
13796         LDKC2Tuple_u64u64Z _res_conv = *(LDKC2Tuple_u64u64Z*)(_res_ptr);
13797         FREE((void*)_res);
13798         C2Tuple_u64u64Z_free(_res_conv);
13799 }
13800
13801 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_u64u64ZZ_some"))) TS_COption_C2Tuple_u64u64ZZ_some(uint32_t o) {
13802         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
13803         CHECK_ACCESS(o_ptr);
13804         LDKC2Tuple_u64u64Z o_conv = *(LDKC2Tuple_u64u64Z*)(o_ptr);
13805         o_conv = C2Tuple_u64u64Z_clone((LDKC2Tuple_u64u64Z*)(((uintptr_t)o) & ~1));
13806         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
13807         *ret_copy = COption_C2Tuple_u64u64ZZ_some(o_conv);
13808         uint32_t ret_ref = (uintptr_t)ret_copy;
13809         return ret_ref;
13810 }
13811
13812 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_u64u64ZZ_none"))) TS_COption_C2Tuple_u64u64ZZ_none() {
13813         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
13814         *ret_copy = COption_C2Tuple_u64u64ZZ_none();
13815         uint32_t ret_ref = (uintptr_t)ret_copy;
13816         return ret_ref;
13817 }
13818
13819 void  __attribute__((export_name("TS_COption_C2Tuple_u64u64ZZ_free"))) TS_COption_C2Tuple_u64u64ZZ_free(uint32_t _res) {
13820         if ((_res & 1) != 0) return;
13821         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13822         CHECK_ACCESS(_res_ptr);
13823         LDKCOption_C2Tuple_u64u64ZZ _res_conv = *(LDKCOption_C2Tuple_u64u64ZZ*)(_res_ptr);
13824         FREE((void*)_res);
13825         COption_C2Tuple_u64u64ZZ_free(_res_conv);
13826 }
13827
13828 static inline uintptr_t COption_C2Tuple_u64u64ZZ_clone_ptr(LDKCOption_C2Tuple_u64u64ZZ *NONNULL_PTR arg) {
13829         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
13830         *ret_copy = COption_C2Tuple_u64u64ZZ_clone(arg);
13831 uint32_t ret_ref = (uintptr_t)ret_copy;
13832         return ret_ref;
13833 }
13834 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_u64u64ZZ_clone_ptr"))) TS_COption_C2Tuple_u64u64ZZ_clone_ptr(uint32_t arg) {
13835         LDKCOption_C2Tuple_u64u64ZZ* arg_conv = (LDKCOption_C2Tuple_u64u64ZZ*)arg;
13836         uint32_t ret_conv = COption_C2Tuple_u64u64ZZ_clone_ptr(arg_conv);
13837         return ret_conv;
13838 }
13839
13840 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_u64u64ZZ_clone"))) TS_COption_C2Tuple_u64u64ZZ_clone(uint32_t orig) {
13841         LDKCOption_C2Tuple_u64u64ZZ* orig_conv = (LDKCOption_C2Tuple_u64u64ZZ*)orig;
13842         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
13843         *ret_copy = COption_C2Tuple_u64u64ZZ_clone(orig_conv);
13844         uint32_t ret_ref = (uintptr_t)ret_copy;
13845         return ret_ref;
13846 }
13847
13848 void  __attribute__((export_name("TS_CVec_NodeIdZ_free"))) TS_CVec_NodeIdZ_free(uint32_tArray _res) {
13849         LDKCVec_NodeIdZ _res_constr;
13850         _res_constr.datalen = _res->arr_len;
13851         if (_res_constr.datalen > 0)
13852                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeId), "LDKCVec_NodeIdZ Elements");
13853         else
13854                 _res_constr.data = NULL;
13855         uint32_t* _res_vals = _res->elems;
13856         for (size_t i = 0; i < _res_constr.datalen; i++) {
13857                 uint32_t _res_conv_8 = _res_vals[i];
13858                 LDKNodeId _res_conv_8_conv;
13859                 _res_conv_8_conv.inner = (void*)(_res_conv_8 & (~1));
13860                 _res_conv_8_conv.is_owned = (_res_conv_8 & 1) || (_res_conv_8 == 0);
13861                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_8_conv);
13862                 _res_constr.data[i] = _res_conv_8_conv;
13863         }
13864         FREE(_res);
13865         CVec_NodeIdZ_free(_res_constr);
13866 }
13867
13868 uint32_t  __attribute__((export_name("TS_CResult_ProbabilisticScorerDecodeErrorZ_ok"))) TS_CResult_ProbabilisticScorerDecodeErrorZ_ok(uint32_t o) {
13869         LDKProbabilisticScorer o_conv;
13870         o_conv.inner = (void*)(o & (~1));
13871         o_conv.is_owned = (o & 1) || (o == 0);
13872         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13873         // WARNING: we need a move here but no clone is available for LDKProbabilisticScorer
13874         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
13875         *ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_ok(o_conv);
13876         return (uint32_t)ret_conv;
13877 }
13878
13879 uint32_t  __attribute__((export_name("TS_CResult_ProbabilisticScorerDecodeErrorZ_err"))) TS_CResult_ProbabilisticScorerDecodeErrorZ_err(uint32_t e) {
13880         LDKDecodeError e_conv;
13881         e_conv.inner = (void*)(e & (~1));
13882         e_conv.is_owned = (e & 1) || (e == 0);
13883         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13884         e_conv = DecodeError_clone(&e_conv);
13885         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
13886         *ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_err(e_conv);
13887         return (uint32_t)ret_conv;
13888 }
13889
13890 jboolean  __attribute__((export_name("TS_CResult_ProbabilisticScorerDecodeErrorZ_is_ok"))) TS_CResult_ProbabilisticScorerDecodeErrorZ_is_ok(uint32_t o) {
13891         LDKCResult_ProbabilisticScorerDecodeErrorZ* o_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)(o & ~1);
13892         jboolean ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_is_ok(o_conv);
13893         return ret_conv;
13894 }
13895
13896 void  __attribute__((export_name("TS_CResult_ProbabilisticScorerDecodeErrorZ_free"))) TS_CResult_ProbabilisticScorerDecodeErrorZ_free(uint32_t _res) {
13897         if ((_res & 1) != 0) return;
13898         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13899         CHECK_ACCESS(_res_ptr);
13900         LDKCResult_ProbabilisticScorerDecodeErrorZ _res_conv = *(LDKCResult_ProbabilisticScorerDecodeErrorZ*)(_res_ptr);
13901         FREE((void*)_res);
13902         CResult_ProbabilisticScorerDecodeErrorZ_free(_res_conv);
13903 }
13904
13905 uint32_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_ok"))) TS_CResult_InitFeaturesDecodeErrorZ_ok(uint32_t o) {
13906         LDKInitFeatures o_conv;
13907         o_conv.inner = (void*)(o & (~1));
13908         o_conv.is_owned = (o & 1) || (o == 0);
13909         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13910         o_conv = InitFeatures_clone(&o_conv);
13911         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
13912         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
13913         return (uint32_t)ret_conv;
13914 }
13915
13916 uint32_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_err"))) TS_CResult_InitFeaturesDecodeErrorZ_err(uint32_t e) {
13917         LDKDecodeError e_conv;
13918         e_conv.inner = (void*)(e & (~1));
13919         e_conv.is_owned = (e & 1) || (e == 0);
13920         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13921         e_conv = DecodeError_clone(&e_conv);
13922         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
13923         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
13924         return (uint32_t)ret_conv;
13925 }
13926
13927 jboolean  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_is_ok"))) TS_CResult_InitFeaturesDecodeErrorZ_is_ok(uint32_t o) {
13928         LDKCResult_InitFeaturesDecodeErrorZ* o_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(o & ~1);
13929         jboolean ret_conv = CResult_InitFeaturesDecodeErrorZ_is_ok(o_conv);
13930         return ret_conv;
13931 }
13932
13933 void  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_free"))) TS_CResult_InitFeaturesDecodeErrorZ_free(uint32_t _res) {
13934         if ((_res & 1) != 0) return;
13935         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13936         CHECK_ACCESS(_res_ptr);
13937         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(_res_ptr);
13938         FREE((void*)_res);
13939         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
13940 }
13941
13942 static inline uintptr_t CResult_InitFeaturesDecodeErrorZ_clone_ptr(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR arg) {
13943         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
13944         *ret_conv = CResult_InitFeaturesDecodeErrorZ_clone(arg);
13945         return (uint32_t)ret_conv;
13946 }
13947 uint32_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_clone_ptr"))) TS_CResult_InitFeaturesDecodeErrorZ_clone_ptr(uint32_t arg) {
13948         LDKCResult_InitFeaturesDecodeErrorZ* arg_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
13949         uint32_t ret_conv = CResult_InitFeaturesDecodeErrorZ_clone_ptr(arg_conv);
13950         return ret_conv;
13951 }
13952
13953 uint32_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_clone"))) TS_CResult_InitFeaturesDecodeErrorZ_clone(uint32_t orig) {
13954         LDKCResult_InitFeaturesDecodeErrorZ* orig_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(orig & ~1);
13955         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
13956         *ret_conv = CResult_InitFeaturesDecodeErrorZ_clone(orig_conv);
13957         return (uint32_t)ret_conv;
13958 }
13959
13960 uint32_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_ok"))) TS_CResult_ChannelFeaturesDecodeErrorZ_ok(uint32_t o) {
13961         LDKChannelFeatures o_conv;
13962         o_conv.inner = (void*)(o & (~1));
13963         o_conv.is_owned = (o & 1) || (o == 0);
13964         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13965         o_conv = ChannelFeatures_clone(&o_conv);
13966         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
13967         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
13968         return (uint32_t)ret_conv;
13969 }
13970
13971 uint32_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_err"))) TS_CResult_ChannelFeaturesDecodeErrorZ_err(uint32_t e) {
13972         LDKDecodeError e_conv;
13973         e_conv.inner = (void*)(e & (~1));
13974         e_conv.is_owned = (e & 1) || (e == 0);
13975         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13976         e_conv = DecodeError_clone(&e_conv);
13977         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
13978         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
13979         return (uint32_t)ret_conv;
13980 }
13981
13982 jboolean  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_is_ok"))) TS_CResult_ChannelFeaturesDecodeErrorZ_is_ok(uint32_t o) {
13983         LDKCResult_ChannelFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(o & ~1);
13984         jboolean ret_conv = CResult_ChannelFeaturesDecodeErrorZ_is_ok(o_conv);
13985         return ret_conv;
13986 }
13987
13988 void  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_free"))) TS_CResult_ChannelFeaturesDecodeErrorZ_free(uint32_t _res) {
13989         if ((_res & 1) != 0) return;
13990         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13991         CHECK_ACCESS(_res_ptr);
13992         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(_res_ptr);
13993         FREE((void*)_res);
13994         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
13995 }
13996
13997 static inline uintptr_t CResult_ChannelFeaturesDecodeErrorZ_clone_ptr(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR arg) {
13998         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
13999         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_clone(arg);
14000         return (uint32_t)ret_conv;
14001 }
14002 uint32_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelFeaturesDecodeErrorZ_clone_ptr(uint32_t arg) {
14003         LDKCResult_ChannelFeaturesDecodeErrorZ* arg_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
14004         uint32_t ret_conv = CResult_ChannelFeaturesDecodeErrorZ_clone_ptr(arg_conv);
14005         return ret_conv;
14006 }
14007
14008 uint32_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_clone"))) TS_CResult_ChannelFeaturesDecodeErrorZ_clone(uint32_t orig) {
14009         LDKCResult_ChannelFeaturesDecodeErrorZ* orig_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(orig & ~1);
14010         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
14011         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_clone(orig_conv);
14012         return (uint32_t)ret_conv;
14013 }
14014
14015 uint32_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_ok"))) TS_CResult_NodeFeaturesDecodeErrorZ_ok(uint32_t o) {
14016         LDKNodeFeatures o_conv;
14017         o_conv.inner = (void*)(o & (~1));
14018         o_conv.is_owned = (o & 1) || (o == 0);
14019         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14020         o_conv = NodeFeatures_clone(&o_conv);
14021         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
14022         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
14023         return (uint32_t)ret_conv;
14024 }
14025
14026 uint32_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_err"))) TS_CResult_NodeFeaturesDecodeErrorZ_err(uint32_t e) {
14027         LDKDecodeError e_conv;
14028         e_conv.inner = (void*)(e & (~1));
14029         e_conv.is_owned = (e & 1) || (e == 0);
14030         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14031         e_conv = DecodeError_clone(&e_conv);
14032         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
14033         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
14034         return (uint32_t)ret_conv;
14035 }
14036
14037 jboolean  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_is_ok"))) TS_CResult_NodeFeaturesDecodeErrorZ_is_ok(uint32_t o) {
14038         LDKCResult_NodeFeaturesDecodeErrorZ* o_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(o & ~1);
14039         jboolean ret_conv = CResult_NodeFeaturesDecodeErrorZ_is_ok(o_conv);
14040         return ret_conv;
14041 }
14042
14043 void  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_free"))) TS_CResult_NodeFeaturesDecodeErrorZ_free(uint32_t _res) {
14044         if ((_res & 1) != 0) return;
14045         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14046         CHECK_ACCESS(_res_ptr);
14047         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(_res_ptr);
14048         FREE((void*)_res);
14049         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
14050 }
14051
14052 static inline uintptr_t CResult_NodeFeaturesDecodeErrorZ_clone_ptr(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR arg) {
14053         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
14054         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_clone(arg);
14055         return (uint32_t)ret_conv;
14056 }
14057 uint32_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_clone_ptr"))) TS_CResult_NodeFeaturesDecodeErrorZ_clone_ptr(uint32_t arg) {
14058         LDKCResult_NodeFeaturesDecodeErrorZ* arg_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
14059         uint32_t ret_conv = CResult_NodeFeaturesDecodeErrorZ_clone_ptr(arg_conv);
14060         return ret_conv;
14061 }
14062
14063 uint32_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_clone"))) TS_CResult_NodeFeaturesDecodeErrorZ_clone(uint32_t orig) {
14064         LDKCResult_NodeFeaturesDecodeErrorZ* orig_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(orig & ~1);
14065         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
14066         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_clone(orig_conv);
14067         return (uint32_t)ret_conv;
14068 }
14069
14070 uint32_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_ok"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_ok(uint32_t o) {
14071         LDKInvoiceFeatures o_conv;
14072         o_conv.inner = (void*)(o & (~1));
14073         o_conv.is_owned = (o & 1) || (o == 0);
14074         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14075         o_conv = InvoiceFeatures_clone(&o_conv);
14076         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
14077         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_ok(o_conv);
14078         return (uint32_t)ret_conv;
14079 }
14080
14081 uint32_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_err"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_err(uint32_t e) {
14082         LDKDecodeError e_conv;
14083         e_conv.inner = (void*)(e & (~1));
14084         e_conv.is_owned = (e & 1) || (e == 0);
14085         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14086         e_conv = DecodeError_clone(&e_conv);
14087         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
14088         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_err(e_conv);
14089         return (uint32_t)ret_conv;
14090 }
14091
14092 jboolean  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_is_ok"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_is_ok(uint32_t o) {
14093         LDKCResult_InvoiceFeaturesDecodeErrorZ* o_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(o & ~1);
14094         jboolean ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_is_ok(o_conv);
14095         return ret_conv;
14096 }
14097
14098 void  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_free"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_free(uint32_t _res) {
14099         if ((_res & 1) != 0) return;
14100         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14101         CHECK_ACCESS(_res_ptr);
14102         LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(_res_ptr);
14103         FREE((void*)_res);
14104         CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv);
14105 }
14106
14107 static inline uintptr_t CResult_InvoiceFeaturesDecodeErrorZ_clone_ptr(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR arg) {
14108         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
14109         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_clone(arg);
14110         return (uint32_t)ret_conv;
14111 }
14112 uint32_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_clone_ptr"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_clone_ptr(uint32_t arg) {
14113         LDKCResult_InvoiceFeaturesDecodeErrorZ* arg_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
14114         uint32_t ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_clone_ptr(arg_conv);
14115         return ret_conv;
14116 }
14117
14118 uint32_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_clone"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_clone(uint32_t orig) {
14119         LDKCResult_InvoiceFeaturesDecodeErrorZ* orig_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(orig & ~1);
14120         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
14121         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_clone(orig_conv);
14122         return (uint32_t)ret_conv;
14123 }
14124
14125 uint32_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_ok"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_ok(uint32_t o) {
14126         LDKChannelTypeFeatures o_conv;
14127         o_conv.inner = (void*)(o & (~1));
14128         o_conv.is_owned = (o & 1) || (o == 0);
14129         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14130         o_conv = ChannelTypeFeatures_clone(&o_conv);
14131         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
14132         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_ok(o_conv);
14133         return (uint32_t)ret_conv;
14134 }
14135
14136 uint32_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_err"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_err(uint32_t e) {
14137         LDKDecodeError e_conv;
14138         e_conv.inner = (void*)(e & (~1));
14139         e_conv.is_owned = (e & 1) || (e == 0);
14140         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14141         e_conv = DecodeError_clone(&e_conv);
14142         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
14143         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_err(e_conv);
14144         return (uint32_t)ret_conv;
14145 }
14146
14147 jboolean  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok(uint32_t o) {
14148         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(o & ~1);
14149         jboolean ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok(o_conv);
14150         return ret_conv;
14151 }
14152
14153 void  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_free"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_free(uint32_t _res) {
14154         if ((_res & 1) != 0) return;
14155         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14156         CHECK_ACCESS(_res_ptr);
14157         LDKCResult_ChannelTypeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(_res_ptr);
14158         FREE((void*)_res);
14159         CResult_ChannelTypeFeaturesDecodeErrorZ_free(_res_conv);
14160 }
14161
14162 static inline uintptr_t CResult_ChannelTypeFeaturesDecodeErrorZ_clone_ptr(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR arg) {
14163         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
14164         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_clone(arg);
14165         return (uint32_t)ret_conv;
14166 }
14167 uint32_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_clone_ptr(uint32_t arg) {
14168         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* arg_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(arg & ~1);
14169         uint32_t ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_clone_ptr(arg_conv);
14170         return ret_conv;
14171 }
14172
14173 uint32_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_clone"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_clone(uint32_t orig) {
14174         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* orig_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(orig & ~1);
14175         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
14176         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_clone(orig_conv);
14177         return (uint32_t)ret_conv;
14178 }
14179
14180 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_ok"))) TS_CResult_NodeIdDecodeErrorZ_ok(uint32_t o) {
14181         LDKNodeId o_conv;
14182         o_conv.inner = (void*)(o & (~1));
14183         o_conv.is_owned = (o & 1) || (o == 0);
14184         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14185         o_conv = NodeId_clone(&o_conv);
14186         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
14187         *ret_conv = CResult_NodeIdDecodeErrorZ_ok(o_conv);
14188         return (uint32_t)ret_conv;
14189 }
14190
14191 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_err"))) TS_CResult_NodeIdDecodeErrorZ_err(uint32_t e) {
14192         LDKDecodeError e_conv;
14193         e_conv.inner = (void*)(e & (~1));
14194         e_conv.is_owned = (e & 1) || (e == 0);
14195         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14196         e_conv = DecodeError_clone(&e_conv);
14197         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
14198         *ret_conv = CResult_NodeIdDecodeErrorZ_err(e_conv);
14199         return (uint32_t)ret_conv;
14200 }
14201
14202 jboolean  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_is_ok"))) TS_CResult_NodeIdDecodeErrorZ_is_ok(uint32_t o) {
14203         LDKCResult_NodeIdDecodeErrorZ* o_conv = (LDKCResult_NodeIdDecodeErrorZ*)(o & ~1);
14204         jboolean ret_conv = CResult_NodeIdDecodeErrorZ_is_ok(o_conv);
14205         return ret_conv;
14206 }
14207
14208 void  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_free"))) TS_CResult_NodeIdDecodeErrorZ_free(uint32_t _res) {
14209         if ((_res & 1) != 0) return;
14210         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14211         CHECK_ACCESS(_res_ptr);
14212         LDKCResult_NodeIdDecodeErrorZ _res_conv = *(LDKCResult_NodeIdDecodeErrorZ*)(_res_ptr);
14213         FREE((void*)_res);
14214         CResult_NodeIdDecodeErrorZ_free(_res_conv);
14215 }
14216
14217 static inline uintptr_t CResult_NodeIdDecodeErrorZ_clone_ptr(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR arg) {
14218         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
14219         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(arg);
14220         return (uint32_t)ret_conv;
14221 }
14222 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_clone_ptr"))) TS_CResult_NodeIdDecodeErrorZ_clone_ptr(uint32_t arg) {
14223         LDKCResult_NodeIdDecodeErrorZ* arg_conv = (LDKCResult_NodeIdDecodeErrorZ*)(arg & ~1);
14224         uint32_t ret_conv = CResult_NodeIdDecodeErrorZ_clone_ptr(arg_conv);
14225         return ret_conv;
14226 }
14227
14228 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_clone"))) TS_CResult_NodeIdDecodeErrorZ_clone(uint32_t orig) {
14229         LDKCResult_NodeIdDecodeErrorZ* orig_conv = (LDKCResult_NodeIdDecodeErrorZ*)(orig & ~1);
14230         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
14231         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(orig_conv);
14232         return (uint32_t)ret_conv;
14233 }
14234
14235 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_ok"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_ok(uint32_t o) {
14236         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
14237         CHECK_ACCESS(o_ptr);
14238         LDKCOption_NetworkUpdateZ o_conv = *(LDKCOption_NetworkUpdateZ*)(o_ptr);
14239         o_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uintptr_t)o) & ~1));
14240         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
14241         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_ok(o_conv);
14242         return (uint32_t)ret_conv;
14243 }
14244
14245 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_err"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_err(uint32_t e) {
14246         LDKDecodeError e_conv;
14247         e_conv.inner = (void*)(e & (~1));
14248         e_conv.is_owned = (e & 1) || (e == 0);
14249         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14250         e_conv = DecodeError_clone(&e_conv);
14251         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
14252         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_err(e_conv);
14253         return (uint32_t)ret_conv;
14254 }
14255
14256 jboolean  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok(uint32_t o) {
14257         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* o_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(o & ~1);
14258         jboolean ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok(o_conv);
14259         return ret_conv;
14260 }
14261
14262 void  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_free"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_free(uint32_t _res) {
14263         if ((_res & 1) != 0) return;
14264         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14265         CHECK_ACCESS(_res_ptr);
14266         LDKCResult_COption_NetworkUpdateZDecodeErrorZ _res_conv = *(LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(_res_ptr);
14267         FREE((void*)_res);
14268         CResult_COption_NetworkUpdateZDecodeErrorZ_free(_res_conv);
14269 }
14270
14271 static inline uintptr_t CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR arg) {
14272         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
14273         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(arg);
14274         return (uint32_t)ret_conv;
14275 }
14276 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(uint32_t arg) {
14277         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* arg_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(arg & ~1);
14278         uint32_t ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(arg_conv);
14279         return ret_conv;
14280 }
14281
14282 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_clone"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_clone(uint32_t orig) {
14283         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* orig_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(orig & ~1);
14284         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
14285         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(orig_conv);
14286         return (uint32_t)ret_conv;
14287 }
14288
14289 uint32_t  __attribute__((export_name("TS_COption_AccessZ_some"))) TS_COption_AccessZ_some(uint32_t o) {
14290         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
14291         CHECK_ACCESS(o_ptr);
14292         LDKAccess o_conv = *(LDKAccess*)(o_ptr);
14293         if (o_conv.free == LDKAccess_JCalls_free) {
14294                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14295                 LDKAccess_JCalls_cloned(&o_conv);
14296         }
14297         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
14298         *ret_copy = COption_AccessZ_some(o_conv);
14299         uint32_t ret_ref = (uintptr_t)ret_copy;
14300         return ret_ref;
14301 }
14302
14303 uint32_t  __attribute__((export_name("TS_COption_AccessZ_none"))) TS_COption_AccessZ_none() {
14304         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
14305         *ret_copy = COption_AccessZ_none();
14306         uint32_t ret_ref = (uintptr_t)ret_copy;
14307         return ret_ref;
14308 }
14309
14310 void  __attribute__((export_name("TS_COption_AccessZ_free"))) TS_COption_AccessZ_free(uint32_t _res) {
14311         if ((_res & 1) != 0) return;
14312         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14313         CHECK_ACCESS(_res_ptr);
14314         LDKCOption_AccessZ _res_conv = *(LDKCOption_AccessZ*)(_res_ptr);
14315         FREE((void*)_res);
14316         COption_AccessZ_free(_res_conv);
14317 }
14318
14319 uint32_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_ok"))) TS_CResult_boolLightningErrorZ_ok(jboolean o) {
14320         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
14321         *ret_conv = CResult_boolLightningErrorZ_ok(o);
14322         return (uint32_t)ret_conv;
14323 }
14324
14325 uint32_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_err"))) TS_CResult_boolLightningErrorZ_err(uint32_t e) {
14326         LDKLightningError e_conv;
14327         e_conv.inner = (void*)(e & (~1));
14328         e_conv.is_owned = (e & 1) || (e == 0);
14329         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14330         e_conv = LightningError_clone(&e_conv);
14331         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
14332         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
14333         return (uint32_t)ret_conv;
14334 }
14335
14336 jboolean  __attribute__((export_name("TS_CResult_boolLightningErrorZ_is_ok"))) TS_CResult_boolLightningErrorZ_is_ok(uint32_t o) {
14337         LDKCResult_boolLightningErrorZ* o_conv = (LDKCResult_boolLightningErrorZ*)(o & ~1);
14338         jboolean ret_conv = CResult_boolLightningErrorZ_is_ok(o_conv);
14339         return ret_conv;
14340 }
14341
14342 void  __attribute__((export_name("TS_CResult_boolLightningErrorZ_free"))) TS_CResult_boolLightningErrorZ_free(uint32_t _res) {
14343         if ((_res & 1) != 0) return;
14344         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14345         CHECK_ACCESS(_res_ptr);
14346         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(_res_ptr);
14347         FREE((void*)_res);
14348         CResult_boolLightningErrorZ_free(_res_conv);
14349 }
14350
14351 static inline uintptr_t CResult_boolLightningErrorZ_clone_ptr(LDKCResult_boolLightningErrorZ *NONNULL_PTR arg) {
14352         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
14353         *ret_conv = CResult_boolLightningErrorZ_clone(arg);
14354         return (uint32_t)ret_conv;
14355 }
14356 uint32_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_clone_ptr"))) TS_CResult_boolLightningErrorZ_clone_ptr(uint32_t arg) {
14357         LDKCResult_boolLightningErrorZ* arg_conv = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
14358         uint32_t ret_conv = CResult_boolLightningErrorZ_clone_ptr(arg_conv);
14359         return ret_conv;
14360 }
14361
14362 uint32_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_clone"))) TS_CResult_boolLightningErrorZ_clone(uint32_t orig) {
14363         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)(orig & ~1);
14364         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
14365         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
14366         return (uint32_t)ret_conv;
14367 }
14368
14369 static inline uintptr_t C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR arg) {
14370         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
14371         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(arg);
14372         return ((uint32_t)ret_conv);
14373 }
14374 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(uint32_t arg) {
14375         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* arg_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(arg & ~1);
14376         uint32_t ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(arg_conv);
14377         return ret_conv;
14378 }
14379
14380 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(uint32_t orig) {
14381         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(orig & ~1);
14382         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
14383         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
14384         return ((uint32_t)ret_conv);
14385 }
14386
14387 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(uint32_t a, uint32_t b, uint32_t c) {
14388         LDKChannelAnnouncement a_conv;
14389         a_conv.inner = (void*)(a & (~1));
14390         a_conv.is_owned = (a & 1) || (a == 0);
14391         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
14392         a_conv = ChannelAnnouncement_clone(&a_conv);
14393         LDKChannelUpdate b_conv;
14394         b_conv.inner = (void*)(b & (~1));
14395         b_conv.is_owned = (b & 1) || (b == 0);
14396         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
14397         b_conv = ChannelUpdate_clone(&b_conv);
14398         LDKChannelUpdate c_conv;
14399         c_conv.inner = (void*)(c & (~1));
14400         c_conv.is_owned = (c & 1) || (c == 0);
14401         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
14402         c_conv = ChannelUpdate_clone(&c_conv);
14403         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
14404         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
14405         return ((uint32_t)ret_conv);
14406 }
14407
14408 void  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(uint32_t _res) {
14409         if ((_res & 1) != 0) return;
14410         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14411         CHECK_ACCESS(_res_ptr);
14412         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_ptr);
14413         FREE((void*)_res);
14414         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
14415 }
14416
14417 void  __attribute__((export_name("TS_CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free"))) TS_CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(uint32_tArray _res) {
14418         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_constr;
14419         _res_constr.datalen = _res->arr_len;
14420         if (_res_constr.datalen > 0)
14421                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
14422         else
14423                 _res_constr.data = NULL;
14424         uint32_t* _res_vals = _res->elems;
14425         for (size_t h = 0; h < _res_constr.datalen; h++) {
14426                 uint32_t _res_conv_59 = _res_vals[h];
14427                 void* _res_conv_59_ptr = (void*)(((uintptr_t)_res_conv_59) & ~1);
14428                 CHECK_ACCESS(_res_conv_59_ptr);
14429                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_conv_59_ptr);
14430                 FREE((void*)_res_conv_59);
14431                 _res_constr.data[h] = _res_conv_59_conv;
14432         }
14433         FREE(_res);
14434         CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_constr);
14435 }
14436
14437 void  __attribute__((export_name("TS_CVec_NodeAnnouncementZ_free"))) TS_CVec_NodeAnnouncementZ_free(uint32_tArray _res) {
14438         LDKCVec_NodeAnnouncementZ _res_constr;
14439         _res_constr.datalen = _res->arr_len;
14440         if (_res_constr.datalen > 0)
14441                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
14442         else
14443                 _res_constr.data = NULL;
14444         uint32_t* _res_vals = _res->elems;
14445         for (size_t s = 0; s < _res_constr.datalen; s++) {
14446                 uint32_t _res_conv_18 = _res_vals[s];
14447                 LDKNodeAnnouncement _res_conv_18_conv;
14448                 _res_conv_18_conv.inner = (void*)(_res_conv_18 & (~1));
14449                 _res_conv_18_conv.is_owned = (_res_conv_18 & 1) || (_res_conv_18 == 0);
14450                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_18_conv);
14451                 _res_constr.data[s] = _res_conv_18_conv;
14452         }
14453         FREE(_res);
14454         CVec_NodeAnnouncementZ_free(_res_constr);
14455 }
14456
14457 uint32_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_ok"))) TS_CResult_NoneLightningErrorZ_ok() {
14458         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
14459         *ret_conv = CResult_NoneLightningErrorZ_ok();
14460         return (uint32_t)ret_conv;
14461 }
14462
14463 uint32_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_err"))) TS_CResult_NoneLightningErrorZ_err(uint32_t e) {
14464         LDKLightningError e_conv;
14465         e_conv.inner = (void*)(e & (~1));
14466         e_conv.is_owned = (e & 1) || (e == 0);
14467         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14468         e_conv = LightningError_clone(&e_conv);
14469         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
14470         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
14471         return (uint32_t)ret_conv;
14472 }
14473
14474 jboolean  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_is_ok"))) TS_CResult_NoneLightningErrorZ_is_ok(uint32_t o) {
14475         LDKCResult_NoneLightningErrorZ* o_conv = (LDKCResult_NoneLightningErrorZ*)(o & ~1);
14476         jboolean ret_conv = CResult_NoneLightningErrorZ_is_ok(o_conv);
14477         return ret_conv;
14478 }
14479
14480 void  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_free"))) TS_CResult_NoneLightningErrorZ_free(uint32_t _res) {
14481         if ((_res & 1) != 0) return;
14482         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14483         CHECK_ACCESS(_res_ptr);
14484         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(_res_ptr);
14485         FREE((void*)_res);
14486         CResult_NoneLightningErrorZ_free(_res_conv);
14487 }
14488
14489 static inline uintptr_t CResult_NoneLightningErrorZ_clone_ptr(LDKCResult_NoneLightningErrorZ *NONNULL_PTR arg) {
14490         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
14491         *ret_conv = CResult_NoneLightningErrorZ_clone(arg);
14492         return (uint32_t)ret_conv;
14493 }
14494 uint32_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_clone_ptr"))) TS_CResult_NoneLightningErrorZ_clone_ptr(uint32_t arg) {
14495         LDKCResult_NoneLightningErrorZ* arg_conv = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
14496         uint32_t ret_conv = CResult_NoneLightningErrorZ_clone_ptr(arg_conv);
14497         return ret_conv;
14498 }
14499
14500 uint32_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_clone"))) TS_CResult_NoneLightningErrorZ_clone(uint32_t orig) {
14501         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)(orig & ~1);
14502         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
14503         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
14504         return (uint32_t)ret_conv;
14505 }
14506
14507 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_ok"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_ok(uint32_t o) {
14508         LDKChannelUpdateInfo o_conv;
14509         o_conv.inner = (void*)(o & (~1));
14510         o_conv.is_owned = (o & 1) || (o == 0);
14511         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14512         o_conv = ChannelUpdateInfo_clone(&o_conv);
14513         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
14514         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_ok(o_conv);
14515         return (uint32_t)ret_conv;
14516 }
14517
14518 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_err"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_err(uint32_t e) {
14519         LDKDecodeError e_conv;
14520         e_conv.inner = (void*)(e & (~1));
14521         e_conv.is_owned = (e & 1) || (e == 0);
14522         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14523         e_conv = DecodeError_clone(&e_conv);
14524         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
14525         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_err(e_conv);
14526         return (uint32_t)ret_conv;
14527 }
14528
14529 jboolean  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_is_ok"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_is_ok(uint32_t o) {
14530         LDKCResult_ChannelUpdateInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(o & ~1);
14531         jboolean ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_is_ok(o_conv);
14532         return ret_conv;
14533 }
14534
14535 void  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_free"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_free(uint32_t _res) {
14536         if ((_res & 1) != 0) return;
14537         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14538         CHECK_ACCESS(_res_ptr);
14539         LDKCResult_ChannelUpdateInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(_res_ptr);
14540         FREE((void*)_res);
14541         CResult_ChannelUpdateInfoDecodeErrorZ_free(_res_conv);
14542 }
14543
14544 static inline uintptr_t CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR arg) {
14545         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
14546         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone(arg);
14547         return (uint32_t)ret_conv;
14548 }
14549 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
14550         LDKCResult_ChannelUpdateInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(arg & ~1);
14551         uint32_t ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(arg_conv);
14552         return ret_conv;
14553 }
14554
14555 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_clone"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_clone(uint32_t orig) {
14556         LDKCResult_ChannelUpdateInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(orig & ~1);
14557         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
14558         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone(orig_conv);
14559         return (uint32_t)ret_conv;
14560 }
14561
14562 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_ok"))) TS_CResult_ChannelInfoDecodeErrorZ_ok(uint32_t o) {
14563         LDKChannelInfo o_conv;
14564         o_conv.inner = (void*)(o & (~1));
14565         o_conv.is_owned = (o & 1) || (o == 0);
14566         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14567         o_conv = ChannelInfo_clone(&o_conv);
14568         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
14569         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
14570         return (uint32_t)ret_conv;
14571 }
14572
14573 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_err"))) TS_CResult_ChannelInfoDecodeErrorZ_err(uint32_t e) {
14574         LDKDecodeError e_conv;
14575         e_conv.inner = (void*)(e & (~1));
14576         e_conv.is_owned = (e & 1) || (e == 0);
14577         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14578         e_conv = DecodeError_clone(&e_conv);
14579         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
14580         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
14581         return (uint32_t)ret_conv;
14582 }
14583
14584 jboolean  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_is_ok"))) TS_CResult_ChannelInfoDecodeErrorZ_is_ok(uint32_t o) {
14585         LDKCResult_ChannelInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(o & ~1);
14586         jboolean ret_conv = CResult_ChannelInfoDecodeErrorZ_is_ok(o_conv);
14587         return ret_conv;
14588 }
14589
14590 void  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_free"))) TS_CResult_ChannelInfoDecodeErrorZ_free(uint32_t _res) {
14591         if ((_res & 1) != 0) return;
14592         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14593         CHECK_ACCESS(_res_ptr);
14594         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(_res_ptr);
14595         FREE((void*)_res);
14596         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
14597 }
14598
14599 static inline uintptr_t CResult_ChannelInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR arg) {
14600         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
14601         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(arg);
14602         return (uint32_t)ret_conv;
14603 }
14604 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
14605         LDKCResult_ChannelInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
14606         uint32_t ret_conv = CResult_ChannelInfoDecodeErrorZ_clone_ptr(arg_conv);
14607         return ret_conv;
14608 }
14609
14610 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_clone"))) TS_CResult_ChannelInfoDecodeErrorZ_clone(uint32_t orig) {
14611         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(orig & ~1);
14612         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
14613         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
14614         return (uint32_t)ret_conv;
14615 }
14616
14617 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_ok"))) TS_CResult_RoutingFeesDecodeErrorZ_ok(uint32_t o) {
14618         LDKRoutingFees o_conv;
14619         o_conv.inner = (void*)(o & (~1));
14620         o_conv.is_owned = (o & 1) || (o == 0);
14621         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14622         o_conv = RoutingFees_clone(&o_conv);
14623         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
14624         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
14625         return (uint32_t)ret_conv;
14626 }
14627
14628 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_err"))) TS_CResult_RoutingFeesDecodeErrorZ_err(uint32_t e) {
14629         LDKDecodeError e_conv;
14630         e_conv.inner = (void*)(e & (~1));
14631         e_conv.is_owned = (e & 1) || (e == 0);
14632         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14633         e_conv = DecodeError_clone(&e_conv);
14634         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
14635         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
14636         return (uint32_t)ret_conv;
14637 }
14638
14639 jboolean  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_is_ok"))) TS_CResult_RoutingFeesDecodeErrorZ_is_ok(uint32_t o) {
14640         LDKCResult_RoutingFeesDecodeErrorZ* o_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(o & ~1);
14641         jboolean ret_conv = CResult_RoutingFeesDecodeErrorZ_is_ok(o_conv);
14642         return ret_conv;
14643 }
14644
14645 void  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_free"))) TS_CResult_RoutingFeesDecodeErrorZ_free(uint32_t _res) {
14646         if ((_res & 1) != 0) return;
14647         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14648         CHECK_ACCESS(_res_ptr);
14649         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(_res_ptr);
14650         FREE((void*)_res);
14651         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
14652 }
14653
14654 static inline uintptr_t CResult_RoutingFeesDecodeErrorZ_clone_ptr(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR arg) {
14655         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
14656         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(arg);
14657         return (uint32_t)ret_conv;
14658 }
14659 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_clone_ptr"))) TS_CResult_RoutingFeesDecodeErrorZ_clone_ptr(uint32_t arg) {
14660         LDKCResult_RoutingFeesDecodeErrorZ* arg_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
14661         uint32_t ret_conv = CResult_RoutingFeesDecodeErrorZ_clone_ptr(arg_conv);
14662         return ret_conv;
14663 }
14664
14665 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_clone"))) TS_CResult_RoutingFeesDecodeErrorZ_clone(uint32_t orig) {
14666         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(orig & ~1);
14667         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
14668         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
14669         return (uint32_t)ret_conv;
14670 }
14671
14672 void  __attribute__((export_name("TS_CVec_NetAddressZ_free"))) TS_CVec_NetAddressZ_free(uint32_tArray _res) {
14673         LDKCVec_NetAddressZ _res_constr;
14674         _res_constr.datalen = _res->arr_len;
14675         if (_res_constr.datalen > 0)
14676                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
14677         else
14678                 _res_constr.data = NULL;
14679         uint32_t* _res_vals = _res->elems;
14680         for (size_t m = 0; m < _res_constr.datalen; m++) {
14681                 uint32_t _res_conv_12 = _res_vals[m];
14682                 void* _res_conv_12_ptr = (void*)(((uintptr_t)_res_conv_12) & ~1);
14683                 CHECK_ACCESS(_res_conv_12_ptr);
14684                 LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(_res_conv_12_ptr);
14685                 FREE((void*)_res_conv_12);
14686                 _res_constr.data[m] = _res_conv_12_conv;
14687         }
14688         FREE(_res);
14689         CVec_NetAddressZ_free(_res_constr);
14690 }
14691
14692 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_ok"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_ok(uint32_t o) {
14693         LDKNodeAnnouncementInfo o_conv;
14694         o_conv.inner = (void*)(o & (~1));
14695         o_conv.is_owned = (o & 1) || (o == 0);
14696         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14697         o_conv = NodeAnnouncementInfo_clone(&o_conv);
14698         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
14699         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
14700         return (uint32_t)ret_conv;
14701 }
14702
14703 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_err"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_err(uint32_t e) {
14704         LDKDecodeError e_conv;
14705         e_conv.inner = (void*)(e & (~1));
14706         e_conv.is_owned = (e & 1) || (e == 0);
14707         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14708         e_conv = DecodeError_clone(&e_conv);
14709         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
14710         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
14711         return (uint32_t)ret_conv;
14712 }
14713
14714 jboolean  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok(uint32_t o) {
14715         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(o & ~1);
14716         jboolean ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok(o_conv);
14717         return ret_conv;
14718 }
14719
14720 void  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_free"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_free(uint32_t _res) {
14721         if ((_res & 1) != 0) return;
14722         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14723         CHECK_ACCESS(_res_ptr);
14724         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(_res_ptr);
14725         FREE((void*)_res);
14726         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
14727 }
14728
14729 static inline uintptr_t CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR arg) {
14730         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
14731         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(arg);
14732         return (uint32_t)ret_conv;
14733 }
14734 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
14735         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
14736         uint32_t ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(arg_conv);
14737         return ret_conv;
14738 }
14739
14740 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone(uint32_t orig) {
14741         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(orig & ~1);
14742         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
14743         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
14744         return (uint32_t)ret_conv;
14745 }
14746
14747 uint32_t  __attribute__((export_name("TS_CResult_NodeAliasDecodeErrorZ_ok"))) TS_CResult_NodeAliasDecodeErrorZ_ok(uint32_t o) {
14748         LDKNodeAlias o_conv;
14749         o_conv.inner = (void*)(o & (~1));
14750         o_conv.is_owned = (o & 1) || (o == 0);
14751         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14752         o_conv = NodeAlias_clone(&o_conv);
14753         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
14754         *ret_conv = CResult_NodeAliasDecodeErrorZ_ok(o_conv);
14755         return (uint32_t)ret_conv;
14756 }
14757
14758 uint32_t  __attribute__((export_name("TS_CResult_NodeAliasDecodeErrorZ_err"))) TS_CResult_NodeAliasDecodeErrorZ_err(uint32_t e) {
14759         LDKDecodeError e_conv;
14760         e_conv.inner = (void*)(e & (~1));
14761         e_conv.is_owned = (e & 1) || (e == 0);
14762         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14763         e_conv = DecodeError_clone(&e_conv);
14764         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
14765         *ret_conv = CResult_NodeAliasDecodeErrorZ_err(e_conv);
14766         return (uint32_t)ret_conv;
14767 }
14768
14769 jboolean  __attribute__((export_name("TS_CResult_NodeAliasDecodeErrorZ_is_ok"))) TS_CResult_NodeAliasDecodeErrorZ_is_ok(uint32_t o) {
14770         LDKCResult_NodeAliasDecodeErrorZ* o_conv = (LDKCResult_NodeAliasDecodeErrorZ*)(o & ~1);
14771         jboolean ret_conv = CResult_NodeAliasDecodeErrorZ_is_ok(o_conv);
14772         return ret_conv;
14773 }
14774
14775 void  __attribute__((export_name("TS_CResult_NodeAliasDecodeErrorZ_free"))) TS_CResult_NodeAliasDecodeErrorZ_free(uint32_t _res) {
14776         if ((_res & 1) != 0) return;
14777         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14778         CHECK_ACCESS(_res_ptr);
14779         LDKCResult_NodeAliasDecodeErrorZ _res_conv = *(LDKCResult_NodeAliasDecodeErrorZ*)(_res_ptr);
14780         FREE((void*)_res);
14781         CResult_NodeAliasDecodeErrorZ_free(_res_conv);
14782 }
14783
14784 static inline uintptr_t CResult_NodeAliasDecodeErrorZ_clone_ptr(LDKCResult_NodeAliasDecodeErrorZ *NONNULL_PTR arg) {
14785         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
14786         *ret_conv = CResult_NodeAliasDecodeErrorZ_clone(arg);
14787         return (uint32_t)ret_conv;
14788 }
14789 uint32_t  __attribute__((export_name("TS_CResult_NodeAliasDecodeErrorZ_clone_ptr"))) TS_CResult_NodeAliasDecodeErrorZ_clone_ptr(uint32_t arg) {
14790         LDKCResult_NodeAliasDecodeErrorZ* arg_conv = (LDKCResult_NodeAliasDecodeErrorZ*)(arg & ~1);
14791         uint32_t ret_conv = CResult_NodeAliasDecodeErrorZ_clone_ptr(arg_conv);
14792         return ret_conv;
14793 }
14794
14795 uint32_t  __attribute__((export_name("TS_CResult_NodeAliasDecodeErrorZ_clone"))) TS_CResult_NodeAliasDecodeErrorZ_clone(uint32_t orig) {
14796         LDKCResult_NodeAliasDecodeErrorZ* orig_conv = (LDKCResult_NodeAliasDecodeErrorZ*)(orig & ~1);
14797         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
14798         *ret_conv = CResult_NodeAliasDecodeErrorZ_clone(orig_conv);
14799         return (uint32_t)ret_conv;
14800 }
14801
14802 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_ok"))) TS_CResult_NodeInfoDecodeErrorZ_ok(uint32_t o) {
14803         LDKNodeInfo o_conv;
14804         o_conv.inner = (void*)(o & (~1));
14805         o_conv.is_owned = (o & 1) || (o == 0);
14806         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14807         o_conv = NodeInfo_clone(&o_conv);
14808         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
14809         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
14810         return (uint32_t)ret_conv;
14811 }
14812
14813 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_err"))) TS_CResult_NodeInfoDecodeErrorZ_err(uint32_t e) {
14814         LDKDecodeError e_conv;
14815         e_conv.inner = (void*)(e & (~1));
14816         e_conv.is_owned = (e & 1) || (e == 0);
14817         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14818         e_conv = DecodeError_clone(&e_conv);
14819         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
14820         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
14821         return (uint32_t)ret_conv;
14822 }
14823
14824 jboolean  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_is_ok"))) TS_CResult_NodeInfoDecodeErrorZ_is_ok(uint32_t o) {
14825         LDKCResult_NodeInfoDecodeErrorZ* o_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(o & ~1);
14826         jboolean ret_conv = CResult_NodeInfoDecodeErrorZ_is_ok(o_conv);
14827         return ret_conv;
14828 }
14829
14830 void  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_free"))) TS_CResult_NodeInfoDecodeErrorZ_free(uint32_t _res) {
14831         if ((_res & 1) != 0) return;
14832         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14833         CHECK_ACCESS(_res_ptr);
14834         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(_res_ptr);
14835         FREE((void*)_res);
14836         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
14837 }
14838
14839 static inline uintptr_t CResult_NodeInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR arg) {
14840         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
14841         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(arg);
14842         return (uint32_t)ret_conv;
14843 }
14844 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_clone_ptr"))) TS_CResult_NodeInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
14845         LDKCResult_NodeInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
14846         uint32_t ret_conv = CResult_NodeInfoDecodeErrorZ_clone_ptr(arg_conv);
14847         return ret_conv;
14848 }
14849
14850 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_clone"))) TS_CResult_NodeInfoDecodeErrorZ_clone(uint32_t orig) {
14851         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(orig & ~1);
14852         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
14853         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
14854         return (uint32_t)ret_conv;
14855 }
14856
14857 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_ok"))) TS_CResult_NetworkGraphDecodeErrorZ_ok(uint32_t o) {
14858         LDKNetworkGraph o_conv;
14859         o_conv.inner = (void*)(o & (~1));
14860         o_conv.is_owned = (o & 1) || (o == 0);
14861         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14862         // WARNING: we need a move here but no clone is available for LDKNetworkGraph
14863         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
14864         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
14865         return (uint32_t)ret_conv;
14866 }
14867
14868 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_err"))) TS_CResult_NetworkGraphDecodeErrorZ_err(uint32_t e) {
14869         LDKDecodeError e_conv;
14870         e_conv.inner = (void*)(e & (~1));
14871         e_conv.is_owned = (e & 1) || (e == 0);
14872         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14873         e_conv = DecodeError_clone(&e_conv);
14874         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
14875         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
14876         return (uint32_t)ret_conv;
14877 }
14878
14879 jboolean  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_is_ok"))) TS_CResult_NetworkGraphDecodeErrorZ_is_ok(uint32_t o) {
14880         LDKCResult_NetworkGraphDecodeErrorZ* o_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(o & ~1);
14881         jboolean ret_conv = CResult_NetworkGraphDecodeErrorZ_is_ok(o_conv);
14882         return ret_conv;
14883 }
14884
14885 void  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_free"))) TS_CResult_NetworkGraphDecodeErrorZ_free(uint32_t _res) {
14886         if ((_res & 1) != 0) return;
14887         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14888         CHECK_ACCESS(_res_ptr);
14889         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(_res_ptr);
14890         FREE((void*)_res);
14891         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
14892 }
14893
14894 uint32_t  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_some"))) TS_COption_CVec_NetAddressZZ_some(uint32_tArray o) {
14895         LDKCVec_NetAddressZ o_constr;
14896         o_constr.datalen = o->arr_len;
14897         if (o_constr.datalen > 0)
14898                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
14899         else
14900                 o_constr.data = NULL;
14901         uint32_t* o_vals = o->elems;
14902         for (size_t m = 0; m < o_constr.datalen; m++) {
14903                 uint32_t o_conv_12 = o_vals[m];
14904                 void* o_conv_12_ptr = (void*)(((uintptr_t)o_conv_12) & ~1);
14905                 CHECK_ACCESS(o_conv_12_ptr);
14906                 LDKNetAddress o_conv_12_conv = *(LDKNetAddress*)(o_conv_12_ptr);
14907                 o_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)o_conv_12) & ~1));
14908                 o_constr.data[m] = o_conv_12_conv;
14909         }
14910         FREE(o);
14911         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
14912         *ret_copy = COption_CVec_NetAddressZZ_some(o_constr);
14913         uint32_t ret_ref = (uintptr_t)ret_copy;
14914         return ret_ref;
14915 }
14916
14917 uint32_t  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_none"))) TS_COption_CVec_NetAddressZZ_none() {
14918         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
14919         *ret_copy = COption_CVec_NetAddressZZ_none();
14920         uint32_t ret_ref = (uintptr_t)ret_copy;
14921         return ret_ref;
14922 }
14923
14924 void  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_free"))) TS_COption_CVec_NetAddressZZ_free(uint32_t _res) {
14925         if ((_res & 1) != 0) return;
14926         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14927         CHECK_ACCESS(_res_ptr);
14928         LDKCOption_CVec_NetAddressZZ _res_conv = *(LDKCOption_CVec_NetAddressZZ*)(_res_ptr);
14929         FREE((void*)_res);
14930         COption_CVec_NetAddressZZ_free(_res_conv);
14931 }
14932
14933 static inline uintptr_t COption_CVec_NetAddressZZ_clone_ptr(LDKCOption_CVec_NetAddressZZ *NONNULL_PTR arg) {
14934         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
14935         *ret_copy = COption_CVec_NetAddressZZ_clone(arg);
14936 uint32_t ret_ref = (uintptr_t)ret_copy;
14937         return ret_ref;
14938 }
14939 uint32_t  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_clone_ptr"))) TS_COption_CVec_NetAddressZZ_clone_ptr(uint32_t arg) {
14940         LDKCOption_CVec_NetAddressZZ* arg_conv = (LDKCOption_CVec_NetAddressZZ*)arg;
14941         uint32_t ret_conv = COption_CVec_NetAddressZZ_clone_ptr(arg_conv);
14942         return ret_conv;
14943 }
14944
14945 uint32_t  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_clone"))) TS_COption_CVec_NetAddressZZ_clone(uint32_t orig) {
14946         LDKCOption_CVec_NetAddressZZ* orig_conv = (LDKCOption_CVec_NetAddressZZ*)orig;
14947         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
14948         *ret_copy = COption_CVec_NetAddressZZ_clone(orig_conv);
14949         uint32_t ret_ref = (uintptr_t)ret_copy;
14950         return ret_ref;
14951 }
14952
14953 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
14954         LDKDelayedPaymentOutputDescriptor o_conv;
14955         o_conv.inner = (void*)(o & (~1));
14956         o_conv.is_owned = (o & 1) || (o == 0);
14957         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14958         o_conv = DelayedPaymentOutputDescriptor_clone(&o_conv);
14959         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
14960         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
14961         return (uint32_t)ret_conv;
14962 }
14963
14964 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(uint32_t e) {
14965         LDKDecodeError e_conv;
14966         e_conv.inner = (void*)(e & (~1));
14967         e_conv.is_owned = (e & 1) || (e == 0);
14968         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14969         e_conv = DecodeError_clone(&e_conv);
14970         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
14971         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
14972         return (uint32_t)ret_conv;
14973 }
14974
14975 jboolean  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(uint32_t o) {
14976         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(o & ~1);
14977         jboolean ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
14978         return ret_conv;
14979 }
14980
14981 void  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
14982         if ((_res & 1) != 0) return;
14983         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14984         CHECK_ACCESS(_res_ptr);
14985         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
14986         FREE((void*)_res);
14987         CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
14988 }
14989
14990 static inline uintptr_t CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
14991         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
14992         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(arg);
14993         return (uint32_t)ret_conv;
14994 }
14995 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(uint32_t arg) {
14996         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
14997         uint32_t ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
14998         return ret_conv;
14999 }
15000
15001 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
15002         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
15003         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
15004         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
15005         return (uint32_t)ret_conv;
15006 }
15007
15008 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
15009         LDKStaticPaymentOutputDescriptor o_conv;
15010         o_conv.inner = (void*)(o & (~1));
15011         o_conv.is_owned = (o & 1) || (o == 0);
15012         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15013         o_conv = StaticPaymentOutputDescriptor_clone(&o_conv);
15014         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
15015         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
15016         return (uint32_t)ret_conv;
15017 }
15018
15019 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(uint32_t e) {
15020         LDKDecodeError e_conv;
15021         e_conv.inner = (void*)(e & (~1));
15022         e_conv.is_owned = (e & 1) || (e == 0);
15023         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15024         e_conv = DecodeError_clone(&e_conv);
15025         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
15026         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
15027         return (uint32_t)ret_conv;
15028 }
15029
15030 jboolean  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok(uint32_t o) {
15031         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(o & ~1);
15032         jboolean ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
15033         return ret_conv;
15034 }
15035
15036 void  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
15037         if ((_res & 1) != 0) return;
15038         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15039         CHECK_ACCESS(_res_ptr);
15040         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
15041         FREE((void*)_res);
15042         CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
15043 }
15044
15045 static inline uintptr_t CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
15046         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
15047         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(arg);
15048         return (uint32_t)ret_conv;
15049 }
15050 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(uint32_t arg) {
15051         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
15052         uint32_t ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
15053         return ret_conv;
15054 }
15055
15056 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
15057         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
15058         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
15059         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
15060         return (uint32_t)ret_conv;
15061 }
15062
15063 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_ok"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
15064         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15065         CHECK_ACCESS(o_ptr);
15066         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(o_ptr);
15067         o_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)o) & ~1));
15068         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
15069         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
15070         return (uint32_t)ret_conv;
15071 }
15072
15073 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_err"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_err(uint32_t e) {
15074         LDKDecodeError e_conv;
15075         e_conv.inner = (void*)(e & (~1));
15076         e_conv.is_owned = (e & 1) || (e == 0);
15077         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15078         e_conv = DecodeError_clone(&e_conv);
15079         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
15080         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
15081         return (uint32_t)ret_conv;
15082 }
15083
15084 jboolean  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok(uint32_t o) {
15085         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(o & ~1);
15086         jboolean ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok(o_conv);
15087         return ret_conv;
15088 }
15089
15090 void  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_free"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
15091         if ((_res & 1) != 0) return;
15092         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15093         CHECK_ACCESS(_res_ptr);
15094         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(_res_ptr);
15095         FREE((void*)_res);
15096         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
15097 }
15098
15099 static inline uintptr_t CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
15100         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
15101         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(arg);
15102         return (uint32_t)ret_conv;
15103 }
15104 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(uint32_t arg) {
15105         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
15106         uint32_t ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
15107         return ret_conv;
15108 }
15109
15110 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
15111         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(orig & ~1);
15112         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
15113         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
15114         return (uint32_t)ret_conv;
15115 }
15116
15117 void  __attribute__((export_name("TS_CVec_PaymentPreimageZ_free"))) TS_CVec_PaymentPreimageZ_free(ptrArray _res) {
15118         LDKCVec_PaymentPreimageZ _res_constr;
15119         _res_constr.datalen = _res->arr_len;
15120         if (_res_constr.datalen > 0)
15121                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
15122         else
15123                 _res_constr.data = NULL;
15124         int8_tArray* _res_vals = (void*) _res->elems;
15125         for (size_t m = 0; m < _res_constr.datalen; m++) {
15126                 int8_tArray _res_conv_12 = _res_vals[m];
15127                 LDKThirtyTwoBytes _res_conv_12_ref;
15128                 CHECK(_res_conv_12->arr_len == 32);
15129                 memcpy(_res_conv_12_ref.data, _res_conv_12->elems, 32); FREE(_res_conv_12);
15130                 _res_constr.data[m] = _res_conv_12_ref;
15131         }
15132         FREE(_res);
15133         CVec_PaymentPreimageZ_free(_res_constr);
15134 }
15135
15136 static inline uintptr_t C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR arg) {
15137         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
15138         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(arg);
15139         return ((uint32_t)ret_conv);
15140 }
15141 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_clone_ptr"))) TS_C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(uint32_t arg) {
15142         LDKC2Tuple_SignatureCVec_SignatureZZ* arg_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(arg & ~1);
15143         uint32_t ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(arg_conv);
15144         return ret_conv;
15145 }
15146
15147 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_clone"))) TS_C2Tuple_SignatureCVec_SignatureZZ_clone(uint32_t orig) {
15148         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(orig & ~1);
15149         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
15150         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
15151         return ((uint32_t)ret_conv);
15152 }
15153
15154 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_new"))) TS_C2Tuple_SignatureCVec_SignatureZZ_new(int8_tArray a, ptrArray b) {
15155         LDKSignature a_ref;
15156         CHECK(a->arr_len == 64);
15157         memcpy(a_ref.compact_form, a->elems, 64); FREE(a);
15158         LDKCVec_SignatureZ b_constr;
15159         b_constr.datalen = b->arr_len;
15160         if (b_constr.datalen > 0)
15161                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
15162         else
15163                 b_constr.data = NULL;
15164         int8_tArray* b_vals = (void*) b->elems;
15165         for (size_t m = 0; m < b_constr.datalen; m++) {
15166                 int8_tArray b_conv_12 = b_vals[m];
15167                 LDKSignature b_conv_12_ref;
15168                 CHECK(b_conv_12->arr_len == 64);
15169                 memcpy(b_conv_12_ref.compact_form, b_conv_12->elems, 64); FREE(b_conv_12);
15170                 b_constr.data[m] = b_conv_12_ref;
15171         }
15172         FREE(b);
15173         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
15174         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
15175         return ((uint32_t)ret_conv);
15176 }
15177
15178 void  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_free"))) TS_C2Tuple_SignatureCVec_SignatureZZ_free(uint32_t _res) {
15179         if ((_res & 1) != 0) return;
15180         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15181         CHECK_ACCESS(_res_ptr);
15182         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(_res_ptr);
15183         FREE((void*)_res);
15184         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
15185 }
15186
15187 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(uint32_t o) {
15188         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15189         CHECK_ACCESS(o_ptr);
15190         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(o_ptr);
15191         o_conv = C2Tuple_SignatureCVec_SignatureZZ_clone((LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uintptr_t)o) & ~1));
15192         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
15193         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
15194         return (uint32_t)ret_conv;
15195 }
15196
15197 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err() {
15198         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
15199         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
15200         return (uint32_t)ret_conv;
15201 }
15202
15203 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok(uint32_t o) {
15204         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* o_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(o & ~1);
15205         jboolean ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok(o_conv);
15206         return ret_conv;
15207 }
15208
15209 void  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(uint32_t _res) {
15210         if ((_res & 1) != 0) return;
15211         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15212         CHECK_ACCESS(_res_ptr);
15213         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(_res_ptr);
15214         FREE((void*)_res);
15215         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
15216 }
15217
15218 static inline uintptr_t CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR arg) {
15219         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
15220         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(arg);
15221         return (uint32_t)ret_conv;
15222 }
15223 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(uint32_t arg) {
15224         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* arg_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
15225         uint32_t ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(arg_conv);
15226         return ret_conv;
15227 }
15228
15229 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(uint32_t orig) {
15230         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(orig & ~1);
15231         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
15232         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
15233         return (uint32_t)ret_conv;
15234 }
15235
15236 uint32_t  __attribute__((export_name("TS_CResult_SignatureNoneZ_ok"))) TS_CResult_SignatureNoneZ_ok(int8_tArray o) {
15237         LDKSignature o_ref;
15238         CHECK(o->arr_len == 64);
15239         memcpy(o_ref.compact_form, o->elems, 64); FREE(o);
15240         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
15241         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
15242         return (uint32_t)ret_conv;
15243 }
15244
15245 uint32_t  __attribute__((export_name("TS_CResult_SignatureNoneZ_err"))) TS_CResult_SignatureNoneZ_err() {
15246         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
15247         *ret_conv = CResult_SignatureNoneZ_err();
15248         return (uint32_t)ret_conv;
15249 }
15250
15251 jboolean  __attribute__((export_name("TS_CResult_SignatureNoneZ_is_ok"))) TS_CResult_SignatureNoneZ_is_ok(uint32_t o) {
15252         LDKCResult_SignatureNoneZ* o_conv = (LDKCResult_SignatureNoneZ*)(o & ~1);
15253         jboolean ret_conv = CResult_SignatureNoneZ_is_ok(o_conv);
15254         return ret_conv;
15255 }
15256
15257 void  __attribute__((export_name("TS_CResult_SignatureNoneZ_free"))) TS_CResult_SignatureNoneZ_free(uint32_t _res) {
15258         if ((_res & 1) != 0) return;
15259         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15260         CHECK_ACCESS(_res_ptr);
15261         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(_res_ptr);
15262         FREE((void*)_res);
15263         CResult_SignatureNoneZ_free(_res_conv);
15264 }
15265
15266 static inline uintptr_t CResult_SignatureNoneZ_clone_ptr(LDKCResult_SignatureNoneZ *NONNULL_PTR arg) {
15267         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
15268         *ret_conv = CResult_SignatureNoneZ_clone(arg);
15269         return (uint32_t)ret_conv;
15270 }
15271 uint32_t  __attribute__((export_name("TS_CResult_SignatureNoneZ_clone_ptr"))) TS_CResult_SignatureNoneZ_clone_ptr(uint32_t arg) {
15272         LDKCResult_SignatureNoneZ* arg_conv = (LDKCResult_SignatureNoneZ*)(arg & ~1);
15273         uint32_t ret_conv = CResult_SignatureNoneZ_clone_ptr(arg_conv);
15274         return ret_conv;
15275 }
15276
15277 uint32_t  __attribute__((export_name("TS_CResult_SignatureNoneZ_clone"))) TS_CResult_SignatureNoneZ_clone(uint32_t orig) {
15278         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)(orig & ~1);
15279         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
15280         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
15281         return (uint32_t)ret_conv;
15282 }
15283
15284 static inline uintptr_t C2Tuple_SignatureSignatureZ_clone_ptr(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR arg) {
15285         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
15286         *ret_conv = C2Tuple_SignatureSignatureZ_clone(arg);
15287         return ((uint32_t)ret_conv);
15288 }
15289 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_clone_ptr"))) TS_C2Tuple_SignatureSignatureZ_clone_ptr(uint32_t arg) {
15290         LDKC2Tuple_SignatureSignatureZ* arg_conv = (LDKC2Tuple_SignatureSignatureZ*)(arg & ~1);
15291         uint32_t ret_conv = C2Tuple_SignatureSignatureZ_clone_ptr(arg_conv);
15292         return ret_conv;
15293 }
15294
15295 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_clone"))) TS_C2Tuple_SignatureSignatureZ_clone(uint32_t orig) {
15296         LDKC2Tuple_SignatureSignatureZ* orig_conv = (LDKC2Tuple_SignatureSignatureZ*)(orig & ~1);
15297         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
15298         *ret_conv = C2Tuple_SignatureSignatureZ_clone(orig_conv);
15299         return ((uint32_t)ret_conv);
15300 }
15301
15302 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_new"))) TS_C2Tuple_SignatureSignatureZ_new(int8_tArray a, int8_tArray b) {
15303         LDKSignature a_ref;
15304         CHECK(a->arr_len == 64);
15305         memcpy(a_ref.compact_form, a->elems, 64); FREE(a);
15306         LDKSignature b_ref;
15307         CHECK(b->arr_len == 64);
15308         memcpy(b_ref.compact_form, b->elems, 64); FREE(b);
15309         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
15310         *ret_conv = C2Tuple_SignatureSignatureZ_new(a_ref, b_ref);
15311         return ((uint32_t)ret_conv);
15312 }
15313
15314 void  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_free"))) TS_C2Tuple_SignatureSignatureZ_free(uint32_t _res) {
15315         if ((_res & 1) != 0) return;
15316         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15317         CHECK_ACCESS(_res_ptr);
15318         LDKC2Tuple_SignatureSignatureZ _res_conv = *(LDKC2Tuple_SignatureSignatureZ*)(_res_ptr);
15319         FREE((void*)_res);
15320         C2Tuple_SignatureSignatureZ_free(_res_conv);
15321 }
15322
15323 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_ok"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_ok(uint32_t o) {
15324         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15325         CHECK_ACCESS(o_ptr);
15326         LDKC2Tuple_SignatureSignatureZ o_conv = *(LDKC2Tuple_SignatureSignatureZ*)(o_ptr);
15327         o_conv = C2Tuple_SignatureSignatureZ_clone((LDKC2Tuple_SignatureSignatureZ*)(((uintptr_t)o) & ~1));
15328         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
15329         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_ok(o_conv);
15330         return (uint32_t)ret_conv;
15331 }
15332
15333 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_err"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_err() {
15334         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
15335         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_err();
15336         return (uint32_t)ret_conv;
15337 }
15338
15339 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_is_ok"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_is_ok(uint32_t o) {
15340         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* o_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(o & ~1);
15341         jboolean ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_is_ok(o_conv);
15342         return ret_conv;
15343 }
15344
15345 void  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_free"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_free(uint32_t _res) {
15346         if ((_res & 1) != 0) return;
15347         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15348         CHECK_ACCESS(_res_ptr);
15349         LDKCResult_C2Tuple_SignatureSignatureZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(_res_ptr);
15350         FREE((void*)_res);
15351         CResult_C2Tuple_SignatureSignatureZNoneZ_free(_res_conv);
15352 }
15353
15354 static inline uintptr_t CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR arg) {
15355         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
15356         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone(arg);
15357         return (uint32_t)ret_conv;
15358 }
15359 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr(uint32_t arg) {
15360         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* arg_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(arg & ~1);
15361         uint32_t ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr(arg_conv);
15362         return ret_conv;
15363 }
15364
15365 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_clone"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_clone(uint32_t orig) {
15366         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(orig & ~1);
15367         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
15368         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone(orig_conv);
15369         return (uint32_t)ret_conv;
15370 }
15371
15372 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_ok"))) TS_CResult_SecretKeyNoneZ_ok(int8_tArray o) {
15373         LDKSecretKey o_ref;
15374         CHECK(o->arr_len == 32);
15375         memcpy(o_ref.bytes, o->elems, 32); FREE(o);
15376         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
15377         *ret_conv = CResult_SecretKeyNoneZ_ok(o_ref);
15378         return (uint32_t)ret_conv;
15379 }
15380
15381 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_err"))) TS_CResult_SecretKeyNoneZ_err() {
15382         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
15383         *ret_conv = CResult_SecretKeyNoneZ_err();
15384         return (uint32_t)ret_conv;
15385 }
15386
15387 jboolean  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_is_ok"))) TS_CResult_SecretKeyNoneZ_is_ok(uint32_t o) {
15388         LDKCResult_SecretKeyNoneZ* o_conv = (LDKCResult_SecretKeyNoneZ*)(o & ~1);
15389         jboolean ret_conv = CResult_SecretKeyNoneZ_is_ok(o_conv);
15390         return ret_conv;
15391 }
15392
15393 void  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_free"))) TS_CResult_SecretKeyNoneZ_free(uint32_t _res) {
15394         if ((_res & 1) != 0) return;
15395         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15396         CHECK_ACCESS(_res_ptr);
15397         LDKCResult_SecretKeyNoneZ _res_conv = *(LDKCResult_SecretKeyNoneZ*)(_res_ptr);
15398         FREE((void*)_res);
15399         CResult_SecretKeyNoneZ_free(_res_conv);
15400 }
15401
15402 static inline uintptr_t CResult_SecretKeyNoneZ_clone_ptr(LDKCResult_SecretKeyNoneZ *NONNULL_PTR arg) {
15403         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
15404         *ret_conv = CResult_SecretKeyNoneZ_clone(arg);
15405         return (uint32_t)ret_conv;
15406 }
15407 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_clone_ptr"))) TS_CResult_SecretKeyNoneZ_clone_ptr(uint32_t arg) {
15408         LDKCResult_SecretKeyNoneZ* arg_conv = (LDKCResult_SecretKeyNoneZ*)(arg & ~1);
15409         uint32_t ret_conv = CResult_SecretKeyNoneZ_clone_ptr(arg_conv);
15410         return ret_conv;
15411 }
15412
15413 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_clone"))) TS_CResult_SecretKeyNoneZ_clone(uint32_t orig) {
15414         LDKCResult_SecretKeyNoneZ* orig_conv = (LDKCResult_SecretKeyNoneZ*)(orig & ~1);
15415         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
15416         *ret_conv = CResult_SecretKeyNoneZ_clone(orig_conv);
15417         return (uint32_t)ret_conv;
15418 }
15419
15420 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_ok"))) TS_CResult_SignDecodeErrorZ_ok(uint32_t o) {
15421         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15422         CHECK_ACCESS(o_ptr);
15423         LDKSign o_conv = *(LDKSign*)(o_ptr);
15424         if (o_conv.free == LDKSign_JCalls_free) {
15425                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15426                 LDKSign_JCalls_cloned(&o_conv);
15427         }
15428         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
15429         *ret_conv = CResult_SignDecodeErrorZ_ok(o_conv);
15430         return (uint32_t)ret_conv;
15431 }
15432
15433 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_err"))) TS_CResult_SignDecodeErrorZ_err(uint32_t e) {
15434         LDKDecodeError e_conv;
15435         e_conv.inner = (void*)(e & (~1));
15436         e_conv.is_owned = (e & 1) || (e == 0);
15437         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15438         e_conv = DecodeError_clone(&e_conv);
15439         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
15440         *ret_conv = CResult_SignDecodeErrorZ_err(e_conv);
15441         return (uint32_t)ret_conv;
15442 }
15443
15444 jboolean  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_is_ok"))) TS_CResult_SignDecodeErrorZ_is_ok(uint32_t o) {
15445         LDKCResult_SignDecodeErrorZ* o_conv = (LDKCResult_SignDecodeErrorZ*)(o & ~1);
15446         jboolean ret_conv = CResult_SignDecodeErrorZ_is_ok(o_conv);
15447         return ret_conv;
15448 }
15449
15450 void  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_free"))) TS_CResult_SignDecodeErrorZ_free(uint32_t _res) {
15451         if ((_res & 1) != 0) return;
15452         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15453         CHECK_ACCESS(_res_ptr);
15454         LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(_res_ptr);
15455         FREE((void*)_res);
15456         CResult_SignDecodeErrorZ_free(_res_conv);
15457 }
15458
15459 static inline uintptr_t CResult_SignDecodeErrorZ_clone_ptr(LDKCResult_SignDecodeErrorZ *NONNULL_PTR arg) {
15460         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
15461         *ret_conv = CResult_SignDecodeErrorZ_clone(arg);
15462         return (uint32_t)ret_conv;
15463 }
15464 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_clone_ptr"))) TS_CResult_SignDecodeErrorZ_clone_ptr(uint32_t arg) {
15465         LDKCResult_SignDecodeErrorZ* arg_conv = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
15466         uint32_t ret_conv = CResult_SignDecodeErrorZ_clone_ptr(arg_conv);
15467         return ret_conv;
15468 }
15469
15470 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_clone"))) TS_CResult_SignDecodeErrorZ_clone(uint32_t orig) {
15471         LDKCResult_SignDecodeErrorZ* orig_conv = (LDKCResult_SignDecodeErrorZ*)(orig & ~1);
15472         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
15473         *ret_conv = CResult_SignDecodeErrorZ_clone(orig_conv);
15474         return (uint32_t)ret_conv;
15475 }
15476
15477 void  __attribute__((export_name("TS_CVec_u5Z_free"))) TS_CVec_u5Z_free(ptrArray _res) {
15478         LDKCVec_u5Z _res_constr;
15479         _res_constr.datalen = _res->arr_len;
15480         if (_res_constr.datalen > 0)
15481                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
15482         else
15483                 _res_constr.data = NULL;
15484         int8_t* _res_vals = (void*) _res->elems;
15485         for (size_t h = 0; h < _res_constr.datalen; h++) {
15486                 int8_t _res_conv_7 = _res_vals[h];
15487                 
15488                 _res_constr.data[h] = (LDKu5){ ._0 = _res_conv_7 };
15489         }
15490         FREE(_res);
15491         CVec_u5Z_free(_res_constr);
15492 }
15493
15494 uint32_t  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_ok"))) TS_CResult_RecoverableSignatureNoneZ_ok(int8_tArray o) {
15495         LDKRecoverableSignature o_ref;
15496         CHECK(o->arr_len == 68);
15497         memcpy(o_ref.serialized_form, o->elems, 68); FREE(o);
15498         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
15499         *ret_conv = CResult_RecoverableSignatureNoneZ_ok(o_ref);
15500         return (uint32_t)ret_conv;
15501 }
15502
15503 uint32_t  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_err"))) TS_CResult_RecoverableSignatureNoneZ_err() {
15504         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
15505         *ret_conv = CResult_RecoverableSignatureNoneZ_err();
15506         return (uint32_t)ret_conv;
15507 }
15508
15509 jboolean  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_is_ok"))) TS_CResult_RecoverableSignatureNoneZ_is_ok(uint32_t o) {
15510         LDKCResult_RecoverableSignatureNoneZ* o_conv = (LDKCResult_RecoverableSignatureNoneZ*)(o & ~1);
15511         jboolean ret_conv = CResult_RecoverableSignatureNoneZ_is_ok(o_conv);
15512         return ret_conv;
15513 }
15514
15515 void  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_free"))) TS_CResult_RecoverableSignatureNoneZ_free(uint32_t _res) {
15516         if ((_res & 1) != 0) return;
15517         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15518         CHECK_ACCESS(_res_ptr);
15519         LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(_res_ptr);
15520         FREE((void*)_res);
15521         CResult_RecoverableSignatureNoneZ_free(_res_conv);
15522 }
15523
15524 static inline uintptr_t CResult_RecoverableSignatureNoneZ_clone_ptr(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR arg) {
15525         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
15526         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(arg);
15527         return (uint32_t)ret_conv;
15528 }
15529 uint32_t  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_clone_ptr"))) TS_CResult_RecoverableSignatureNoneZ_clone_ptr(uint32_t arg) {
15530         LDKCResult_RecoverableSignatureNoneZ* arg_conv = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
15531         uint32_t ret_conv = CResult_RecoverableSignatureNoneZ_clone_ptr(arg_conv);
15532         return ret_conv;
15533 }
15534
15535 uint32_t  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_clone"))) TS_CResult_RecoverableSignatureNoneZ_clone(uint32_t orig) {
15536         LDKCResult_RecoverableSignatureNoneZ* orig_conv = (LDKCResult_RecoverableSignatureNoneZ*)(orig & ~1);
15537         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
15538         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(orig_conv);
15539         return (uint32_t)ret_conv;
15540 }
15541
15542 void  __attribute__((export_name("TS_CVec_u8Z_free"))) TS_CVec_u8Z_free(int8_tArray _res) {
15543         LDKCVec_u8Z _res_ref;
15544         _res_ref.datalen = _res->arr_len;
15545         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
15546         memcpy(_res_ref.data, _res->elems, _res_ref.datalen); FREE(_res);
15547         CVec_u8Z_free(_res_ref);
15548 }
15549
15550 void  __attribute__((export_name("TS_CVec_CVec_u8ZZ_free"))) TS_CVec_CVec_u8ZZ_free(ptrArray _res) {
15551         LDKCVec_CVec_u8ZZ _res_constr;
15552         _res_constr.datalen = _res->arr_len;
15553         if (_res_constr.datalen > 0)
15554                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
15555         else
15556                 _res_constr.data = NULL;
15557         int8_tArray* _res_vals = (void*) _res->elems;
15558         for (size_t m = 0; m < _res_constr.datalen; m++) {
15559                 int8_tArray _res_conv_12 = _res_vals[m];
15560                 LDKCVec_u8Z _res_conv_12_ref;
15561                 _res_conv_12_ref.datalen = _res_conv_12->arr_len;
15562                 _res_conv_12_ref.data = MALLOC(_res_conv_12_ref.datalen, "LDKCVec_u8Z Bytes");
15563                 memcpy(_res_conv_12_ref.data, _res_conv_12->elems, _res_conv_12_ref.datalen); FREE(_res_conv_12);
15564                 _res_constr.data[m] = _res_conv_12_ref;
15565         }
15566         FREE(_res);
15567         CVec_CVec_u8ZZ_free(_res_constr);
15568 }
15569
15570 uint32_t  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_ok"))) TS_CResult_CVec_CVec_u8ZZNoneZ_ok(ptrArray o) {
15571         LDKCVec_CVec_u8ZZ o_constr;
15572         o_constr.datalen = o->arr_len;
15573         if (o_constr.datalen > 0)
15574                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
15575         else
15576                 o_constr.data = NULL;
15577         int8_tArray* o_vals = (void*) o->elems;
15578         for (size_t m = 0; m < o_constr.datalen; m++) {
15579                 int8_tArray o_conv_12 = o_vals[m];
15580                 LDKCVec_u8Z o_conv_12_ref;
15581                 o_conv_12_ref.datalen = o_conv_12->arr_len;
15582                 o_conv_12_ref.data = MALLOC(o_conv_12_ref.datalen, "LDKCVec_u8Z Bytes");
15583                 memcpy(o_conv_12_ref.data, o_conv_12->elems, o_conv_12_ref.datalen); FREE(o_conv_12);
15584                 o_constr.data[m] = o_conv_12_ref;
15585         }
15586         FREE(o);
15587         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
15588         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
15589         return (uint32_t)ret_conv;
15590 }
15591
15592 uint32_t  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_err"))) TS_CResult_CVec_CVec_u8ZZNoneZ_err() {
15593         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
15594         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
15595         return (uint32_t)ret_conv;
15596 }
15597
15598 jboolean  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_is_ok"))) TS_CResult_CVec_CVec_u8ZZNoneZ_is_ok(uint32_t o) {
15599         LDKCResult_CVec_CVec_u8ZZNoneZ* o_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(o & ~1);
15600         jboolean ret_conv = CResult_CVec_CVec_u8ZZNoneZ_is_ok(o_conv);
15601         return ret_conv;
15602 }
15603
15604 void  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_free"))) TS_CResult_CVec_CVec_u8ZZNoneZ_free(uint32_t _res) {
15605         if ((_res & 1) != 0) return;
15606         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15607         CHECK_ACCESS(_res_ptr);
15608         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(_res_ptr);
15609         FREE((void*)_res);
15610         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
15611 }
15612
15613 static inline uintptr_t CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR arg) {
15614         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
15615         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(arg);
15616         return (uint32_t)ret_conv;
15617 }
15618 uint32_t  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_clone_ptr"))) TS_CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(uint32_t arg) {
15619         LDKCResult_CVec_CVec_u8ZZNoneZ* arg_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
15620         uint32_t ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(arg_conv);
15621         return ret_conv;
15622 }
15623
15624 uint32_t  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_clone"))) TS_CResult_CVec_CVec_u8ZZNoneZ_clone(uint32_t orig) {
15625         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(orig & ~1);
15626         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
15627         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
15628         return (uint32_t)ret_conv;
15629 }
15630
15631 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_ok"))) TS_CResult_InMemorySignerDecodeErrorZ_ok(uint32_t o) {
15632         LDKInMemorySigner o_conv;
15633         o_conv.inner = (void*)(o & (~1));
15634         o_conv.is_owned = (o & 1) || (o == 0);
15635         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15636         o_conv = InMemorySigner_clone(&o_conv);
15637         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
15638         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
15639         return (uint32_t)ret_conv;
15640 }
15641
15642 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_err"))) TS_CResult_InMemorySignerDecodeErrorZ_err(uint32_t e) {
15643         LDKDecodeError e_conv;
15644         e_conv.inner = (void*)(e & (~1));
15645         e_conv.is_owned = (e & 1) || (e == 0);
15646         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15647         e_conv = DecodeError_clone(&e_conv);
15648         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
15649         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
15650         return (uint32_t)ret_conv;
15651 }
15652
15653 jboolean  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_is_ok"))) TS_CResult_InMemorySignerDecodeErrorZ_is_ok(uint32_t o) {
15654         LDKCResult_InMemorySignerDecodeErrorZ* o_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(o & ~1);
15655         jboolean ret_conv = CResult_InMemorySignerDecodeErrorZ_is_ok(o_conv);
15656         return ret_conv;
15657 }
15658
15659 void  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_free"))) TS_CResult_InMemorySignerDecodeErrorZ_free(uint32_t _res) {
15660         if ((_res & 1) != 0) return;
15661         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15662         CHECK_ACCESS(_res_ptr);
15663         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(_res_ptr);
15664         FREE((void*)_res);
15665         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
15666 }
15667
15668 static inline uintptr_t CResult_InMemorySignerDecodeErrorZ_clone_ptr(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR arg) {
15669         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
15670         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(arg);
15671         return (uint32_t)ret_conv;
15672 }
15673 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_clone_ptr"))) TS_CResult_InMemorySignerDecodeErrorZ_clone_ptr(uint32_t arg) {
15674         LDKCResult_InMemorySignerDecodeErrorZ* arg_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
15675         uint32_t ret_conv = CResult_InMemorySignerDecodeErrorZ_clone_ptr(arg_conv);
15676         return ret_conv;
15677 }
15678
15679 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_clone"))) TS_CResult_InMemorySignerDecodeErrorZ_clone(uint32_t orig) {
15680         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(orig & ~1);
15681         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
15682         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
15683         return (uint32_t)ret_conv;
15684 }
15685
15686 void  __attribute__((export_name("TS_CVec_TxOutZ_free"))) TS_CVec_TxOutZ_free(uint32_tArray _res) {
15687         LDKCVec_TxOutZ _res_constr;
15688         _res_constr.datalen = _res->arr_len;
15689         if (_res_constr.datalen > 0)
15690                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
15691         else
15692                 _res_constr.data = NULL;
15693         uint32_t* _res_vals = _res->elems;
15694         for (size_t h = 0; h < _res_constr.datalen; h++) {
15695                 uint32_t _res_conv_7 = _res_vals[h];
15696                 void* _res_conv_7_ptr = (void*)(((uintptr_t)_res_conv_7) & ~1);
15697                 CHECK_ACCESS(_res_conv_7_ptr);
15698                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(_res_conv_7_ptr);
15699                 FREE((void*)_res_conv_7);
15700                 _res_constr.data[h] = _res_conv_7_conv;
15701         }
15702         FREE(_res);
15703         CVec_TxOutZ_free(_res_constr);
15704 }
15705
15706 uint32_t  __attribute__((export_name("TS_CResult_TransactionNoneZ_ok"))) TS_CResult_TransactionNoneZ_ok(int8_tArray o) {
15707         LDKTransaction o_ref;
15708         o_ref.datalen = o->arr_len;
15709         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
15710         memcpy(o_ref.data, o->elems, o_ref.datalen); FREE(o);
15711         o_ref.data_is_owned = true;
15712         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
15713         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
15714         return (uint32_t)ret_conv;
15715 }
15716
15717 uint32_t  __attribute__((export_name("TS_CResult_TransactionNoneZ_err"))) TS_CResult_TransactionNoneZ_err() {
15718         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
15719         *ret_conv = CResult_TransactionNoneZ_err();
15720         return (uint32_t)ret_conv;
15721 }
15722
15723 jboolean  __attribute__((export_name("TS_CResult_TransactionNoneZ_is_ok"))) TS_CResult_TransactionNoneZ_is_ok(uint32_t o) {
15724         LDKCResult_TransactionNoneZ* o_conv = (LDKCResult_TransactionNoneZ*)(o & ~1);
15725         jboolean ret_conv = CResult_TransactionNoneZ_is_ok(o_conv);
15726         return ret_conv;
15727 }
15728
15729 void  __attribute__((export_name("TS_CResult_TransactionNoneZ_free"))) TS_CResult_TransactionNoneZ_free(uint32_t _res) {
15730         if ((_res & 1) != 0) return;
15731         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15732         CHECK_ACCESS(_res_ptr);
15733         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(_res_ptr);
15734         FREE((void*)_res);
15735         CResult_TransactionNoneZ_free(_res_conv);
15736 }
15737
15738 static inline uintptr_t CResult_TransactionNoneZ_clone_ptr(LDKCResult_TransactionNoneZ *NONNULL_PTR arg) {
15739         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
15740         *ret_conv = CResult_TransactionNoneZ_clone(arg);
15741         return (uint32_t)ret_conv;
15742 }
15743 uint32_t  __attribute__((export_name("TS_CResult_TransactionNoneZ_clone_ptr"))) TS_CResult_TransactionNoneZ_clone_ptr(uint32_t arg) {
15744         LDKCResult_TransactionNoneZ* arg_conv = (LDKCResult_TransactionNoneZ*)(arg & ~1);
15745         uint32_t ret_conv = CResult_TransactionNoneZ_clone_ptr(arg_conv);
15746         return ret_conv;
15747 }
15748
15749 uint32_t  __attribute__((export_name("TS_CResult_TransactionNoneZ_clone"))) TS_CResult_TransactionNoneZ_clone(uint32_t orig) {
15750         LDKCResult_TransactionNoneZ* orig_conv = (LDKCResult_TransactionNoneZ*)(orig & ~1);
15751         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
15752         *ret_conv = CResult_TransactionNoneZ_clone(orig_conv);
15753         return (uint32_t)ret_conv;
15754 }
15755
15756 uint32_t  __attribute__((export_name("TS_COption_u16Z_some"))) TS_COption_u16Z_some(int16_t o) {
15757         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
15758         *ret_copy = COption_u16Z_some(o);
15759         uint32_t ret_ref = (uintptr_t)ret_copy;
15760         return ret_ref;
15761 }
15762
15763 uint32_t  __attribute__((export_name("TS_COption_u16Z_none"))) TS_COption_u16Z_none() {
15764         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
15765         *ret_copy = COption_u16Z_none();
15766         uint32_t ret_ref = (uintptr_t)ret_copy;
15767         return ret_ref;
15768 }
15769
15770 void  __attribute__((export_name("TS_COption_u16Z_free"))) TS_COption_u16Z_free(uint32_t _res) {
15771         if ((_res & 1) != 0) return;
15772         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15773         CHECK_ACCESS(_res_ptr);
15774         LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(_res_ptr);
15775         FREE((void*)_res);
15776         COption_u16Z_free(_res_conv);
15777 }
15778
15779 static inline uintptr_t COption_u16Z_clone_ptr(LDKCOption_u16Z *NONNULL_PTR arg) {
15780         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
15781         *ret_copy = COption_u16Z_clone(arg);
15782 uint32_t ret_ref = (uintptr_t)ret_copy;
15783         return ret_ref;
15784 }
15785 uint32_t  __attribute__((export_name("TS_COption_u16Z_clone_ptr"))) TS_COption_u16Z_clone_ptr(uint32_t arg) {
15786         LDKCOption_u16Z* arg_conv = (LDKCOption_u16Z*)arg;
15787         uint32_t ret_conv = COption_u16Z_clone_ptr(arg_conv);
15788         return ret_conv;
15789 }
15790
15791 uint32_t  __attribute__((export_name("TS_COption_u16Z_clone"))) TS_COption_u16Z_clone(uint32_t orig) {
15792         LDKCOption_u16Z* orig_conv = (LDKCOption_u16Z*)orig;
15793         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
15794         *ret_copy = COption_u16Z_clone(orig_conv);
15795         uint32_t ret_ref = (uintptr_t)ret_copy;
15796         return ret_ref;
15797 }
15798
15799 uint32_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_ok"))) TS_CResult_NoneAPIErrorZ_ok() {
15800         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
15801         *ret_conv = CResult_NoneAPIErrorZ_ok();
15802         return (uint32_t)ret_conv;
15803 }
15804
15805 uint32_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_err"))) TS_CResult_NoneAPIErrorZ_err(uint32_t e) {
15806         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
15807         CHECK_ACCESS(e_ptr);
15808         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
15809         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
15810         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
15811         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
15812         return (uint32_t)ret_conv;
15813 }
15814
15815 jboolean  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_is_ok"))) TS_CResult_NoneAPIErrorZ_is_ok(uint32_t o) {
15816         LDKCResult_NoneAPIErrorZ* o_conv = (LDKCResult_NoneAPIErrorZ*)(o & ~1);
15817         jboolean ret_conv = CResult_NoneAPIErrorZ_is_ok(o_conv);
15818         return ret_conv;
15819 }
15820
15821 void  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_free"))) TS_CResult_NoneAPIErrorZ_free(uint32_t _res) {
15822         if ((_res & 1) != 0) return;
15823         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15824         CHECK_ACCESS(_res_ptr);
15825         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_ptr);
15826         FREE((void*)_res);
15827         CResult_NoneAPIErrorZ_free(_res_conv);
15828 }
15829
15830 static inline uintptr_t CResult_NoneAPIErrorZ_clone_ptr(LDKCResult_NoneAPIErrorZ *NONNULL_PTR arg) {
15831         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
15832         *ret_conv = CResult_NoneAPIErrorZ_clone(arg);
15833         return (uint32_t)ret_conv;
15834 }
15835 uint32_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_clone_ptr"))) TS_CResult_NoneAPIErrorZ_clone_ptr(uint32_t arg) {
15836         LDKCResult_NoneAPIErrorZ* arg_conv = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
15837         uint32_t ret_conv = CResult_NoneAPIErrorZ_clone_ptr(arg_conv);
15838         return ret_conv;
15839 }
15840
15841 uint32_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_clone"))) TS_CResult_NoneAPIErrorZ_clone(uint32_t orig) {
15842         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)(orig & ~1);
15843         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
15844         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
15845         return (uint32_t)ret_conv;
15846 }
15847
15848 void  __attribute__((export_name("TS_CVec_CResult_NoneAPIErrorZZ_free"))) TS_CVec_CResult_NoneAPIErrorZZ_free(uint32_tArray _res) {
15849         LDKCVec_CResult_NoneAPIErrorZZ _res_constr;
15850         _res_constr.datalen = _res->arr_len;
15851         if (_res_constr.datalen > 0)
15852                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
15853         else
15854                 _res_constr.data = NULL;
15855         uint32_t* _res_vals = _res->elems;
15856         for (size_t w = 0; w < _res_constr.datalen; w++) {
15857                 uint32_t _res_conv_22 = _res_vals[w];
15858                 void* _res_conv_22_ptr = (void*)(((uintptr_t)_res_conv_22) & ~1);
15859                 CHECK_ACCESS(_res_conv_22_ptr);
15860                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_conv_22_ptr);
15861                 FREE((void*)_res_conv_22);
15862                 _res_constr.data[w] = _res_conv_22_conv;
15863         }
15864         FREE(_res);
15865         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
15866 }
15867
15868 void  __attribute__((export_name("TS_CVec_APIErrorZ_free"))) TS_CVec_APIErrorZ_free(uint32_tArray _res) {
15869         LDKCVec_APIErrorZ _res_constr;
15870         _res_constr.datalen = _res->arr_len;
15871         if (_res_constr.datalen > 0)
15872                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
15873         else
15874                 _res_constr.data = NULL;
15875         uint32_t* _res_vals = _res->elems;
15876         for (size_t k = 0; k < _res_constr.datalen; k++) {
15877                 uint32_t _res_conv_10 = _res_vals[k];
15878                 void* _res_conv_10_ptr = (void*)(((uintptr_t)_res_conv_10) & ~1);
15879                 CHECK_ACCESS(_res_conv_10_ptr);
15880                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(_res_conv_10_ptr);
15881                 FREE((void*)_res_conv_10);
15882                 _res_constr.data[k] = _res_conv_10_conv;
15883         }
15884         FREE(_res);
15885         CVec_APIErrorZ_free(_res_constr);
15886 }
15887
15888 uint32_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_ok"))) TS_CResult__u832APIErrorZ_ok(int8_tArray o) {
15889         LDKThirtyTwoBytes o_ref;
15890         CHECK(o->arr_len == 32);
15891         memcpy(o_ref.data, o->elems, 32); FREE(o);
15892         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
15893         *ret_conv = CResult__u832APIErrorZ_ok(o_ref);
15894         return (uint32_t)ret_conv;
15895 }
15896
15897 uint32_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_err"))) TS_CResult__u832APIErrorZ_err(uint32_t e) {
15898         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
15899         CHECK_ACCESS(e_ptr);
15900         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
15901         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
15902         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
15903         *ret_conv = CResult__u832APIErrorZ_err(e_conv);
15904         return (uint32_t)ret_conv;
15905 }
15906
15907 jboolean  __attribute__((export_name("TS_CResult__u832APIErrorZ_is_ok"))) TS_CResult__u832APIErrorZ_is_ok(uint32_t o) {
15908         LDKCResult__u832APIErrorZ* o_conv = (LDKCResult__u832APIErrorZ*)(o & ~1);
15909         jboolean ret_conv = CResult__u832APIErrorZ_is_ok(o_conv);
15910         return ret_conv;
15911 }
15912
15913 void  __attribute__((export_name("TS_CResult__u832APIErrorZ_free"))) TS_CResult__u832APIErrorZ_free(uint32_t _res) {
15914         if ((_res & 1) != 0) return;
15915         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15916         CHECK_ACCESS(_res_ptr);
15917         LDKCResult__u832APIErrorZ _res_conv = *(LDKCResult__u832APIErrorZ*)(_res_ptr);
15918         FREE((void*)_res);
15919         CResult__u832APIErrorZ_free(_res_conv);
15920 }
15921
15922 static inline uintptr_t CResult__u832APIErrorZ_clone_ptr(LDKCResult__u832APIErrorZ *NONNULL_PTR arg) {
15923         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
15924         *ret_conv = CResult__u832APIErrorZ_clone(arg);
15925         return (uint32_t)ret_conv;
15926 }
15927 uint32_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_clone_ptr"))) TS_CResult__u832APIErrorZ_clone_ptr(uint32_t arg) {
15928         LDKCResult__u832APIErrorZ* arg_conv = (LDKCResult__u832APIErrorZ*)(arg & ~1);
15929         uint32_t ret_conv = CResult__u832APIErrorZ_clone_ptr(arg_conv);
15930         return ret_conv;
15931 }
15932
15933 uint32_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_clone"))) TS_CResult__u832APIErrorZ_clone(uint32_t orig) {
15934         LDKCResult__u832APIErrorZ* orig_conv = (LDKCResult__u832APIErrorZ*)(orig & ~1);
15935         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
15936         *ret_conv = CResult__u832APIErrorZ_clone(orig_conv);
15937         return (uint32_t)ret_conv;
15938 }
15939
15940 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_ok"))) TS_CResult_PaymentIdPaymentSendFailureZ_ok(int8_tArray o) {
15941         LDKThirtyTwoBytes o_ref;
15942         CHECK(o->arr_len == 32);
15943         memcpy(o_ref.data, o->elems, 32); FREE(o);
15944         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
15945         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_ok(o_ref);
15946         return (uint32_t)ret_conv;
15947 }
15948
15949 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_err"))) TS_CResult_PaymentIdPaymentSendFailureZ_err(uint32_t e) {
15950         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
15951         CHECK_ACCESS(e_ptr);
15952         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
15953         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
15954         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
15955         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_err(e_conv);
15956         return (uint32_t)ret_conv;
15957 }
15958
15959 jboolean  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_is_ok"))) TS_CResult_PaymentIdPaymentSendFailureZ_is_ok(uint32_t o) {
15960         LDKCResult_PaymentIdPaymentSendFailureZ* o_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(o & ~1);
15961         jboolean ret_conv = CResult_PaymentIdPaymentSendFailureZ_is_ok(o_conv);
15962         return ret_conv;
15963 }
15964
15965 void  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_free"))) TS_CResult_PaymentIdPaymentSendFailureZ_free(uint32_t _res) {
15966         if ((_res & 1) != 0) return;
15967         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15968         CHECK_ACCESS(_res_ptr);
15969         LDKCResult_PaymentIdPaymentSendFailureZ _res_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(_res_ptr);
15970         FREE((void*)_res);
15971         CResult_PaymentIdPaymentSendFailureZ_free(_res_conv);
15972 }
15973
15974 static inline uintptr_t CResult_PaymentIdPaymentSendFailureZ_clone_ptr(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR arg) {
15975         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
15976         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(arg);
15977         return (uint32_t)ret_conv;
15978 }
15979 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_clone_ptr"))) TS_CResult_PaymentIdPaymentSendFailureZ_clone_ptr(uint32_t arg) {
15980         LDKCResult_PaymentIdPaymentSendFailureZ* arg_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(arg & ~1);
15981         uint32_t ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone_ptr(arg_conv);
15982         return ret_conv;
15983 }
15984
15985 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_clone"))) TS_CResult_PaymentIdPaymentSendFailureZ_clone(uint32_t orig) {
15986         LDKCResult_PaymentIdPaymentSendFailureZ* orig_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(orig & ~1);
15987         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
15988         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(orig_conv);
15989         return (uint32_t)ret_conv;
15990 }
15991
15992 uint32_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_ok"))) TS_CResult_NonePaymentSendFailureZ_ok() {
15993         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
15994         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
15995         return (uint32_t)ret_conv;
15996 }
15997
15998 uint32_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_err"))) TS_CResult_NonePaymentSendFailureZ_err(uint32_t e) {
15999         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
16000         CHECK_ACCESS(e_ptr);
16001         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
16002         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
16003         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
16004         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
16005         return (uint32_t)ret_conv;
16006 }
16007
16008 jboolean  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_is_ok"))) TS_CResult_NonePaymentSendFailureZ_is_ok(uint32_t o) {
16009         LDKCResult_NonePaymentSendFailureZ* o_conv = (LDKCResult_NonePaymentSendFailureZ*)(o & ~1);
16010         jboolean ret_conv = CResult_NonePaymentSendFailureZ_is_ok(o_conv);
16011         return ret_conv;
16012 }
16013
16014 void  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_free"))) TS_CResult_NonePaymentSendFailureZ_free(uint32_t _res) {
16015         if ((_res & 1) != 0) return;
16016         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16017         CHECK_ACCESS(_res_ptr);
16018         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(_res_ptr);
16019         FREE((void*)_res);
16020         CResult_NonePaymentSendFailureZ_free(_res_conv);
16021 }
16022
16023 static inline uintptr_t CResult_NonePaymentSendFailureZ_clone_ptr(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR arg) {
16024         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
16025         *ret_conv = CResult_NonePaymentSendFailureZ_clone(arg);
16026         return (uint32_t)ret_conv;
16027 }
16028 uint32_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_clone_ptr"))) TS_CResult_NonePaymentSendFailureZ_clone_ptr(uint32_t arg) {
16029         LDKCResult_NonePaymentSendFailureZ* arg_conv = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
16030         uint32_t ret_conv = CResult_NonePaymentSendFailureZ_clone_ptr(arg_conv);
16031         return ret_conv;
16032 }
16033
16034 uint32_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_clone"))) TS_CResult_NonePaymentSendFailureZ_clone(uint32_t orig) {
16035         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)(orig & ~1);
16036         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
16037         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
16038         return (uint32_t)ret_conv;
16039 }
16040
16041 static inline uintptr_t C2Tuple_PaymentHashPaymentIdZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR arg) {
16042         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
16043         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(arg);
16044         return ((uint32_t)ret_conv);
16045 }
16046 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_clone_ptr"))) TS_C2Tuple_PaymentHashPaymentIdZ_clone_ptr(uint32_t arg) {
16047         LDKC2Tuple_PaymentHashPaymentIdZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(arg & ~1);
16048         uint32_t ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone_ptr(arg_conv);
16049         return ret_conv;
16050 }
16051
16052 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_clone"))) TS_C2Tuple_PaymentHashPaymentIdZ_clone(uint32_t orig) {
16053         LDKC2Tuple_PaymentHashPaymentIdZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(orig & ~1);
16054         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
16055         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(orig_conv);
16056         return ((uint32_t)ret_conv);
16057 }
16058
16059 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_new"))) TS_C2Tuple_PaymentHashPaymentIdZ_new(int8_tArray a, int8_tArray b) {
16060         LDKThirtyTwoBytes a_ref;
16061         CHECK(a->arr_len == 32);
16062         memcpy(a_ref.data, a->elems, 32); FREE(a);
16063         LDKThirtyTwoBytes b_ref;
16064         CHECK(b->arr_len == 32);
16065         memcpy(b_ref.data, b->elems, 32); FREE(b);
16066         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
16067         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_new(a_ref, b_ref);
16068         return ((uint32_t)ret_conv);
16069 }
16070
16071 void  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_free"))) TS_C2Tuple_PaymentHashPaymentIdZ_free(uint32_t _res) {
16072         if ((_res & 1) != 0) return;
16073         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16074         CHECK_ACCESS(_res_ptr);
16075         LDKC2Tuple_PaymentHashPaymentIdZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(_res_ptr);
16076         FREE((void*)_res);
16077         C2Tuple_PaymentHashPaymentIdZ_free(_res_conv);
16078 }
16079
16080 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(uint32_t o) {
16081         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16082         CHECK_ACCESS(o_ptr);
16083         LDKC2Tuple_PaymentHashPaymentIdZ o_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(o_ptr);
16084         o_conv = C2Tuple_PaymentHashPaymentIdZ_clone((LDKC2Tuple_PaymentHashPaymentIdZ*)(((uintptr_t)o) & ~1));
16085         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
16086         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(o_conv);
16087         return (uint32_t)ret_conv;
16088 }
16089
16090 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(uint32_t e) {
16091         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
16092         CHECK_ACCESS(e_ptr);
16093         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
16094         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
16095         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
16096         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(e_conv);
16097         return (uint32_t)ret_conv;
16098 }
16099
16100 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok(uint32_t o) {
16101         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(o & ~1);
16102         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok(o_conv);
16103         return ret_conv;
16104 }
16105
16106 void  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(uint32_t _res) {
16107         if ((_res & 1) != 0) return;
16108         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16109         CHECK_ACCESS(_res_ptr);
16110         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(_res_ptr);
16111         FREE((void*)_res);
16112         CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(_res_conv);
16113 }
16114
16115 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR arg) {
16116         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
16117         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(arg);
16118         return (uint32_t)ret_conv;
16119 }
16120 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(uint32_t arg) {
16121         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(arg & ~1);
16122         uint32_t ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(arg_conv);
16123         return ret_conv;
16124 }
16125
16126 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(uint32_t orig) {
16127         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(orig & ~1);
16128         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
16129         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(orig_conv);
16130         return (uint32_t)ret_conv;
16131 }
16132
16133 void  __attribute__((export_name("TS_CVec_ThirtyTwoBytesZ_free"))) TS_CVec_ThirtyTwoBytesZ_free(ptrArray _res) {
16134         LDKCVec_ThirtyTwoBytesZ _res_constr;
16135         _res_constr.datalen = _res->arr_len;
16136         if (_res_constr.datalen > 0)
16137                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_ThirtyTwoBytesZ Elements");
16138         else
16139                 _res_constr.data = NULL;
16140         int8_tArray* _res_vals = (void*) _res->elems;
16141         for (size_t m = 0; m < _res_constr.datalen; m++) {
16142                 int8_tArray _res_conv_12 = _res_vals[m];
16143                 LDKThirtyTwoBytes _res_conv_12_ref;
16144                 CHECK(_res_conv_12->arr_len == 32);
16145                 memcpy(_res_conv_12_ref.data, _res_conv_12->elems, 32); FREE(_res_conv_12);
16146                 _res_constr.data[m] = _res_conv_12_ref;
16147         }
16148         FREE(_res);
16149         CVec_ThirtyTwoBytesZ_free(_res_constr);
16150 }
16151
16152 static inline uintptr_t C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR arg) {
16153         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
16154         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(arg);
16155         return ((uint32_t)ret_conv);
16156 }
16157 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_clone_ptr"))) TS_C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(uint32_t arg) {
16158         LDKC2Tuple_PaymentHashPaymentSecretZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(arg & ~1);
16159         uint32_t ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(arg_conv);
16160         return ret_conv;
16161 }
16162
16163 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_clone"))) TS_C2Tuple_PaymentHashPaymentSecretZ_clone(uint32_t orig) {
16164         LDKC2Tuple_PaymentHashPaymentSecretZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(orig & ~1);
16165         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
16166         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(orig_conv);
16167         return ((uint32_t)ret_conv);
16168 }
16169
16170 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_new"))) TS_C2Tuple_PaymentHashPaymentSecretZ_new(int8_tArray a, int8_tArray b) {
16171         LDKThirtyTwoBytes a_ref;
16172         CHECK(a->arr_len == 32);
16173         memcpy(a_ref.data, a->elems, 32); FREE(a);
16174         LDKThirtyTwoBytes b_ref;
16175         CHECK(b->arr_len == 32);
16176         memcpy(b_ref.data, b->elems, 32); FREE(b);
16177         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
16178         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_new(a_ref, b_ref);
16179         return ((uint32_t)ret_conv);
16180 }
16181
16182 void  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_free"))) TS_C2Tuple_PaymentHashPaymentSecretZ_free(uint32_t _res) {
16183         if ((_res & 1) != 0) return;
16184         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16185         CHECK_ACCESS(_res_ptr);
16186         LDKC2Tuple_PaymentHashPaymentSecretZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(_res_ptr);
16187         FREE((void*)_res);
16188         C2Tuple_PaymentHashPaymentSecretZ_free(_res_conv);
16189 }
16190
16191 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok(uint32_t o) {
16192         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16193         CHECK_ACCESS(o_ptr);
16194         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
16195         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uintptr_t)o) & ~1));
16196         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
16197         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok(o_conv);
16198         return (uint32_t)ret_conv;
16199 }
16200
16201 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err() {
16202         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
16203         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err();
16204         return (uint32_t)ret_conv;
16205 }
16206
16207 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok(uint32_t o) {
16208         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(o & ~1);
16209         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok(o_conv);
16210         return ret_conv;
16211 }
16212
16213 void  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free(uint32_t _res) {
16214         if ((_res & 1) != 0) return;
16215         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16216         CHECK_ACCESS(_res_ptr);
16217         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(_res_ptr);
16218         FREE((void*)_res);
16219         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free(_res_conv);
16220 }
16221
16222 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR arg) {
16223         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
16224         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(arg);
16225         return (uint32_t)ret_conv;
16226 }
16227 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(uint32_t arg) {
16228         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(arg & ~1);
16229         uint32_t ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(arg_conv);
16230         return ret_conv;
16231 }
16232
16233 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(uint32_t orig) {
16234         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(orig & ~1);
16235         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
16236         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(orig_conv);
16237         return (uint32_t)ret_conv;
16238 }
16239
16240 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok(uint32_t o) {
16241         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16242         CHECK_ACCESS(o_ptr);
16243         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
16244         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uintptr_t)o) & ~1));
16245         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
16246         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok(o_conv);
16247         return (uint32_t)ret_conv;
16248 }
16249
16250 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err(uint32_t e) {
16251         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
16252         CHECK_ACCESS(e_ptr);
16253         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
16254         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
16255         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
16256         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err(e_conv);
16257         return (uint32_t)ret_conv;
16258 }
16259
16260 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok(uint32_t o) {
16261         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(o & ~1);
16262         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok(o_conv);
16263         return ret_conv;
16264 }
16265
16266 void  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free(uint32_t _res) {
16267         if ((_res & 1) != 0) return;
16268         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16269         CHECK_ACCESS(_res_ptr);
16270         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(_res_ptr);
16271         FREE((void*)_res);
16272         CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free(_res_conv);
16273 }
16274
16275 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR arg) {
16276         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
16277         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(arg);
16278         return (uint32_t)ret_conv;
16279 }
16280 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(uint32_t arg) {
16281         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(arg & ~1);
16282         uint32_t ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(arg_conv);
16283         return ret_conv;
16284 }
16285
16286 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(uint32_t orig) {
16287         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(orig & ~1);
16288         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
16289         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(orig_conv);
16290         return (uint32_t)ret_conv;
16291 }
16292
16293 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_ok"))) TS_CResult_PaymentSecretNoneZ_ok(int8_tArray o) {
16294         LDKThirtyTwoBytes o_ref;
16295         CHECK(o->arr_len == 32);
16296         memcpy(o_ref.data, o->elems, 32); FREE(o);
16297         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
16298         *ret_conv = CResult_PaymentSecretNoneZ_ok(o_ref);
16299         return (uint32_t)ret_conv;
16300 }
16301
16302 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_err"))) TS_CResult_PaymentSecretNoneZ_err() {
16303         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
16304         *ret_conv = CResult_PaymentSecretNoneZ_err();
16305         return (uint32_t)ret_conv;
16306 }
16307
16308 jboolean  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_is_ok"))) TS_CResult_PaymentSecretNoneZ_is_ok(uint32_t o) {
16309         LDKCResult_PaymentSecretNoneZ* o_conv = (LDKCResult_PaymentSecretNoneZ*)(o & ~1);
16310         jboolean ret_conv = CResult_PaymentSecretNoneZ_is_ok(o_conv);
16311         return ret_conv;
16312 }
16313
16314 void  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_free"))) TS_CResult_PaymentSecretNoneZ_free(uint32_t _res) {
16315         if ((_res & 1) != 0) return;
16316         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16317         CHECK_ACCESS(_res_ptr);
16318         LDKCResult_PaymentSecretNoneZ _res_conv = *(LDKCResult_PaymentSecretNoneZ*)(_res_ptr);
16319         FREE((void*)_res);
16320         CResult_PaymentSecretNoneZ_free(_res_conv);
16321 }
16322
16323 static inline uintptr_t CResult_PaymentSecretNoneZ_clone_ptr(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR arg) {
16324         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
16325         *ret_conv = CResult_PaymentSecretNoneZ_clone(arg);
16326         return (uint32_t)ret_conv;
16327 }
16328 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_clone_ptr"))) TS_CResult_PaymentSecretNoneZ_clone_ptr(uint32_t arg) {
16329         LDKCResult_PaymentSecretNoneZ* arg_conv = (LDKCResult_PaymentSecretNoneZ*)(arg & ~1);
16330         uint32_t ret_conv = CResult_PaymentSecretNoneZ_clone_ptr(arg_conv);
16331         return ret_conv;
16332 }
16333
16334 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_clone"))) TS_CResult_PaymentSecretNoneZ_clone(uint32_t orig) {
16335         LDKCResult_PaymentSecretNoneZ* orig_conv = (LDKCResult_PaymentSecretNoneZ*)(orig & ~1);
16336         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
16337         *ret_conv = CResult_PaymentSecretNoneZ_clone(orig_conv);
16338         return (uint32_t)ret_conv;
16339 }
16340
16341 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_ok"))) TS_CResult_PaymentSecretAPIErrorZ_ok(int8_tArray o) {
16342         LDKThirtyTwoBytes o_ref;
16343         CHECK(o->arr_len == 32);
16344         memcpy(o_ref.data, o->elems, 32); FREE(o);
16345         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
16346         *ret_conv = CResult_PaymentSecretAPIErrorZ_ok(o_ref);
16347         return (uint32_t)ret_conv;
16348 }
16349
16350 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_err"))) TS_CResult_PaymentSecretAPIErrorZ_err(uint32_t e) {
16351         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
16352         CHECK_ACCESS(e_ptr);
16353         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
16354         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
16355         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
16356         *ret_conv = CResult_PaymentSecretAPIErrorZ_err(e_conv);
16357         return (uint32_t)ret_conv;
16358 }
16359
16360 jboolean  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_is_ok"))) TS_CResult_PaymentSecretAPIErrorZ_is_ok(uint32_t o) {
16361         LDKCResult_PaymentSecretAPIErrorZ* o_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(o & ~1);
16362         jboolean ret_conv = CResult_PaymentSecretAPIErrorZ_is_ok(o_conv);
16363         return ret_conv;
16364 }
16365
16366 void  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_free"))) TS_CResult_PaymentSecretAPIErrorZ_free(uint32_t _res) {
16367         if ((_res & 1) != 0) return;
16368         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16369         CHECK_ACCESS(_res_ptr);
16370         LDKCResult_PaymentSecretAPIErrorZ _res_conv = *(LDKCResult_PaymentSecretAPIErrorZ*)(_res_ptr);
16371         FREE((void*)_res);
16372         CResult_PaymentSecretAPIErrorZ_free(_res_conv);
16373 }
16374
16375 static inline uintptr_t CResult_PaymentSecretAPIErrorZ_clone_ptr(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR arg) {
16376         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
16377         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(arg);
16378         return (uint32_t)ret_conv;
16379 }
16380 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_clone_ptr"))) TS_CResult_PaymentSecretAPIErrorZ_clone_ptr(uint32_t arg) {
16381         LDKCResult_PaymentSecretAPIErrorZ* arg_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
16382         uint32_t ret_conv = CResult_PaymentSecretAPIErrorZ_clone_ptr(arg_conv);
16383         return ret_conv;
16384 }
16385
16386 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_clone"))) TS_CResult_PaymentSecretAPIErrorZ_clone(uint32_t orig) {
16387         LDKCResult_PaymentSecretAPIErrorZ* orig_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(orig & ~1);
16388         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
16389         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(orig_conv);
16390         return (uint32_t)ret_conv;
16391 }
16392
16393 uint32_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_ok"))) TS_CResult_PaymentPreimageAPIErrorZ_ok(int8_tArray o) {
16394         LDKThirtyTwoBytes o_ref;
16395         CHECK(o->arr_len == 32);
16396         memcpy(o_ref.data, o->elems, 32); FREE(o);
16397         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
16398         *ret_conv = CResult_PaymentPreimageAPIErrorZ_ok(o_ref);
16399         return (uint32_t)ret_conv;
16400 }
16401
16402 uint32_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_err"))) TS_CResult_PaymentPreimageAPIErrorZ_err(uint32_t e) {
16403         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
16404         CHECK_ACCESS(e_ptr);
16405         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
16406         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
16407         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
16408         *ret_conv = CResult_PaymentPreimageAPIErrorZ_err(e_conv);
16409         return (uint32_t)ret_conv;
16410 }
16411
16412 jboolean  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_is_ok"))) TS_CResult_PaymentPreimageAPIErrorZ_is_ok(uint32_t o) {
16413         LDKCResult_PaymentPreimageAPIErrorZ* o_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(o & ~1);
16414         jboolean ret_conv = CResult_PaymentPreimageAPIErrorZ_is_ok(o_conv);
16415         return ret_conv;
16416 }
16417
16418 void  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_free"))) TS_CResult_PaymentPreimageAPIErrorZ_free(uint32_t _res) {
16419         if ((_res & 1) != 0) return;
16420         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16421         CHECK_ACCESS(_res_ptr);
16422         LDKCResult_PaymentPreimageAPIErrorZ _res_conv = *(LDKCResult_PaymentPreimageAPIErrorZ*)(_res_ptr);
16423         FREE((void*)_res);
16424         CResult_PaymentPreimageAPIErrorZ_free(_res_conv);
16425 }
16426
16427 static inline uintptr_t CResult_PaymentPreimageAPIErrorZ_clone_ptr(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR arg) {
16428         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
16429         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(arg);
16430         return (uint32_t)ret_conv;
16431 }
16432 uint32_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_clone_ptr"))) TS_CResult_PaymentPreimageAPIErrorZ_clone_ptr(uint32_t arg) {
16433         LDKCResult_PaymentPreimageAPIErrorZ* arg_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(arg & ~1);
16434         uint32_t ret_conv = CResult_PaymentPreimageAPIErrorZ_clone_ptr(arg_conv);
16435         return ret_conv;
16436 }
16437
16438 uint32_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_clone"))) TS_CResult_PaymentPreimageAPIErrorZ_clone(uint32_t orig) {
16439         LDKCResult_PaymentPreimageAPIErrorZ* orig_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(orig & ~1);
16440         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
16441         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(orig_conv);
16442         return (uint32_t)ret_conv;
16443 }
16444
16445 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_ok"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_ok(uint32_t o) {
16446         LDKCounterpartyForwardingInfo o_conv;
16447         o_conv.inner = (void*)(o & (~1));
16448         o_conv.is_owned = (o & 1) || (o == 0);
16449         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16450         o_conv = CounterpartyForwardingInfo_clone(&o_conv);
16451         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
16452         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_ok(o_conv);
16453         return (uint32_t)ret_conv;
16454 }
16455
16456 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_err"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_err(uint32_t e) {
16457         LDKDecodeError e_conv;
16458         e_conv.inner = (void*)(e & (~1));
16459         e_conv.is_owned = (e & 1) || (e == 0);
16460         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16461         e_conv = DecodeError_clone(&e_conv);
16462         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
16463         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_err(e_conv);
16464         return (uint32_t)ret_conv;
16465 }
16466
16467 jboolean  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok(uint32_t o) {
16468         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* o_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(o & ~1);
16469         jboolean ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok(o_conv);
16470         return ret_conv;
16471 }
16472
16473 void  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_free"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_free(uint32_t _res) {
16474         if ((_res & 1) != 0) return;
16475         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16476         CHECK_ACCESS(_res_ptr);
16477         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(_res_ptr);
16478         FREE((void*)_res);
16479         CResult_CounterpartyForwardingInfoDecodeErrorZ_free(_res_conv);
16480 }
16481
16482 static inline uintptr_t CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR arg) {
16483         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
16484         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(arg);
16485         return (uint32_t)ret_conv;
16486 }
16487 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
16488         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(arg & ~1);
16489         uint32_t ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(arg_conv);
16490         return ret_conv;
16491 }
16492
16493 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_clone"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(uint32_t orig) {
16494         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(orig & ~1);
16495         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
16496         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(orig_conv);
16497         return (uint32_t)ret_conv;
16498 }
16499
16500 uint32_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_ok"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_ok(uint32_t o) {
16501         LDKChannelCounterparty o_conv;
16502         o_conv.inner = (void*)(o & (~1));
16503         o_conv.is_owned = (o & 1) || (o == 0);
16504         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16505         o_conv = ChannelCounterparty_clone(&o_conv);
16506         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
16507         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_ok(o_conv);
16508         return (uint32_t)ret_conv;
16509 }
16510
16511 uint32_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_err"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_err(uint32_t e) {
16512         LDKDecodeError e_conv;
16513         e_conv.inner = (void*)(e & (~1));
16514         e_conv.is_owned = (e & 1) || (e == 0);
16515         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16516         e_conv = DecodeError_clone(&e_conv);
16517         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
16518         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_err(e_conv);
16519         return (uint32_t)ret_conv;
16520 }
16521
16522 jboolean  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_is_ok"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_is_ok(uint32_t o) {
16523         LDKCResult_ChannelCounterpartyDecodeErrorZ* o_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(o & ~1);
16524         jboolean ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_is_ok(o_conv);
16525         return ret_conv;
16526 }
16527
16528 void  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_free"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_free(uint32_t _res) {
16529         if ((_res & 1) != 0) return;
16530         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16531         CHECK_ACCESS(_res_ptr);
16532         LDKCResult_ChannelCounterpartyDecodeErrorZ _res_conv = *(LDKCResult_ChannelCounterpartyDecodeErrorZ*)(_res_ptr);
16533         FREE((void*)_res);
16534         CResult_ChannelCounterpartyDecodeErrorZ_free(_res_conv);
16535 }
16536
16537 static inline uintptr_t CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR arg) {
16538         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
16539         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone(arg);
16540         return (uint32_t)ret_conv;
16541 }
16542 uint32_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(uint32_t arg) {
16543         LDKCResult_ChannelCounterpartyDecodeErrorZ* arg_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(arg & ~1);
16544         uint32_t ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(arg_conv);
16545         return ret_conv;
16546 }
16547
16548 uint32_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_clone"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_clone(uint32_t orig) {
16549         LDKCResult_ChannelCounterpartyDecodeErrorZ* orig_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(orig & ~1);
16550         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
16551         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone(orig_conv);
16552         return (uint32_t)ret_conv;
16553 }
16554
16555 uint32_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_ok"))) TS_CResult_ChannelDetailsDecodeErrorZ_ok(uint32_t o) {
16556         LDKChannelDetails o_conv;
16557         o_conv.inner = (void*)(o & (~1));
16558         o_conv.is_owned = (o & 1) || (o == 0);
16559         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16560         o_conv = ChannelDetails_clone(&o_conv);
16561         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
16562         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_ok(o_conv);
16563         return (uint32_t)ret_conv;
16564 }
16565
16566 uint32_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_err"))) TS_CResult_ChannelDetailsDecodeErrorZ_err(uint32_t e) {
16567         LDKDecodeError e_conv;
16568         e_conv.inner = (void*)(e & (~1));
16569         e_conv.is_owned = (e & 1) || (e == 0);
16570         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16571         e_conv = DecodeError_clone(&e_conv);
16572         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
16573         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_err(e_conv);
16574         return (uint32_t)ret_conv;
16575 }
16576
16577 jboolean  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_is_ok"))) TS_CResult_ChannelDetailsDecodeErrorZ_is_ok(uint32_t o) {
16578         LDKCResult_ChannelDetailsDecodeErrorZ* o_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(o & ~1);
16579         jboolean ret_conv = CResult_ChannelDetailsDecodeErrorZ_is_ok(o_conv);
16580         return ret_conv;
16581 }
16582
16583 void  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_free"))) TS_CResult_ChannelDetailsDecodeErrorZ_free(uint32_t _res) {
16584         if ((_res & 1) != 0) return;
16585         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16586         CHECK_ACCESS(_res_ptr);
16587         LDKCResult_ChannelDetailsDecodeErrorZ _res_conv = *(LDKCResult_ChannelDetailsDecodeErrorZ*)(_res_ptr);
16588         FREE((void*)_res);
16589         CResult_ChannelDetailsDecodeErrorZ_free(_res_conv);
16590 }
16591
16592 static inline uintptr_t CResult_ChannelDetailsDecodeErrorZ_clone_ptr(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR arg) {
16593         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
16594         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone(arg);
16595         return (uint32_t)ret_conv;
16596 }
16597 uint32_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelDetailsDecodeErrorZ_clone_ptr(uint32_t arg) {
16598         LDKCResult_ChannelDetailsDecodeErrorZ* arg_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(arg & ~1);
16599         uint32_t ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone_ptr(arg_conv);
16600         return ret_conv;
16601 }
16602
16603 uint32_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_clone"))) TS_CResult_ChannelDetailsDecodeErrorZ_clone(uint32_t orig) {
16604         LDKCResult_ChannelDetailsDecodeErrorZ* orig_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(orig & ~1);
16605         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
16606         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone(orig_conv);
16607         return (uint32_t)ret_conv;
16608 }
16609
16610 uint32_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_ok"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_ok(uint32_t o) {
16611         LDKPhantomRouteHints o_conv;
16612         o_conv.inner = (void*)(o & (~1));
16613         o_conv.is_owned = (o & 1) || (o == 0);
16614         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16615         o_conv = PhantomRouteHints_clone(&o_conv);
16616         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
16617         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_ok(o_conv);
16618         return (uint32_t)ret_conv;
16619 }
16620
16621 uint32_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_err"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_err(uint32_t e) {
16622         LDKDecodeError e_conv;
16623         e_conv.inner = (void*)(e & (~1));
16624         e_conv.is_owned = (e & 1) || (e == 0);
16625         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16626         e_conv = DecodeError_clone(&e_conv);
16627         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
16628         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_err(e_conv);
16629         return (uint32_t)ret_conv;
16630 }
16631
16632 jboolean  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_is_ok"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_is_ok(uint32_t o) {
16633         LDKCResult_PhantomRouteHintsDecodeErrorZ* o_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(o & ~1);
16634         jboolean ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_is_ok(o_conv);
16635         return ret_conv;
16636 }
16637
16638 void  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_free"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_free(uint32_t _res) {
16639         if ((_res & 1) != 0) return;
16640         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16641         CHECK_ACCESS(_res_ptr);
16642         LDKCResult_PhantomRouteHintsDecodeErrorZ _res_conv = *(LDKCResult_PhantomRouteHintsDecodeErrorZ*)(_res_ptr);
16643         FREE((void*)_res);
16644         CResult_PhantomRouteHintsDecodeErrorZ_free(_res_conv);
16645 }
16646
16647 static inline uintptr_t CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR arg) {
16648         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
16649         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone(arg);
16650         return (uint32_t)ret_conv;
16651 }
16652 uint32_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(uint32_t arg) {
16653         LDKCResult_PhantomRouteHintsDecodeErrorZ* arg_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(arg & ~1);
16654         uint32_t ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(arg_conv);
16655         return ret_conv;
16656 }
16657
16658 uint32_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_clone"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_clone(uint32_t orig) {
16659         LDKCResult_PhantomRouteHintsDecodeErrorZ* orig_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(orig & ~1);
16660         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
16661         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone(orig_conv);
16662         return (uint32_t)ret_conv;
16663 }
16664
16665 void  __attribute__((export_name("TS_CVec_ChannelMonitorZ_free"))) TS_CVec_ChannelMonitorZ_free(uint32_tArray _res) {
16666         LDKCVec_ChannelMonitorZ _res_constr;
16667         _res_constr.datalen = _res->arr_len;
16668         if (_res_constr.datalen > 0)
16669                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
16670         else
16671                 _res_constr.data = NULL;
16672         uint32_t* _res_vals = _res->elems;
16673         for (size_t q = 0; q < _res_constr.datalen; q++) {
16674                 uint32_t _res_conv_16 = _res_vals[q];
16675                 LDKChannelMonitor _res_conv_16_conv;
16676                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
16677                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
16678                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
16679                 _res_constr.data[q] = _res_conv_16_conv;
16680         }
16681         FREE(_res);
16682         CVec_ChannelMonitorZ_free(_res_constr);
16683 }
16684
16685 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_new"))) TS_C2Tuple_BlockHashChannelManagerZ_new(int8_tArray a, uint32_t b) {
16686         LDKThirtyTwoBytes a_ref;
16687         CHECK(a->arr_len == 32);
16688         memcpy(a_ref.data, a->elems, 32); FREE(a);
16689         LDKChannelManager b_conv;
16690         b_conv.inner = (void*)(b & (~1));
16691         b_conv.is_owned = (b & 1) || (b == 0);
16692         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
16693         // WARNING: we need a move here but no clone is available for LDKChannelManager
16694         LDKC2Tuple_BlockHashChannelManagerZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
16695         *ret_conv = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
16696         return ((uint32_t)ret_conv);
16697 }
16698
16699 void  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_free"))) TS_C2Tuple_BlockHashChannelManagerZ_free(uint32_t _res) {
16700         if ((_res & 1) != 0) return;
16701         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16702         CHECK_ACCESS(_res_ptr);
16703         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(_res_ptr);
16704         FREE((void*)_res);
16705         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
16706 }
16707
16708 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(uint32_t o) {
16709         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16710         CHECK_ACCESS(o_ptr);
16711         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(o_ptr);
16712         // WARNING: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelManagerZ
16713         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
16714         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
16715         return (uint32_t)ret_conv;
16716 }
16717
16718 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(uint32_t e) {
16719         LDKDecodeError e_conv;
16720         e_conv.inner = (void*)(e & (~1));
16721         e_conv.is_owned = (e & 1) || (e == 0);
16722         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16723         e_conv = DecodeError_clone(&e_conv);
16724         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
16725         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
16726         return (uint32_t)ret_conv;
16727 }
16728
16729 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok(uint32_t o) {
16730         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(o & ~1);
16731         jboolean ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok(o_conv);
16732         return ret_conv;
16733 }
16734
16735 void  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(uint32_t _res) {
16736         if ((_res & 1) != 0) return;
16737         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16738         CHECK_ACCESS(_res_ptr);
16739         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(_res_ptr);
16740         FREE((void*)_res);
16741         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
16742 }
16743
16744 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_ok"))) TS_CResult_ChannelConfigDecodeErrorZ_ok(uint32_t o) {
16745         LDKChannelConfig o_conv;
16746         o_conv.inner = (void*)(o & (~1));
16747         o_conv.is_owned = (o & 1) || (o == 0);
16748         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16749         o_conv = ChannelConfig_clone(&o_conv);
16750         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
16751         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
16752         return (uint32_t)ret_conv;
16753 }
16754
16755 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_err"))) TS_CResult_ChannelConfigDecodeErrorZ_err(uint32_t e) {
16756         LDKDecodeError e_conv;
16757         e_conv.inner = (void*)(e & (~1));
16758         e_conv.is_owned = (e & 1) || (e == 0);
16759         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16760         e_conv = DecodeError_clone(&e_conv);
16761         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
16762         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
16763         return (uint32_t)ret_conv;
16764 }
16765
16766 jboolean  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_is_ok"))) TS_CResult_ChannelConfigDecodeErrorZ_is_ok(uint32_t o) {
16767         LDKCResult_ChannelConfigDecodeErrorZ* o_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(o & ~1);
16768         jboolean ret_conv = CResult_ChannelConfigDecodeErrorZ_is_ok(o_conv);
16769         return ret_conv;
16770 }
16771
16772 void  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_free"))) TS_CResult_ChannelConfigDecodeErrorZ_free(uint32_t _res) {
16773         if ((_res & 1) != 0) return;
16774         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16775         CHECK_ACCESS(_res_ptr);
16776         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(_res_ptr);
16777         FREE((void*)_res);
16778         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
16779 }
16780
16781 static inline uintptr_t CResult_ChannelConfigDecodeErrorZ_clone_ptr(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR arg) {
16782         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
16783         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(arg);
16784         return (uint32_t)ret_conv;
16785 }
16786 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelConfigDecodeErrorZ_clone_ptr(uint32_t arg) {
16787         LDKCResult_ChannelConfigDecodeErrorZ* arg_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
16788         uint32_t ret_conv = CResult_ChannelConfigDecodeErrorZ_clone_ptr(arg_conv);
16789         return ret_conv;
16790 }
16791
16792 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_clone"))) TS_CResult_ChannelConfigDecodeErrorZ_clone(uint32_t orig) {
16793         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(orig & ~1);
16794         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
16795         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
16796         return (uint32_t)ret_conv;
16797 }
16798
16799 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_ok"))) TS_CResult_OutPointDecodeErrorZ_ok(uint32_t o) {
16800         LDKOutPoint o_conv;
16801         o_conv.inner = (void*)(o & (~1));
16802         o_conv.is_owned = (o & 1) || (o == 0);
16803         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16804         o_conv = OutPoint_clone(&o_conv);
16805         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
16806         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
16807         return (uint32_t)ret_conv;
16808 }
16809
16810 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_err"))) TS_CResult_OutPointDecodeErrorZ_err(uint32_t e) {
16811         LDKDecodeError e_conv;
16812         e_conv.inner = (void*)(e & (~1));
16813         e_conv.is_owned = (e & 1) || (e == 0);
16814         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16815         e_conv = DecodeError_clone(&e_conv);
16816         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
16817         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
16818         return (uint32_t)ret_conv;
16819 }
16820
16821 jboolean  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_is_ok"))) TS_CResult_OutPointDecodeErrorZ_is_ok(uint32_t o) {
16822         LDKCResult_OutPointDecodeErrorZ* o_conv = (LDKCResult_OutPointDecodeErrorZ*)(o & ~1);
16823         jboolean ret_conv = CResult_OutPointDecodeErrorZ_is_ok(o_conv);
16824         return ret_conv;
16825 }
16826
16827 void  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_free"))) TS_CResult_OutPointDecodeErrorZ_free(uint32_t _res) {
16828         if ((_res & 1) != 0) return;
16829         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16830         CHECK_ACCESS(_res_ptr);
16831         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(_res_ptr);
16832         FREE((void*)_res);
16833         CResult_OutPointDecodeErrorZ_free(_res_conv);
16834 }
16835
16836 static inline uintptr_t CResult_OutPointDecodeErrorZ_clone_ptr(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR arg) {
16837         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
16838         *ret_conv = CResult_OutPointDecodeErrorZ_clone(arg);
16839         return (uint32_t)ret_conv;
16840 }
16841 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_clone_ptr"))) TS_CResult_OutPointDecodeErrorZ_clone_ptr(uint32_t arg) {
16842         LDKCResult_OutPointDecodeErrorZ* arg_conv = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
16843         uint32_t ret_conv = CResult_OutPointDecodeErrorZ_clone_ptr(arg_conv);
16844         return ret_conv;
16845 }
16846
16847 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_clone"))) TS_CResult_OutPointDecodeErrorZ_clone(uint32_t orig) {
16848         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)(orig & ~1);
16849         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
16850         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
16851         return (uint32_t)ret_conv;
16852 }
16853
16854 uint32_t  __attribute__((export_name("TS_COption_TypeZ_some"))) TS_COption_TypeZ_some(uint32_t o) {
16855         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16856         CHECK_ACCESS(o_ptr);
16857         LDKType o_conv = *(LDKType*)(o_ptr);
16858         if (o_conv.free == LDKType_JCalls_free) {
16859                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16860                 LDKType_JCalls_cloned(&o_conv);
16861         }
16862         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
16863         *ret_copy = COption_TypeZ_some(o_conv);
16864         uint32_t ret_ref = (uintptr_t)ret_copy;
16865         return ret_ref;
16866 }
16867
16868 uint32_t  __attribute__((export_name("TS_COption_TypeZ_none"))) TS_COption_TypeZ_none() {
16869         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
16870         *ret_copy = COption_TypeZ_none();
16871         uint32_t ret_ref = (uintptr_t)ret_copy;
16872         return ret_ref;
16873 }
16874
16875 void  __attribute__((export_name("TS_COption_TypeZ_free"))) TS_COption_TypeZ_free(uint32_t _res) {
16876         if ((_res & 1) != 0) return;
16877         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16878         CHECK_ACCESS(_res_ptr);
16879         LDKCOption_TypeZ _res_conv = *(LDKCOption_TypeZ*)(_res_ptr);
16880         FREE((void*)_res);
16881         COption_TypeZ_free(_res_conv);
16882 }
16883
16884 static inline uintptr_t COption_TypeZ_clone_ptr(LDKCOption_TypeZ *NONNULL_PTR arg) {
16885         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
16886         *ret_copy = COption_TypeZ_clone(arg);
16887 uint32_t ret_ref = (uintptr_t)ret_copy;
16888         return ret_ref;
16889 }
16890 uint32_t  __attribute__((export_name("TS_COption_TypeZ_clone_ptr"))) TS_COption_TypeZ_clone_ptr(uint32_t arg) {
16891         LDKCOption_TypeZ* arg_conv = (LDKCOption_TypeZ*)arg;
16892         uint32_t ret_conv = COption_TypeZ_clone_ptr(arg_conv);
16893         return ret_conv;
16894 }
16895
16896 uint32_t  __attribute__((export_name("TS_COption_TypeZ_clone"))) TS_COption_TypeZ_clone(uint32_t orig) {
16897         LDKCOption_TypeZ* orig_conv = (LDKCOption_TypeZ*)orig;
16898         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
16899         *ret_copy = COption_TypeZ_clone(orig_conv);
16900         uint32_t ret_ref = (uintptr_t)ret_copy;
16901         return ret_ref;
16902 }
16903
16904 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_ok"))) TS_CResult_COption_TypeZDecodeErrorZ_ok(uint32_t o) {
16905         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16906         CHECK_ACCESS(o_ptr);
16907         LDKCOption_TypeZ o_conv = *(LDKCOption_TypeZ*)(o_ptr);
16908         o_conv = COption_TypeZ_clone((LDKCOption_TypeZ*)(((uintptr_t)o) & ~1));
16909         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
16910         *ret_conv = CResult_COption_TypeZDecodeErrorZ_ok(o_conv);
16911         return (uint32_t)ret_conv;
16912 }
16913
16914 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_err"))) TS_CResult_COption_TypeZDecodeErrorZ_err(uint32_t e) {
16915         LDKDecodeError e_conv;
16916         e_conv.inner = (void*)(e & (~1));
16917         e_conv.is_owned = (e & 1) || (e == 0);
16918         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16919         e_conv = DecodeError_clone(&e_conv);
16920         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
16921         *ret_conv = CResult_COption_TypeZDecodeErrorZ_err(e_conv);
16922         return (uint32_t)ret_conv;
16923 }
16924
16925 jboolean  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_is_ok"))) TS_CResult_COption_TypeZDecodeErrorZ_is_ok(uint32_t o) {
16926         LDKCResult_COption_TypeZDecodeErrorZ* o_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(o & ~1);
16927         jboolean ret_conv = CResult_COption_TypeZDecodeErrorZ_is_ok(o_conv);
16928         return ret_conv;
16929 }
16930
16931 void  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_free"))) TS_CResult_COption_TypeZDecodeErrorZ_free(uint32_t _res) {
16932         if ((_res & 1) != 0) return;
16933         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16934         CHECK_ACCESS(_res_ptr);
16935         LDKCResult_COption_TypeZDecodeErrorZ _res_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(_res_ptr);
16936         FREE((void*)_res);
16937         CResult_COption_TypeZDecodeErrorZ_free(_res_conv);
16938 }
16939
16940 static inline uintptr_t CResult_COption_TypeZDecodeErrorZ_clone_ptr(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR arg) {
16941         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
16942         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(arg);
16943         return (uint32_t)ret_conv;
16944 }
16945 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_TypeZDecodeErrorZ_clone_ptr(uint32_t arg) {
16946         LDKCResult_COption_TypeZDecodeErrorZ* arg_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(arg & ~1);
16947         uint32_t ret_conv = CResult_COption_TypeZDecodeErrorZ_clone_ptr(arg_conv);
16948         return ret_conv;
16949 }
16950
16951 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_clone"))) TS_CResult_COption_TypeZDecodeErrorZ_clone(uint32_t orig) {
16952         LDKCResult_COption_TypeZDecodeErrorZ* orig_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(orig & ~1);
16953         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
16954         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(orig_conv);
16955         return (uint32_t)ret_conv;
16956 }
16957
16958 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_ok"))) TS_CResult_PaymentIdPaymentErrorZ_ok(int8_tArray o) {
16959         LDKThirtyTwoBytes o_ref;
16960         CHECK(o->arr_len == 32);
16961         memcpy(o_ref.data, o->elems, 32); FREE(o);
16962         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
16963         *ret_conv = CResult_PaymentIdPaymentErrorZ_ok(o_ref);
16964         return (uint32_t)ret_conv;
16965 }
16966
16967 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_err"))) TS_CResult_PaymentIdPaymentErrorZ_err(uint32_t e) {
16968         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
16969         CHECK_ACCESS(e_ptr);
16970         LDKPaymentError e_conv = *(LDKPaymentError*)(e_ptr);
16971         e_conv = PaymentError_clone((LDKPaymentError*)(((uintptr_t)e) & ~1));
16972         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
16973         *ret_conv = CResult_PaymentIdPaymentErrorZ_err(e_conv);
16974         return (uint32_t)ret_conv;
16975 }
16976
16977 jboolean  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_is_ok"))) TS_CResult_PaymentIdPaymentErrorZ_is_ok(uint32_t o) {
16978         LDKCResult_PaymentIdPaymentErrorZ* o_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(o & ~1);
16979         jboolean ret_conv = CResult_PaymentIdPaymentErrorZ_is_ok(o_conv);
16980         return ret_conv;
16981 }
16982
16983 void  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_free"))) TS_CResult_PaymentIdPaymentErrorZ_free(uint32_t _res) {
16984         if ((_res & 1) != 0) return;
16985         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16986         CHECK_ACCESS(_res_ptr);
16987         LDKCResult_PaymentIdPaymentErrorZ _res_conv = *(LDKCResult_PaymentIdPaymentErrorZ*)(_res_ptr);
16988         FREE((void*)_res);
16989         CResult_PaymentIdPaymentErrorZ_free(_res_conv);
16990 }
16991
16992 static inline uintptr_t CResult_PaymentIdPaymentErrorZ_clone_ptr(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR arg) {
16993         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
16994         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(arg);
16995         return (uint32_t)ret_conv;
16996 }
16997 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_clone_ptr"))) TS_CResult_PaymentIdPaymentErrorZ_clone_ptr(uint32_t arg) {
16998         LDKCResult_PaymentIdPaymentErrorZ* arg_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(arg & ~1);
16999         uint32_t ret_conv = CResult_PaymentIdPaymentErrorZ_clone_ptr(arg_conv);
17000         return ret_conv;
17001 }
17002
17003 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_clone"))) TS_CResult_PaymentIdPaymentErrorZ_clone(uint32_t orig) {
17004         LDKCResult_PaymentIdPaymentErrorZ* orig_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(orig & ~1);
17005         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
17006         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(orig_conv);
17007         return (uint32_t)ret_conv;
17008 }
17009
17010 uint32_t  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_ok"))) TS_CResult_SiPrefixParseErrorZ_ok(uint32_t o) {
17011         LDKSiPrefix o_conv = LDKSiPrefix_from_js(o);
17012         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
17013         *ret_conv = CResult_SiPrefixParseErrorZ_ok(o_conv);
17014         return (uint32_t)ret_conv;
17015 }
17016
17017 uint32_t  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_err"))) TS_CResult_SiPrefixParseErrorZ_err(uint32_t e) {
17018         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
17019         CHECK_ACCESS(e_ptr);
17020         LDKParseError e_conv = *(LDKParseError*)(e_ptr);
17021         e_conv = ParseError_clone((LDKParseError*)(((uintptr_t)e) & ~1));
17022         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
17023         *ret_conv = CResult_SiPrefixParseErrorZ_err(e_conv);
17024         return (uint32_t)ret_conv;
17025 }
17026
17027 jboolean  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_is_ok"))) TS_CResult_SiPrefixParseErrorZ_is_ok(uint32_t o) {
17028         LDKCResult_SiPrefixParseErrorZ* o_conv = (LDKCResult_SiPrefixParseErrorZ*)(o & ~1);
17029         jboolean ret_conv = CResult_SiPrefixParseErrorZ_is_ok(o_conv);
17030         return ret_conv;
17031 }
17032
17033 void  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_free"))) TS_CResult_SiPrefixParseErrorZ_free(uint32_t _res) {
17034         if ((_res & 1) != 0) return;
17035         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17036         CHECK_ACCESS(_res_ptr);
17037         LDKCResult_SiPrefixParseErrorZ _res_conv = *(LDKCResult_SiPrefixParseErrorZ*)(_res_ptr);
17038         FREE((void*)_res);
17039         CResult_SiPrefixParseErrorZ_free(_res_conv);
17040 }
17041
17042 static inline uintptr_t CResult_SiPrefixParseErrorZ_clone_ptr(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR arg) {
17043         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
17044         *ret_conv = CResult_SiPrefixParseErrorZ_clone(arg);
17045         return (uint32_t)ret_conv;
17046 }
17047 uint32_t  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_clone_ptr"))) TS_CResult_SiPrefixParseErrorZ_clone_ptr(uint32_t arg) {
17048         LDKCResult_SiPrefixParseErrorZ* arg_conv = (LDKCResult_SiPrefixParseErrorZ*)(arg & ~1);
17049         uint32_t ret_conv = CResult_SiPrefixParseErrorZ_clone_ptr(arg_conv);
17050         return ret_conv;
17051 }
17052
17053 uint32_t  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_clone"))) TS_CResult_SiPrefixParseErrorZ_clone(uint32_t orig) {
17054         LDKCResult_SiPrefixParseErrorZ* orig_conv = (LDKCResult_SiPrefixParseErrorZ*)(orig & ~1);
17055         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
17056         *ret_conv = CResult_SiPrefixParseErrorZ_clone(orig_conv);
17057         return (uint32_t)ret_conv;
17058 }
17059
17060 uint32_t  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_ok"))) TS_CResult_InvoiceParseOrSemanticErrorZ_ok(uint32_t o) {
17061         LDKInvoice o_conv;
17062         o_conv.inner = (void*)(o & (~1));
17063         o_conv.is_owned = (o & 1) || (o == 0);
17064         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17065         o_conv = Invoice_clone(&o_conv);
17066         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
17067         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_ok(o_conv);
17068         return (uint32_t)ret_conv;
17069 }
17070
17071 uint32_t  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_err"))) TS_CResult_InvoiceParseOrSemanticErrorZ_err(uint32_t e) {
17072         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
17073         CHECK_ACCESS(e_ptr);
17074         LDKParseOrSemanticError e_conv = *(LDKParseOrSemanticError*)(e_ptr);
17075         e_conv = ParseOrSemanticError_clone((LDKParseOrSemanticError*)(((uintptr_t)e) & ~1));
17076         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
17077         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_err(e_conv);
17078         return (uint32_t)ret_conv;
17079 }
17080
17081 jboolean  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_is_ok"))) TS_CResult_InvoiceParseOrSemanticErrorZ_is_ok(uint32_t o) {
17082         LDKCResult_InvoiceParseOrSemanticErrorZ* o_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(o & ~1);
17083         jboolean ret_conv = CResult_InvoiceParseOrSemanticErrorZ_is_ok(o_conv);
17084         return ret_conv;
17085 }
17086
17087 void  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_free"))) TS_CResult_InvoiceParseOrSemanticErrorZ_free(uint32_t _res) {
17088         if ((_res & 1) != 0) return;
17089         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17090         CHECK_ACCESS(_res_ptr);
17091         LDKCResult_InvoiceParseOrSemanticErrorZ _res_conv = *(LDKCResult_InvoiceParseOrSemanticErrorZ*)(_res_ptr);
17092         FREE((void*)_res);
17093         CResult_InvoiceParseOrSemanticErrorZ_free(_res_conv);
17094 }
17095
17096 static inline uintptr_t CResult_InvoiceParseOrSemanticErrorZ_clone_ptr(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR arg) {
17097         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
17098         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone(arg);
17099         return (uint32_t)ret_conv;
17100 }
17101 uint32_t  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_clone_ptr"))) TS_CResult_InvoiceParseOrSemanticErrorZ_clone_ptr(uint32_t arg) {
17102         LDKCResult_InvoiceParseOrSemanticErrorZ* arg_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(arg & ~1);
17103         uint32_t ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone_ptr(arg_conv);
17104         return ret_conv;
17105 }
17106
17107 uint32_t  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_clone"))) TS_CResult_InvoiceParseOrSemanticErrorZ_clone(uint32_t orig) {
17108         LDKCResult_InvoiceParseOrSemanticErrorZ* orig_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(orig & ~1);
17109         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
17110         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone(orig_conv);
17111         return (uint32_t)ret_conv;
17112 }
17113
17114 uint32_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_ok"))) TS_CResult_SignedRawInvoiceParseErrorZ_ok(uint32_t o) {
17115         LDKSignedRawInvoice o_conv;
17116         o_conv.inner = (void*)(o & (~1));
17117         o_conv.is_owned = (o & 1) || (o == 0);
17118         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17119         o_conv = SignedRawInvoice_clone(&o_conv);
17120         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
17121         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_ok(o_conv);
17122         return (uint32_t)ret_conv;
17123 }
17124
17125 uint32_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_err"))) TS_CResult_SignedRawInvoiceParseErrorZ_err(uint32_t e) {
17126         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
17127         CHECK_ACCESS(e_ptr);
17128         LDKParseError e_conv = *(LDKParseError*)(e_ptr);
17129         e_conv = ParseError_clone((LDKParseError*)(((uintptr_t)e) & ~1));
17130         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
17131         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_err(e_conv);
17132         return (uint32_t)ret_conv;
17133 }
17134
17135 jboolean  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_is_ok"))) TS_CResult_SignedRawInvoiceParseErrorZ_is_ok(uint32_t o) {
17136         LDKCResult_SignedRawInvoiceParseErrorZ* o_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(o & ~1);
17137         jboolean ret_conv = CResult_SignedRawInvoiceParseErrorZ_is_ok(o_conv);
17138         return ret_conv;
17139 }
17140
17141 void  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_free"))) TS_CResult_SignedRawInvoiceParseErrorZ_free(uint32_t _res) {
17142         if ((_res & 1) != 0) return;
17143         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17144         CHECK_ACCESS(_res_ptr);
17145         LDKCResult_SignedRawInvoiceParseErrorZ _res_conv = *(LDKCResult_SignedRawInvoiceParseErrorZ*)(_res_ptr);
17146         FREE((void*)_res);
17147         CResult_SignedRawInvoiceParseErrorZ_free(_res_conv);
17148 }
17149
17150 static inline uintptr_t CResult_SignedRawInvoiceParseErrorZ_clone_ptr(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR arg) {
17151         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
17152         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone(arg);
17153         return (uint32_t)ret_conv;
17154 }
17155 uint32_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_clone_ptr"))) TS_CResult_SignedRawInvoiceParseErrorZ_clone_ptr(uint32_t arg) {
17156         LDKCResult_SignedRawInvoiceParseErrorZ* arg_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(arg & ~1);
17157         uint32_t ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone_ptr(arg_conv);
17158         return ret_conv;
17159 }
17160
17161 uint32_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_clone"))) TS_CResult_SignedRawInvoiceParseErrorZ_clone(uint32_t orig) {
17162         LDKCResult_SignedRawInvoiceParseErrorZ* orig_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(orig & ~1);
17163         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
17164         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone(orig_conv);
17165         return (uint32_t)ret_conv;
17166 }
17167
17168 static inline uintptr_t C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR arg) {
17169         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
17170         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(arg);
17171         return ((uint32_t)ret_conv);
17172 }
17173 uint32_t  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(uint32_t arg) {
17174         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* arg_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(arg & ~1);
17175         uint32_t ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(arg_conv);
17176         return ret_conv;
17177 }
17178
17179 uint32_t  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(uint32_t orig) {
17180         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* orig_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(orig & ~1);
17181         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
17182         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(orig_conv);
17183         return ((uint32_t)ret_conv);
17184 }
17185
17186 uint32_t  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_new"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(uint32_t a, int8_tArray b, uint32_t c) {
17187         LDKRawInvoice a_conv;
17188         a_conv.inner = (void*)(a & (~1));
17189         a_conv.is_owned = (a & 1) || (a == 0);
17190         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
17191         a_conv = RawInvoice_clone(&a_conv);
17192         LDKThirtyTwoBytes b_ref;
17193         CHECK(b->arr_len == 32);
17194         memcpy(b_ref.data, b->elems, 32); FREE(b);
17195         LDKInvoiceSignature c_conv;
17196         c_conv.inner = (void*)(c & (~1));
17197         c_conv.is_owned = (c & 1) || (c == 0);
17198         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
17199         c_conv = InvoiceSignature_clone(&c_conv);
17200         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
17201         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(a_conv, b_ref, c_conv);
17202         return ((uint32_t)ret_conv);
17203 }
17204
17205 void  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_free"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(uint32_t _res) {
17206         if ((_res & 1) != 0) return;
17207         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17208         CHECK_ACCESS(_res_ptr);
17209         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res_conv = *(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(_res_ptr);
17210         FREE((void*)_res);
17211         C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(_res_conv);
17212 }
17213
17214 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_ok"))) TS_CResult_PayeePubKeyErrorZ_ok(uint32_t o) {
17215         LDKPayeePubKey o_conv;
17216         o_conv.inner = (void*)(o & (~1));
17217         o_conv.is_owned = (o & 1) || (o == 0);
17218         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17219         o_conv = PayeePubKey_clone(&o_conv);
17220         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
17221         *ret_conv = CResult_PayeePubKeyErrorZ_ok(o_conv);
17222         return (uint32_t)ret_conv;
17223 }
17224
17225 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_err"))) TS_CResult_PayeePubKeyErrorZ_err(uint32_t e) {
17226         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
17227         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
17228         *ret_conv = CResult_PayeePubKeyErrorZ_err(e_conv);
17229         return (uint32_t)ret_conv;
17230 }
17231
17232 jboolean  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_is_ok"))) TS_CResult_PayeePubKeyErrorZ_is_ok(uint32_t o) {
17233         LDKCResult_PayeePubKeyErrorZ* o_conv = (LDKCResult_PayeePubKeyErrorZ*)(o & ~1);
17234         jboolean ret_conv = CResult_PayeePubKeyErrorZ_is_ok(o_conv);
17235         return ret_conv;
17236 }
17237
17238 void  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_free"))) TS_CResult_PayeePubKeyErrorZ_free(uint32_t _res) {
17239         if ((_res & 1) != 0) return;
17240         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17241         CHECK_ACCESS(_res_ptr);
17242         LDKCResult_PayeePubKeyErrorZ _res_conv = *(LDKCResult_PayeePubKeyErrorZ*)(_res_ptr);
17243         FREE((void*)_res);
17244         CResult_PayeePubKeyErrorZ_free(_res_conv);
17245 }
17246
17247 static inline uintptr_t CResult_PayeePubKeyErrorZ_clone_ptr(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR arg) {
17248         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
17249         *ret_conv = CResult_PayeePubKeyErrorZ_clone(arg);
17250         return (uint32_t)ret_conv;
17251 }
17252 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_clone_ptr"))) TS_CResult_PayeePubKeyErrorZ_clone_ptr(uint32_t arg) {
17253         LDKCResult_PayeePubKeyErrorZ* arg_conv = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
17254         uint32_t ret_conv = CResult_PayeePubKeyErrorZ_clone_ptr(arg_conv);
17255         return ret_conv;
17256 }
17257
17258 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_clone"))) TS_CResult_PayeePubKeyErrorZ_clone(uint32_t orig) {
17259         LDKCResult_PayeePubKeyErrorZ* orig_conv = (LDKCResult_PayeePubKeyErrorZ*)(orig & ~1);
17260         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
17261         *ret_conv = CResult_PayeePubKeyErrorZ_clone(orig_conv);
17262         return (uint32_t)ret_conv;
17263 }
17264
17265 void  __attribute__((export_name("TS_CVec_PrivateRouteZ_free"))) TS_CVec_PrivateRouteZ_free(uint32_tArray _res) {
17266         LDKCVec_PrivateRouteZ _res_constr;
17267         _res_constr.datalen = _res->arr_len;
17268         if (_res_constr.datalen > 0)
17269                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPrivateRoute), "LDKCVec_PrivateRouteZ Elements");
17270         else
17271                 _res_constr.data = NULL;
17272         uint32_t* _res_vals = _res->elems;
17273         for (size_t o = 0; o < _res_constr.datalen; o++) {
17274                 uint32_t _res_conv_14 = _res_vals[o];
17275                 LDKPrivateRoute _res_conv_14_conv;
17276                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
17277                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
17278                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
17279                 _res_constr.data[o] = _res_conv_14_conv;
17280         }
17281         FREE(_res);
17282         CVec_PrivateRouteZ_free(_res_constr);
17283 }
17284
17285 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_ok"))) TS_CResult_PositiveTimestampCreationErrorZ_ok(uint32_t o) {
17286         LDKPositiveTimestamp o_conv;
17287         o_conv.inner = (void*)(o & (~1));
17288         o_conv.is_owned = (o & 1) || (o == 0);
17289         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17290         o_conv = PositiveTimestamp_clone(&o_conv);
17291         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
17292         *ret_conv = CResult_PositiveTimestampCreationErrorZ_ok(o_conv);
17293         return (uint32_t)ret_conv;
17294 }
17295
17296 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_err"))) TS_CResult_PositiveTimestampCreationErrorZ_err(uint32_t e) {
17297         LDKCreationError e_conv = LDKCreationError_from_js(e);
17298         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
17299         *ret_conv = CResult_PositiveTimestampCreationErrorZ_err(e_conv);
17300         return (uint32_t)ret_conv;
17301 }
17302
17303 jboolean  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_is_ok"))) TS_CResult_PositiveTimestampCreationErrorZ_is_ok(uint32_t o) {
17304         LDKCResult_PositiveTimestampCreationErrorZ* o_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(o & ~1);
17305         jboolean ret_conv = CResult_PositiveTimestampCreationErrorZ_is_ok(o_conv);
17306         return ret_conv;
17307 }
17308
17309 void  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_free"))) TS_CResult_PositiveTimestampCreationErrorZ_free(uint32_t _res) {
17310         if ((_res & 1) != 0) return;
17311         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17312         CHECK_ACCESS(_res_ptr);
17313         LDKCResult_PositiveTimestampCreationErrorZ _res_conv = *(LDKCResult_PositiveTimestampCreationErrorZ*)(_res_ptr);
17314         FREE((void*)_res);
17315         CResult_PositiveTimestampCreationErrorZ_free(_res_conv);
17316 }
17317
17318 static inline uintptr_t CResult_PositiveTimestampCreationErrorZ_clone_ptr(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR arg) {
17319         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
17320         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(arg);
17321         return (uint32_t)ret_conv;
17322 }
17323 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_clone_ptr"))) TS_CResult_PositiveTimestampCreationErrorZ_clone_ptr(uint32_t arg) {
17324         LDKCResult_PositiveTimestampCreationErrorZ* arg_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
17325         uint32_t ret_conv = CResult_PositiveTimestampCreationErrorZ_clone_ptr(arg_conv);
17326         return ret_conv;
17327 }
17328
17329 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_clone"))) TS_CResult_PositiveTimestampCreationErrorZ_clone(uint32_t orig) {
17330         LDKCResult_PositiveTimestampCreationErrorZ* orig_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(orig & ~1);
17331         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
17332         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(orig_conv);
17333         return (uint32_t)ret_conv;
17334 }
17335
17336 uint32_t  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_ok"))) TS_CResult_NoneSemanticErrorZ_ok() {
17337         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
17338         *ret_conv = CResult_NoneSemanticErrorZ_ok();
17339         return (uint32_t)ret_conv;
17340 }
17341
17342 uint32_t  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_err"))) TS_CResult_NoneSemanticErrorZ_err(uint32_t e) {
17343         LDKSemanticError e_conv = LDKSemanticError_from_js(e);
17344         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
17345         *ret_conv = CResult_NoneSemanticErrorZ_err(e_conv);
17346         return (uint32_t)ret_conv;
17347 }
17348
17349 jboolean  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_is_ok"))) TS_CResult_NoneSemanticErrorZ_is_ok(uint32_t o) {
17350         LDKCResult_NoneSemanticErrorZ* o_conv = (LDKCResult_NoneSemanticErrorZ*)(o & ~1);
17351         jboolean ret_conv = CResult_NoneSemanticErrorZ_is_ok(o_conv);
17352         return ret_conv;
17353 }
17354
17355 void  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_free"))) TS_CResult_NoneSemanticErrorZ_free(uint32_t _res) {
17356         if ((_res & 1) != 0) return;
17357         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17358         CHECK_ACCESS(_res_ptr);
17359         LDKCResult_NoneSemanticErrorZ _res_conv = *(LDKCResult_NoneSemanticErrorZ*)(_res_ptr);
17360         FREE((void*)_res);
17361         CResult_NoneSemanticErrorZ_free(_res_conv);
17362 }
17363
17364 static inline uintptr_t CResult_NoneSemanticErrorZ_clone_ptr(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR arg) {
17365         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
17366         *ret_conv = CResult_NoneSemanticErrorZ_clone(arg);
17367         return (uint32_t)ret_conv;
17368 }
17369 uint32_t  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_clone_ptr"))) TS_CResult_NoneSemanticErrorZ_clone_ptr(uint32_t arg) {
17370         LDKCResult_NoneSemanticErrorZ* arg_conv = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
17371         uint32_t ret_conv = CResult_NoneSemanticErrorZ_clone_ptr(arg_conv);
17372         return ret_conv;
17373 }
17374
17375 uint32_t  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_clone"))) TS_CResult_NoneSemanticErrorZ_clone(uint32_t orig) {
17376         LDKCResult_NoneSemanticErrorZ* orig_conv = (LDKCResult_NoneSemanticErrorZ*)(orig & ~1);
17377         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
17378         *ret_conv = CResult_NoneSemanticErrorZ_clone(orig_conv);
17379         return (uint32_t)ret_conv;
17380 }
17381
17382 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_ok"))) TS_CResult_InvoiceSemanticErrorZ_ok(uint32_t o) {
17383         LDKInvoice o_conv;
17384         o_conv.inner = (void*)(o & (~1));
17385         o_conv.is_owned = (o & 1) || (o == 0);
17386         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17387         o_conv = Invoice_clone(&o_conv);
17388         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
17389         *ret_conv = CResult_InvoiceSemanticErrorZ_ok(o_conv);
17390         return (uint32_t)ret_conv;
17391 }
17392
17393 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_err"))) TS_CResult_InvoiceSemanticErrorZ_err(uint32_t e) {
17394         LDKSemanticError e_conv = LDKSemanticError_from_js(e);
17395         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
17396         *ret_conv = CResult_InvoiceSemanticErrorZ_err(e_conv);
17397         return (uint32_t)ret_conv;
17398 }
17399
17400 jboolean  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_is_ok"))) TS_CResult_InvoiceSemanticErrorZ_is_ok(uint32_t o) {
17401         LDKCResult_InvoiceSemanticErrorZ* o_conv = (LDKCResult_InvoiceSemanticErrorZ*)(o & ~1);
17402         jboolean ret_conv = CResult_InvoiceSemanticErrorZ_is_ok(o_conv);
17403         return ret_conv;
17404 }
17405
17406 void  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_free"))) TS_CResult_InvoiceSemanticErrorZ_free(uint32_t _res) {
17407         if ((_res & 1) != 0) return;
17408         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17409         CHECK_ACCESS(_res_ptr);
17410         LDKCResult_InvoiceSemanticErrorZ _res_conv = *(LDKCResult_InvoiceSemanticErrorZ*)(_res_ptr);
17411         FREE((void*)_res);
17412         CResult_InvoiceSemanticErrorZ_free(_res_conv);
17413 }
17414
17415 static inline uintptr_t CResult_InvoiceSemanticErrorZ_clone_ptr(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR arg) {
17416         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
17417         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(arg);
17418         return (uint32_t)ret_conv;
17419 }
17420 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_clone_ptr"))) TS_CResult_InvoiceSemanticErrorZ_clone_ptr(uint32_t arg) {
17421         LDKCResult_InvoiceSemanticErrorZ* arg_conv = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
17422         uint32_t ret_conv = CResult_InvoiceSemanticErrorZ_clone_ptr(arg_conv);
17423         return ret_conv;
17424 }
17425
17426 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_clone"))) TS_CResult_InvoiceSemanticErrorZ_clone(uint32_t orig) {
17427         LDKCResult_InvoiceSemanticErrorZ* orig_conv = (LDKCResult_InvoiceSemanticErrorZ*)(orig & ~1);
17428         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
17429         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(orig_conv);
17430         return (uint32_t)ret_conv;
17431 }
17432
17433 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_ok"))) TS_CResult_DescriptionCreationErrorZ_ok(uint32_t o) {
17434         LDKDescription o_conv;
17435         o_conv.inner = (void*)(o & (~1));
17436         o_conv.is_owned = (o & 1) || (o == 0);
17437         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17438         o_conv = Description_clone(&o_conv);
17439         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
17440         *ret_conv = CResult_DescriptionCreationErrorZ_ok(o_conv);
17441         return (uint32_t)ret_conv;
17442 }
17443
17444 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_err"))) TS_CResult_DescriptionCreationErrorZ_err(uint32_t e) {
17445         LDKCreationError e_conv = LDKCreationError_from_js(e);
17446         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
17447         *ret_conv = CResult_DescriptionCreationErrorZ_err(e_conv);
17448         return (uint32_t)ret_conv;
17449 }
17450
17451 jboolean  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_is_ok"))) TS_CResult_DescriptionCreationErrorZ_is_ok(uint32_t o) {
17452         LDKCResult_DescriptionCreationErrorZ* o_conv = (LDKCResult_DescriptionCreationErrorZ*)(o & ~1);
17453         jboolean ret_conv = CResult_DescriptionCreationErrorZ_is_ok(o_conv);
17454         return ret_conv;
17455 }
17456
17457 void  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_free"))) TS_CResult_DescriptionCreationErrorZ_free(uint32_t _res) {
17458         if ((_res & 1) != 0) return;
17459         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17460         CHECK_ACCESS(_res_ptr);
17461         LDKCResult_DescriptionCreationErrorZ _res_conv = *(LDKCResult_DescriptionCreationErrorZ*)(_res_ptr);
17462         FREE((void*)_res);
17463         CResult_DescriptionCreationErrorZ_free(_res_conv);
17464 }
17465
17466 static inline uintptr_t CResult_DescriptionCreationErrorZ_clone_ptr(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR arg) {
17467         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
17468         *ret_conv = CResult_DescriptionCreationErrorZ_clone(arg);
17469         return (uint32_t)ret_conv;
17470 }
17471 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_clone_ptr"))) TS_CResult_DescriptionCreationErrorZ_clone_ptr(uint32_t arg) {
17472         LDKCResult_DescriptionCreationErrorZ* arg_conv = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
17473         uint32_t ret_conv = CResult_DescriptionCreationErrorZ_clone_ptr(arg_conv);
17474         return ret_conv;
17475 }
17476
17477 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_clone"))) TS_CResult_DescriptionCreationErrorZ_clone(uint32_t orig) {
17478         LDKCResult_DescriptionCreationErrorZ* orig_conv = (LDKCResult_DescriptionCreationErrorZ*)(orig & ~1);
17479         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
17480         *ret_conv = CResult_DescriptionCreationErrorZ_clone(orig_conv);
17481         return (uint32_t)ret_conv;
17482 }
17483
17484 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_ok"))) TS_CResult_PrivateRouteCreationErrorZ_ok(uint32_t o) {
17485         LDKPrivateRoute o_conv;
17486         o_conv.inner = (void*)(o & (~1));
17487         o_conv.is_owned = (o & 1) || (o == 0);
17488         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17489         o_conv = PrivateRoute_clone(&o_conv);
17490         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
17491         *ret_conv = CResult_PrivateRouteCreationErrorZ_ok(o_conv);
17492         return (uint32_t)ret_conv;
17493 }
17494
17495 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_err"))) TS_CResult_PrivateRouteCreationErrorZ_err(uint32_t e) {
17496         LDKCreationError e_conv = LDKCreationError_from_js(e);
17497         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
17498         *ret_conv = CResult_PrivateRouteCreationErrorZ_err(e_conv);
17499         return (uint32_t)ret_conv;
17500 }
17501
17502 jboolean  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_is_ok"))) TS_CResult_PrivateRouteCreationErrorZ_is_ok(uint32_t o) {
17503         LDKCResult_PrivateRouteCreationErrorZ* o_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(o & ~1);
17504         jboolean ret_conv = CResult_PrivateRouteCreationErrorZ_is_ok(o_conv);
17505         return ret_conv;
17506 }
17507
17508 void  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_free"))) TS_CResult_PrivateRouteCreationErrorZ_free(uint32_t _res) {
17509         if ((_res & 1) != 0) return;
17510         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17511         CHECK_ACCESS(_res_ptr);
17512         LDKCResult_PrivateRouteCreationErrorZ _res_conv = *(LDKCResult_PrivateRouteCreationErrorZ*)(_res_ptr);
17513         FREE((void*)_res);
17514         CResult_PrivateRouteCreationErrorZ_free(_res_conv);
17515 }
17516
17517 static inline uintptr_t CResult_PrivateRouteCreationErrorZ_clone_ptr(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR arg) {
17518         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
17519         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(arg);
17520         return (uint32_t)ret_conv;
17521 }
17522 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_clone_ptr"))) TS_CResult_PrivateRouteCreationErrorZ_clone_ptr(uint32_t arg) {
17523         LDKCResult_PrivateRouteCreationErrorZ* arg_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
17524         uint32_t ret_conv = CResult_PrivateRouteCreationErrorZ_clone_ptr(arg_conv);
17525         return ret_conv;
17526 }
17527
17528 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_clone"))) TS_CResult_PrivateRouteCreationErrorZ_clone(uint32_t orig) {
17529         LDKCResult_PrivateRouteCreationErrorZ* orig_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(orig & ~1);
17530         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
17531         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(orig_conv);
17532         return (uint32_t)ret_conv;
17533 }
17534
17535 uint32_t  __attribute__((export_name("TS_CResult_StringErrorZ_ok"))) TS_CResult_StringErrorZ_ok(jstring o) {
17536         LDKStr o_conv = str_ref_to_owned_c(o);
17537         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
17538         *ret_conv = CResult_StringErrorZ_ok(o_conv);
17539         return (uint32_t)ret_conv;
17540 }
17541
17542 uint32_t  __attribute__((export_name("TS_CResult_StringErrorZ_err"))) TS_CResult_StringErrorZ_err(uint32_t e) {
17543         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
17544         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
17545         *ret_conv = CResult_StringErrorZ_err(e_conv);
17546         return (uint32_t)ret_conv;
17547 }
17548
17549 jboolean  __attribute__((export_name("TS_CResult_StringErrorZ_is_ok"))) TS_CResult_StringErrorZ_is_ok(uint32_t o) {
17550         LDKCResult_StringErrorZ* o_conv = (LDKCResult_StringErrorZ*)(o & ~1);
17551         jboolean ret_conv = CResult_StringErrorZ_is_ok(o_conv);
17552         return ret_conv;
17553 }
17554
17555 void  __attribute__((export_name("TS_CResult_StringErrorZ_free"))) TS_CResult_StringErrorZ_free(uint32_t _res) {
17556         if ((_res & 1) != 0) return;
17557         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17558         CHECK_ACCESS(_res_ptr);
17559         LDKCResult_StringErrorZ _res_conv = *(LDKCResult_StringErrorZ*)(_res_ptr);
17560         FREE((void*)_res);
17561         CResult_StringErrorZ_free(_res_conv);
17562 }
17563
17564 static inline uintptr_t CResult_StringErrorZ_clone_ptr(LDKCResult_StringErrorZ *NONNULL_PTR arg) {
17565         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
17566         *ret_conv = CResult_StringErrorZ_clone(arg);
17567         return (uint32_t)ret_conv;
17568 }
17569 uint32_t  __attribute__((export_name("TS_CResult_StringErrorZ_clone_ptr"))) TS_CResult_StringErrorZ_clone_ptr(uint32_t arg) {
17570         LDKCResult_StringErrorZ* arg_conv = (LDKCResult_StringErrorZ*)(arg & ~1);
17571         uint32_t ret_conv = CResult_StringErrorZ_clone_ptr(arg_conv);
17572         return ret_conv;
17573 }
17574
17575 uint32_t  __attribute__((export_name("TS_CResult_StringErrorZ_clone"))) TS_CResult_StringErrorZ_clone(uint32_t orig) {
17576         LDKCResult_StringErrorZ* orig_conv = (LDKCResult_StringErrorZ*)(orig & ~1);
17577         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
17578         *ret_conv = CResult_StringErrorZ_clone(orig_conv);
17579         return (uint32_t)ret_conv;
17580 }
17581
17582 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_ok"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_ok(uint32_t o) {
17583         LDKChannelMonitorUpdate o_conv;
17584         o_conv.inner = (void*)(o & (~1));
17585         o_conv.is_owned = (o & 1) || (o == 0);
17586         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17587         o_conv = ChannelMonitorUpdate_clone(&o_conv);
17588         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
17589         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
17590         return (uint32_t)ret_conv;
17591 }
17592
17593 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_err"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_err(uint32_t e) {
17594         LDKDecodeError e_conv;
17595         e_conv.inner = (void*)(e & (~1));
17596         e_conv.is_owned = (e & 1) || (e == 0);
17597         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17598         e_conv = DecodeError_clone(&e_conv);
17599         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
17600         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
17601         return (uint32_t)ret_conv;
17602 }
17603
17604 jboolean  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(uint32_t o) {
17605         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(o & ~1);
17606         jboolean ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(o_conv);
17607         return ret_conv;
17608 }
17609
17610 void  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_free"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_free(uint32_t _res) {
17611         if ((_res & 1) != 0) return;
17612         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17613         CHECK_ACCESS(_res_ptr);
17614         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(_res_ptr);
17615         FREE((void*)_res);
17616         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
17617 }
17618
17619 static inline uintptr_t CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR arg) {
17620         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
17621         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(arg);
17622         return (uint32_t)ret_conv;
17623 }
17624 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(uint32_t arg) {
17625         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
17626         uint32_t ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(arg_conv);
17627         return ret_conv;
17628 }
17629
17630 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone(uint32_t orig) {
17631         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(orig & ~1);
17632         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
17633         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
17634         return (uint32_t)ret_conv;
17635 }
17636
17637 uint32_t  __attribute__((export_name("TS_COption_MonitorEventZ_some"))) TS_COption_MonitorEventZ_some(uint32_t o) {
17638         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
17639         CHECK_ACCESS(o_ptr);
17640         LDKMonitorEvent o_conv = *(LDKMonitorEvent*)(o_ptr);
17641         o_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uintptr_t)o) & ~1));
17642         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
17643         *ret_copy = COption_MonitorEventZ_some(o_conv);
17644         uint32_t ret_ref = (uintptr_t)ret_copy;
17645         return ret_ref;
17646 }
17647
17648 uint32_t  __attribute__((export_name("TS_COption_MonitorEventZ_none"))) TS_COption_MonitorEventZ_none() {
17649         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
17650         *ret_copy = COption_MonitorEventZ_none();
17651         uint32_t ret_ref = (uintptr_t)ret_copy;
17652         return ret_ref;
17653 }
17654
17655 void  __attribute__((export_name("TS_COption_MonitorEventZ_free"))) TS_COption_MonitorEventZ_free(uint32_t _res) {
17656         if ((_res & 1) != 0) return;
17657         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17658         CHECK_ACCESS(_res_ptr);
17659         LDKCOption_MonitorEventZ _res_conv = *(LDKCOption_MonitorEventZ*)(_res_ptr);
17660         FREE((void*)_res);
17661         COption_MonitorEventZ_free(_res_conv);
17662 }
17663
17664 static inline uintptr_t COption_MonitorEventZ_clone_ptr(LDKCOption_MonitorEventZ *NONNULL_PTR arg) {
17665         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
17666         *ret_copy = COption_MonitorEventZ_clone(arg);
17667 uint32_t ret_ref = (uintptr_t)ret_copy;
17668         return ret_ref;
17669 }
17670 uint32_t  __attribute__((export_name("TS_COption_MonitorEventZ_clone_ptr"))) TS_COption_MonitorEventZ_clone_ptr(uint32_t arg) {
17671         LDKCOption_MonitorEventZ* arg_conv = (LDKCOption_MonitorEventZ*)arg;
17672         uint32_t ret_conv = COption_MonitorEventZ_clone_ptr(arg_conv);
17673         return ret_conv;
17674 }
17675
17676 uint32_t  __attribute__((export_name("TS_COption_MonitorEventZ_clone"))) TS_COption_MonitorEventZ_clone(uint32_t orig) {
17677         LDKCOption_MonitorEventZ* orig_conv = (LDKCOption_MonitorEventZ*)orig;
17678         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
17679         *ret_copy = COption_MonitorEventZ_clone(orig_conv);
17680         uint32_t ret_ref = (uintptr_t)ret_copy;
17681         return ret_ref;
17682 }
17683
17684 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_ok"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_ok(uint32_t o) {
17685         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
17686         CHECK_ACCESS(o_ptr);
17687         LDKCOption_MonitorEventZ o_conv = *(LDKCOption_MonitorEventZ*)(o_ptr);
17688         o_conv = COption_MonitorEventZ_clone((LDKCOption_MonitorEventZ*)(((uintptr_t)o) & ~1));
17689         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
17690         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_ok(o_conv);
17691         return (uint32_t)ret_conv;
17692 }
17693
17694 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_err"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_err(uint32_t e) {
17695         LDKDecodeError e_conv;
17696         e_conv.inner = (void*)(e & (~1));
17697         e_conv.is_owned = (e & 1) || (e == 0);
17698         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17699         e_conv = DecodeError_clone(&e_conv);
17700         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
17701         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_err(e_conv);
17702         return (uint32_t)ret_conv;
17703 }
17704
17705 jboolean  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_is_ok"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_is_ok(uint32_t o) {
17706         LDKCResult_COption_MonitorEventZDecodeErrorZ* o_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(o & ~1);
17707         jboolean ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_is_ok(o_conv);
17708         return ret_conv;
17709 }
17710
17711 void  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_free"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_free(uint32_t _res) {
17712         if ((_res & 1) != 0) return;
17713         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17714         CHECK_ACCESS(_res_ptr);
17715         LDKCResult_COption_MonitorEventZDecodeErrorZ _res_conv = *(LDKCResult_COption_MonitorEventZDecodeErrorZ*)(_res_ptr);
17716         FREE((void*)_res);
17717         CResult_COption_MonitorEventZDecodeErrorZ_free(_res_conv);
17718 }
17719
17720 static inline uintptr_t CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR arg) {
17721         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
17722         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(arg);
17723         return (uint32_t)ret_conv;
17724 }
17725 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(uint32_t arg) {
17726         LDKCResult_COption_MonitorEventZDecodeErrorZ* arg_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(arg & ~1);
17727         uint32_t ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(arg_conv);
17728         return ret_conv;
17729 }
17730
17731 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_clone"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_clone(uint32_t orig) {
17732         LDKCResult_COption_MonitorEventZDecodeErrorZ* orig_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(orig & ~1);
17733         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
17734         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(orig_conv);
17735         return (uint32_t)ret_conv;
17736 }
17737
17738 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_ok"))) TS_CResult_HTLCUpdateDecodeErrorZ_ok(uint32_t o) {
17739         LDKHTLCUpdate o_conv;
17740         o_conv.inner = (void*)(o & (~1));
17741         o_conv.is_owned = (o & 1) || (o == 0);
17742         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17743         o_conv = HTLCUpdate_clone(&o_conv);
17744         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
17745         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
17746         return (uint32_t)ret_conv;
17747 }
17748
17749 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_err"))) TS_CResult_HTLCUpdateDecodeErrorZ_err(uint32_t e) {
17750         LDKDecodeError e_conv;
17751         e_conv.inner = (void*)(e & (~1));
17752         e_conv.is_owned = (e & 1) || (e == 0);
17753         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17754         e_conv = DecodeError_clone(&e_conv);
17755         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
17756         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
17757         return (uint32_t)ret_conv;
17758 }
17759
17760 jboolean  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_is_ok"))) TS_CResult_HTLCUpdateDecodeErrorZ_is_ok(uint32_t o) {
17761         LDKCResult_HTLCUpdateDecodeErrorZ* o_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(o & ~1);
17762         jboolean ret_conv = CResult_HTLCUpdateDecodeErrorZ_is_ok(o_conv);
17763         return ret_conv;
17764 }
17765
17766 void  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_free"))) TS_CResult_HTLCUpdateDecodeErrorZ_free(uint32_t _res) {
17767         if ((_res & 1) != 0) return;
17768         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17769         CHECK_ACCESS(_res_ptr);
17770         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(_res_ptr);
17771         FREE((void*)_res);
17772         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
17773 }
17774
17775 static inline uintptr_t CResult_HTLCUpdateDecodeErrorZ_clone_ptr(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR arg) {
17776         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
17777         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(arg);
17778         return (uint32_t)ret_conv;
17779 }
17780 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_clone_ptr"))) TS_CResult_HTLCUpdateDecodeErrorZ_clone_ptr(uint32_t arg) {
17781         LDKCResult_HTLCUpdateDecodeErrorZ* arg_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
17782         uint32_t ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone_ptr(arg_conv);
17783         return ret_conv;
17784 }
17785
17786 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_clone"))) TS_CResult_HTLCUpdateDecodeErrorZ_clone(uint32_t orig) {
17787         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(orig & ~1);
17788         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
17789         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
17790         return (uint32_t)ret_conv;
17791 }
17792
17793 static inline uintptr_t C2Tuple_OutPointScriptZ_clone_ptr(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR arg) {
17794         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
17795         *ret_conv = C2Tuple_OutPointScriptZ_clone(arg);
17796         return ((uint32_t)ret_conv);
17797 }
17798 uint32_t  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_clone_ptr"))) TS_C2Tuple_OutPointScriptZ_clone_ptr(uint32_t arg) {
17799         LDKC2Tuple_OutPointScriptZ* arg_conv = (LDKC2Tuple_OutPointScriptZ*)(arg & ~1);
17800         uint32_t ret_conv = C2Tuple_OutPointScriptZ_clone_ptr(arg_conv);
17801         return ret_conv;
17802 }
17803
17804 uint32_t  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_clone"))) TS_C2Tuple_OutPointScriptZ_clone(uint32_t orig) {
17805         LDKC2Tuple_OutPointScriptZ* orig_conv = (LDKC2Tuple_OutPointScriptZ*)(orig & ~1);
17806         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
17807         *ret_conv = C2Tuple_OutPointScriptZ_clone(orig_conv);
17808         return ((uint32_t)ret_conv);
17809 }
17810
17811 uint32_t  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_new"))) TS_C2Tuple_OutPointScriptZ_new(uint32_t a, int8_tArray b) {
17812         LDKOutPoint a_conv;
17813         a_conv.inner = (void*)(a & (~1));
17814         a_conv.is_owned = (a & 1) || (a == 0);
17815         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
17816         a_conv = OutPoint_clone(&a_conv);
17817         LDKCVec_u8Z b_ref;
17818         b_ref.datalen = b->arr_len;
17819         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
17820         memcpy(b_ref.data, b->elems, b_ref.datalen); FREE(b);
17821         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
17822         *ret_conv = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
17823         return ((uint32_t)ret_conv);
17824 }
17825
17826 void  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_free"))) TS_C2Tuple_OutPointScriptZ_free(uint32_t _res) {
17827         if ((_res & 1) != 0) return;
17828         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17829         CHECK_ACCESS(_res_ptr);
17830         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(_res_ptr);
17831         FREE((void*)_res);
17832         C2Tuple_OutPointScriptZ_free(_res_conv);
17833 }
17834
17835 static inline uintptr_t C2Tuple_u32ScriptZ_clone_ptr(LDKC2Tuple_u32ScriptZ *NONNULL_PTR arg) {
17836         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
17837         *ret_conv = C2Tuple_u32ScriptZ_clone(arg);
17838         return ((uint32_t)ret_conv);
17839 }
17840 uint32_t  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_clone_ptr"))) TS_C2Tuple_u32ScriptZ_clone_ptr(uint32_t arg) {
17841         LDKC2Tuple_u32ScriptZ* arg_conv = (LDKC2Tuple_u32ScriptZ*)(arg & ~1);
17842         uint32_t ret_conv = C2Tuple_u32ScriptZ_clone_ptr(arg_conv);
17843         return ret_conv;
17844 }
17845
17846 uint32_t  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_clone"))) TS_C2Tuple_u32ScriptZ_clone(uint32_t orig) {
17847         LDKC2Tuple_u32ScriptZ* orig_conv = (LDKC2Tuple_u32ScriptZ*)(orig & ~1);
17848         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
17849         *ret_conv = C2Tuple_u32ScriptZ_clone(orig_conv);
17850         return ((uint32_t)ret_conv);
17851 }
17852
17853 uint32_t  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_new"))) TS_C2Tuple_u32ScriptZ_new(int32_t a, int8_tArray b) {
17854         LDKCVec_u8Z b_ref;
17855         b_ref.datalen = b->arr_len;
17856         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
17857         memcpy(b_ref.data, b->elems, b_ref.datalen); FREE(b);
17858         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
17859         *ret_conv = C2Tuple_u32ScriptZ_new(a, b_ref);
17860         return ((uint32_t)ret_conv);
17861 }
17862
17863 void  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_free"))) TS_C2Tuple_u32ScriptZ_free(uint32_t _res) {
17864         if ((_res & 1) != 0) return;
17865         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17866         CHECK_ACCESS(_res_ptr);
17867         LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_ptr);
17868         FREE((void*)_res);
17869         C2Tuple_u32ScriptZ_free(_res_conv);
17870 }
17871
17872 void  __attribute__((export_name("TS_CVec_C2Tuple_u32ScriptZZ_free"))) TS_CVec_C2Tuple_u32ScriptZZ_free(uint32_tArray _res) {
17873         LDKCVec_C2Tuple_u32ScriptZZ _res_constr;
17874         _res_constr.datalen = _res->arr_len;
17875         if (_res_constr.datalen > 0)
17876                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
17877         else
17878                 _res_constr.data = NULL;
17879         uint32_t* _res_vals = _res->elems;
17880         for (size_t v = 0; v < _res_constr.datalen; v++) {
17881                 uint32_t _res_conv_21 = _res_vals[v];
17882                 void* _res_conv_21_ptr = (void*)(((uintptr_t)_res_conv_21) & ~1);
17883                 CHECK_ACCESS(_res_conv_21_ptr);
17884                 LDKC2Tuple_u32ScriptZ _res_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_conv_21_ptr);
17885                 FREE((void*)_res_conv_21);
17886                 _res_constr.data[v] = _res_conv_21_conv;
17887         }
17888         FREE(_res);
17889         CVec_C2Tuple_u32ScriptZZ_free(_res_constr);
17890 }
17891
17892 static inline uintptr_t C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR arg) {
17893         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
17894         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(arg);
17895         return ((uint32_t)ret_conv);
17896 }
17897 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(uint32_t arg) {
17898         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(arg & ~1);
17899         uint32_t ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(arg_conv);
17900         return ret_conv;
17901 }
17902
17903 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(uint32_t orig) {
17904         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(orig & ~1);
17905         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
17906         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(orig_conv);
17907         return ((uint32_t)ret_conv);
17908 }
17909
17910 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(int8_tArray a, uint32_tArray b) {
17911         LDKThirtyTwoBytes a_ref;
17912         CHECK(a->arr_len == 32);
17913         memcpy(a_ref.data, a->elems, 32); FREE(a);
17914         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
17915         b_constr.datalen = b->arr_len;
17916         if (b_constr.datalen > 0)
17917                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
17918         else
17919                 b_constr.data = NULL;
17920         uint32_t* b_vals = b->elems;
17921         for (size_t v = 0; v < b_constr.datalen; v++) {
17922                 uint32_t b_conv_21 = b_vals[v];
17923                 void* b_conv_21_ptr = (void*)(((uintptr_t)b_conv_21) & ~1);
17924                 CHECK_ACCESS(b_conv_21_ptr);
17925                 LDKC2Tuple_u32ScriptZ b_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(b_conv_21_ptr);
17926                 b_conv_21_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uintptr_t)b_conv_21) & ~1));
17927                 b_constr.data[v] = b_conv_21_conv;
17928         }
17929         FREE(b);
17930         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
17931         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a_ref, b_constr);
17932         return ((uint32_t)ret_conv);
17933 }
17934
17935 void  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(uint32_t _res) {
17936         if ((_res & 1) != 0) return;
17937         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17938         CHECK_ACCESS(_res_ptr);
17939         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_ptr);
17940         FREE((void*)_res);
17941         C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
17942 }
17943
17944 void  __attribute__((export_name("TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free"))) TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(uint32_tArray _res) {
17945         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res_constr;
17946         _res_constr.datalen = _res->arr_len;
17947         if (_res_constr.datalen > 0)
17948                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Elements");
17949         else
17950                 _res_constr.data = NULL;
17951         uint32_t* _res_vals = _res->elems;
17952         for (size_t o = 0; o < _res_constr.datalen; o++) {
17953                 uint32_t _res_conv_40 = _res_vals[o];
17954                 void* _res_conv_40_ptr = (void*)(((uintptr_t)_res_conv_40) & ~1);
17955                 CHECK_ACCESS(_res_conv_40_ptr);
17956                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_40_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_conv_40_ptr);
17957                 FREE((void*)_res_conv_40);
17958                 _res_constr.data[o] = _res_conv_40_conv;
17959         }
17960         FREE(_res);
17961         CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res_constr);
17962 }
17963
17964 void  __attribute__((export_name("TS_CVec_EventZ_free"))) TS_CVec_EventZ_free(uint32_tArray _res) {
17965         LDKCVec_EventZ _res_constr;
17966         _res_constr.datalen = _res->arr_len;
17967         if (_res_constr.datalen > 0)
17968                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
17969         else
17970                 _res_constr.data = NULL;
17971         uint32_t* _res_vals = _res->elems;
17972         for (size_t h = 0; h < _res_constr.datalen; h++) {
17973                 uint32_t _res_conv_7 = _res_vals[h];
17974                 void* _res_conv_7_ptr = (void*)(((uintptr_t)_res_conv_7) & ~1);
17975                 CHECK_ACCESS(_res_conv_7_ptr);
17976                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(_res_conv_7_ptr);
17977                 FREE((void*)_res_conv_7);
17978                 _res_constr.data[h] = _res_conv_7_conv;
17979         }
17980         FREE(_res);
17981         CVec_EventZ_free(_res_constr);
17982 }
17983
17984 void  __attribute__((export_name("TS_CVec_TransactionZ_free"))) TS_CVec_TransactionZ_free(ptrArray _res) {
17985         LDKCVec_TransactionZ _res_constr;
17986         _res_constr.datalen = _res->arr_len;
17987         if (_res_constr.datalen > 0)
17988                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
17989         else
17990                 _res_constr.data = NULL;
17991         int8_tArray* _res_vals = (void*) _res->elems;
17992         for (size_t m = 0; m < _res_constr.datalen; m++) {
17993                 int8_tArray _res_conv_12 = _res_vals[m];
17994                 LDKTransaction _res_conv_12_ref;
17995                 _res_conv_12_ref.datalen = _res_conv_12->arr_len;
17996                 _res_conv_12_ref.data = MALLOC(_res_conv_12_ref.datalen, "LDKTransaction Bytes");
17997                 memcpy(_res_conv_12_ref.data, _res_conv_12->elems, _res_conv_12_ref.datalen); FREE(_res_conv_12);
17998                 _res_conv_12_ref.data_is_owned = true;
17999                 _res_constr.data[m] = _res_conv_12_ref;
18000         }
18001         FREE(_res);
18002         CVec_TransactionZ_free(_res_constr);
18003 }
18004
18005 static inline uintptr_t C2Tuple_u32TxOutZ_clone_ptr(LDKC2Tuple_u32TxOutZ *NONNULL_PTR arg) {
18006         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
18007         *ret_conv = C2Tuple_u32TxOutZ_clone(arg);
18008         return ((uint32_t)ret_conv);
18009 }
18010 uint32_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_clone_ptr"))) TS_C2Tuple_u32TxOutZ_clone_ptr(uint32_t arg) {
18011         LDKC2Tuple_u32TxOutZ* arg_conv = (LDKC2Tuple_u32TxOutZ*)(arg & ~1);
18012         uint32_t ret_conv = C2Tuple_u32TxOutZ_clone_ptr(arg_conv);
18013         return ret_conv;
18014 }
18015
18016 uint32_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_clone"))) TS_C2Tuple_u32TxOutZ_clone(uint32_t orig) {
18017         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)(orig & ~1);
18018         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
18019         *ret_conv = C2Tuple_u32TxOutZ_clone(orig_conv);
18020         return ((uint32_t)ret_conv);
18021 }
18022
18023 uint32_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_new"))) TS_C2Tuple_u32TxOutZ_new(int32_t a, uint32_t b) {
18024         void* b_ptr = (void*)(((uintptr_t)b) & ~1);
18025         CHECK_ACCESS(b_ptr);
18026         LDKTxOut b_conv = *(LDKTxOut*)(b_ptr);
18027         b_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)b) & ~1));
18028         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
18029         *ret_conv = C2Tuple_u32TxOutZ_new(a, b_conv);
18030         return ((uint32_t)ret_conv);
18031 }
18032
18033 void  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_free"))) TS_C2Tuple_u32TxOutZ_free(uint32_t _res) {
18034         if ((_res & 1) != 0) return;
18035         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18036         CHECK_ACCESS(_res_ptr);
18037         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_ptr);
18038         FREE((void*)_res);
18039         C2Tuple_u32TxOutZ_free(_res_conv);
18040 }
18041
18042 void  __attribute__((export_name("TS_CVec_C2Tuple_u32TxOutZZ_free"))) TS_CVec_C2Tuple_u32TxOutZZ_free(uint32_tArray _res) {
18043         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
18044         _res_constr.datalen = _res->arr_len;
18045         if (_res_constr.datalen > 0)
18046                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
18047         else
18048                 _res_constr.data = NULL;
18049         uint32_t* _res_vals = _res->elems;
18050         for (size_t u = 0; u < _res_constr.datalen; u++) {
18051                 uint32_t _res_conv_20 = _res_vals[u];
18052                 void* _res_conv_20_ptr = (void*)(((uintptr_t)_res_conv_20) & ~1);
18053                 CHECK_ACCESS(_res_conv_20_ptr);
18054                 LDKC2Tuple_u32TxOutZ _res_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_conv_20_ptr);
18055                 FREE((void*)_res_conv_20);
18056                 _res_constr.data[u] = _res_conv_20_conv;
18057         }
18058         FREE(_res);
18059         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
18060 }
18061
18062 static inline uintptr_t C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR arg) {
18063         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
18064         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(arg);
18065         return ((uint32_t)ret_conv);
18066 }
18067 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(uint32_t arg) {
18068         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(arg & ~1);
18069         uint32_t ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(arg_conv);
18070         return ret_conv;
18071 }
18072
18073 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(uint32_t orig) {
18074         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(orig & ~1);
18075         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
18076         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(orig_conv);
18077         return ((uint32_t)ret_conv);
18078 }
18079
18080 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(int8_tArray a, uint32_tArray b) {
18081         LDKThirtyTwoBytes a_ref;
18082         CHECK(a->arr_len == 32);
18083         memcpy(a_ref.data, a->elems, 32); FREE(a);
18084         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
18085         b_constr.datalen = b->arr_len;
18086         if (b_constr.datalen > 0)
18087                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
18088         else
18089                 b_constr.data = NULL;
18090         uint32_t* b_vals = b->elems;
18091         for (size_t u = 0; u < b_constr.datalen; u++) {
18092                 uint32_t b_conv_20 = b_vals[u];
18093                 void* b_conv_20_ptr = (void*)(((uintptr_t)b_conv_20) & ~1);
18094                 CHECK_ACCESS(b_conv_20_ptr);
18095                 LDKC2Tuple_u32TxOutZ b_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(b_conv_20_ptr);
18096                 b_conv_20_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uintptr_t)b_conv_20) & ~1));
18097                 b_constr.data[u] = b_conv_20_conv;
18098         }
18099         FREE(b);
18100         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
18101         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
18102         return ((uint32_t)ret_conv);
18103 }
18104
18105 void  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(uint32_t _res) {
18106         if ((_res & 1) != 0) return;
18107         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18108         CHECK_ACCESS(_res_ptr);
18109         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_ptr);
18110         FREE((void*)_res);
18111         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
18112 }
18113
18114 void  __attribute__((export_name("TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free"))) TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(uint32_tArray _res) {
18115         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
18116         _res_constr.datalen = _res->arr_len;
18117         if (_res_constr.datalen > 0)
18118                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
18119         else
18120                 _res_constr.data = NULL;
18121         uint32_t* _res_vals = _res->elems;
18122         for (size_t n = 0; n < _res_constr.datalen; n++) {
18123                 uint32_t _res_conv_39 = _res_vals[n];
18124                 void* _res_conv_39_ptr = (void*)(((uintptr_t)_res_conv_39) & ~1);
18125                 CHECK_ACCESS(_res_conv_39_ptr);
18126                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_39_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_conv_39_ptr);
18127                 FREE((void*)_res_conv_39);
18128                 _res_constr.data[n] = _res_conv_39_conv;
18129         }
18130         FREE(_res);
18131         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
18132 }
18133
18134 void  __attribute__((export_name("TS_CVec_BalanceZ_free"))) TS_CVec_BalanceZ_free(uint32_tArray _res) {
18135         LDKCVec_BalanceZ _res_constr;
18136         _res_constr.datalen = _res->arr_len;
18137         if (_res_constr.datalen > 0)
18138                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKBalance), "LDKCVec_BalanceZ Elements");
18139         else
18140                 _res_constr.data = NULL;
18141         uint32_t* _res_vals = _res->elems;
18142         for (size_t j = 0; j < _res_constr.datalen; j++) {
18143                 uint32_t _res_conv_9 = _res_vals[j];
18144                 void* _res_conv_9_ptr = (void*)(((uintptr_t)_res_conv_9) & ~1);
18145                 CHECK_ACCESS(_res_conv_9_ptr);
18146                 LDKBalance _res_conv_9_conv = *(LDKBalance*)(_res_conv_9_ptr);
18147                 FREE((void*)_res_conv_9);
18148                 _res_constr.data[j] = _res_conv_9_conv;
18149         }
18150         FREE(_res);
18151         CVec_BalanceZ_free(_res_constr);
18152 }
18153
18154 static inline uintptr_t C2Tuple_BlockHashChannelMonitorZ_clone_ptr(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR arg) {
18155         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
18156         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(arg);
18157         return ((uint32_t)ret_conv);
18158 }
18159 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_clone_ptr"))) TS_C2Tuple_BlockHashChannelMonitorZ_clone_ptr(uint32_t arg) {
18160         LDKC2Tuple_BlockHashChannelMonitorZ* arg_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(arg & ~1);
18161         uint32_t ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone_ptr(arg_conv);
18162         return ret_conv;
18163 }
18164
18165 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_clone"))) TS_C2Tuple_BlockHashChannelMonitorZ_clone(uint32_t orig) {
18166         LDKC2Tuple_BlockHashChannelMonitorZ* orig_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(orig & ~1);
18167         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
18168         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(orig_conv);
18169         return ((uint32_t)ret_conv);
18170 }
18171
18172 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_new"))) TS_C2Tuple_BlockHashChannelMonitorZ_new(int8_tArray a, uint32_t b) {
18173         LDKThirtyTwoBytes a_ref;
18174         CHECK(a->arr_len == 32);
18175         memcpy(a_ref.data, a->elems, 32); FREE(a);
18176         LDKChannelMonitor b_conv;
18177         b_conv.inner = (void*)(b & (~1));
18178         b_conv.is_owned = (b & 1) || (b == 0);
18179         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
18180         b_conv = ChannelMonitor_clone(&b_conv);
18181         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
18182         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
18183         return ((uint32_t)ret_conv);
18184 }
18185
18186 void  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_free"))) TS_C2Tuple_BlockHashChannelMonitorZ_free(uint32_t _res) {
18187         if ((_res & 1) != 0) return;
18188         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18189         CHECK_ACCESS(_res_ptr);
18190         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_ptr);
18191         FREE((void*)_res);
18192         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
18193 }
18194
18195 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(uint32_t o) {
18196         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
18197         CHECK_ACCESS(o_ptr);
18198         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_ptr);
18199         o_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uintptr_t)o) & ~1));
18200         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
18201         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
18202         return (uint32_t)ret_conv;
18203 }
18204
18205 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(uint32_t e) {
18206         LDKDecodeError e_conv;
18207         e_conv.inner = (void*)(e & (~1));
18208         e_conv.is_owned = (e & 1) || (e == 0);
18209         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18210         e_conv = DecodeError_clone(&e_conv);
18211         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
18212         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
18213         return (uint32_t)ret_conv;
18214 }
18215
18216 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok(uint32_t o) {
18217         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(o & ~1);
18218         jboolean ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok(o_conv);
18219         return ret_conv;
18220 }
18221
18222 void  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(uint32_t _res) {
18223         if ((_res & 1) != 0) return;
18224         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18225         CHECK_ACCESS(_res_ptr);
18226         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(_res_ptr);
18227         FREE((void*)_res);
18228         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
18229 }
18230
18231 static inline uintptr_t CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR arg) {
18232         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
18233         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(arg);
18234         return (uint32_t)ret_conv;
18235 }
18236 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(uint32_t arg) {
18237         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* arg_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
18238         uint32_t ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(arg_conv);
18239         return ret_conv;
18240 }
18241
18242 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(uint32_t orig) {
18243         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* orig_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(orig & ~1);
18244         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
18245         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(orig_conv);
18246         return (uint32_t)ret_conv;
18247 }
18248
18249 static inline uintptr_t C2Tuple_PublicKeyTypeZ_clone_ptr(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR arg) {
18250         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
18251         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(arg);
18252         return ((uint32_t)ret_conv);
18253 }
18254 uint32_t  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_clone_ptr"))) TS_C2Tuple_PublicKeyTypeZ_clone_ptr(uint32_t arg) {
18255         LDKC2Tuple_PublicKeyTypeZ* arg_conv = (LDKC2Tuple_PublicKeyTypeZ*)(arg & ~1);
18256         uint32_t ret_conv = C2Tuple_PublicKeyTypeZ_clone_ptr(arg_conv);
18257         return ret_conv;
18258 }
18259
18260 uint32_t  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_clone"))) TS_C2Tuple_PublicKeyTypeZ_clone(uint32_t orig) {
18261         LDKC2Tuple_PublicKeyTypeZ* orig_conv = (LDKC2Tuple_PublicKeyTypeZ*)(orig & ~1);
18262         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
18263         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(orig_conv);
18264         return ((uint32_t)ret_conv);
18265 }
18266
18267 uint32_t  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_new"))) TS_C2Tuple_PublicKeyTypeZ_new(int8_tArray a, uint32_t b) {
18268         LDKPublicKey a_ref;
18269         CHECK(a->arr_len == 33);
18270         memcpy(a_ref.compressed_form, a->elems, 33); FREE(a);
18271         void* b_ptr = (void*)(((uintptr_t)b) & ~1);
18272         CHECK_ACCESS(b_ptr);
18273         LDKType b_conv = *(LDKType*)(b_ptr);
18274         if (b_conv.free == LDKType_JCalls_free) {
18275                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
18276                 LDKType_JCalls_cloned(&b_conv);
18277         }
18278         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
18279         *ret_conv = C2Tuple_PublicKeyTypeZ_new(a_ref, b_conv);
18280         return ((uint32_t)ret_conv);
18281 }
18282
18283 void  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_free"))) TS_C2Tuple_PublicKeyTypeZ_free(uint32_t _res) {
18284         if ((_res & 1) != 0) return;
18285         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18286         CHECK_ACCESS(_res_ptr);
18287         LDKC2Tuple_PublicKeyTypeZ _res_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_ptr);
18288         FREE((void*)_res);
18289         C2Tuple_PublicKeyTypeZ_free(_res_conv);
18290 }
18291
18292 void  __attribute__((export_name("TS_CVec_C2Tuple_PublicKeyTypeZZ_free"))) TS_CVec_C2Tuple_PublicKeyTypeZZ_free(uint32_tArray _res) {
18293         LDKCVec_C2Tuple_PublicKeyTypeZZ _res_constr;
18294         _res_constr.datalen = _res->arr_len;
18295         if (_res_constr.datalen > 0)
18296                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
18297         else
18298                 _res_constr.data = NULL;
18299         uint32_t* _res_vals = _res->elems;
18300         for (size_t z = 0; z < _res_constr.datalen; z++) {
18301                 uint32_t _res_conv_25 = _res_vals[z];
18302                 void* _res_conv_25_ptr = (void*)(((uintptr_t)_res_conv_25) & ~1);
18303                 CHECK_ACCESS(_res_conv_25_ptr);
18304                 LDKC2Tuple_PublicKeyTypeZ _res_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_conv_25_ptr);
18305                 FREE((void*)_res_conv_25);
18306                 _res_constr.data[z] = _res_conv_25_conv;
18307         }
18308         FREE(_res);
18309         CVec_C2Tuple_PublicKeyTypeZZ_free(_res_constr);
18310 }
18311
18312 uint32_t  __attribute__((export_name("TS_COption_NetAddressZ_some"))) TS_COption_NetAddressZ_some(uint32_t o) {
18313         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
18314         CHECK_ACCESS(o_ptr);
18315         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
18316         o_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)o) & ~1));
18317         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
18318         *ret_copy = COption_NetAddressZ_some(o_conv);
18319         uint32_t ret_ref = (uintptr_t)ret_copy;
18320         return ret_ref;
18321 }
18322
18323 uint32_t  __attribute__((export_name("TS_COption_NetAddressZ_none"))) TS_COption_NetAddressZ_none() {
18324         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
18325         *ret_copy = COption_NetAddressZ_none();
18326         uint32_t ret_ref = (uintptr_t)ret_copy;
18327         return ret_ref;
18328 }
18329
18330 void  __attribute__((export_name("TS_COption_NetAddressZ_free"))) TS_COption_NetAddressZ_free(uint32_t _res) {
18331         if ((_res & 1) != 0) return;
18332         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18333         CHECK_ACCESS(_res_ptr);
18334         LDKCOption_NetAddressZ _res_conv = *(LDKCOption_NetAddressZ*)(_res_ptr);
18335         FREE((void*)_res);
18336         COption_NetAddressZ_free(_res_conv);
18337 }
18338
18339 static inline uintptr_t COption_NetAddressZ_clone_ptr(LDKCOption_NetAddressZ *NONNULL_PTR arg) {
18340         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
18341         *ret_copy = COption_NetAddressZ_clone(arg);
18342 uint32_t ret_ref = (uintptr_t)ret_copy;
18343         return ret_ref;
18344 }
18345 uint32_t  __attribute__((export_name("TS_COption_NetAddressZ_clone_ptr"))) TS_COption_NetAddressZ_clone_ptr(uint32_t arg) {
18346         LDKCOption_NetAddressZ* arg_conv = (LDKCOption_NetAddressZ*)arg;
18347         uint32_t ret_conv = COption_NetAddressZ_clone_ptr(arg_conv);
18348         return ret_conv;
18349 }
18350
18351 uint32_t  __attribute__((export_name("TS_COption_NetAddressZ_clone"))) TS_COption_NetAddressZ_clone(uint32_t orig) {
18352         LDKCOption_NetAddressZ* orig_conv = (LDKCOption_NetAddressZ*)orig;
18353         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
18354         *ret_copy = COption_NetAddressZ_clone(orig_conv);
18355         uint32_t ret_ref = (uintptr_t)ret_copy;
18356         return ret_ref;
18357 }
18358
18359 uint32_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_ok"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_ok(int8_tArray o) {
18360         LDKCVec_u8Z o_ref;
18361         o_ref.datalen = o->arr_len;
18362         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
18363         memcpy(o_ref.data, o->elems, o_ref.datalen); FREE(o);
18364         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
18365         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
18366         return (uint32_t)ret_conv;
18367 }
18368
18369 uint32_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_err"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_err(uint32_t e) {
18370         LDKPeerHandleError e_conv;
18371         e_conv.inner = (void*)(e & (~1));
18372         e_conv.is_owned = (e & 1) || (e == 0);
18373         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18374         e_conv = PeerHandleError_clone(&e_conv);
18375         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
18376         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
18377         return (uint32_t)ret_conv;
18378 }
18379
18380 jboolean  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_is_ok"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_is_ok(uint32_t o) {
18381         LDKCResult_CVec_u8ZPeerHandleErrorZ* o_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(o & ~1);
18382         jboolean ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_is_ok(o_conv);
18383         return ret_conv;
18384 }
18385
18386 void  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_free"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_free(uint32_t _res) {
18387         if ((_res & 1) != 0) return;
18388         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18389         CHECK_ACCESS(_res_ptr);
18390         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(_res_ptr);
18391         FREE((void*)_res);
18392         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
18393 }
18394
18395 static inline uintptr_t CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR arg) {
18396         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
18397         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(arg);
18398         return (uint32_t)ret_conv;
18399 }
18400 uint32_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(uint32_t arg) {
18401         LDKCResult_CVec_u8ZPeerHandleErrorZ* arg_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
18402         uint32_t ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(arg_conv);
18403         return ret_conv;
18404 }
18405
18406 uint32_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_clone"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_clone(uint32_t orig) {
18407         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(orig & ~1);
18408         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
18409         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
18410         return (uint32_t)ret_conv;
18411 }
18412
18413 uint32_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_ok"))) TS_CResult_NonePeerHandleErrorZ_ok() {
18414         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
18415         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
18416         return (uint32_t)ret_conv;
18417 }
18418
18419 uint32_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_err"))) TS_CResult_NonePeerHandleErrorZ_err(uint32_t e) {
18420         LDKPeerHandleError e_conv;
18421         e_conv.inner = (void*)(e & (~1));
18422         e_conv.is_owned = (e & 1) || (e == 0);
18423         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18424         e_conv = PeerHandleError_clone(&e_conv);
18425         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
18426         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
18427         return (uint32_t)ret_conv;
18428 }
18429
18430 jboolean  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_is_ok"))) TS_CResult_NonePeerHandleErrorZ_is_ok(uint32_t o) {
18431         LDKCResult_NonePeerHandleErrorZ* o_conv = (LDKCResult_NonePeerHandleErrorZ*)(o & ~1);
18432         jboolean ret_conv = CResult_NonePeerHandleErrorZ_is_ok(o_conv);
18433         return ret_conv;
18434 }
18435
18436 void  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_free"))) TS_CResult_NonePeerHandleErrorZ_free(uint32_t _res) {
18437         if ((_res & 1) != 0) return;
18438         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18439         CHECK_ACCESS(_res_ptr);
18440         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(_res_ptr);
18441         FREE((void*)_res);
18442         CResult_NonePeerHandleErrorZ_free(_res_conv);
18443 }
18444
18445 static inline uintptr_t CResult_NonePeerHandleErrorZ_clone_ptr(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR arg) {
18446         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
18447         *ret_conv = CResult_NonePeerHandleErrorZ_clone(arg);
18448         return (uint32_t)ret_conv;
18449 }
18450 uint32_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_clone_ptr"))) TS_CResult_NonePeerHandleErrorZ_clone_ptr(uint32_t arg) {
18451         LDKCResult_NonePeerHandleErrorZ* arg_conv = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
18452         uint32_t ret_conv = CResult_NonePeerHandleErrorZ_clone_ptr(arg_conv);
18453         return ret_conv;
18454 }
18455
18456 uint32_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_clone"))) TS_CResult_NonePeerHandleErrorZ_clone(uint32_t orig) {
18457         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)(orig & ~1);
18458         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
18459         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
18460         return (uint32_t)ret_conv;
18461 }
18462
18463 uint32_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_ok"))) TS_CResult_boolPeerHandleErrorZ_ok(jboolean o) {
18464         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
18465         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
18466         return (uint32_t)ret_conv;
18467 }
18468
18469 uint32_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_err"))) TS_CResult_boolPeerHandleErrorZ_err(uint32_t e) {
18470         LDKPeerHandleError e_conv;
18471         e_conv.inner = (void*)(e & (~1));
18472         e_conv.is_owned = (e & 1) || (e == 0);
18473         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18474         e_conv = PeerHandleError_clone(&e_conv);
18475         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
18476         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
18477         return (uint32_t)ret_conv;
18478 }
18479
18480 jboolean  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_is_ok"))) TS_CResult_boolPeerHandleErrorZ_is_ok(uint32_t o) {
18481         LDKCResult_boolPeerHandleErrorZ* o_conv = (LDKCResult_boolPeerHandleErrorZ*)(o & ~1);
18482         jboolean ret_conv = CResult_boolPeerHandleErrorZ_is_ok(o_conv);
18483         return ret_conv;
18484 }
18485
18486 void  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_free"))) TS_CResult_boolPeerHandleErrorZ_free(uint32_t _res) {
18487         if ((_res & 1) != 0) return;
18488         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18489         CHECK_ACCESS(_res_ptr);
18490         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(_res_ptr);
18491         FREE((void*)_res);
18492         CResult_boolPeerHandleErrorZ_free(_res_conv);
18493 }
18494
18495 static inline uintptr_t CResult_boolPeerHandleErrorZ_clone_ptr(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR arg) {
18496         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
18497         *ret_conv = CResult_boolPeerHandleErrorZ_clone(arg);
18498         return (uint32_t)ret_conv;
18499 }
18500 uint32_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_clone_ptr"))) TS_CResult_boolPeerHandleErrorZ_clone_ptr(uint32_t arg) {
18501         LDKCResult_boolPeerHandleErrorZ* arg_conv = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
18502         uint32_t ret_conv = CResult_boolPeerHandleErrorZ_clone_ptr(arg_conv);
18503         return ret_conv;
18504 }
18505
18506 uint32_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_clone"))) TS_CResult_boolPeerHandleErrorZ_clone(uint32_t orig) {
18507         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)(orig & ~1);
18508         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
18509         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
18510         return (uint32_t)ret_conv;
18511 }
18512
18513 uint32_t  __attribute__((export_name("TS_CResult_NoneErrorZ_ok"))) TS_CResult_NoneErrorZ_ok() {
18514         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
18515         *ret_conv = CResult_NoneErrorZ_ok();
18516         return (uint32_t)ret_conv;
18517 }
18518
18519 uint32_t  __attribute__((export_name("TS_CResult_NoneErrorZ_err"))) TS_CResult_NoneErrorZ_err(uint32_t e) {
18520         LDKIOError e_conv = LDKIOError_from_js(e);
18521         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
18522         *ret_conv = CResult_NoneErrorZ_err(e_conv);
18523         return (uint32_t)ret_conv;
18524 }
18525
18526 jboolean  __attribute__((export_name("TS_CResult_NoneErrorZ_is_ok"))) TS_CResult_NoneErrorZ_is_ok(uint32_t o) {
18527         LDKCResult_NoneErrorZ* o_conv = (LDKCResult_NoneErrorZ*)(o & ~1);
18528         jboolean ret_conv = CResult_NoneErrorZ_is_ok(o_conv);
18529         return ret_conv;
18530 }
18531
18532 void  __attribute__((export_name("TS_CResult_NoneErrorZ_free"))) TS_CResult_NoneErrorZ_free(uint32_t _res) {
18533         if ((_res & 1) != 0) return;
18534         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18535         CHECK_ACCESS(_res_ptr);
18536         LDKCResult_NoneErrorZ _res_conv = *(LDKCResult_NoneErrorZ*)(_res_ptr);
18537         FREE((void*)_res);
18538         CResult_NoneErrorZ_free(_res_conv);
18539 }
18540
18541 static inline uintptr_t CResult_NoneErrorZ_clone_ptr(LDKCResult_NoneErrorZ *NONNULL_PTR arg) {
18542         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
18543         *ret_conv = CResult_NoneErrorZ_clone(arg);
18544         return (uint32_t)ret_conv;
18545 }
18546 uint32_t  __attribute__((export_name("TS_CResult_NoneErrorZ_clone_ptr"))) TS_CResult_NoneErrorZ_clone_ptr(uint32_t arg) {
18547         LDKCResult_NoneErrorZ* arg_conv = (LDKCResult_NoneErrorZ*)(arg & ~1);
18548         uint32_t ret_conv = CResult_NoneErrorZ_clone_ptr(arg_conv);
18549         return ret_conv;
18550 }
18551
18552 uint32_t  __attribute__((export_name("TS_CResult_NoneErrorZ_clone"))) TS_CResult_NoneErrorZ_clone(uint32_t orig) {
18553         LDKCResult_NoneErrorZ* orig_conv = (LDKCResult_NoneErrorZ*)(orig & ~1);
18554         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
18555         *ret_conv = CResult_NoneErrorZ_clone(orig_conv);
18556         return (uint32_t)ret_conv;
18557 }
18558
18559 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_ok"))) TS_CResult_NetAddressDecodeErrorZ_ok(uint32_t o) {
18560         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
18561         CHECK_ACCESS(o_ptr);
18562         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
18563         o_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)o) & ~1));
18564         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
18565         *ret_conv = CResult_NetAddressDecodeErrorZ_ok(o_conv);
18566         return (uint32_t)ret_conv;
18567 }
18568
18569 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_err"))) TS_CResult_NetAddressDecodeErrorZ_err(uint32_t e) {
18570         LDKDecodeError e_conv;
18571         e_conv.inner = (void*)(e & (~1));
18572         e_conv.is_owned = (e & 1) || (e == 0);
18573         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18574         e_conv = DecodeError_clone(&e_conv);
18575         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
18576         *ret_conv = CResult_NetAddressDecodeErrorZ_err(e_conv);
18577         return (uint32_t)ret_conv;
18578 }
18579
18580 jboolean  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_is_ok"))) TS_CResult_NetAddressDecodeErrorZ_is_ok(uint32_t o) {
18581         LDKCResult_NetAddressDecodeErrorZ* o_conv = (LDKCResult_NetAddressDecodeErrorZ*)(o & ~1);
18582         jboolean ret_conv = CResult_NetAddressDecodeErrorZ_is_ok(o_conv);
18583         return ret_conv;
18584 }
18585
18586 void  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_free"))) TS_CResult_NetAddressDecodeErrorZ_free(uint32_t _res) {
18587         if ((_res & 1) != 0) return;
18588         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18589         CHECK_ACCESS(_res_ptr);
18590         LDKCResult_NetAddressDecodeErrorZ _res_conv = *(LDKCResult_NetAddressDecodeErrorZ*)(_res_ptr);
18591         FREE((void*)_res);
18592         CResult_NetAddressDecodeErrorZ_free(_res_conv);
18593 }
18594
18595 static inline uintptr_t CResult_NetAddressDecodeErrorZ_clone_ptr(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR arg) {
18596         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
18597         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(arg);
18598         return (uint32_t)ret_conv;
18599 }
18600 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_clone_ptr"))) TS_CResult_NetAddressDecodeErrorZ_clone_ptr(uint32_t arg) {
18601         LDKCResult_NetAddressDecodeErrorZ* arg_conv = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
18602         uint32_t ret_conv = CResult_NetAddressDecodeErrorZ_clone_ptr(arg_conv);
18603         return ret_conv;
18604 }
18605
18606 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_clone"))) TS_CResult_NetAddressDecodeErrorZ_clone(uint32_t orig) {
18607         LDKCResult_NetAddressDecodeErrorZ* orig_conv = (LDKCResult_NetAddressDecodeErrorZ*)(orig & ~1);
18608         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
18609         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(orig_conv);
18610         return (uint32_t)ret_conv;
18611 }
18612
18613 void  __attribute__((export_name("TS_CVec_UpdateAddHTLCZ_free"))) TS_CVec_UpdateAddHTLCZ_free(uint32_tArray _res) {
18614         LDKCVec_UpdateAddHTLCZ _res_constr;
18615         _res_constr.datalen = _res->arr_len;
18616         if (_res_constr.datalen > 0)
18617                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
18618         else
18619                 _res_constr.data = NULL;
18620         uint32_t* _res_vals = _res->elems;
18621         for (size_t p = 0; p < _res_constr.datalen; p++) {
18622                 uint32_t _res_conv_15 = _res_vals[p];
18623                 LDKUpdateAddHTLC _res_conv_15_conv;
18624                 _res_conv_15_conv.inner = (void*)(_res_conv_15 & (~1));
18625                 _res_conv_15_conv.is_owned = (_res_conv_15 & 1) || (_res_conv_15 == 0);
18626                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_15_conv);
18627                 _res_constr.data[p] = _res_conv_15_conv;
18628         }
18629         FREE(_res);
18630         CVec_UpdateAddHTLCZ_free(_res_constr);
18631 }
18632
18633 void  __attribute__((export_name("TS_CVec_UpdateFulfillHTLCZ_free"))) TS_CVec_UpdateFulfillHTLCZ_free(uint32_tArray _res) {
18634         LDKCVec_UpdateFulfillHTLCZ _res_constr;
18635         _res_constr.datalen = _res->arr_len;
18636         if (_res_constr.datalen > 0)
18637                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
18638         else
18639                 _res_constr.data = NULL;
18640         uint32_t* _res_vals = _res->elems;
18641         for (size_t t = 0; t < _res_constr.datalen; t++) {
18642                 uint32_t _res_conv_19 = _res_vals[t];
18643                 LDKUpdateFulfillHTLC _res_conv_19_conv;
18644                 _res_conv_19_conv.inner = (void*)(_res_conv_19 & (~1));
18645                 _res_conv_19_conv.is_owned = (_res_conv_19 & 1) || (_res_conv_19 == 0);
18646                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_19_conv);
18647                 _res_constr.data[t] = _res_conv_19_conv;
18648         }
18649         FREE(_res);
18650         CVec_UpdateFulfillHTLCZ_free(_res_constr);
18651 }
18652
18653 void  __attribute__((export_name("TS_CVec_UpdateFailHTLCZ_free"))) TS_CVec_UpdateFailHTLCZ_free(uint32_tArray _res) {
18654         LDKCVec_UpdateFailHTLCZ _res_constr;
18655         _res_constr.datalen = _res->arr_len;
18656         if (_res_constr.datalen > 0)
18657                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
18658         else
18659                 _res_constr.data = NULL;
18660         uint32_t* _res_vals = _res->elems;
18661         for (size_t q = 0; q < _res_constr.datalen; q++) {
18662                 uint32_t _res_conv_16 = _res_vals[q];
18663                 LDKUpdateFailHTLC _res_conv_16_conv;
18664                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
18665                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
18666                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
18667                 _res_constr.data[q] = _res_conv_16_conv;
18668         }
18669         FREE(_res);
18670         CVec_UpdateFailHTLCZ_free(_res_constr);
18671 }
18672
18673 void  __attribute__((export_name("TS_CVec_UpdateFailMalformedHTLCZ_free"))) TS_CVec_UpdateFailMalformedHTLCZ_free(uint32_tArray _res) {
18674         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
18675         _res_constr.datalen = _res->arr_len;
18676         if (_res_constr.datalen > 0)
18677                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
18678         else
18679                 _res_constr.data = NULL;
18680         uint32_t* _res_vals = _res->elems;
18681         for (size_t z = 0; z < _res_constr.datalen; z++) {
18682                 uint32_t _res_conv_25 = _res_vals[z];
18683                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
18684                 _res_conv_25_conv.inner = (void*)(_res_conv_25 & (~1));
18685                 _res_conv_25_conv.is_owned = (_res_conv_25 & 1) || (_res_conv_25 == 0);
18686                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_25_conv);
18687                 _res_constr.data[z] = _res_conv_25_conv;
18688         }
18689         FREE(_res);
18690         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
18691 }
18692
18693 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_ok"))) TS_CResult_AcceptChannelDecodeErrorZ_ok(uint32_t o) {
18694         LDKAcceptChannel o_conv;
18695         o_conv.inner = (void*)(o & (~1));
18696         o_conv.is_owned = (o & 1) || (o == 0);
18697         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18698         o_conv = AcceptChannel_clone(&o_conv);
18699         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
18700         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
18701         return (uint32_t)ret_conv;
18702 }
18703
18704 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_err"))) TS_CResult_AcceptChannelDecodeErrorZ_err(uint32_t e) {
18705         LDKDecodeError e_conv;
18706         e_conv.inner = (void*)(e & (~1));
18707         e_conv.is_owned = (e & 1) || (e == 0);
18708         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18709         e_conv = DecodeError_clone(&e_conv);
18710         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
18711         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
18712         return (uint32_t)ret_conv;
18713 }
18714
18715 jboolean  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_is_ok"))) TS_CResult_AcceptChannelDecodeErrorZ_is_ok(uint32_t o) {
18716         LDKCResult_AcceptChannelDecodeErrorZ* o_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(o & ~1);
18717         jboolean ret_conv = CResult_AcceptChannelDecodeErrorZ_is_ok(o_conv);
18718         return ret_conv;
18719 }
18720
18721 void  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_free"))) TS_CResult_AcceptChannelDecodeErrorZ_free(uint32_t _res) {
18722         if ((_res & 1) != 0) return;
18723         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18724         CHECK_ACCESS(_res_ptr);
18725         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(_res_ptr);
18726         FREE((void*)_res);
18727         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
18728 }
18729
18730 static inline uintptr_t CResult_AcceptChannelDecodeErrorZ_clone_ptr(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR arg) {
18731         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
18732         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(arg);
18733         return (uint32_t)ret_conv;
18734 }
18735 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_clone_ptr"))) TS_CResult_AcceptChannelDecodeErrorZ_clone_ptr(uint32_t arg) {
18736         LDKCResult_AcceptChannelDecodeErrorZ* arg_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
18737         uint32_t ret_conv = CResult_AcceptChannelDecodeErrorZ_clone_ptr(arg_conv);
18738         return ret_conv;
18739 }
18740
18741 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_clone"))) TS_CResult_AcceptChannelDecodeErrorZ_clone(uint32_t orig) {
18742         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(orig & ~1);
18743         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
18744         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
18745         return (uint32_t)ret_conv;
18746 }
18747
18748 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_ok"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_ok(uint32_t o) {
18749         LDKAnnouncementSignatures o_conv;
18750         o_conv.inner = (void*)(o & (~1));
18751         o_conv.is_owned = (o & 1) || (o == 0);
18752         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18753         o_conv = AnnouncementSignatures_clone(&o_conv);
18754         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
18755         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
18756         return (uint32_t)ret_conv;
18757 }
18758
18759 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_err"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_err(uint32_t e) {
18760         LDKDecodeError e_conv;
18761         e_conv.inner = (void*)(e & (~1));
18762         e_conv.is_owned = (e & 1) || (e == 0);
18763         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18764         e_conv = DecodeError_clone(&e_conv);
18765         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
18766         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
18767         return (uint32_t)ret_conv;
18768 }
18769
18770 jboolean  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_is_ok"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(uint32_t o) {
18771         LDKCResult_AnnouncementSignaturesDecodeErrorZ* o_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(o & ~1);
18772         jboolean ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(o_conv);
18773         return ret_conv;
18774 }
18775
18776 void  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_free"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_free(uint32_t _res) {
18777         if ((_res & 1) != 0) return;
18778         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18779         CHECK_ACCESS(_res_ptr);
18780         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(_res_ptr);
18781         FREE((void*)_res);
18782         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
18783 }
18784
18785 static inline uintptr_t CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR arg) {
18786         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
18787         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(arg);
18788         return (uint32_t)ret_conv;
18789 }
18790 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(uint32_t arg) {
18791         LDKCResult_AnnouncementSignaturesDecodeErrorZ* arg_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
18792         uint32_t ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(arg_conv);
18793         return ret_conv;
18794 }
18795
18796 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone(uint32_t orig) {
18797         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(orig & ~1);
18798         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
18799         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
18800         return (uint32_t)ret_conv;
18801 }
18802
18803 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_ok"))) TS_CResult_ChannelReestablishDecodeErrorZ_ok(uint32_t o) {
18804         LDKChannelReestablish o_conv;
18805         o_conv.inner = (void*)(o & (~1));
18806         o_conv.is_owned = (o & 1) || (o == 0);
18807         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18808         o_conv = ChannelReestablish_clone(&o_conv);
18809         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
18810         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
18811         return (uint32_t)ret_conv;
18812 }
18813
18814 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_err"))) TS_CResult_ChannelReestablishDecodeErrorZ_err(uint32_t e) {
18815         LDKDecodeError e_conv;
18816         e_conv.inner = (void*)(e & (~1));
18817         e_conv.is_owned = (e & 1) || (e == 0);
18818         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18819         e_conv = DecodeError_clone(&e_conv);
18820         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
18821         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
18822         return (uint32_t)ret_conv;
18823 }
18824
18825 jboolean  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_is_ok"))) TS_CResult_ChannelReestablishDecodeErrorZ_is_ok(uint32_t o) {
18826         LDKCResult_ChannelReestablishDecodeErrorZ* o_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(o & ~1);
18827         jboolean ret_conv = CResult_ChannelReestablishDecodeErrorZ_is_ok(o_conv);
18828         return ret_conv;
18829 }
18830
18831 void  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_free"))) TS_CResult_ChannelReestablishDecodeErrorZ_free(uint32_t _res) {
18832         if ((_res & 1) != 0) return;
18833         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18834         CHECK_ACCESS(_res_ptr);
18835         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(_res_ptr);
18836         FREE((void*)_res);
18837         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
18838 }
18839
18840 static inline uintptr_t CResult_ChannelReestablishDecodeErrorZ_clone_ptr(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR arg) {
18841         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
18842         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(arg);
18843         return (uint32_t)ret_conv;
18844 }
18845 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelReestablishDecodeErrorZ_clone_ptr(uint32_t arg) {
18846         LDKCResult_ChannelReestablishDecodeErrorZ* arg_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
18847         uint32_t ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone_ptr(arg_conv);
18848         return ret_conv;
18849 }
18850
18851 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_clone"))) TS_CResult_ChannelReestablishDecodeErrorZ_clone(uint32_t orig) {
18852         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(orig & ~1);
18853         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
18854         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
18855         return (uint32_t)ret_conv;
18856 }
18857
18858 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_ok"))) TS_CResult_ClosingSignedDecodeErrorZ_ok(uint32_t o) {
18859         LDKClosingSigned o_conv;
18860         o_conv.inner = (void*)(o & (~1));
18861         o_conv.is_owned = (o & 1) || (o == 0);
18862         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18863         o_conv = ClosingSigned_clone(&o_conv);
18864         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
18865         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
18866         return (uint32_t)ret_conv;
18867 }
18868
18869 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_err"))) TS_CResult_ClosingSignedDecodeErrorZ_err(uint32_t e) {
18870         LDKDecodeError e_conv;
18871         e_conv.inner = (void*)(e & (~1));
18872         e_conv.is_owned = (e & 1) || (e == 0);
18873         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18874         e_conv = DecodeError_clone(&e_conv);
18875         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
18876         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
18877         return (uint32_t)ret_conv;
18878 }
18879
18880 jboolean  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_is_ok"))) TS_CResult_ClosingSignedDecodeErrorZ_is_ok(uint32_t o) {
18881         LDKCResult_ClosingSignedDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(o & ~1);
18882         jboolean ret_conv = CResult_ClosingSignedDecodeErrorZ_is_ok(o_conv);
18883         return ret_conv;
18884 }
18885
18886 void  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_free"))) TS_CResult_ClosingSignedDecodeErrorZ_free(uint32_t _res) {
18887         if ((_res & 1) != 0) return;
18888         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18889         CHECK_ACCESS(_res_ptr);
18890         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(_res_ptr);
18891         FREE((void*)_res);
18892         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
18893 }
18894
18895 static inline uintptr_t CResult_ClosingSignedDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR arg) {
18896         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
18897         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(arg);
18898         return (uint32_t)ret_conv;
18899 }
18900 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_clone_ptr"))) TS_CResult_ClosingSignedDecodeErrorZ_clone_ptr(uint32_t arg) {
18901         LDKCResult_ClosingSignedDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
18902         uint32_t ret_conv = CResult_ClosingSignedDecodeErrorZ_clone_ptr(arg_conv);
18903         return ret_conv;
18904 }
18905
18906 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_clone"))) TS_CResult_ClosingSignedDecodeErrorZ_clone(uint32_t orig) {
18907         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(orig & ~1);
18908         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
18909         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
18910         return (uint32_t)ret_conv;
18911 }
18912
18913 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_ok"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(uint32_t o) {
18914         LDKClosingSignedFeeRange o_conv;
18915         o_conv.inner = (void*)(o & (~1));
18916         o_conv.is_owned = (o & 1) || (o == 0);
18917         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18918         o_conv = ClosingSignedFeeRange_clone(&o_conv);
18919         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
18920         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(o_conv);
18921         return (uint32_t)ret_conv;
18922 }
18923
18924 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_err"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_err(uint32_t e) {
18925         LDKDecodeError e_conv;
18926         e_conv.inner = (void*)(e & (~1));
18927         e_conv.is_owned = (e & 1) || (e == 0);
18928         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18929         e_conv = DecodeError_clone(&e_conv);
18930         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
18931         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_err(e_conv);
18932         return (uint32_t)ret_conv;
18933 }
18934
18935 jboolean  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(uint32_t o) {
18936         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(o & ~1);
18937         jboolean ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(o_conv);
18938         return ret_conv;
18939 }
18940
18941 void  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_free"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_free(uint32_t _res) {
18942         if ((_res & 1) != 0) return;
18943         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18944         CHECK_ACCESS(_res_ptr);
18945         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(_res_ptr);
18946         FREE((void*)_res);
18947         CResult_ClosingSignedFeeRangeDecodeErrorZ_free(_res_conv);
18948 }
18949
18950 static inline uintptr_t CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR arg) {
18951         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
18952         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(arg);
18953         return (uint32_t)ret_conv;
18954 }
18955 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(uint32_t arg) {
18956         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(arg & ~1);
18957         uint32_t ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(arg_conv);
18958         return ret_conv;
18959 }
18960
18961 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(uint32_t orig) {
18962         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(orig & ~1);
18963         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
18964         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(orig_conv);
18965         return (uint32_t)ret_conv;
18966 }
18967
18968 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_ok"))) TS_CResult_CommitmentSignedDecodeErrorZ_ok(uint32_t o) {
18969         LDKCommitmentSigned o_conv;
18970         o_conv.inner = (void*)(o & (~1));
18971         o_conv.is_owned = (o & 1) || (o == 0);
18972         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18973         o_conv = CommitmentSigned_clone(&o_conv);
18974         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
18975         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
18976         return (uint32_t)ret_conv;
18977 }
18978
18979 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_err"))) TS_CResult_CommitmentSignedDecodeErrorZ_err(uint32_t e) {
18980         LDKDecodeError e_conv;
18981         e_conv.inner = (void*)(e & (~1));
18982         e_conv.is_owned = (e & 1) || (e == 0);
18983         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18984         e_conv = DecodeError_clone(&e_conv);
18985         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
18986         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
18987         return (uint32_t)ret_conv;
18988 }
18989
18990 jboolean  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_is_ok"))) TS_CResult_CommitmentSignedDecodeErrorZ_is_ok(uint32_t o) {
18991         LDKCResult_CommitmentSignedDecodeErrorZ* o_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(o & ~1);
18992         jboolean ret_conv = CResult_CommitmentSignedDecodeErrorZ_is_ok(o_conv);
18993         return ret_conv;
18994 }
18995
18996 void  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_free"))) TS_CResult_CommitmentSignedDecodeErrorZ_free(uint32_t _res) {
18997         if ((_res & 1) != 0) return;
18998         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18999         CHECK_ACCESS(_res_ptr);
19000         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(_res_ptr);
19001         FREE((void*)_res);
19002         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
19003 }
19004
19005 static inline uintptr_t CResult_CommitmentSignedDecodeErrorZ_clone_ptr(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR arg) {
19006         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
19007         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(arg);
19008         return (uint32_t)ret_conv;
19009 }
19010 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_clone_ptr"))) TS_CResult_CommitmentSignedDecodeErrorZ_clone_ptr(uint32_t arg) {
19011         LDKCResult_CommitmentSignedDecodeErrorZ* arg_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
19012         uint32_t ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone_ptr(arg_conv);
19013         return ret_conv;
19014 }
19015
19016 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_clone"))) TS_CResult_CommitmentSignedDecodeErrorZ_clone(uint32_t orig) {
19017         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(orig & ~1);
19018         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
19019         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
19020         return (uint32_t)ret_conv;
19021 }
19022
19023 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_ok"))) TS_CResult_FundingCreatedDecodeErrorZ_ok(uint32_t o) {
19024         LDKFundingCreated o_conv;
19025         o_conv.inner = (void*)(o & (~1));
19026         o_conv.is_owned = (o & 1) || (o == 0);
19027         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19028         o_conv = FundingCreated_clone(&o_conv);
19029         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
19030         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
19031         return (uint32_t)ret_conv;
19032 }
19033
19034 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_err"))) TS_CResult_FundingCreatedDecodeErrorZ_err(uint32_t e) {
19035         LDKDecodeError e_conv;
19036         e_conv.inner = (void*)(e & (~1));
19037         e_conv.is_owned = (e & 1) || (e == 0);
19038         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19039         e_conv = DecodeError_clone(&e_conv);
19040         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
19041         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
19042         return (uint32_t)ret_conv;
19043 }
19044
19045 jboolean  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_is_ok"))) TS_CResult_FundingCreatedDecodeErrorZ_is_ok(uint32_t o) {
19046         LDKCResult_FundingCreatedDecodeErrorZ* o_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(o & ~1);
19047         jboolean ret_conv = CResult_FundingCreatedDecodeErrorZ_is_ok(o_conv);
19048         return ret_conv;
19049 }
19050
19051 void  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_free"))) TS_CResult_FundingCreatedDecodeErrorZ_free(uint32_t _res) {
19052         if ((_res & 1) != 0) return;
19053         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19054         CHECK_ACCESS(_res_ptr);
19055         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(_res_ptr);
19056         FREE((void*)_res);
19057         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
19058 }
19059
19060 static inline uintptr_t CResult_FundingCreatedDecodeErrorZ_clone_ptr(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR arg) {
19061         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
19062         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(arg);
19063         return (uint32_t)ret_conv;
19064 }
19065 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_clone_ptr"))) TS_CResult_FundingCreatedDecodeErrorZ_clone_ptr(uint32_t arg) {
19066         LDKCResult_FundingCreatedDecodeErrorZ* arg_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
19067         uint32_t ret_conv = CResult_FundingCreatedDecodeErrorZ_clone_ptr(arg_conv);
19068         return ret_conv;
19069 }
19070
19071 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_clone"))) TS_CResult_FundingCreatedDecodeErrorZ_clone(uint32_t orig) {
19072         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(orig & ~1);
19073         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
19074         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
19075         return (uint32_t)ret_conv;
19076 }
19077
19078 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_ok"))) TS_CResult_FundingSignedDecodeErrorZ_ok(uint32_t o) {
19079         LDKFundingSigned o_conv;
19080         o_conv.inner = (void*)(o & (~1));
19081         o_conv.is_owned = (o & 1) || (o == 0);
19082         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19083         o_conv = FundingSigned_clone(&o_conv);
19084         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
19085         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
19086         return (uint32_t)ret_conv;
19087 }
19088
19089 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_err"))) TS_CResult_FundingSignedDecodeErrorZ_err(uint32_t e) {
19090         LDKDecodeError e_conv;
19091         e_conv.inner = (void*)(e & (~1));
19092         e_conv.is_owned = (e & 1) || (e == 0);
19093         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19094         e_conv = DecodeError_clone(&e_conv);
19095         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
19096         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
19097         return (uint32_t)ret_conv;
19098 }
19099
19100 jboolean  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_is_ok"))) TS_CResult_FundingSignedDecodeErrorZ_is_ok(uint32_t o) {
19101         LDKCResult_FundingSignedDecodeErrorZ* o_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(o & ~1);
19102         jboolean ret_conv = CResult_FundingSignedDecodeErrorZ_is_ok(o_conv);
19103         return ret_conv;
19104 }
19105
19106 void  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_free"))) TS_CResult_FundingSignedDecodeErrorZ_free(uint32_t _res) {
19107         if ((_res & 1) != 0) return;
19108         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19109         CHECK_ACCESS(_res_ptr);
19110         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(_res_ptr);
19111         FREE((void*)_res);
19112         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
19113 }
19114
19115 static inline uintptr_t CResult_FundingSignedDecodeErrorZ_clone_ptr(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR arg) {
19116         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
19117         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(arg);
19118         return (uint32_t)ret_conv;
19119 }
19120 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_clone_ptr"))) TS_CResult_FundingSignedDecodeErrorZ_clone_ptr(uint32_t arg) {
19121         LDKCResult_FundingSignedDecodeErrorZ* arg_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
19122         uint32_t ret_conv = CResult_FundingSignedDecodeErrorZ_clone_ptr(arg_conv);
19123         return ret_conv;
19124 }
19125
19126 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_clone"))) TS_CResult_FundingSignedDecodeErrorZ_clone(uint32_t orig) {
19127         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(orig & ~1);
19128         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
19129         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
19130         return (uint32_t)ret_conv;
19131 }
19132
19133 uint32_t  __attribute__((export_name("TS_CResult_ChannelReadyDecodeErrorZ_ok"))) TS_CResult_ChannelReadyDecodeErrorZ_ok(uint32_t o) {
19134         LDKChannelReady o_conv;
19135         o_conv.inner = (void*)(o & (~1));
19136         o_conv.is_owned = (o & 1) || (o == 0);
19137         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19138         o_conv = ChannelReady_clone(&o_conv);
19139         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
19140         *ret_conv = CResult_ChannelReadyDecodeErrorZ_ok(o_conv);
19141         return (uint32_t)ret_conv;
19142 }
19143
19144 uint32_t  __attribute__((export_name("TS_CResult_ChannelReadyDecodeErrorZ_err"))) TS_CResult_ChannelReadyDecodeErrorZ_err(uint32_t e) {
19145         LDKDecodeError e_conv;
19146         e_conv.inner = (void*)(e & (~1));
19147         e_conv.is_owned = (e & 1) || (e == 0);
19148         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19149         e_conv = DecodeError_clone(&e_conv);
19150         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
19151         *ret_conv = CResult_ChannelReadyDecodeErrorZ_err(e_conv);
19152         return (uint32_t)ret_conv;
19153 }
19154
19155 jboolean  __attribute__((export_name("TS_CResult_ChannelReadyDecodeErrorZ_is_ok"))) TS_CResult_ChannelReadyDecodeErrorZ_is_ok(uint32_t o) {
19156         LDKCResult_ChannelReadyDecodeErrorZ* o_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)(o & ~1);
19157         jboolean ret_conv = CResult_ChannelReadyDecodeErrorZ_is_ok(o_conv);
19158         return ret_conv;
19159 }
19160
19161 void  __attribute__((export_name("TS_CResult_ChannelReadyDecodeErrorZ_free"))) TS_CResult_ChannelReadyDecodeErrorZ_free(uint32_t _res) {
19162         if ((_res & 1) != 0) return;
19163         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19164         CHECK_ACCESS(_res_ptr);
19165         LDKCResult_ChannelReadyDecodeErrorZ _res_conv = *(LDKCResult_ChannelReadyDecodeErrorZ*)(_res_ptr);
19166         FREE((void*)_res);
19167         CResult_ChannelReadyDecodeErrorZ_free(_res_conv);
19168 }
19169
19170 static inline uintptr_t CResult_ChannelReadyDecodeErrorZ_clone_ptr(LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR arg) {
19171         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
19172         *ret_conv = CResult_ChannelReadyDecodeErrorZ_clone(arg);
19173         return (uint32_t)ret_conv;
19174 }
19175 uint32_t  __attribute__((export_name("TS_CResult_ChannelReadyDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelReadyDecodeErrorZ_clone_ptr(uint32_t arg) {
19176         LDKCResult_ChannelReadyDecodeErrorZ* arg_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)(arg & ~1);
19177         uint32_t ret_conv = CResult_ChannelReadyDecodeErrorZ_clone_ptr(arg_conv);
19178         return ret_conv;
19179 }
19180
19181 uint32_t  __attribute__((export_name("TS_CResult_ChannelReadyDecodeErrorZ_clone"))) TS_CResult_ChannelReadyDecodeErrorZ_clone(uint32_t orig) {
19182         LDKCResult_ChannelReadyDecodeErrorZ* orig_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)(orig & ~1);
19183         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
19184         *ret_conv = CResult_ChannelReadyDecodeErrorZ_clone(orig_conv);
19185         return (uint32_t)ret_conv;
19186 }
19187
19188 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_ok"))) TS_CResult_InitDecodeErrorZ_ok(uint32_t o) {
19189         LDKInit o_conv;
19190         o_conv.inner = (void*)(o & (~1));
19191         o_conv.is_owned = (o & 1) || (o == 0);
19192         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19193         o_conv = Init_clone(&o_conv);
19194         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
19195         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
19196         return (uint32_t)ret_conv;
19197 }
19198
19199 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_err"))) TS_CResult_InitDecodeErrorZ_err(uint32_t e) {
19200         LDKDecodeError e_conv;
19201         e_conv.inner = (void*)(e & (~1));
19202         e_conv.is_owned = (e & 1) || (e == 0);
19203         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19204         e_conv = DecodeError_clone(&e_conv);
19205         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
19206         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
19207         return (uint32_t)ret_conv;
19208 }
19209
19210 jboolean  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_is_ok"))) TS_CResult_InitDecodeErrorZ_is_ok(uint32_t o) {
19211         LDKCResult_InitDecodeErrorZ* o_conv = (LDKCResult_InitDecodeErrorZ*)(o & ~1);
19212         jboolean ret_conv = CResult_InitDecodeErrorZ_is_ok(o_conv);
19213         return ret_conv;
19214 }
19215
19216 void  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_free"))) TS_CResult_InitDecodeErrorZ_free(uint32_t _res) {
19217         if ((_res & 1) != 0) return;
19218         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19219         CHECK_ACCESS(_res_ptr);
19220         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(_res_ptr);
19221         FREE((void*)_res);
19222         CResult_InitDecodeErrorZ_free(_res_conv);
19223 }
19224
19225 static inline uintptr_t CResult_InitDecodeErrorZ_clone_ptr(LDKCResult_InitDecodeErrorZ *NONNULL_PTR arg) {
19226         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
19227         *ret_conv = CResult_InitDecodeErrorZ_clone(arg);
19228         return (uint32_t)ret_conv;
19229 }
19230 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_clone_ptr"))) TS_CResult_InitDecodeErrorZ_clone_ptr(uint32_t arg) {
19231         LDKCResult_InitDecodeErrorZ* arg_conv = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
19232         uint32_t ret_conv = CResult_InitDecodeErrorZ_clone_ptr(arg_conv);
19233         return ret_conv;
19234 }
19235
19236 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_clone"))) TS_CResult_InitDecodeErrorZ_clone(uint32_t orig) {
19237         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)(orig & ~1);
19238         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
19239         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
19240         return (uint32_t)ret_conv;
19241 }
19242
19243 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_ok"))) TS_CResult_OpenChannelDecodeErrorZ_ok(uint32_t o) {
19244         LDKOpenChannel o_conv;
19245         o_conv.inner = (void*)(o & (~1));
19246         o_conv.is_owned = (o & 1) || (o == 0);
19247         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19248         o_conv = OpenChannel_clone(&o_conv);
19249         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
19250         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
19251         return (uint32_t)ret_conv;
19252 }
19253
19254 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_err"))) TS_CResult_OpenChannelDecodeErrorZ_err(uint32_t e) {
19255         LDKDecodeError e_conv;
19256         e_conv.inner = (void*)(e & (~1));
19257         e_conv.is_owned = (e & 1) || (e == 0);
19258         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19259         e_conv = DecodeError_clone(&e_conv);
19260         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
19261         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
19262         return (uint32_t)ret_conv;
19263 }
19264
19265 jboolean  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_is_ok"))) TS_CResult_OpenChannelDecodeErrorZ_is_ok(uint32_t o) {
19266         LDKCResult_OpenChannelDecodeErrorZ* o_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(o & ~1);
19267         jboolean ret_conv = CResult_OpenChannelDecodeErrorZ_is_ok(o_conv);
19268         return ret_conv;
19269 }
19270
19271 void  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_free"))) TS_CResult_OpenChannelDecodeErrorZ_free(uint32_t _res) {
19272         if ((_res & 1) != 0) return;
19273         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19274         CHECK_ACCESS(_res_ptr);
19275         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(_res_ptr);
19276         FREE((void*)_res);
19277         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
19278 }
19279
19280 static inline uintptr_t CResult_OpenChannelDecodeErrorZ_clone_ptr(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR arg) {
19281         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
19282         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(arg);
19283         return (uint32_t)ret_conv;
19284 }
19285 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_clone_ptr"))) TS_CResult_OpenChannelDecodeErrorZ_clone_ptr(uint32_t arg) {
19286         LDKCResult_OpenChannelDecodeErrorZ* arg_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
19287         uint32_t ret_conv = CResult_OpenChannelDecodeErrorZ_clone_ptr(arg_conv);
19288         return ret_conv;
19289 }
19290
19291 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_clone"))) TS_CResult_OpenChannelDecodeErrorZ_clone(uint32_t orig) {
19292         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(orig & ~1);
19293         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
19294         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
19295         return (uint32_t)ret_conv;
19296 }
19297
19298 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_ok"))) TS_CResult_RevokeAndACKDecodeErrorZ_ok(uint32_t o) {
19299         LDKRevokeAndACK o_conv;
19300         o_conv.inner = (void*)(o & (~1));
19301         o_conv.is_owned = (o & 1) || (o == 0);
19302         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19303         o_conv = RevokeAndACK_clone(&o_conv);
19304         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
19305         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
19306         return (uint32_t)ret_conv;
19307 }
19308
19309 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_err"))) TS_CResult_RevokeAndACKDecodeErrorZ_err(uint32_t e) {
19310         LDKDecodeError e_conv;
19311         e_conv.inner = (void*)(e & (~1));
19312         e_conv.is_owned = (e & 1) || (e == 0);
19313         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19314         e_conv = DecodeError_clone(&e_conv);
19315         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
19316         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
19317         return (uint32_t)ret_conv;
19318 }
19319
19320 jboolean  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_is_ok"))) TS_CResult_RevokeAndACKDecodeErrorZ_is_ok(uint32_t o) {
19321         LDKCResult_RevokeAndACKDecodeErrorZ* o_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(o & ~1);
19322         jboolean ret_conv = CResult_RevokeAndACKDecodeErrorZ_is_ok(o_conv);
19323         return ret_conv;
19324 }
19325
19326 void  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_free"))) TS_CResult_RevokeAndACKDecodeErrorZ_free(uint32_t _res) {
19327         if ((_res & 1) != 0) return;
19328         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19329         CHECK_ACCESS(_res_ptr);
19330         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(_res_ptr);
19331         FREE((void*)_res);
19332         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
19333 }
19334
19335 static inline uintptr_t CResult_RevokeAndACKDecodeErrorZ_clone_ptr(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR arg) {
19336         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
19337         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(arg);
19338         return (uint32_t)ret_conv;
19339 }
19340 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_clone_ptr"))) TS_CResult_RevokeAndACKDecodeErrorZ_clone_ptr(uint32_t arg) {
19341         LDKCResult_RevokeAndACKDecodeErrorZ* arg_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
19342         uint32_t ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone_ptr(arg_conv);
19343         return ret_conv;
19344 }
19345
19346 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_clone"))) TS_CResult_RevokeAndACKDecodeErrorZ_clone(uint32_t orig) {
19347         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(orig & ~1);
19348         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
19349         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
19350         return (uint32_t)ret_conv;
19351 }
19352
19353 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_ok"))) TS_CResult_ShutdownDecodeErrorZ_ok(uint32_t o) {
19354         LDKShutdown o_conv;
19355         o_conv.inner = (void*)(o & (~1));
19356         o_conv.is_owned = (o & 1) || (o == 0);
19357         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19358         o_conv = Shutdown_clone(&o_conv);
19359         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
19360         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
19361         return (uint32_t)ret_conv;
19362 }
19363
19364 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_err"))) TS_CResult_ShutdownDecodeErrorZ_err(uint32_t e) {
19365         LDKDecodeError e_conv;
19366         e_conv.inner = (void*)(e & (~1));
19367         e_conv.is_owned = (e & 1) || (e == 0);
19368         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19369         e_conv = DecodeError_clone(&e_conv);
19370         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
19371         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
19372         return (uint32_t)ret_conv;
19373 }
19374
19375 jboolean  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_is_ok"))) TS_CResult_ShutdownDecodeErrorZ_is_ok(uint32_t o) {
19376         LDKCResult_ShutdownDecodeErrorZ* o_conv = (LDKCResult_ShutdownDecodeErrorZ*)(o & ~1);
19377         jboolean ret_conv = CResult_ShutdownDecodeErrorZ_is_ok(o_conv);
19378         return ret_conv;
19379 }
19380
19381 void  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_free"))) TS_CResult_ShutdownDecodeErrorZ_free(uint32_t _res) {
19382         if ((_res & 1) != 0) return;
19383         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19384         CHECK_ACCESS(_res_ptr);
19385         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(_res_ptr);
19386         FREE((void*)_res);
19387         CResult_ShutdownDecodeErrorZ_free(_res_conv);
19388 }
19389
19390 static inline uintptr_t CResult_ShutdownDecodeErrorZ_clone_ptr(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR arg) {
19391         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
19392         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(arg);
19393         return (uint32_t)ret_conv;
19394 }
19395 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_clone_ptr"))) TS_CResult_ShutdownDecodeErrorZ_clone_ptr(uint32_t arg) {
19396         LDKCResult_ShutdownDecodeErrorZ* arg_conv = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
19397         uint32_t ret_conv = CResult_ShutdownDecodeErrorZ_clone_ptr(arg_conv);
19398         return ret_conv;
19399 }
19400
19401 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_clone"))) TS_CResult_ShutdownDecodeErrorZ_clone(uint32_t orig) {
19402         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)(orig & ~1);
19403         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
19404         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
19405         return (uint32_t)ret_conv;
19406 }
19407
19408 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_ok"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_ok(uint32_t o) {
19409         LDKUpdateFailHTLC o_conv;
19410         o_conv.inner = (void*)(o & (~1));
19411         o_conv.is_owned = (o & 1) || (o == 0);
19412         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19413         o_conv = UpdateFailHTLC_clone(&o_conv);
19414         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
19415         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
19416         return (uint32_t)ret_conv;
19417 }
19418
19419 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_err"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_err(uint32_t e) {
19420         LDKDecodeError e_conv;
19421         e_conv.inner = (void*)(e & (~1));
19422         e_conv.is_owned = (e & 1) || (e == 0);
19423         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19424         e_conv = DecodeError_clone(&e_conv);
19425         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
19426         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
19427         return (uint32_t)ret_conv;
19428 }
19429
19430 jboolean  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_is_ok"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_is_ok(uint32_t o) {
19431         LDKCResult_UpdateFailHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(o & ~1);
19432         jboolean ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_is_ok(o_conv);
19433         return ret_conv;
19434 }
19435
19436 void  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_free"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_free(uint32_t _res) {
19437         if ((_res & 1) != 0) return;
19438         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19439         CHECK_ACCESS(_res_ptr);
19440         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(_res_ptr);
19441         FREE((void*)_res);
19442         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
19443 }
19444
19445 static inline uintptr_t CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR arg) {
19446         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
19447         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(arg);
19448         return (uint32_t)ret_conv;
19449 }
19450 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(uint32_t arg) {
19451         LDKCResult_UpdateFailHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
19452         uint32_t ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(arg_conv);
19453         return ret_conv;
19454 }
19455
19456 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_clone"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_clone(uint32_t orig) {
19457         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(orig & ~1);
19458         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
19459         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
19460         return (uint32_t)ret_conv;
19461 }
19462
19463 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(uint32_t o) {
19464         LDKUpdateFailMalformedHTLC o_conv;
19465         o_conv.inner = (void*)(o & (~1));
19466         o_conv.is_owned = (o & 1) || (o == 0);
19467         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19468         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
19469         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
19470         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
19471         return (uint32_t)ret_conv;
19472 }
19473
19474 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_err"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(uint32_t e) {
19475         LDKDecodeError e_conv;
19476         e_conv.inner = (void*)(e & (~1));
19477         e_conv.is_owned = (e & 1) || (e == 0);
19478         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19479         e_conv = DecodeError_clone(&e_conv);
19480         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
19481         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
19482         return (uint32_t)ret_conv;
19483 }
19484
19485 jboolean  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(uint32_t o) {
19486         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(o & ~1);
19487         jboolean ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(o_conv);
19488         return ret_conv;
19489 }
19490
19491 void  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_free"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(uint32_t _res) {
19492         if ((_res & 1) != 0) return;
19493         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19494         CHECK_ACCESS(_res_ptr);
19495         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(_res_ptr);
19496         FREE((void*)_res);
19497         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
19498 }
19499
19500 static inline uintptr_t CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR arg) {
19501         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
19502         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(arg);
19503         return (uint32_t)ret_conv;
19504 }
19505 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(uint32_t arg) {
19506         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
19507         uint32_t ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(arg_conv);
19508         return ret_conv;
19509 }
19510
19511 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(uint32_t orig) {
19512         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(orig & ~1);
19513         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
19514         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
19515         return (uint32_t)ret_conv;
19516 }
19517
19518 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_ok"))) TS_CResult_UpdateFeeDecodeErrorZ_ok(uint32_t o) {
19519         LDKUpdateFee o_conv;
19520         o_conv.inner = (void*)(o & (~1));
19521         o_conv.is_owned = (o & 1) || (o == 0);
19522         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19523         o_conv = UpdateFee_clone(&o_conv);
19524         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
19525         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
19526         return (uint32_t)ret_conv;
19527 }
19528
19529 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_err"))) TS_CResult_UpdateFeeDecodeErrorZ_err(uint32_t e) {
19530         LDKDecodeError e_conv;
19531         e_conv.inner = (void*)(e & (~1));
19532         e_conv.is_owned = (e & 1) || (e == 0);
19533         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19534         e_conv = DecodeError_clone(&e_conv);
19535         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
19536         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
19537         return (uint32_t)ret_conv;
19538 }
19539
19540 jboolean  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_is_ok"))) TS_CResult_UpdateFeeDecodeErrorZ_is_ok(uint32_t o) {
19541         LDKCResult_UpdateFeeDecodeErrorZ* o_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(o & ~1);
19542         jboolean ret_conv = CResult_UpdateFeeDecodeErrorZ_is_ok(o_conv);
19543         return ret_conv;
19544 }
19545
19546 void  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_free"))) TS_CResult_UpdateFeeDecodeErrorZ_free(uint32_t _res) {
19547         if ((_res & 1) != 0) return;
19548         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19549         CHECK_ACCESS(_res_ptr);
19550         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(_res_ptr);
19551         FREE((void*)_res);
19552         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
19553 }
19554
19555 static inline uintptr_t CResult_UpdateFeeDecodeErrorZ_clone_ptr(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR arg) {
19556         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
19557         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(arg);
19558         return (uint32_t)ret_conv;
19559 }
19560 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateFeeDecodeErrorZ_clone_ptr(uint32_t arg) {
19561         LDKCResult_UpdateFeeDecodeErrorZ* arg_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
19562         uint32_t ret_conv = CResult_UpdateFeeDecodeErrorZ_clone_ptr(arg_conv);
19563         return ret_conv;
19564 }
19565
19566 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_clone"))) TS_CResult_UpdateFeeDecodeErrorZ_clone(uint32_t orig) {
19567         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(orig & ~1);
19568         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
19569         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
19570         return (uint32_t)ret_conv;
19571 }
19572
19573 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_ok"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_ok(uint32_t o) {
19574         LDKUpdateFulfillHTLC o_conv;
19575         o_conv.inner = (void*)(o & (~1));
19576         o_conv.is_owned = (o & 1) || (o == 0);
19577         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19578         o_conv = UpdateFulfillHTLC_clone(&o_conv);
19579         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
19580         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
19581         return (uint32_t)ret_conv;
19582 }
19583
19584 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_err"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_err(uint32_t e) {
19585         LDKDecodeError e_conv;
19586         e_conv.inner = (void*)(e & (~1));
19587         e_conv.is_owned = (e & 1) || (e == 0);
19588         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19589         e_conv = DecodeError_clone(&e_conv);
19590         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
19591         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
19592         return (uint32_t)ret_conv;
19593 }
19594
19595 jboolean  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(uint32_t o) {
19596         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(o & ~1);
19597         jboolean ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(o_conv);
19598         return ret_conv;
19599 }
19600
19601 void  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_free"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_free(uint32_t _res) {
19602         if ((_res & 1) != 0) return;
19603         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19604         CHECK_ACCESS(_res_ptr);
19605         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(_res_ptr);
19606         FREE((void*)_res);
19607         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
19608 }
19609
19610 static inline uintptr_t CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR arg) {
19611         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
19612         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(arg);
19613         return (uint32_t)ret_conv;
19614 }
19615 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(uint32_t arg) {
19616         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
19617         uint32_t ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(arg_conv);
19618         return ret_conv;
19619 }
19620
19621 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone(uint32_t orig) {
19622         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(orig & ~1);
19623         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
19624         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
19625         return (uint32_t)ret_conv;
19626 }
19627
19628 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_ok"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_ok(uint32_t o) {
19629         LDKUpdateAddHTLC o_conv;
19630         o_conv.inner = (void*)(o & (~1));
19631         o_conv.is_owned = (o & 1) || (o == 0);
19632         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19633         o_conv = UpdateAddHTLC_clone(&o_conv);
19634         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
19635         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
19636         return (uint32_t)ret_conv;
19637 }
19638
19639 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_err"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_err(uint32_t e) {
19640         LDKDecodeError e_conv;
19641         e_conv.inner = (void*)(e & (~1));
19642         e_conv.is_owned = (e & 1) || (e == 0);
19643         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19644         e_conv = DecodeError_clone(&e_conv);
19645         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
19646         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
19647         return (uint32_t)ret_conv;
19648 }
19649
19650 jboolean  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_is_ok"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_is_ok(uint32_t o) {
19651         LDKCResult_UpdateAddHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(o & ~1);
19652         jboolean ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_is_ok(o_conv);
19653         return ret_conv;
19654 }
19655
19656 void  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_free"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_free(uint32_t _res) {
19657         if ((_res & 1) != 0) return;
19658         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19659         CHECK_ACCESS(_res_ptr);
19660         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(_res_ptr);
19661         FREE((void*)_res);
19662         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
19663 }
19664
19665 static inline uintptr_t CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR arg) {
19666         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
19667         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(arg);
19668         return (uint32_t)ret_conv;
19669 }
19670 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(uint32_t arg) {
19671         LDKCResult_UpdateAddHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
19672         uint32_t ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(arg_conv);
19673         return ret_conv;
19674 }
19675
19676 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_clone"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_clone(uint32_t orig) {
19677         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(orig & ~1);
19678         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
19679         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
19680         return (uint32_t)ret_conv;
19681 }
19682
19683 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_ok"))) TS_CResult_PingDecodeErrorZ_ok(uint32_t o) {
19684         LDKPing o_conv;
19685         o_conv.inner = (void*)(o & (~1));
19686         o_conv.is_owned = (o & 1) || (o == 0);
19687         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19688         o_conv = Ping_clone(&o_conv);
19689         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
19690         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
19691         return (uint32_t)ret_conv;
19692 }
19693
19694 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_err"))) TS_CResult_PingDecodeErrorZ_err(uint32_t e) {
19695         LDKDecodeError e_conv;
19696         e_conv.inner = (void*)(e & (~1));
19697         e_conv.is_owned = (e & 1) || (e == 0);
19698         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19699         e_conv = DecodeError_clone(&e_conv);
19700         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
19701         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
19702         return (uint32_t)ret_conv;
19703 }
19704
19705 jboolean  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_is_ok"))) TS_CResult_PingDecodeErrorZ_is_ok(uint32_t o) {
19706         LDKCResult_PingDecodeErrorZ* o_conv = (LDKCResult_PingDecodeErrorZ*)(o & ~1);
19707         jboolean ret_conv = CResult_PingDecodeErrorZ_is_ok(o_conv);
19708         return ret_conv;
19709 }
19710
19711 void  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_free"))) TS_CResult_PingDecodeErrorZ_free(uint32_t _res) {
19712         if ((_res & 1) != 0) return;
19713         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19714         CHECK_ACCESS(_res_ptr);
19715         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(_res_ptr);
19716         FREE((void*)_res);
19717         CResult_PingDecodeErrorZ_free(_res_conv);
19718 }
19719
19720 static inline uintptr_t CResult_PingDecodeErrorZ_clone_ptr(LDKCResult_PingDecodeErrorZ *NONNULL_PTR arg) {
19721         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
19722         *ret_conv = CResult_PingDecodeErrorZ_clone(arg);
19723         return (uint32_t)ret_conv;
19724 }
19725 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_clone_ptr"))) TS_CResult_PingDecodeErrorZ_clone_ptr(uint32_t arg) {
19726         LDKCResult_PingDecodeErrorZ* arg_conv = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
19727         uint32_t ret_conv = CResult_PingDecodeErrorZ_clone_ptr(arg_conv);
19728         return ret_conv;
19729 }
19730
19731 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_clone"))) TS_CResult_PingDecodeErrorZ_clone(uint32_t orig) {
19732         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)(orig & ~1);
19733         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
19734         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
19735         return (uint32_t)ret_conv;
19736 }
19737
19738 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_ok"))) TS_CResult_PongDecodeErrorZ_ok(uint32_t o) {
19739         LDKPong o_conv;
19740         o_conv.inner = (void*)(o & (~1));
19741         o_conv.is_owned = (o & 1) || (o == 0);
19742         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19743         o_conv = Pong_clone(&o_conv);
19744         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
19745         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
19746         return (uint32_t)ret_conv;
19747 }
19748
19749 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_err"))) TS_CResult_PongDecodeErrorZ_err(uint32_t e) {
19750         LDKDecodeError e_conv;
19751         e_conv.inner = (void*)(e & (~1));
19752         e_conv.is_owned = (e & 1) || (e == 0);
19753         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19754         e_conv = DecodeError_clone(&e_conv);
19755         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
19756         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
19757         return (uint32_t)ret_conv;
19758 }
19759
19760 jboolean  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_is_ok"))) TS_CResult_PongDecodeErrorZ_is_ok(uint32_t o) {
19761         LDKCResult_PongDecodeErrorZ* o_conv = (LDKCResult_PongDecodeErrorZ*)(o & ~1);
19762         jboolean ret_conv = CResult_PongDecodeErrorZ_is_ok(o_conv);
19763         return ret_conv;
19764 }
19765
19766 void  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_free"))) TS_CResult_PongDecodeErrorZ_free(uint32_t _res) {
19767         if ((_res & 1) != 0) return;
19768         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19769         CHECK_ACCESS(_res_ptr);
19770         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(_res_ptr);
19771         FREE((void*)_res);
19772         CResult_PongDecodeErrorZ_free(_res_conv);
19773 }
19774
19775 static inline uintptr_t CResult_PongDecodeErrorZ_clone_ptr(LDKCResult_PongDecodeErrorZ *NONNULL_PTR arg) {
19776         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
19777         *ret_conv = CResult_PongDecodeErrorZ_clone(arg);
19778         return (uint32_t)ret_conv;
19779 }
19780 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_clone_ptr"))) TS_CResult_PongDecodeErrorZ_clone_ptr(uint32_t arg) {
19781         LDKCResult_PongDecodeErrorZ* arg_conv = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
19782         uint32_t ret_conv = CResult_PongDecodeErrorZ_clone_ptr(arg_conv);
19783         return ret_conv;
19784 }
19785
19786 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_clone"))) TS_CResult_PongDecodeErrorZ_clone(uint32_t orig) {
19787         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)(orig & ~1);
19788         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
19789         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
19790         return (uint32_t)ret_conv;
19791 }
19792
19793 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(uint32_t o) {
19794         LDKUnsignedChannelAnnouncement o_conv;
19795         o_conv.inner = (void*)(o & (~1));
19796         o_conv.is_owned = (o & 1) || (o == 0);
19797         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19798         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
19799         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
19800         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
19801         return (uint32_t)ret_conv;
19802 }
19803
19804 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_err"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(uint32_t e) {
19805         LDKDecodeError e_conv;
19806         e_conv.inner = (void*)(e & (~1));
19807         e_conv.is_owned = (e & 1) || (e == 0);
19808         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19809         e_conv = DecodeError_clone(&e_conv);
19810         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
19811         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
19812         return (uint32_t)ret_conv;
19813 }
19814
19815 jboolean  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(uint32_t o) {
19816         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(o & ~1);
19817         jboolean ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
19818         return ret_conv;
19819 }
19820
19821 void  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_free"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(uint32_t _res) {
19822         if ((_res & 1) != 0) return;
19823         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19824         CHECK_ACCESS(_res_ptr);
19825         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(_res_ptr);
19826         FREE((void*)_res);
19827         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
19828 }
19829
19830 static inline uintptr_t CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
19831         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
19832         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(arg);
19833         return (uint32_t)ret_conv;
19834 }
19835 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(uint32_t arg) {
19836         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
19837         uint32_t ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
19838         return ret_conv;
19839 }
19840
19841 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(uint32_t orig) {
19842         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(orig & ~1);
19843         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
19844         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
19845         return (uint32_t)ret_conv;
19846 }
19847
19848 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_ok"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_ok(uint32_t o) {
19849         LDKChannelAnnouncement o_conv;
19850         o_conv.inner = (void*)(o & (~1));
19851         o_conv.is_owned = (o & 1) || (o == 0);
19852         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19853         o_conv = ChannelAnnouncement_clone(&o_conv);
19854         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
19855         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
19856         return (uint32_t)ret_conv;
19857 }
19858
19859 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_err"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_err(uint32_t e) {
19860         LDKDecodeError e_conv;
19861         e_conv.inner = (void*)(e & (~1));
19862         e_conv.is_owned = (e & 1) || (e == 0);
19863         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19864         e_conv = DecodeError_clone(&e_conv);
19865         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
19866         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
19867         return (uint32_t)ret_conv;
19868 }
19869
19870 jboolean  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_is_ok"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_is_ok(uint32_t o) {
19871         LDKCResult_ChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(o & ~1);
19872         jboolean ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
19873         return ret_conv;
19874 }
19875
19876 void  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_free"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_free(uint32_t _res) {
19877         if ((_res & 1) != 0) return;
19878         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19879         CHECK_ACCESS(_res_ptr);
19880         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(_res_ptr);
19881         FREE((void*)_res);
19882         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
19883 }
19884
19885 static inline uintptr_t CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
19886         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
19887         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(arg);
19888         return (uint32_t)ret_conv;
19889 }
19890 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(uint32_t arg) {
19891         LDKCResult_ChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
19892         uint32_t ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
19893         return ret_conv;
19894 }
19895
19896 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_clone"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_clone(uint32_t orig) {
19897         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(orig & ~1);
19898         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
19899         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
19900         return (uint32_t)ret_conv;
19901 }
19902
19903 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_ok"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_ok(uint32_t o) {
19904         LDKUnsignedChannelUpdate o_conv;
19905         o_conv.inner = (void*)(o & (~1));
19906         o_conv.is_owned = (o & 1) || (o == 0);
19907         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19908         o_conv = UnsignedChannelUpdate_clone(&o_conv);
19909         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
19910         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
19911         return (uint32_t)ret_conv;
19912 }
19913
19914 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_err"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_err(uint32_t e) {
19915         LDKDecodeError e_conv;
19916         e_conv.inner = (void*)(e & (~1));
19917         e_conv.is_owned = (e & 1) || (e == 0);
19918         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19919         e_conv = DecodeError_clone(&e_conv);
19920         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
19921         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
19922         return (uint32_t)ret_conv;
19923 }
19924
19925 jboolean  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(uint32_t o) {
19926         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(o & ~1);
19927         jboolean ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(o_conv);
19928         return ret_conv;
19929 }
19930
19931 void  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_free"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_free(uint32_t _res) {
19932         if ((_res & 1) != 0) return;
19933         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19934         CHECK_ACCESS(_res_ptr);
19935         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(_res_ptr);
19936         FREE((void*)_res);
19937         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
19938 }
19939
19940 static inline uintptr_t CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
19941         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
19942         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(arg);
19943         return (uint32_t)ret_conv;
19944 }
19945 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(uint32_t arg) {
19946         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
19947         uint32_t ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
19948         return ret_conv;
19949 }
19950
19951 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone(uint32_t orig) {
19952         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(orig & ~1);
19953         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
19954         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
19955         return (uint32_t)ret_conv;
19956 }
19957
19958 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_ok"))) TS_CResult_ChannelUpdateDecodeErrorZ_ok(uint32_t o) {
19959         LDKChannelUpdate o_conv;
19960         o_conv.inner = (void*)(o & (~1));
19961         o_conv.is_owned = (o & 1) || (o == 0);
19962         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19963         o_conv = ChannelUpdate_clone(&o_conv);
19964         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
19965         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
19966         return (uint32_t)ret_conv;
19967 }
19968
19969 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_err"))) TS_CResult_ChannelUpdateDecodeErrorZ_err(uint32_t e) {
19970         LDKDecodeError e_conv;
19971         e_conv.inner = (void*)(e & (~1));
19972         e_conv.is_owned = (e & 1) || (e == 0);
19973         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19974         e_conv = DecodeError_clone(&e_conv);
19975         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
19976         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
19977         return (uint32_t)ret_conv;
19978 }
19979
19980 jboolean  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_is_ok"))) TS_CResult_ChannelUpdateDecodeErrorZ_is_ok(uint32_t o) {
19981         LDKCResult_ChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(o & ~1);
19982         jboolean ret_conv = CResult_ChannelUpdateDecodeErrorZ_is_ok(o_conv);
19983         return ret_conv;
19984 }
19985
19986 void  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_free"))) TS_CResult_ChannelUpdateDecodeErrorZ_free(uint32_t _res) {
19987         if ((_res & 1) != 0) return;
19988         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19989         CHECK_ACCESS(_res_ptr);
19990         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(_res_ptr);
19991         FREE((void*)_res);
19992         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
19993 }
19994
19995 static inline uintptr_t CResult_ChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
19996         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
19997         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(arg);
19998         return (uint32_t)ret_conv;
19999 }
20000 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelUpdateDecodeErrorZ_clone_ptr(uint32_t arg) {
20001         LDKCResult_ChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
20002         uint32_t ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
20003         return ret_conv;
20004 }
20005
20006 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_clone"))) TS_CResult_ChannelUpdateDecodeErrorZ_clone(uint32_t orig) {
20007         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(orig & ~1);
20008         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
20009         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
20010         return (uint32_t)ret_conv;
20011 }
20012
20013 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_ok"))) TS_CResult_ErrorMessageDecodeErrorZ_ok(uint32_t o) {
20014         LDKErrorMessage o_conv;
20015         o_conv.inner = (void*)(o & (~1));
20016         o_conv.is_owned = (o & 1) || (o == 0);
20017         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20018         o_conv = ErrorMessage_clone(&o_conv);
20019         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
20020         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
20021         return (uint32_t)ret_conv;
20022 }
20023
20024 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_err"))) TS_CResult_ErrorMessageDecodeErrorZ_err(uint32_t e) {
20025         LDKDecodeError e_conv;
20026         e_conv.inner = (void*)(e & (~1));
20027         e_conv.is_owned = (e & 1) || (e == 0);
20028         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20029         e_conv = DecodeError_clone(&e_conv);
20030         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
20031         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
20032         return (uint32_t)ret_conv;
20033 }
20034
20035 jboolean  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_is_ok"))) TS_CResult_ErrorMessageDecodeErrorZ_is_ok(uint32_t o) {
20036         LDKCResult_ErrorMessageDecodeErrorZ* o_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(o & ~1);
20037         jboolean ret_conv = CResult_ErrorMessageDecodeErrorZ_is_ok(o_conv);
20038         return ret_conv;
20039 }
20040
20041 void  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_free"))) TS_CResult_ErrorMessageDecodeErrorZ_free(uint32_t _res) {
20042         if ((_res & 1) != 0) return;
20043         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20044         CHECK_ACCESS(_res_ptr);
20045         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(_res_ptr);
20046         FREE((void*)_res);
20047         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
20048 }
20049
20050 static inline uintptr_t CResult_ErrorMessageDecodeErrorZ_clone_ptr(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR arg) {
20051         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
20052         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(arg);
20053         return (uint32_t)ret_conv;
20054 }
20055 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_clone_ptr"))) TS_CResult_ErrorMessageDecodeErrorZ_clone_ptr(uint32_t arg) {
20056         LDKCResult_ErrorMessageDecodeErrorZ* arg_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
20057         uint32_t ret_conv = CResult_ErrorMessageDecodeErrorZ_clone_ptr(arg_conv);
20058         return ret_conv;
20059 }
20060
20061 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_clone"))) TS_CResult_ErrorMessageDecodeErrorZ_clone(uint32_t orig) {
20062         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(orig & ~1);
20063         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
20064         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
20065         return (uint32_t)ret_conv;
20066 }
20067
20068 uint32_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_ok"))) TS_CResult_WarningMessageDecodeErrorZ_ok(uint32_t o) {
20069         LDKWarningMessage o_conv;
20070         o_conv.inner = (void*)(o & (~1));
20071         o_conv.is_owned = (o & 1) || (o == 0);
20072         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20073         o_conv = WarningMessage_clone(&o_conv);
20074         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
20075         *ret_conv = CResult_WarningMessageDecodeErrorZ_ok(o_conv);
20076         return (uint32_t)ret_conv;
20077 }
20078
20079 uint32_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_err"))) TS_CResult_WarningMessageDecodeErrorZ_err(uint32_t e) {
20080         LDKDecodeError e_conv;
20081         e_conv.inner = (void*)(e & (~1));
20082         e_conv.is_owned = (e & 1) || (e == 0);
20083         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20084         e_conv = DecodeError_clone(&e_conv);
20085         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
20086         *ret_conv = CResult_WarningMessageDecodeErrorZ_err(e_conv);
20087         return (uint32_t)ret_conv;
20088 }
20089
20090 jboolean  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_is_ok"))) TS_CResult_WarningMessageDecodeErrorZ_is_ok(uint32_t o) {
20091         LDKCResult_WarningMessageDecodeErrorZ* o_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(o & ~1);
20092         jboolean ret_conv = CResult_WarningMessageDecodeErrorZ_is_ok(o_conv);
20093         return ret_conv;
20094 }
20095
20096 void  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_free"))) TS_CResult_WarningMessageDecodeErrorZ_free(uint32_t _res) {
20097         if ((_res & 1) != 0) return;
20098         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20099         CHECK_ACCESS(_res_ptr);
20100         LDKCResult_WarningMessageDecodeErrorZ _res_conv = *(LDKCResult_WarningMessageDecodeErrorZ*)(_res_ptr);
20101         FREE((void*)_res);
20102         CResult_WarningMessageDecodeErrorZ_free(_res_conv);
20103 }
20104
20105 static inline uintptr_t CResult_WarningMessageDecodeErrorZ_clone_ptr(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR arg) {
20106         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
20107         *ret_conv = CResult_WarningMessageDecodeErrorZ_clone(arg);
20108         return (uint32_t)ret_conv;
20109 }
20110 uint32_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_clone_ptr"))) TS_CResult_WarningMessageDecodeErrorZ_clone_ptr(uint32_t arg) {
20111         LDKCResult_WarningMessageDecodeErrorZ* arg_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(arg & ~1);
20112         uint32_t ret_conv = CResult_WarningMessageDecodeErrorZ_clone_ptr(arg_conv);
20113         return ret_conv;
20114 }
20115
20116 uint32_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_clone"))) TS_CResult_WarningMessageDecodeErrorZ_clone(uint32_t orig) {
20117         LDKCResult_WarningMessageDecodeErrorZ* orig_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(orig & ~1);
20118         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
20119         *ret_conv = CResult_WarningMessageDecodeErrorZ_clone(orig_conv);
20120         return (uint32_t)ret_conv;
20121 }
20122
20123 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(uint32_t o) {
20124         LDKUnsignedNodeAnnouncement o_conv;
20125         o_conv.inner = (void*)(o & (~1));
20126         o_conv.is_owned = (o & 1) || (o == 0);
20127         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20128         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
20129         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
20130         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
20131         return (uint32_t)ret_conv;
20132 }
20133
20134 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_err"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(uint32_t e) {
20135         LDKDecodeError e_conv;
20136         e_conv.inner = (void*)(e & (~1));
20137         e_conv.is_owned = (e & 1) || (e == 0);
20138         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20139         e_conv = DecodeError_clone(&e_conv);
20140         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
20141         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
20142         return (uint32_t)ret_conv;
20143 }
20144
20145 jboolean  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(uint32_t o) {
20146         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(o & ~1);
20147         jboolean ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(o_conv);
20148         return ret_conv;
20149 }
20150
20151 void  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_free"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(uint32_t _res) {
20152         if ((_res & 1) != 0) return;
20153         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20154         CHECK_ACCESS(_res_ptr);
20155         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(_res_ptr);
20156         FREE((void*)_res);
20157         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
20158 }
20159
20160 static inline uintptr_t CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
20161         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
20162         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(arg);
20163         return (uint32_t)ret_conv;
20164 }
20165 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(uint32_t arg) {
20166         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
20167         uint32_t ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
20168         return ret_conv;
20169 }
20170
20171 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(uint32_t orig) {
20172         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(orig & ~1);
20173         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
20174         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
20175         return (uint32_t)ret_conv;
20176 }
20177
20178 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_ok"))) TS_CResult_NodeAnnouncementDecodeErrorZ_ok(uint32_t o) {
20179         LDKNodeAnnouncement o_conv;
20180         o_conv.inner = (void*)(o & (~1));
20181         o_conv.is_owned = (o & 1) || (o == 0);
20182         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20183         o_conv = NodeAnnouncement_clone(&o_conv);
20184         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
20185         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
20186         return (uint32_t)ret_conv;
20187 }
20188
20189 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_err"))) TS_CResult_NodeAnnouncementDecodeErrorZ_err(uint32_t e) {
20190         LDKDecodeError e_conv;
20191         e_conv.inner = (void*)(e & (~1));
20192         e_conv.is_owned = (e & 1) || (e == 0);
20193         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20194         e_conv = DecodeError_clone(&e_conv);
20195         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
20196         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
20197         return (uint32_t)ret_conv;
20198 }
20199
20200 jboolean  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_is_ok"))) TS_CResult_NodeAnnouncementDecodeErrorZ_is_ok(uint32_t o) {
20201         LDKCResult_NodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(o & ~1);
20202         jboolean ret_conv = CResult_NodeAnnouncementDecodeErrorZ_is_ok(o_conv);
20203         return ret_conv;
20204 }
20205
20206 void  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_free"))) TS_CResult_NodeAnnouncementDecodeErrorZ_free(uint32_t _res) {
20207         if ((_res & 1) != 0) return;
20208         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20209         CHECK_ACCESS(_res_ptr);
20210         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(_res_ptr);
20211         FREE((void*)_res);
20212         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
20213 }
20214
20215 static inline uintptr_t CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
20216         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
20217         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(arg);
20218         return (uint32_t)ret_conv;
20219 }
20220 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_clone_ptr"))) TS_CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(uint32_t arg) {
20221         LDKCResult_NodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
20222         uint32_t ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
20223         return ret_conv;
20224 }
20225
20226 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_clone"))) TS_CResult_NodeAnnouncementDecodeErrorZ_clone(uint32_t orig) {
20227         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(orig & ~1);
20228         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
20229         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
20230         return (uint32_t)ret_conv;
20231 }
20232
20233 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_ok"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_ok(uint32_t o) {
20234         LDKQueryShortChannelIds o_conv;
20235         o_conv.inner = (void*)(o & (~1));
20236         o_conv.is_owned = (o & 1) || (o == 0);
20237         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20238         o_conv = QueryShortChannelIds_clone(&o_conv);
20239         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
20240         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
20241         return (uint32_t)ret_conv;
20242 }
20243
20244 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_err"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_err(uint32_t e) {
20245         LDKDecodeError e_conv;
20246         e_conv.inner = (void*)(e & (~1));
20247         e_conv.is_owned = (e & 1) || (e == 0);
20248         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20249         e_conv = DecodeError_clone(&e_conv);
20250         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
20251         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
20252         return (uint32_t)ret_conv;
20253 }
20254
20255 jboolean  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_is_ok"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(uint32_t o) {
20256         LDKCResult_QueryShortChannelIdsDecodeErrorZ* o_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(o & ~1);
20257         jboolean ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(o_conv);
20258         return ret_conv;
20259 }
20260
20261 void  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_free"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_free(uint32_t _res) {
20262         if ((_res & 1) != 0) return;
20263         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20264         CHECK_ACCESS(_res_ptr);
20265         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(_res_ptr);
20266         FREE((void*)_res);
20267         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
20268 }
20269
20270 static inline uintptr_t CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR arg) {
20271         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
20272         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(arg);
20273         return (uint32_t)ret_conv;
20274 }
20275 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(uint32_t arg) {
20276         LDKCResult_QueryShortChannelIdsDecodeErrorZ* arg_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
20277         uint32_t ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(arg_conv);
20278         return ret_conv;
20279 }
20280
20281 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone(uint32_t orig) {
20282         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(orig & ~1);
20283         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
20284         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
20285         return (uint32_t)ret_conv;
20286 }
20287
20288 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(uint32_t o) {
20289         LDKReplyShortChannelIdsEnd o_conv;
20290         o_conv.inner = (void*)(o & (~1));
20291         o_conv.is_owned = (o & 1) || (o == 0);
20292         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20293         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
20294         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
20295         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
20296         return (uint32_t)ret_conv;
20297 }
20298
20299 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_err"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(uint32_t e) {
20300         LDKDecodeError e_conv;
20301         e_conv.inner = (void*)(e & (~1));
20302         e_conv.is_owned = (e & 1) || (e == 0);
20303         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20304         e_conv = DecodeError_clone(&e_conv);
20305         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
20306         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
20307         return (uint32_t)ret_conv;
20308 }
20309
20310 jboolean  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(uint32_t o) {
20311         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* o_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(o & ~1);
20312         jboolean ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(o_conv);
20313         return ret_conv;
20314 }
20315
20316 void  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_free"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(uint32_t _res) {
20317         if ((_res & 1) != 0) return;
20318         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20319         CHECK_ACCESS(_res_ptr);
20320         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(_res_ptr);
20321         FREE((void*)_res);
20322         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
20323 }
20324
20325 static inline uintptr_t CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR arg) {
20326         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
20327         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(arg);
20328         return (uint32_t)ret_conv;
20329 }
20330 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(uint32_t arg) {
20331         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* arg_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
20332         uint32_t ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(arg_conv);
20333         return ret_conv;
20334 }
20335
20336 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(uint32_t orig) {
20337         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(orig & ~1);
20338         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
20339         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
20340         return (uint32_t)ret_conv;
20341 }
20342
20343 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_ok"))) TS_CResult_QueryChannelRangeDecodeErrorZ_ok(uint32_t o) {
20344         LDKQueryChannelRange o_conv;
20345         o_conv.inner = (void*)(o & (~1));
20346         o_conv.is_owned = (o & 1) || (o == 0);
20347         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20348         o_conv = QueryChannelRange_clone(&o_conv);
20349         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
20350         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
20351         return (uint32_t)ret_conv;
20352 }
20353
20354 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_err"))) TS_CResult_QueryChannelRangeDecodeErrorZ_err(uint32_t e) {
20355         LDKDecodeError e_conv;
20356         e_conv.inner = (void*)(e & (~1));
20357         e_conv.is_owned = (e & 1) || (e == 0);
20358         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20359         e_conv = DecodeError_clone(&e_conv);
20360         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
20361         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
20362         return (uint32_t)ret_conv;
20363 }
20364
20365 jboolean  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_is_ok"))) TS_CResult_QueryChannelRangeDecodeErrorZ_is_ok(uint32_t o) {
20366         LDKCResult_QueryChannelRangeDecodeErrorZ* o_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(o & ~1);
20367         jboolean ret_conv = CResult_QueryChannelRangeDecodeErrorZ_is_ok(o_conv);
20368         return ret_conv;
20369 }
20370
20371 void  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_free"))) TS_CResult_QueryChannelRangeDecodeErrorZ_free(uint32_t _res) {
20372         if ((_res & 1) != 0) return;
20373         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20374         CHECK_ACCESS(_res_ptr);
20375         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(_res_ptr);
20376         FREE((void*)_res);
20377         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
20378 }
20379
20380 static inline uintptr_t CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
20381         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
20382         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(arg);
20383         return (uint32_t)ret_conv;
20384 }
20385 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_clone_ptr"))) TS_CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(uint32_t arg) {
20386         LDKCResult_QueryChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
20387         uint32_t ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
20388         return ret_conv;
20389 }
20390
20391 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_clone"))) TS_CResult_QueryChannelRangeDecodeErrorZ_clone(uint32_t orig) {
20392         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(orig & ~1);
20393         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
20394         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
20395         return (uint32_t)ret_conv;
20396 }
20397
20398 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_ok"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_ok(uint32_t o) {
20399         LDKReplyChannelRange o_conv;
20400         o_conv.inner = (void*)(o & (~1));
20401         o_conv.is_owned = (o & 1) || (o == 0);
20402         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20403         o_conv = ReplyChannelRange_clone(&o_conv);
20404         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
20405         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
20406         return (uint32_t)ret_conv;
20407 }
20408
20409 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_err"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_err(uint32_t e) {
20410         LDKDecodeError e_conv;
20411         e_conv.inner = (void*)(e & (~1));
20412         e_conv.is_owned = (e & 1) || (e == 0);
20413         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20414         e_conv = DecodeError_clone(&e_conv);
20415         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
20416         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
20417         return (uint32_t)ret_conv;
20418 }
20419
20420 jboolean  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_is_ok"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_is_ok(uint32_t o) {
20421         LDKCResult_ReplyChannelRangeDecodeErrorZ* o_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(o & ~1);
20422         jboolean ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_is_ok(o_conv);
20423         return ret_conv;
20424 }
20425
20426 void  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_free"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_free(uint32_t _res) {
20427         if ((_res & 1) != 0) return;
20428         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20429         CHECK_ACCESS(_res_ptr);
20430         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(_res_ptr);
20431         FREE((void*)_res);
20432         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
20433 }
20434
20435 static inline uintptr_t CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
20436         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
20437         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(arg);
20438         return (uint32_t)ret_conv;
20439 }
20440 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(uint32_t arg) {
20441         LDKCResult_ReplyChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
20442         uint32_t ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
20443         return ret_conv;
20444 }
20445
20446 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_clone"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_clone(uint32_t orig) {
20447         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(orig & ~1);
20448         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
20449         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
20450         return (uint32_t)ret_conv;
20451 }
20452
20453 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_ok"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_ok(uint32_t o) {
20454         LDKGossipTimestampFilter o_conv;
20455         o_conv.inner = (void*)(o & (~1));
20456         o_conv.is_owned = (o & 1) || (o == 0);
20457         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20458         o_conv = GossipTimestampFilter_clone(&o_conv);
20459         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
20460         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
20461         return (uint32_t)ret_conv;
20462 }
20463
20464 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_err"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_err(uint32_t e) {
20465         LDKDecodeError e_conv;
20466         e_conv.inner = (void*)(e & (~1));
20467         e_conv.is_owned = (e & 1) || (e == 0);
20468         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20469         e_conv = DecodeError_clone(&e_conv);
20470         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
20471         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
20472         return (uint32_t)ret_conv;
20473 }
20474
20475 jboolean  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_is_ok"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_is_ok(uint32_t o) {
20476         LDKCResult_GossipTimestampFilterDecodeErrorZ* o_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(o & ~1);
20477         jboolean ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_is_ok(o_conv);
20478         return ret_conv;
20479 }
20480
20481 void  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_free"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_free(uint32_t _res) {
20482         if ((_res & 1) != 0) return;
20483         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20484         CHECK_ACCESS(_res_ptr);
20485         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(_res_ptr);
20486         FREE((void*)_res);
20487         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
20488 }
20489
20490 static inline uintptr_t CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR arg) {
20491         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
20492         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(arg);
20493         return (uint32_t)ret_conv;
20494 }
20495 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(uint32_t arg) {
20496         LDKCResult_GossipTimestampFilterDecodeErrorZ* arg_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
20497         uint32_t ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(arg_conv);
20498         return ret_conv;
20499 }
20500
20501 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_clone"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_clone(uint32_t orig) {
20502         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(orig & ~1);
20503         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
20504         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
20505         return (uint32_t)ret_conv;
20506 }
20507
20508 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_ok"))) TS_CResult_InvoiceSignOrCreationErrorZ_ok(uint32_t o) {
20509         LDKInvoice o_conv;
20510         o_conv.inner = (void*)(o & (~1));
20511         o_conv.is_owned = (o & 1) || (o == 0);
20512         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20513         o_conv = Invoice_clone(&o_conv);
20514         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
20515         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_ok(o_conv);
20516         return (uint32_t)ret_conv;
20517 }
20518
20519 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_err"))) TS_CResult_InvoiceSignOrCreationErrorZ_err(uint32_t e) {
20520         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
20521         CHECK_ACCESS(e_ptr);
20522         LDKSignOrCreationError e_conv = *(LDKSignOrCreationError*)(e_ptr);
20523         e_conv = SignOrCreationError_clone((LDKSignOrCreationError*)(((uintptr_t)e) & ~1));
20524         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
20525         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_err(e_conv);
20526         return (uint32_t)ret_conv;
20527 }
20528
20529 jboolean  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_is_ok"))) TS_CResult_InvoiceSignOrCreationErrorZ_is_ok(uint32_t o) {
20530         LDKCResult_InvoiceSignOrCreationErrorZ* o_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(o & ~1);
20531         jboolean ret_conv = CResult_InvoiceSignOrCreationErrorZ_is_ok(o_conv);
20532         return ret_conv;
20533 }
20534
20535 void  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_free"))) TS_CResult_InvoiceSignOrCreationErrorZ_free(uint32_t _res) {
20536         if ((_res & 1) != 0) return;
20537         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20538         CHECK_ACCESS(_res_ptr);
20539         LDKCResult_InvoiceSignOrCreationErrorZ _res_conv = *(LDKCResult_InvoiceSignOrCreationErrorZ*)(_res_ptr);
20540         FREE((void*)_res);
20541         CResult_InvoiceSignOrCreationErrorZ_free(_res_conv);
20542 }
20543
20544 static inline uintptr_t CResult_InvoiceSignOrCreationErrorZ_clone_ptr(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR arg) {
20545         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
20546         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(arg);
20547         return (uint32_t)ret_conv;
20548 }
20549 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_clone_ptr"))) TS_CResult_InvoiceSignOrCreationErrorZ_clone_ptr(uint32_t arg) {
20550         LDKCResult_InvoiceSignOrCreationErrorZ* arg_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
20551         uint32_t ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone_ptr(arg_conv);
20552         return ret_conv;
20553 }
20554
20555 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_clone"))) TS_CResult_InvoiceSignOrCreationErrorZ_clone(uint32_t orig) {
20556         LDKCResult_InvoiceSignOrCreationErrorZ* orig_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(orig & ~1);
20557         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
20558         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(orig_conv);
20559         return (uint32_t)ret_conv;
20560 }
20561
20562 uint32_t  __attribute__((export_name("TS_COption_FilterZ_some"))) TS_COption_FilterZ_some(uint32_t o) {
20563         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
20564         CHECK_ACCESS(o_ptr);
20565         LDKFilter o_conv = *(LDKFilter*)(o_ptr);
20566         if (o_conv.free == LDKFilter_JCalls_free) {
20567                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20568                 LDKFilter_JCalls_cloned(&o_conv);
20569         }
20570         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
20571         *ret_copy = COption_FilterZ_some(o_conv);
20572         uint32_t ret_ref = (uintptr_t)ret_copy;
20573         return ret_ref;
20574 }
20575
20576 uint32_t  __attribute__((export_name("TS_COption_FilterZ_none"))) TS_COption_FilterZ_none() {
20577         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
20578         *ret_copy = COption_FilterZ_none();
20579         uint32_t ret_ref = (uintptr_t)ret_copy;
20580         return ret_ref;
20581 }
20582
20583 void  __attribute__((export_name("TS_COption_FilterZ_free"))) TS_COption_FilterZ_free(uint32_t _res) {
20584         if ((_res & 1) != 0) return;
20585         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20586         CHECK_ACCESS(_res_ptr);
20587         LDKCOption_FilterZ _res_conv = *(LDKCOption_FilterZ*)(_res_ptr);
20588         FREE((void*)_res);
20589         COption_FilterZ_free(_res_conv);
20590 }
20591
20592 uint32_t  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_ok"))) TS_CResult_LockedChannelMonitorNoneZ_ok(uint32_t o) {
20593         LDKLockedChannelMonitor o_conv;
20594         o_conv.inner = (void*)(o & (~1));
20595         o_conv.is_owned = (o & 1) || (o == 0);
20596         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20597         // WARNING: we need a move here but no clone is available for LDKLockedChannelMonitor
20598         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
20599         *ret_conv = CResult_LockedChannelMonitorNoneZ_ok(o_conv);
20600         return (uint32_t)ret_conv;
20601 }
20602
20603 uint32_t  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_err"))) TS_CResult_LockedChannelMonitorNoneZ_err() {
20604         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
20605         *ret_conv = CResult_LockedChannelMonitorNoneZ_err();
20606         return (uint32_t)ret_conv;
20607 }
20608
20609 jboolean  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_is_ok"))) TS_CResult_LockedChannelMonitorNoneZ_is_ok(uint32_t o) {
20610         LDKCResult_LockedChannelMonitorNoneZ* o_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(o & ~1);
20611         jboolean ret_conv = CResult_LockedChannelMonitorNoneZ_is_ok(o_conv);
20612         return ret_conv;
20613 }
20614
20615 void  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_free"))) TS_CResult_LockedChannelMonitorNoneZ_free(uint32_t _res) {
20616         if ((_res & 1) != 0) return;
20617         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20618         CHECK_ACCESS(_res_ptr);
20619         LDKCResult_LockedChannelMonitorNoneZ _res_conv = *(LDKCResult_LockedChannelMonitorNoneZ*)(_res_ptr);
20620         FREE((void*)_res);
20621         CResult_LockedChannelMonitorNoneZ_free(_res_conv);
20622 }
20623
20624 void  __attribute__((export_name("TS_CVec_OutPointZ_free"))) TS_CVec_OutPointZ_free(uint32_tArray _res) {
20625         LDKCVec_OutPointZ _res_constr;
20626         _res_constr.datalen = _res->arr_len;
20627         if (_res_constr.datalen > 0)
20628                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKOutPoint), "LDKCVec_OutPointZ Elements");
20629         else
20630                 _res_constr.data = NULL;
20631         uint32_t* _res_vals = _res->elems;
20632         for (size_t k = 0; k < _res_constr.datalen; k++) {
20633                 uint32_t _res_conv_10 = _res_vals[k];
20634                 LDKOutPoint _res_conv_10_conv;
20635                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
20636                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
20637                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
20638                 _res_constr.data[k] = _res_conv_10_conv;
20639         }
20640         FREE(_res);
20641         CVec_OutPointZ_free(_res_constr);
20642 }
20643
20644 void  __attribute__((export_name("TS_PaymentPurpose_free"))) TS_PaymentPurpose_free(uint32_t this_ptr) {
20645         if ((this_ptr & 1) != 0) return;
20646         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
20647         CHECK_ACCESS(this_ptr_ptr);
20648         LDKPaymentPurpose this_ptr_conv = *(LDKPaymentPurpose*)(this_ptr_ptr);
20649         FREE((void*)this_ptr);
20650         PaymentPurpose_free(this_ptr_conv);
20651 }
20652
20653 static inline uintptr_t PaymentPurpose_clone_ptr(LDKPaymentPurpose *NONNULL_PTR arg) {
20654         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
20655         *ret_copy = PaymentPurpose_clone(arg);
20656 uint32_t ret_ref = (uintptr_t)ret_copy;
20657         return ret_ref;
20658 }
20659 uint32_t  __attribute__((export_name("TS_PaymentPurpose_clone_ptr"))) TS_PaymentPurpose_clone_ptr(uint32_t arg) {
20660         LDKPaymentPurpose* arg_conv = (LDKPaymentPurpose*)arg;
20661         uint32_t ret_conv = PaymentPurpose_clone_ptr(arg_conv);
20662         return ret_conv;
20663 }
20664
20665 uint32_t  __attribute__((export_name("TS_PaymentPurpose_clone"))) TS_PaymentPurpose_clone(uint32_t orig) {
20666         LDKPaymentPurpose* orig_conv = (LDKPaymentPurpose*)orig;
20667         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
20668         *ret_copy = PaymentPurpose_clone(orig_conv);
20669         uint32_t ret_ref = (uintptr_t)ret_copy;
20670         return ret_ref;
20671 }
20672
20673 uint32_t  __attribute__((export_name("TS_PaymentPurpose_invoice_payment"))) TS_PaymentPurpose_invoice_payment(int8_tArray payment_preimage, int8_tArray payment_secret) {
20674         LDKThirtyTwoBytes payment_preimage_ref;
20675         CHECK(payment_preimage->arr_len == 32);
20676         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
20677         LDKThirtyTwoBytes payment_secret_ref;
20678         CHECK(payment_secret->arr_len == 32);
20679         memcpy(payment_secret_ref.data, payment_secret->elems, 32); FREE(payment_secret);
20680         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
20681         *ret_copy = PaymentPurpose_invoice_payment(payment_preimage_ref, payment_secret_ref);
20682         uint32_t ret_ref = (uintptr_t)ret_copy;
20683         return ret_ref;
20684 }
20685
20686 uint32_t  __attribute__((export_name("TS_PaymentPurpose_spontaneous_payment"))) TS_PaymentPurpose_spontaneous_payment(int8_tArray a) {
20687         LDKThirtyTwoBytes a_ref;
20688         CHECK(a->arr_len == 32);
20689         memcpy(a_ref.data, a->elems, 32); FREE(a);
20690         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
20691         *ret_copy = PaymentPurpose_spontaneous_payment(a_ref);
20692         uint32_t ret_ref = (uintptr_t)ret_copy;
20693         return ret_ref;
20694 }
20695
20696 int8_tArray  __attribute__((export_name("TS_PaymentPurpose_write"))) TS_PaymentPurpose_write(uint32_t obj) {
20697         LDKPaymentPurpose* obj_conv = (LDKPaymentPurpose*)obj;
20698         LDKCVec_u8Z ret_var = PaymentPurpose_write(obj_conv);
20699         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
20700         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
20701         CVec_u8Z_free(ret_var);
20702         return ret_arr;
20703 }
20704
20705 uint32_t  __attribute__((export_name("TS_PaymentPurpose_read"))) TS_PaymentPurpose_read(int8_tArray ser) {
20706         LDKu8slice ser_ref;
20707         ser_ref.datalen = ser->arr_len;
20708         ser_ref.data = ser->elems;
20709         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
20710         *ret_conv = PaymentPurpose_read(ser_ref);
20711         FREE(ser);
20712         return (uint32_t)ret_conv;
20713 }
20714
20715 void  __attribute__((export_name("TS_ClosureReason_free"))) TS_ClosureReason_free(uint32_t this_ptr) {
20716         if ((this_ptr & 1) != 0) return;
20717         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
20718         CHECK_ACCESS(this_ptr_ptr);
20719         LDKClosureReason this_ptr_conv = *(LDKClosureReason*)(this_ptr_ptr);
20720         FREE((void*)this_ptr);
20721         ClosureReason_free(this_ptr_conv);
20722 }
20723
20724 static inline uintptr_t ClosureReason_clone_ptr(LDKClosureReason *NONNULL_PTR arg) {
20725         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
20726         *ret_copy = ClosureReason_clone(arg);
20727 uint32_t ret_ref = (uintptr_t)ret_copy;
20728         return ret_ref;
20729 }
20730 uint32_t  __attribute__((export_name("TS_ClosureReason_clone_ptr"))) TS_ClosureReason_clone_ptr(uint32_t arg) {
20731         LDKClosureReason* arg_conv = (LDKClosureReason*)arg;
20732         uint32_t ret_conv = ClosureReason_clone_ptr(arg_conv);
20733         return ret_conv;
20734 }
20735
20736 uint32_t  __attribute__((export_name("TS_ClosureReason_clone"))) TS_ClosureReason_clone(uint32_t orig) {
20737         LDKClosureReason* orig_conv = (LDKClosureReason*)orig;
20738         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
20739         *ret_copy = ClosureReason_clone(orig_conv);
20740         uint32_t ret_ref = (uintptr_t)ret_copy;
20741         return ret_ref;
20742 }
20743
20744 uint32_t  __attribute__((export_name("TS_ClosureReason_counterparty_force_closed"))) TS_ClosureReason_counterparty_force_closed(jstring peer_msg) {
20745         LDKStr peer_msg_conv = str_ref_to_owned_c(peer_msg);
20746         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
20747         *ret_copy = ClosureReason_counterparty_force_closed(peer_msg_conv);
20748         uint32_t ret_ref = (uintptr_t)ret_copy;
20749         return ret_ref;
20750 }
20751
20752 uint32_t  __attribute__((export_name("TS_ClosureReason_holder_force_closed"))) TS_ClosureReason_holder_force_closed() {
20753         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
20754         *ret_copy = ClosureReason_holder_force_closed();
20755         uint32_t ret_ref = (uintptr_t)ret_copy;
20756         return ret_ref;
20757 }
20758
20759 uint32_t  __attribute__((export_name("TS_ClosureReason_cooperative_closure"))) TS_ClosureReason_cooperative_closure() {
20760         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
20761         *ret_copy = ClosureReason_cooperative_closure();
20762         uint32_t ret_ref = (uintptr_t)ret_copy;
20763         return ret_ref;
20764 }
20765
20766 uint32_t  __attribute__((export_name("TS_ClosureReason_commitment_tx_confirmed"))) TS_ClosureReason_commitment_tx_confirmed() {
20767         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
20768         *ret_copy = ClosureReason_commitment_tx_confirmed();
20769         uint32_t ret_ref = (uintptr_t)ret_copy;
20770         return ret_ref;
20771 }
20772
20773 uint32_t  __attribute__((export_name("TS_ClosureReason_funding_timed_out"))) TS_ClosureReason_funding_timed_out() {
20774         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
20775         *ret_copy = ClosureReason_funding_timed_out();
20776         uint32_t ret_ref = (uintptr_t)ret_copy;
20777         return ret_ref;
20778 }
20779
20780 uint32_t  __attribute__((export_name("TS_ClosureReason_processing_error"))) TS_ClosureReason_processing_error(jstring err) {
20781         LDKStr err_conv = str_ref_to_owned_c(err);
20782         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
20783         *ret_copy = ClosureReason_processing_error(err_conv);
20784         uint32_t ret_ref = (uintptr_t)ret_copy;
20785         return ret_ref;
20786 }
20787
20788 uint32_t  __attribute__((export_name("TS_ClosureReason_disconnected_peer"))) TS_ClosureReason_disconnected_peer() {
20789         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
20790         *ret_copy = ClosureReason_disconnected_peer();
20791         uint32_t ret_ref = (uintptr_t)ret_copy;
20792         return ret_ref;
20793 }
20794
20795 uint32_t  __attribute__((export_name("TS_ClosureReason_outdated_channel_manager"))) TS_ClosureReason_outdated_channel_manager() {
20796         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
20797         *ret_copy = ClosureReason_outdated_channel_manager();
20798         uint32_t ret_ref = (uintptr_t)ret_copy;
20799         return ret_ref;
20800 }
20801
20802 int8_tArray  __attribute__((export_name("TS_ClosureReason_write"))) TS_ClosureReason_write(uint32_t obj) {
20803         LDKClosureReason* obj_conv = (LDKClosureReason*)obj;
20804         LDKCVec_u8Z ret_var = ClosureReason_write(obj_conv);
20805         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
20806         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
20807         CVec_u8Z_free(ret_var);
20808         return ret_arr;
20809 }
20810
20811 uint32_t  __attribute__((export_name("TS_ClosureReason_read"))) TS_ClosureReason_read(int8_tArray ser) {
20812         LDKu8slice ser_ref;
20813         ser_ref.datalen = ser->arr_len;
20814         ser_ref.data = ser->elems;
20815         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
20816         *ret_conv = ClosureReason_read(ser_ref);
20817         FREE(ser);
20818         return (uint32_t)ret_conv;
20819 }
20820
20821 void  __attribute__((export_name("TS_HTLCDestination_free"))) TS_HTLCDestination_free(uint32_t this_ptr) {
20822         if ((this_ptr & 1) != 0) return;
20823         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
20824         CHECK_ACCESS(this_ptr_ptr);
20825         LDKHTLCDestination this_ptr_conv = *(LDKHTLCDestination*)(this_ptr_ptr);
20826         FREE((void*)this_ptr);
20827         HTLCDestination_free(this_ptr_conv);
20828 }
20829
20830 static inline uintptr_t HTLCDestination_clone_ptr(LDKHTLCDestination *NONNULL_PTR arg) {
20831         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
20832         *ret_copy = HTLCDestination_clone(arg);
20833 uint32_t ret_ref = (uintptr_t)ret_copy;
20834         return ret_ref;
20835 }
20836 uint32_t  __attribute__((export_name("TS_HTLCDestination_clone_ptr"))) TS_HTLCDestination_clone_ptr(uint32_t arg) {
20837         LDKHTLCDestination* arg_conv = (LDKHTLCDestination*)arg;
20838         uint32_t ret_conv = HTLCDestination_clone_ptr(arg_conv);
20839         return ret_conv;
20840 }
20841
20842 uint32_t  __attribute__((export_name("TS_HTLCDestination_clone"))) TS_HTLCDestination_clone(uint32_t orig) {
20843         LDKHTLCDestination* orig_conv = (LDKHTLCDestination*)orig;
20844         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
20845         *ret_copy = HTLCDestination_clone(orig_conv);
20846         uint32_t ret_ref = (uintptr_t)ret_copy;
20847         return ret_ref;
20848 }
20849
20850 uint32_t  __attribute__((export_name("TS_HTLCDestination_next_hop_channel"))) TS_HTLCDestination_next_hop_channel(int8_tArray node_id, int8_tArray channel_id) {
20851         LDKPublicKey node_id_ref;
20852         CHECK(node_id->arr_len == 33);
20853         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20854         LDKThirtyTwoBytes channel_id_ref;
20855         CHECK(channel_id->arr_len == 32);
20856         memcpy(channel_id_ref.data, channel_id->elems, 32); FREE(channel_id);
20857         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
20858         *ret_copy = HTLCDestination_next_hop_channel(node_id_ref, channel_id_ref);
20859         uint32_t ret_ref = (uintptr_t)ret_copy;
20860         return ret_ref;
20861 }
20862
20863 uint32_t  __attribute__((export_name("TS_HTLCDestination_unknown_next_hop"))) TS_HTLCDestination_unknown_next_hop(int64_t requested_forward_scid) {
20864         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
20865         *ret_copy = HTLCDestination_unknown_next_hop(requested_forward_scid);
20866         uint32_t ret_ref = (uintptr_t)ret_copy;
20867         return ret_ref;
20868 }
20869
20870 uint32_t  __attribute__((export_name("TS_HTLCDestination_failed_payment"))) TS_HTLCDestination_failed_payment(int8_tArray payment_hash) {
20871         LDKThirtyTwoBytes payment_hash_ref;
20872         CHECK(payment_hash->arr_len == 32);
20873         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
20874         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
20875         *ret_copy = HTLCDestination_failed_payment(payment_hash_ref);
20876         uint32_t ret_ref = (uintptr_t)ret_copy;
20877         return ret_ref;
20878 }
20879
20880 int8_tArray  __attribute__((export_name("TS_HTLCDestination_write"))) TS_HTLCDestination_write(uint32_t obj) {
20881         LDKHTLCDestination* obj_conv = (LDKHTLCDestination*)obj;
20882         LDKCVec_u8Z ret_var = HTLCDestination_write(obj_conv);
20883         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
20884         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
20885         CVec_u8Z_free(ret_var);
20886         return ret_arr;
20887 }
20888
20889 uint32_t  __attribute__((export_name("TS_HTLCDestination_read"))) TS_HTLCDestination_read(int8_tArray ser) {
20890         LDKu8slice ser_ref;
20891         ser_ref.datalen = ser->arr_len;
20892         ser_ref.data = ser->elems;
20893         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
20894         *ret_conv = HTLCDestination_read(ser_ref);
20895         FREE(ser);
20896         return (uint32_t)ret_conv;
20897 }
20898
20899 void  __attribute__((export_name("TS_Event_free"))) TS_Event_free(uint32_t this_ptr) {
20900         if ((this_ptr & 1) != 0) return;
20901         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
20902         CHECK_ACCESS(this_ptr_ptr);
20903         LDKEvent this_ptr_conv = *(LDKEvent*)(this_ptr_ptr);
20904         FREE((void*)this_ptr);
20905         Event_free(this_ptr_conv);
20906 }
20907
20908 static inline uintptr_t Event_clone_ptr(LDKEvent *NONNULL_PTR arg) {
20909         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20910         *ret_copy = Event_clone(arg);
20911 uint32_t ret_ref = (uintptr_t)ret_copy;
20912         return ret_ref;
20913 }
20914 uint32_t  __attribute__((export_name("TS_Event_clone_ptr"))) TS_Event_clone_ptr(uint32_t arg) {
20915         LDKEvent* arg_conv = (LDKEvent*)arg;
20916         uint32_t ret_conv = Event_clone_ptr(arg_conv);
20917         return ret_conv;
20918 }
20919
20920 uint32_t  __attribute__((export_name("TS_Event_clone"))) TS_Event_clone(uint32_t orig) {
20921         LDKEvent* orig_conv = (LDKEvent*)orig;
20922         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20923         *ret_copy = Event_clone(orig_conv);
20924         uint32_t ret_ref = (uintptr_t)ret_copy;
20925         return ret_ref;
20926 }
20927
20928 uint32_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) {
20929         LDKThirtyTwoBytes temporary_channel_id_ref;
20930         CHECK(temporary_channel_id->arr_len == 32);
20931         memcpy(temporary_channel_id_ref.data, temporary_channel_id->elems, 32); FREE(temporary_channel_id);
20932         LDKPublicKey counterparty_node_id_ref;
20933         CHECK(counterparty_node_id->arr_len == 33);
20934         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
20935         LDKCVec_u8Z output_script_ref;
20936         output_script_ref.datalen = output_script->arr_len;
20937         output_script_ref.data = MALLOC(output_script_ref.datalen, "LDKCVec_u8Z Bytes");
20938         memcpy(output_script_ref.data, output_script->elems, output_script_ref.datalen); FREE(output_script);
20939         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20940         *ret_copy = Event_funding_generation_ready(temporary_channel_id_ref, counterparty_node_id_ref, channel_value_satoshis, output_script_ref, user_channel_id);
20941         uint32_t ret_ref = (uintptr_t)ret_copy;
20942         return ret_ref;
20943 }
20944
20945 uint32_t  __attribute__((export_name("TS_Event_payment_received"))) TS_Event_payment_received(int8_tArray payment_hash, int64_t amount_msat, uint32_t purpose) {
20946         LDKThirtyTwoBytes payment_hash_ref;
20947         CHECK(payment_hash->arr_len == 32);
20948         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
20949         void* purpose_ptr = (void*)(((uintptr_t)purpose) & ~1);
20950         CHECK_ACCESS(purpose_ptr);
20951         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
20952         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)(((uintptr_t)purpose) & ~1));
20953         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20954         *ret_copy = Event_payment_received(payment_hash_ref, amount_msat, purpose_conv);
20955         uint32_t ret_ref = (uintptr_t)ret_copy;
20956         return ret_ref;
20957 }
20958
20959 uint32_t  __attribute__((export_name("TS_Event_payment_claimed"))) TS_Event_payment_claimed(int8_tArray payment_hash, int64_t amount_msat, uint32_t purpose) {
20960         LDKThirtyTwoBytes payment_hash_ref;
20961         CHECK(payment_hash->arr_len == 32);
20962         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
20963         void* purpose_ptr = (void*)(((uintptr_t)purpose) & ~1);
20964         CHECK_ACCESS(purpose_ptr);
20965         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
20966         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)(((uintptr_t)purpose) & ~1));
20967         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20968         *ret_copy = Event_payment_claimed(payment_hash_ref, amount_msat, purpose_conv);
20969         uint32_t ret_ref = (uintptr_t)ret_copy;
20970         return ret_ref;
20971 }
20972
20973 uint32_t  __attribute__((export_name("TS_Event_payment_sent"))) TS_Event_payment_sent(int8_tArray payment_id, int8_tArray payment_preimage, int8_tArray payment_hash, uint32_t fee_paid_msat) {
20974         LDKThirtyTwoBytes payment_id_ref;
20975         CHECK(payment_id->arr_len == 32);
20976         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
20977         LDKThirtyTwoBytes payment_preimage_ref;
20978         CHECK(payment_preimage->arr_len == 32);
20979         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
20980         LDKThirtyTwoBytes payment_hash_ref;
20981         CHECK(payment_hash->arr_len == 32);
20982         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
20983         void* fee_paid_msat_ptr = (void*)(((uintptr_t)fee_paid_msat) & ~1);
20984         CHECK_ACCESS(fee_paid_msat_ptr);
20985         LDKCOption_u64Z fee_paid_msat_conv = *(LDKCOption_u64Z*)(fee_paid_msat_ptr);
20986         fee_paid_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)fee_paid_msat) & ~1));
20987         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20988         *ret_copy = Event_payment_sent(payment_id_ref, payment_preimage_ref, payment_hash_ref, fee_paid_msat_conv);
20989         uint32_t ret_ref = (uintptr_t)ret_copy;
20990         return ret_ref;
20991 }
20992
20993 uint32_t  __attribute__((export_name("TS_Event_payment_failed"))) TS_Event_payment_failed(int8_tArray payment_id, int8_tArray payment_hash) {
20994         LDKThirtyTwoBytes payment_id_ref;
20995         CHECK(payment_id->arr_len == 32);
20996         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
20997         LDKThirtyTwoBytes payment_hash_ref;
20998         CHECK(payment_hash->arr_len == 32);
20999         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
21000         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
21001         *ret_copy = Event_payment_failed(payment_id_ref, payment_hash_ref);
21002         uint32_t ret_ref = (uintptr_t)ret_copy;
21003         return ret_ref;
21004 }
21005
21006 uint32_t  __attribute__((export_name("TS_Event_payment_path_successful"))) TS_Event_payment_path_successful(int8_tArray payment_id, int8_tArray payment_hash, uint32_tArray path) {
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_hash_ref;
21011         CHECK(payment_hash->arr_len == 32);
21012         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
21013         LDKCVec_RouteHopZ path_constr;
21014         path_constr.datalen = path->arr_len;
21015         if (path_constr.datalen > 0)
21016                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
21017         else
21018                 path_constr.data = NULL;
21019         uint32_t* path_vals = path->elems;
21020         for (size_t k = 0; k < path_constr.datalen; k++) {
21021                 uint32_t path_conv_10 = path_vals[k];
21022                 LDKRouteHop path_conv_10_conv;
21023                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
21024                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
21025                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
21026                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
21027                 path_constr.data[k] = path_conv_10_conv;
21028         }
21029         FREE(path);
21030         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
21031         *ret_copy = Event_payment_path_successful(payment_id_ref, payment_hash_ref, path_constr);
21032         uint32_t ret_ref = (uintptr_t)ret_copy;
21033         return ret_ref;
21034 }
21035
21036 uint32_t  __attribute__((export_name("TS_Event_payment_path_failed"))) TS_Event_payment_path_failed(int8_tArray payment_id, int8_tArray payment_hash, jboolean rejected_by_dest, uint32_t network_update, jboolean all_paths_failed, uint32_tArray path, uint32_t short_channel_id, uint32_t retry) {
21037         LDKThirtyTwoBytes payment_id_ref;
21038         CHECK(payment_id->arr_len == 32);
21039         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
21040         LDKThirtyTwoBytes payment_hash_ref;
21041         CHECK(payment_hash->arr_len == 32);
21042         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
21043         void* network_update_ptr = (void*)(((uintptr_t)network_update) & ~1);
21044         CHECK_ACCESS(network_update_ptr);
21045         LDKCOption_NetworkUpdateZ network_update_conv = *(LDKCOption_NetworkUpdateZ*)(network_update_ptr);
21046         network_update_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uintptr_t)network_update) & ~1));
21047         LDKCVec_RouteHopZ path_constr;
21048         path_constr.datalen = path->arr_len;
21049         if (path_constr.datalen > 0)
21050                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
21051         else
21052                 path_constr.data = NULL;
21053         uint32_t* path_vals = path->elems;
21054         for (size_t k = 0; k < path_constr.datalen; k++) {
21055                 uint32_t path_conv_10 = path_vals[k];
21056                 LDKRouteHop path_conv_10_conv;
21057                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
21058                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
21059                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
21060                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
21061                 path_constr.data[k] = path_conv_10_conv;
21062         }
21063         FREE(path);
21064         void* short_channel_id_ptr = (void*)(((uintptr_t)short_channel_id) & ~1);
21065         CHECK_ACCESS(short_channel_id_ptr);
21066         LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(short_channel_id_ptr);
21067         short_channel_id_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id) & ~1));
21068         LDKRouteParameters retry_conv;
21069         retry_conv.inner = (void*)(retry & (~1));
21070         retry_conv.is_owned = (retry & 1) || (retry == 0);
21071         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_conv);
21072         retry_conv = RouteParameters_clone(&retry_conv);
21073         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
21074         *ret_copy = Event_payment_path_failed(payment_id_ref, payment_hash_ref, rejected_by_dest, network_update_conv, all_paths_failed, path_constr, short_channel_id_conv, retry_conv);
21075         uint32_t ret_ref = (uintptr_t)ret_copy;
21076         return ret_ref;
21077 }
21078
21079 uint32_t  __attribute__((export_name("TS_Event_probe_successful"))) TS_Event_probe_successful(int8_tArray payment_id, int8_tArray payment_hash, uint32_tArray path) {
21080         LDKThirtyTwoBytes payment_id_ref;
21081         CHECK(payment_id->arr_len == 32);
21082         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
21083         LDKThirtyTwoBytes payment_hash_ref;
21084         CHECK(payment_hash->arr_len == 32);
21085         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
21086         LDKCVec_RouteHopZ path_constr;
21087         path_constr.datalen = path->arr_len;
21088         if (path_constr.datalen > 0)
21089                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
21090         else
21091                 path_constr.data = NULL;
21092         uint32_t* path_vals = path->elems;
21093         for (size_t k = 0; k < path_constr.datalen; k++) {
21094                 uint32_t path_conv_10 = path_vals[k];
21095                 LDKRouteHop path_conv_10_conv;
21096                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
21097                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
21098                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
21099                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
21100                 path_constr.data[k] = path_conv_10_conv;
21101         }
21102         FREE(path);
21103         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
21104         *ret_copy = Event_probe_successful(payment_id_ref, payment_hash_ref, path_constr);
21105         uint32_t ret_ref = (uintptr_t)ret_copy;
21106         return ret_ref;
21107 }
21108
21109 uint32_t  __attribute__((export_name("TS_Event_probe_failed"))) TS_Event_probe_failed(int8_tArray payment_id, int8_tArray payment_hash, uint32_tArray path, uint32_t short_channel_id) {
21110         LDKThirtyTwoBytes payment_id_ref;
21111         CHECK(payment_id->arr_len == 32);
21112         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
21113         LDKThirtyTwoBytes payment_hash_ref;
21114         CHECK(payment_hash->arr_len == 32);
21115         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
21116         LDKCVec_RouteHopZ path_constr;
21117         path_constr.datalen = path->arr_len;
21118         if (path_constr.datalen > 0)
21119                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
21120         else
21121                 path_constr.data = NULL;
21122         uint32_t* path_vals = path->elems;
21123         for (size_t k = 0; k < path_constr.datalen; k++) {
21124                 uint32_t path_conv_10 = path_vals[k];
21125                 LDKRouteHop path_conv_10_conv;
21126                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
21127                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
21128                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
21129                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
21130                 path_constr.data[k] = path_conv_10_conv;
21131         }
21132         FREE(path);
21133         void* short_channel_id_ptr = (void*)(((uintptr_t)short_channel_id) & ~1);
21134         CHECK_ACCESS(short_channel_id_ptr);
21135         LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(short_channel_id_ptr);
21136         short_channel_id_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id) & ~1));
21137         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
21138         *ret_copy = Event_probe_failed(payment_id_ref, payment_hash_ref, path_constr, short_channel_id_conv);
21139         uint32_t ret_ref = (uintptr_t)ret_copy;
21140         return ret_ref;
21141 }
21142
21143 uint32_t  __attribute__((export_name("TS_Event_pending_htlcs_forwardable"))) TS_Event_pending_htlcs_forwardable(int64_t time_forwardable) {
21144         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
21145         *ret_copy = Event_pending_htlcs_forwardable(time_forwardable);
21146         uint32_t ret_ref = (uintptr_t)ret_copy;
21147         return ret_ref;
21148 }
21149
21150 uint32_t  __attribute__((export_name("TS_Event_spendable_outputs"))) TS_Event_spendable_outputs(uint32_tArray outputs) {
21151         LDKCVec_SpendableOutputDescriptorZ outputs_constr;
21152         outputs_constr.datalen = outputs->arr_len;
21153         if (outputs_constr.datalen > 0)
21154                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
21155         else
21156                 outputs_constr.data = NULL;
21157         uint32_t* outputs_vals = outputs->elems;
21158         for (size_t b = 0; b < outputs_constr.datalen; b++) {
21159                 uint32_t outputs_conv_27 = outputs_vals[b];
21160                 void* outputs_conv_27_ptr = (void*)(((uintptr_t)outputs_conv_27) & ~1);
21161                 CHECK_ACCESS(outputs_conv_27_ptr);
21162                 LDKSpendableOutputDescriptor outputs_conv_27_conv = *(LDKSpendableOutputDescriptor*)(outputs_conv_27_ptr);
21163                 outputs_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)outputs_conv_27) & ~1));
21164                 outputs_constr.data[b] = outputs_conv_27_conv;
21165         }
21166         FREE(outputs);
21167         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
21168         *ret_copy = Event_spendable_outputs(outputs_constr);
21169         uint32_t ret_ref = (uintptr_t)ret_copy;
21170         return ret_ref;
21171 }
21172
21173 uint32_t  __attribute__((export_name("TS_Event_payment_forwarded"))) TS_Event_payment_forwarded(int8_tArray prev_channel_id, int8_tArray next_channel_id, uint32_t fee_earned_msat, jboolean claim_from_onchain_tx) {
21174         LDKThirtyTwoBytes prev_channel_id_ref;
21175         CHECK(prev_channel_id->arr_len == 32);
21176         memcpy(prev_channel_id_ref.data, prev_channel_id->elems, 32); FREE(prev_channel_id);
21177         LDKThirtyTwoBytes next_channel_id_ref;
21178         CHECK(next_channel_id->arr_len == 32);
21179         memcpy(next_channel_id_ref.data, next_channel_id->elems, 32); FREE(next_channel_id);
21180         void* fee_earned_msat_ptr = (void*)(((uintptr_t)fee_earned_msat) & ~1);
21181         CHECK_ACCESS(fee_earned_msat_ptr);
21182         LDKCOption_u64Z fee_earned_msat_conv = *(LDKCOption_u64Z*)(fee_earned_msat_ptr);
21183         fee_earned_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)fee_earned_msat) & ~1));
21184         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
21185         *ret_copy = Event_payment_forwarded(prev_channel_id_ref, next_channel_id_ref, fee_earned_msat_conv, claim_from_onchain_tx);
21186         uint32_t ret_ref = (uintptr_t)ret_copy;
21187         return ret_ref;
21188 }
21189
21190 uint32_t  __attribute__((export_name("TS_Event_channel_closed"))) TS_Event_channel_closed(int8_tArray channel_id, int64_t user_channel_id, uint32_t reason) {
21191         LDKThirtyTwoBytes channel_id_ref;
21192         CHECK(channel_id->arr_len == 32);
21193         memcpy(channel_id_ref.data, channel_id->elems, 32); FREE(channel_id);
21194         void* reason_ptr = (void*)(((uintptr_t)reason) & ~1);
21195         CHECK_ACCESS(reason_ptr);
21196         LDKClosureReason reason_conv = *(LDKClosureReason*)(reason_ptr);
21197         reason_conv = ClosureReason_clone((LDKClosureReason*)(((uintptr_t)reason) & ~1));
21198         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
21199         *ret_copy = Event_channel_closed(channel_id_ref, user_channel_id, reason_conv);
21200         uint32_t ret_ref = (uintptr_t)ret_copy;
21201         return ret_ref;
21202 }
21203
21204 uint32_t  __attribute__((export_name("TS_Event_discard_funding"))) TS_Event_discard_funding(int8_tArray channel_id, int8_tArray transaction) {
21205         LDKThirtyTwoBytes channel_id_ref;
21206         CHECK(channel_id->arr_len == 32);
21207         memcpy(channel_id_ref.data, channel_id->elems, 32); FREE(channel_id);
21208         LDKTransaction transaction_ref;
21209         transaction_ref.datalen = transaction->arr_len;
21210         transaction_ref.data = MALLOC(transaction_ref.datalen, "LDKTransaction Bytes");
21211         memcpy(transaction_ref.data, transaction->elems, transaction_ref.datalen); FREE(transaction);
21212         transaction_ref.data_is_owned = true;
21213         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
21214         *ret_copy = Event_discard_funding(channel_id_ref, transaction_ref);
21215         uint32_t ret_ref = (uintptr_t)ret_copy;
21216         return ret_ref;
21217 }
21218
21219 uint32_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, uint32_t channel_type) {
21220         LDKThirtyTwoBytes temporary_channel_id_ref;
21221         CHECK(temporary_channel_id->arr_len == 32);
21222         memcpy(temporary_channel_id_ref.data, temporary_channel_id->elems, 32); FREE(temporary_channel_id);
21223         LDKPublicKey counterparty_node_id_ref;
21224         CHECK(counterparty_node_id->arr_len == 33);
21225         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
21226         LDKChannelTypeFeatures channel_type_conv;
21227         channel_type_conv.inner = (void*)(channel_type & (~1));
21228         channel_type_conv.is_owned = (channel_type & 1) || (channel_type == 0);
21229         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_conv);
21230         channel_type_conv = ChannelTypeFeatures_clone(&channel_type_conv);
21231         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
21232         *ret_copy = Event_open_channel_request(temporary_channel_id_ref, counterparty_node_id_ref, funding_satoshis, push_msat, channel_type_conv);
21233         uint32_t ret_ref = (uintptr_t)ret_copy;
21234         return ret_ref;
21235 }
21236
21237 uint32_t  __attribute__((export_name("TS_Event_htlchandling_failed"))) TS_Event_htlchandling_failed(int8_tArray prev_channel_id, uint32_t failed_next_destination) {
21238         LDKThirtyTwoBytes prev_channel_id_ref;
21239         CHECK(prev_channel_id->arr_len == 32);
21240         memcpy(prev_channel_id_ref.data, prev_channel_id->elems, 32); FREE(prev_channel_id);
21241         void* failed_next_destination_ptr = (void*)(((uintptr_t)failed_next_destination) & ~1);
21242         CHECK_ACCESS(failed_next_destination_ptr);
21243         LDKHTLCDestination failed_next_destination_conv = *(LDKHTLCDestination*)(failed_next_destination_ptr);
21244         failed_next_destination_conv = HTLCDestination_clone((LDKHTLCDestination*)(((uintptr_t)failed_next_destination) & ~1));
21245         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
21246         *ret_copy = Event_htlchandling_failed(prev_channel_id_ref, failed_next_destination_conv);
21247         uint32_t ret_ref = (uintptr_t)ret_copy;
21248         return ret_ref;
21249 }
21250
21251 int8_tArray  __attribute__((export_name("TS_Event_write"))) TS_Event_write(uint32_t obj) {
21252         LDKEvent* obj_conv = (LDKEvent*)obj;
21253         LDKCVec_u8Z ret_var = Event_write(obj_conv);
21254         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
21255         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
21256         CVec_u8Z_free(ret_var);
21257         return ret_arr;
21258 }
21259
21260 uint32_t  __attribute__((export_name("TS_Event_read"))) TS_Event_read(int8_tArray ser) {
21261         LDKu8slice ser_ref;
21262         ser_ref.datalen = ser->arr_len;
21263         ser_ref.data = ser->elems;
21264         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
21265         *ret_conv = Event_read(ser_ref);
21266         FREE(ser);
21267         return (uint32_t)ret_conv;
21268 }
21269
21270 void  __attribute__((export_name("TS_MessageSendEvent_free"))) TS_MessageSendEvent_free(uint32_t this_ptr) {
21271         if ((this_ptr & 1) != 0) return;
21272         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21273         CHECK_ACCESS(this_ptr_ptr);
21274         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(this_ptr_ptr);
21275         FREE((void*)this_ptr);
21276         MessageSendEvent_free(this_ptr_conv);
21277 }
21278
21279 static inline uintptr_t MessageSendEvent_clone_ptr(LDKMessageSendEvent *NONNULL_PTR arg) {
21280         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21281         *ret_copy = MessageSendEvent_clone(arg);
21282 uint32_t ret_ref = (uintptr_t)ret_copy;
21283         return ret_ref;
21284 }
21285 uint32_t  __attribute__((export_name("TS_MessageSendEvent_clone_ptr"))) TS_MessageSendEvent_clone_ptr(uint32_t arg) {
21286         LDKMessageSendEvent* arg_conv = (LDKMessageSendEvent*)arg;
21287         uint32_t ret_conv = MessageSendEvent_clone_ptr(arg_conv);
21288         return ret_conv;
21289 }
21290
21291 uint32_t  __attribute__((export_name("TS_MessageSendEvent_clone"))) TS_MessageSendEvent_clone(uint32_t orig) {
21292         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)orig;
21293         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21294         *ret_copy = MessageSendEvent_clone(orig_conv);
21295         uint32_t ret_ref = (uintptr_t)ret_copy;
21296         return ret_ref;
21297 }
21298
21299 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_accept_channel"))) TS_MessageSendEvent_send_accept_channel(int8_tArray node_id, uint32_t msg) {
21300         LDKPublicKey node_id_ref;
21301         CHECK(node_id->arr_len == 33);
21302         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
21303         LDKAcceptChannel msg_conv;
21304         msg_conv.inner = (void*)(msg & (~1));
21305         msg_conv.is_owned = (msg & 1) || (msg == 0);
21306         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21307         msg_conv = AcceptChannel_clone(&msg_conv);
21308         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21309         *ret_copy = MessageSendEvent_send_accept_channel(node_id_ref, msg_conv);
21310         uint32_t ret_ref = (uintptr_t)ret_copy;
21311         return ret_ref;
21312 }
21313
21314 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_open_channel"))) TS_MessageSendEvent_send_open_channel(int8_tArray node_id, uint32_t msg) {
21315         LDKPublicKey node_id_ref;
21316         CHECK(node_id->arr_len == 33);
21317         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
21318         LDKOpenChannel msg_conv;
21319         msg_conv.inner = (void*)(msg & (~1));
21320         msg_conv.is_owned = (msg & 1) || (msg == 0);
21321         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21322         msg_conv = OpenChannel_clone(&msg_conv);
21323         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21324         *ret_copy = MessageSendEvent_send_open_channel(node_id_ref, msg_conv);
21325         uint32_t ret_ref = (uintptr_t)ret_copy;
21326         return ret_ref;
21327 }
21328
21329 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_funding_created"))) TS_MessageSendEvent_send_funding_created(int8_tArray node_id, uint32_t msg) {
21330         LDKPublicKey node_id_ref;
21331         CHECK(node_id->arr_len == 33);
21332         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
21333         LDKFundingCreated msg_conv;
21334         msg_conv.inner = (void*)(msg & (~1));
21335         msg_conv.is_owned = (msg & 1) || (msg == 0);
21336         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21337         msg_conv = FundingCreated_clone(&msg_conv);
21338         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21339         *ret_copy = MessageSendEvent_send_funding_created(node_id_ref, msg_conv);
21340         uint32_t ret_ref = (uintptr_t)ret_copy;
21341         return ret_ref;
21342 }
21343
21344 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_funding_signed"))) TS_MessageSendEvent_send_funding_signed(int8_tArray node_id, uint32_t msg) {
21345         LDKPublicKey node_id_ref;
21346         CHECK(node_id->arr_len == 33);
21347         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
21348         LDKFundingSigned msg_conv;
21349         msg_conv.inner = (void*)(msg & (~1));
21350         msg_conv.is_owned = (msg & 1) || (msg == 0);
21351         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21352         msg_conv = FundingSigned_clone(&msg_conv);
21353         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21354         *ret_copy = MessageSendEvent_send_funding_signed(node_id_ref, msg_conv);
21355         uint32_t ret_ref = (uintptr_t)ret_copy;
21356         return ret_ref;
21357 }
21358
21359 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_channel_ready"))) TS_MessageSendEvent_send_channel_ready(int8_tArray node_id, uint32_t msg) {
21360         LDKPublicKey node_id_ref;
21361         CHECK(node_id->arr_len == 33);
21362         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
21363         LDKChannelReady msg_conv;
21364         msg_conv.inner = (void*)(msg & (~1));
21365         msg_conv.is_owned = (msg & 1) || (msg == 0);
21366         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21367         msg_conv = ChannelReady_clone(&msg_conv);
21368         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21369         *ret_copy = MessageSendEvent_send_channel_ready(node_id_ref, msg_conv);
21370         uint32_t ret_ref = (uintptr_t)ret_copy;
21371         return ret_ref;
21372 }
21373
21374 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_announcement_signatures"))) TS_MessageSendEvent_send_announcement_signatures(int8_tArray node_id, uint32_t msg) {
21375         LDKPublicKey node_id_ref;
21376         CHECK(node_id->arr_len == 33);
21377         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
21378         LDKAnnouncementSignatures msg_conv;
21379         msg_conv.inner = (void*)(msg & (~1));
21380         msg_conv.is_owned = (msg & 1) || (msg == 0);
21381         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21382         msg_conv = AnnouncementSignatures_clone(&msg_conv);
21383         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21384         *ret_copy = MessageSendEvent_send_announcement_signatures(node_id_ref, msg_conv);
21385         uint32_t ret_ref = (uintptr_t)ret_copy;
21386         return ret_ref;
21387 }
21388
21389 uint32_t  __attribute__((export_name("TS_MessageSendEvent_update_htlcs"))) TS_MessageSendEvent_update_htlcs(int8_tArray node_id, uint32_t updates) {
21390         LDKPublicKey node_id_ref;
21391         CHECK(node_id->arr_len == 33);
21392         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
21393         LDKCommitmentUpdate updates_conv;
21394         updates_conv.inner = (void*)(updates & (~1));
21395         updates_conv.is_owned = (updates & 1) || (updates == 0);
21396         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
21397         updates_conv = CommitmentUpdate_clone(&updates_conv);
21398         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21399         *ret_copy = MessageSendEvent_update_htlcs(node_id_ref, updates_conv);
21400         uint32_t ret_ref = (uintptr_t)ret_copy;
21401         return ret_ref;
21402 }
21403
21404 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_revoke_and_ack"))) TS_MessageSendEvent_send_revoke_and_ack(int8_tArray node_id, uint32_t msg) {
21405         LDKPublicKey node_id_ref;
21406         CHECK(node_id->arr_len == 33);
21407         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
21408         LDKRevokeAndACK msg_conv;
21409         msg_conv.inner = (void*)(msg & (~1));
21410         msg_conv.is_owned = (msg & 1) || (msg == 0);
21411         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21412         msg_conv = RevokeAndACK_clone(&msg_conv);
21413         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21414         *ret_copy = MessageSendEvent_send_revoke_and_ack(node_id_ref, msg_conv);
21415         uint32_t ret_ref = (uintptr_t)ret_copy;
21416         return ret_ref;
21417 }
21418
21419 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_closing_signed"))) TS_MessageSendEvent_send_closing_signed(int8_tArray node_id, uint32_t msg) {
21420         LDKPublicKey node_id_ref;
21421         CHECK(node_id->arr_len == 33);
21422         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
21423         LDKClosingSigned msg_conv;
21424         msg_conv.inner = (void*)(msg & (~1));
21425         msg_conv.is_owned = (msg & 1) || (msg == 0);
21426         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21427         msg_conv = ClosingSigned_clone(&msg_conv);
21428         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21429         *ret_copy = MessageSendEvent_send_closing_signed(node_id_ref, msg_conv);
21430         uint32_t ret_ref = (uintptr_t)ret_copy;
21431         return ret_ref;
21432 }
21433
21434 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_shutdown"))) TS_MessageSendEvent_send_shutdown(int8_tArray node_id, uint32_t msg) {
21435         LDKPublicKey node_id_ref;
21436         CHECK(node_id->arr_len == 33);
21437         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
21438         LDKShutdown msg_conv;
21439         msg_conv.inner = (void*)(msg & (~1));
21440         msg_conv.is_owned = (msg & 1) || (msg == 0);
21441         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21442         msg_conv = Shutdown_clone(&msg_conv);
21443         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21444         *ret_copy = MessageSendEvent_send_shutdown(node_id_ref, msg_conv);
21445         uint32_t ret_ref = (uintptr_t)ret_copy;
21446         return ret_ref;
21447 }
21448
21449 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_channel_reestablish"))) TS_MessageSendEvent_send_channel_reestablish(int8_tArray node_id, uint32_t msg) {
21450         LDKPublicKey node_id_ref;
21451         CHECK(node_id->arr_len == 33);
21452         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
21453         LDKChannelReestablish msg_conv;
21454         msg_conv.inner = (void*)(msg & (~1));
21455         msg_conv.is_owned = (msg & 1) || (msg == 0);
21456         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21457         msg_conv = ChannelReestablish_clone(&msg_conv);
21458         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21459         *ret_copy = MessageSendEvent_send_channel_reestablish(node_id_ref, msg_conv);
21460         uint32_t ret_ref = (uintptr_t)ret_copy;
21461         return ret_ref;
21462 }
21463
21464 uint32_t  __attribute__((export_name("TS_MessageSendEvent_broadcast_channel_announcement"))) TS_MessageSendEvent_broadcast_channel_announcement(uint32_t msg, uint32_t update_msg) {
21465         LDKChannelAnnouncement msg_conv;
21466         msg_conv.inner = (void*)(msg & (~1));
21467         msg_conv.is_owned = (msg & 1) || (msg == 0);
21468         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21469         msg_conv = ChannelAnnouncement_clone(&msg_conv);
21470         LDKChannelUpdate update_msg_conv;
21471         update_msg_conv.inner = (void*)(update_msg & (~1));
21472         update_msg_conv.is_owned = (update_msg & 1) || (update_msg == 0);
21473         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_conv);
21474         update_msg_conv = ChannelUpdate_clone(&update_msg_conv);
21475         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21476         *ret_copy = MessageSendEvent_broadcast_channel_announcement(msg_conv, update_msg_conv);
21477         uint32_t ret_ref = (uintptr_t)ret_copy;
21478         return ret_ref;
21479 }
21480
21481 uint32_t  __attribute__((export_name("TS_MessageSendEvent_broadcast_node_announcement"))) TS_MessageSendEvent_broadcast_node_announcement(uint32_t msg) {
21482         LDKNodeAnnouncement msg_conv;
21483         msg_conv.inner = (void*)(msg & (~1));
21484         msg_conv.is_owned = (msg & 1) || (msg == 0);
21485         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21486         msg_conv = NodeAnnouncement_clone(&msg_conv);
21487         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21488         *ret_copy = MessageSendEvent_broadcast_node_announcement(msg_conv);
21489         uint32_t ret_ref = (uintptr_t)ret_copy;
21490         return ret_ref;
21491 }
21492
21493 uint32_t  __attribute__((export_name("TS_MessageSendEvent_broadcast_channel_update"))) TS_MessageSendEvent_broadcast_channel_update(uint32_t msg) {
21494         LDKChannelUpdate msg_conv;
21495         msg_conv.inner = (void*)(msg & (~1));
21496         msg_conv.is_owned = (msg & 1) || (msg == 0);
21497         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21498         msg_conv = ChannelUpdate_clone(&msg_conv);
21499         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21500         *ret_copy = MessageSendEvent_broadcast_channel_update(msg_conv);
21501         uint32_t ret_ref = (uintptr_t)ret_copy;
21502         return ret_ref;
21503 }
21504
21505 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_channel_update"))) TS_MessageSendEvent_send_channel_update(int8_tArray node_id, uint32_t msg) {
21506         LDKPublicKey node_id_ref;
21507         CHECK(node_id->arr_len == 33);
21508         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
21509         LDKChannelUpdate msg_conv;
21510         msg_conv.inner = (void*)(msg & (~1));
21511         msg_conv.is_owned = (msg & 1) || (msg == 0);
21512         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21513         msg_conv = ChannelUpdate_clone(&msg_conv);
21514         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21515         *ret_copy = MessageSendEvent_send_channel_update(node_id_ref, msg_conv);
21516         uint32_t ret_ref = (uintptr_t)ret_copy;
21517         return ret_ref;
21518 }
21519
21520 uint32_t  __attribute__((export_name("TS_MessageSendEvent_handle_error"))) TS_MessageSendEvent_handle_error(int8_tArray node_id, uint32_t action) {
21521         LDKPublicKey node_id_ref;
21522         CHECK(node_id->arr_len == 33);
21523         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
21524         void* action_ptr = (void*)(((uintptr_t)action) & ~1);
21525         CHECK_ACCESS(action_ptr);
21526         LDKErrorAction action_conv = *(LDKErrorAction*)(action_ptr);
21527         action_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)action) & ~1));
21528         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21529         *ret_copy = MessageSendEvent_handle_error(node_id_ref, action_conv);
21530         uint32_t ret_ref = (uintptr_t)ret_copy;
21531         return ret_ref;
21532 }
21533
21534 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_channel_range_query"))) TS_MessageSendEvent_send_channel_range_query(int8_tArray node_id, uint32_t msg) {
21535         LDKPublicKey node_id_ref;
21536         CHECK(node_id->arr_len == 33);
21537         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
21538         LDKQueryChannelRange msg_conv;
21539         msg_conv.inner = (void*)(msg & (~1));
21540         msg_conv.is_owned = (msg & 1) || (msg == 0);
21541         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21542         msg_conv = QueryChannelRange_clone(&msg_conv);
21543         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21544         *ret_copy = MessageSendEvent_send_channel_range_query(node_id_ref, msg_conv);
21545         uint32_t ret_ref = (uintptr_t)ret_copy;
21546         return ret_ref;
21547 }
21548
21549 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_short_ids_query"))) TS_MessageSendEvent_send_short_ids_query(int8_tArray node_id, uint32_t msg) {
21550         LDKPublicKey node_id_ref;
21551         CHECK(node_id->arr_len == 33);
21552         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
21553         LDKQueryShortChannelIds msg_conv;
21554         msg_conv.inner = (void*)(msg & (~1));
21555         msg_conv.is_owned = (msg & 1) || (msg == 0);
21556         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21557         msg_conv = QueryShortChannelIds_clone(&msg_conv);
21558         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21559         *ret_copy = MessageSendEvent_send_short_ids_query(node_id_ref, msg_conv);
21560         uint32_t ret_ref = (uintptr_t)ret_copy;
21561         return ret_ref;
21562 }
21563
21564 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_reply_channel_range"))) TS_MessageSendEvent_send_reply_channel_range(int8_tArray node_id, uint32_t msg) {
21565         LDKPublicKey node_id_ref;
21566         CHECK(node_id->arr_len == 33);
21567         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
21568         LDKReplyChannelRange msg_conv;
21569         msg_conv.inner = (void*)(msg & (~1));
21570         msg_conv.is_owned = (msg & 1) || (msg == 0);
21571         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21572         msg_conv = ReplyChannelRange_clone(&msg_conv);
21573         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21574         *ret_copy = MessageSendEvent_send_reply_channel_range(node_id_ref, msg_conv);
21575         uint32_t ret_ref = (uintptr_t)ret_copy;
21576         return ret_ref;
21577 }
21578
21579 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_gossip_timestamp_filter"))) TS_MessageSendEvent_send_gossip_timestamp_filter(int8_tArray node_id, uint32_t msg) {
21580         LDKPublicKey node_id_ref;
21581         CHECK(node_id->arr_len == 33);
21582         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
21583         LDKGossipTimestampFilter msg_conv;
21584         msg_conv.inner = (void*)(msg & (~1));
21585         msg_conv.is_owned = (msg & 1) || (msg == 0);
21586         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21587         msg_conv = GossipTimestampFilter_clone(&msg_conv);
21588         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21589         *ret_copy = MessageSendEvent_send_gossip_timestamp_filter(node_id_ref, msg_conv);
21590         uint32_t ret_ref = (uintptr_t)ret_copy;
21591         return ret_ref;
21592 }
21593
21594 void  __attribute__((export_name("TS_MessageSendEventsProvider_free"))) TS_MessageSendEventsProvider_free(uint32_t this_ptr) {
21595         if ((this_ptr & 1) != 0) return;
21596         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21597         CHECK_ACCESS(this_ptr_ptr);
21598         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(this_ptr_ptr);
21599         FREE((void*)this_ptr);
21600         MessageSendEventsProvider_free(this_ptr_conv);
21601 }
21602
21603 void  __attribute__((export_name("TS_EventsProvider_free"))) TS_EventsProvider_free(uint32_t this_ptr) {
21604         if ((this_ptr & 1) != 0) return;
21605         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21606         CHECK_ACCESS(this_ptr_ptr);
21607         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(this_ptr_ptr);
21608         FREE((void*)this_ptr);
21609         EventsProvider_free(this_ptr_conv);
21610 }
21611
21612 void  __attribute__((export_name("TS_EventHandler_free"))) TS_EventHandler_free(uint32_t this_ptr) {
21613         if ((this_ptr & 1) != 0) return;
21614         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21615         CHECK_ACCESS(this_ptr_ptr);
21616         LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(this_ptr_ptr);
21617         FREE((void*)this_ptr);
21618         EventHandler_free(this_ptr_conv);
21619 }
21620
21621 void  __attribute__((export_name("TS_APIError_free"))) TS_APIError_free(uint32_t this_ptr) {
21622         if ((this_ptr & 1) != 0) return;
21623         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21624         CHECK_ACCESS(this_ptr_ptr);
21625         LDKAPIError this_ptr_conv = *(LDKAPIError*)(this_ptr_ptr);
21626         FREE((void*)this_ptr);
21627         APIError_free(this_ptr_conv);
21628 }
21629
21630 static inline uintptr_t APIError_clone_ptr(LDKAPIError *NONNULL_PTR arg) {
21631         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
21632         *ret_copy = APIError_clone(arg);
21633 uint32_t ret_ref = (uintptr_t)ret_copy;
21634         return ret_ref;
21635 }
21636 uint32_t  __attribute__((export_name("TS_APIError_clone_ptr"))) TS_APIError_clone_ptr(uint32_t arg) {
21637         LDKAPIError* arg_conv = (LDKAPIError*)arg;
21638         uint32_t ret_conv = APIError_clone_ptr(arg_conv);
21639         return ret_conv;
21640 }
21641
21642 uint32_t  __attribute__((export_name("TS_APIError_clone"))) TS_APIError_clone(uint32_t orig) {
21643         LDKAPIError* orig_conv = (LDKAPIError*)orig;
21644         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
21645         *ret_copy = APIError_clone(orig_conv);
21646         uint32_t ret_ref = (uintptr_t)ret_copy;
21647         return ret_ref;
21648 }
21649
21650 uint32_t  __attribute__((export_name("TS_APIError_apimisuse_error"))) TS_APIError_apimisuse_error(jstring err) {
21651         LDKStr err_conv = str_ref_to_owned_c(err);
21652         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
21653         *ret_copy = APIError_apimisuse_error(err_conv);
21654         uint32_t ret_ref = (uintptr_t)ret_copy;
21655         return ret_ref;
21656 }
21657
21658 uint32_t  __attribute__((export_name("TS_APIError_fee_rate_too_high"))) TS_APIError_fee_rate_too_high(jstring err, int32_t feerate) {
21659         LDKStr err_conv = str_ref_to_owned_c(err);
21660         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
21661         *ret_copy = APIError_fee_rate_too_high(err_conv, feerate);
21662         uint32_t ret_ref = (uintptr_t)ret_copy;
21663         return ret_ref;
21664 }
21665
21666 uint32_t  __attribute__((export_name("TS_APIError_route_error"))) TS_APIError_route_error(jstring err) {
21667         LDKStr err_conv = str_ref_to_owned_c(err);
21668         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
21669         *ret_copy = APIError_route_error(err_conv);
21670         uint32_t ret_ref = (uintptr_t)ret_copy;
21671         return ret_ref;
21672 }
21673
21674 uint32_t  __attribute__((export_name("TS_APIError_channel_unavailable"))) TS_APIError_channel_unavailable(jstring err) {
21675         LDKStr err_conv = str_ref_to_owned_c(err);
21676         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
21677         *ret_copy = APIError_channel_unavailable(err_conv);
21678         uint32_t ret_ref = (uintptr_t)ret_copy;
21679         return ret_ref;
21680 }
21681
21682 uint32_t  __attribute__((export_name("TS_APIError_monitor_update_failed"))) TS_APIError_monitor_update_failed() {
21683         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
21684         *ret_copy = APIError_monitor_update_failed();
21685         uint32_t ret_ref = (uintptr_t)ret_copy;
21686         return ret_ref;
21687 }
21688
21689 uint32_t  __attribute__((export_name("TS_APIError_incompatible_shutdown_script"))) TS_APIError_incompatible_shutdown_script(uint32_t script) {
21690         LDKShutdownScript script_conv;
21691         script_conv.inner = (void*)(script & (~1));
21692         script_conv.is_owned = (script & 1) || (script == 0);
21693         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_conv);
21694         script_conv = ShutdownScript_clone(&script_conv);
21695         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
21696         *ret_copy = APIError_incompatible_shutdown_script(script_conv);
21697         uint32_t ret_ref = (uintptr_t)ret_copy;
21698         return ret_ref;
21699 }
21700
21701 void  __attribute__((export_name("TS_BigSize_free"))) TS_BigSize_free(uint32_t this_obj) {
21702         LDKBigSize this_obj_conv;
21703         this_obj_conv.inner = (void*)(this_obj & (~1));
21704         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21705         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21706         BigSize_free(this_obj_conv);
21707 }
21708
21709 int64_t  __attribute__((export_name("TS_BigSize_get_a"))) TS_BigSize_get_a(uint32_t this_ptr) {
21710         LDKBigSize this_ptr_conv;
21711         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21712         this_ptr_conv.is_owned = false;
21713         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21714         int64_t ret_conv = BigSize_get_a(&this_ptr_conv);
21715         return ret_conv;
21716 }
21717
21718 void  __attribute__((export_name("TS_BigSize_set_a"))) TS_BigSize_set_a(uint32_t this_ptr, int64_t val) {
21719         LDKBigSize this_ptr_conv;
21720         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21721         this_ptr_conv.is_owned = false;
21722         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21723         BigSize_set_a(&this_ptr_conv, val);
21724 }
21725
21726 uint32_t  __attribute__((export_name("TS_BigSize_new"))) TS_BigSize_new(int64_t a_arg) {
21727         LDKBigSize ret_var = BigSize_new(a_arg);
21728         uint32_t ret_ref = 0;
21729         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21730         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21731         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21732         ret_ref = (uintptr_t)ret_var.inner;
21733         if (ret_var.is_owned) {
21734                 ret_ref |= 1;
21735         }
21736         return ret_ref;
21737 }
21738
21739 void  __attribute__((export_name("TS_Hostname_free"))) TS_Hostname_free(uint32_t this_obj) {
21740         LDKHostname this_obj_conv;
21741         this_obj_conv.inner = (void*)(this_obj & (~1));
21742         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21743         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21744         Hostname_free(this_obj_conv);
21745 }
21746
21747 static inline uintptr_t Hostname_clone_ptr(LDKHostname *NONNULL_PTR arg) {
21748         LDKHostname ret_var = Hostname_clone(arg);
21749 uint32_t ret_ref = 0;
21750 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21751 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21752 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21753 ret_ref = (uintptr_t)ret_var.inner;
21754 if (ret_var.is_owned) {
21755         ret_ref |= 1;
21756 }
21757         return ret_ref;
21758 }
21759 uint32_t  __attribute__((export_name("TS_Hostname_clone_ptr"))) TS_Hostname_clone_ptr(uint32_t arg) {
21760         LDKHostname arg_conv;
21761         arg_conv.inner = (void*)(arg & (~1));
21762         arg_conv.is_owned = false;
21763         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21764         uint32_t ret_conv = Hostname_clone_ptr(&arg_conv);
21765         return ret_conv;
21766 }
21767
21768 uint32_t  __attribute__((export_name("TS_Hostname_clone"))) TS_Hostname_clone(uint32_t orig) {
21769         LDKHostname orig_conv;
21770         orig_conv.inner = (void*)(orig & (~1));
21771         orig_conv.is_owned = false;
21772         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21773         LDKHostname ret_var = Hostname_clone(&orig_conv);
21774         uint32_t ret_ref = 0;
21775         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21776         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21777         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21778         ret_ref = (uintptr_t)ret_var.inner;
21779         if (ret_var.is_owned) {
21780                 ret_ref |= 1;
21781         }
21782         return ret_ref;
21783 }
21784
21785 int8_t  __attribute__((export_name("TS_Hostname_len"))) TS_Hostname_len(uint32_t this_arg) {
21786         LDKHostname this_arg_conv;
21787         this_arg_conv.inner = (void*)(this_arg & (~1));
21788         this_arg_conv.is_owned = false;
21789         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21790         int8_t ret_conv = Hostname_len(&this_arg_conv);
21791         return ret_conv;
21792 }
21793
21794 uint32_t  __attribute__((export_name("TS_sign"))) TS_sign(int8_tArray msg, int8_tArray sk) {
21795         LDKu8slice msg_ref;
21796         msg_ref.datalen = msg->arr_len;
21797         msg_ref.data = msg->elems;
21798         unsigned char sk_arr[32];
21799         CHECK(sk->arr_len == 32);
21800         memcpy(sk_arr, sk->elems, 32); FREE(sk);
21801         unsigned char (*sk_ref)[32] = &sk_arr;
21802         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
21803         *ret_conv = sign(msg_ref, sk_ref);
21804         FREE(msg);
21805         return (uint32_t)ret_conv;
21806 }
21807
21808 uint32_t  __attribute__((export_name("TS_recover_pk"))) TS_recover_pk(int8_tArray msg, jstring sig) {
21809         LDKu8slice msg_ref;
21810         msg_ref.datalen = msg->arr_len;
21811         msg_ref.data = msg->elems;
21812         LDKStr sig_conv = str_ref_to_owned_c(sig);
21813         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
21814         *ret_conv = recover_pk(msg_ref, sig_conv);
21815         FREE(msg);
21816         return (uint32_t)ret_conv;
21817 }
21818
21819 jboolean  __attribute__((export_name("TS_verify"))) TS_verify(int8_tArray msg, jstring sig, int8_tArray pk) {
21820         LDKu8slice msg_ref;
21821         msg_ref.datalen = msg->arr_len;
21822         msg_ref.data = msg->elems;
21823         LDKStr sig_conv = str_ref_to_owned_c(sig);
21824         LDKPublicKey pk_ref;
21825         CHECK(pk->arr_len == 33);
21826         memcpy(pk_ref.compressed_form, pk->elems, 33); FREE(pk);
21827         jboolean ret_conv = verify(msg_ref, sig_conv, pk_ref);
21828         FREE(msg);
21829         return ret_conv;
21830 }
21831
21832 int8_tArray  __attribute__((export_name("TS_construct_invoice_preimage"))) TS_construct_invoice_preimage(int8_tArray hrp_bytes, ptrArray data_without_signature) {
21833         LDKu8slice hrp_bytes_ref;
21834         hrp_bytes_ref.datalen = hrp_bytes->arr_len;
21835         hrp_bytes_ref.data = hrp_bytes->elems;
21836         LDKCVec_u5Z data_without_signature_constr;
21837         data_without_signature_constr.datalen = data_without_signature->arr_len;
21838         if (data_without_signature_constr.datalen > 0)
21839                 data_without_signature_constr.data = MALLOC(data_without_signature_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
21840         else
21841                 data_without_signature_constr.data = NULL;
21842         int8_t* data_without_signature_vals = (void*) data_without_signature->elems;
21843         for (size_t h = 0; h < data_without_signature_constr.datalen; h++) {
21844                 int8_t data_without_signature_conv_7 = data_without_signature_vals[h];
21845                 
21846                 data_without_signature_constr.data[h] = (LDKu5){ ._0 = data_without_signature_conv_7 };
21847         }
21848         FREE(data_without_signature);
21849         LDKCVec_u8Z ret_var = construct_invoice_preimage(hrp_bytes_ref, data_without_signature_constr);
21850         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
21851         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
21852         CVec_u8Z_free(ret_var);
21853         FREE(hrp_bytes);
21854         return ret_arr;
21855 }
21856
21857 void  __attribute__((export_name("TS_Persister_free"))) TS_Persister_free(uint32_t this_ptr) {
21858         if ((this_ptr & 1) != 0) return;
21859         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21860         CHECK_ACCESS(this_ptr_ptr);
21861         LDKPersister this_ptr_conv = *(LDKPersister*)(this_ptr_ptr);
21862         FREE((void*)this_ptr);
21863         Persister_free(this_ptr_conv);
21864 }
21865
21866 uint32_t  __attribute__((export_name("TS_Level_clone"))) TS_Level_clone(uint32_t orig) {
21867         LDKLevel* orig_conv = (LDKLevel*)(orig & ~1);
21868         uint32_t ret_conv = LDKLevel_to_js(Level_clone(orig_conv));
21869         return ret_conv;
21870 }
21871
21872 uint32_t  __attribute__((export_name("TS_Level_gossip"))) TS_Level_gossip() {
21873         uint32_t ret_conv = LDKLevel_to_js(Level_gossip());
21874         return ret_conv;
21875 }
21876
21877 uint32_t  __attribute__((export_name("TS_Level_trace"))) TS_Level_trace() {
21878         uint32_t ret_conv = LDKLevel_to_js(Level_trace());
21879         return ret_conv;
21880 }
21881
21882 uint32_t  __attribute__((export_name("TS_Level_debug"))) TS_Level_debug() {
21883         uint32_t ret_conv = LDKLevel_to_js(Level_debug());
21884         return ret_conv;
21885 }
21886
21887 uint32_t  __attribute__((export_name("TS_Level_info"))) TS_Level_info() {
21888         uint32_t ret_conv = LDKLevel_to_js(Level_info());
21889         return ret_conv;
21890 }
21891
21892 uint32_t  __attribute__((export_name("TS_Level_warn"))) TS_Level_warn() {
21893         uint32_t ret_conv = LDKLevel_to_js(Level_warn());
21894         return ret_conv;
21895 }
21896
21897 uint32_t  __attribute__((export_name("TS_Level_error"))) TS_Level_error() {
21898         uint32_t ret_conv = LDKLevel_to_js(Level_error());
21899         return ret_conv;
21900 }
21901
21902 jboolean  __attribute__((export_name("TS_Level_eq"))) TS_Level_eq(uint32_t a, uint32_t b) {
21903         LDKLevel* a_conv = (LDKLevel*)(a & ~1);
21904         LDKLevel* b_conv = (LDKLevel*)(b & ~1);
21905         jboolean ret_conv = Level_eq(a_conv, b_conv);
21906         return ret_conv;
21907 }
21908
21909 int64_t  __attribute__((export_name("TS_Level_hash"))) TS_Level_hash(uint32_t o) {
21910         LDKLevel* o_conv = (LDKLevel*)(o & ~1);
21911         int64_t ret_conv = Level_hash(o_conv);
21912         return ret_conv;
21913 }
21914
21915 uint32_t  __attribute__((export_name("TS_Level_max"))) TS_Level_max() {
21916         uint32_t ret_conv = LDKLevel_to_js(Level_max());
21917         return ret_conv;
21918 }
21919
21920 void  __attribute__((export_name("TS_Record_free"))) TS_Record_free(uint32_t this_obj) {
21921         LDKRecord this_obj_conv;
21922         this_obj_conv.inner = (void*)(this_obj & (~1));
21923         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21924         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21925         Record_free(this_obj_conv);
21926 }
21927
21928 uint32_t  __attribute__((export_name("TS_Record_get_level"))) TS_Record_get_level(uint32_t this_ptr) {
21929         LDKRecord this_ptr_conv;
21930         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21931         this_ptr_conv.is_owned = false;
21932         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21933         uint32_t ret_conv = LDKLevel_to_js(Record_get_level(&this_ptr_conv));
21934         return ret_conv;
21935 }
21936
21937 void  __attribute__((export_name("TS_Record_set_level"))) TS_Record_set_level(uint32_t this_ptr, uint32_t val) {
21938         LDKRecord this_ptr_conv;
21939         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21940         this_ptr_conv.is_owned = false;
21941         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21942         LDKLevel val_conv = LDKLevel_from_js(val);
21943         Record_set_level(&this_ptr_conv, val_conv);
21944 }
21945
21946 jstring  __attribute__((export_name("TS_Record_get_args"))) TS_Record_get_args(uint32_t this_ptr) {
21947         LDKRecord this_ptr_conv;
21948         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21949         this_ptr_conv.is_owned = false;
21950         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21951         LDKStr ret_str = Record_get_args(&this_ptr_conv);
21952         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
21953         Str_free(ret_str);
21954         return ret_conv;
21955 }
21956
21957 void  __attribute__((export_name("TS_Record_set_args"))) TS_Record_set_args(uint32_t this_ptr, jstring val) {
21958         LDKRecord this_ptr_conv;
21959         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21960         this_ptr_conv.is_owned = false;
21961         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21962         LDKStr val_conv = str_ref_to_owned_c(val);
21963         Record_set_args(&this_ptr_conv, val_conv);
21964 }
21965
21966 jstring  __attribute__((export_name("TS_Record_get_module_path"))) TS_Record_get_module_path(uint32_t this_ptr) {
21967         LDKRecord this_ptr_conv;
21968         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21969         this_ptr_conv.is_owned = false;
21970         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21971         LDKStr ret_str = Record_get_module_path(&this_ptr_conv);
21972         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
21973         Str_free(ret_str);
21974         return ret_conv;
21975 }
21976
21977 void  __attribute__((export_name("TS_Record_set_module_path"))) TS_Record_set_module_path(uint32_t this_ptr, jstring val) {
21978         LDKRecord this_ptr_conv;
21979         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21980         this_ptr_conv.is_owned = false;
21981         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21982         LDKStr val_conv = str_ref_to_owned_c(val);
21983         Record_set_module_path(&this_ptr_conv, val_conv);
21984 }
21985
21986 jstring  __attribute__((export_name("TS_Record_get_file"))) TS_Record_get_file(uint32_t this_ptr) {
21987         LDKRecord this_ptr_conv;
21988         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21989         this_ptr_conv.is_owned = false;
21990         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21991         LDKStr ret_str = Record_get_file(&this_ptr_conv);
21992         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
21993         Str_free(ret_str);
21994         return ret_conv;
21995 }
21996
21997 void  __attribute__((export_name("TS_Record_set_file"))) TS_Record_set_file(uint32_t this_ptr, jstring val) {
21998         LDKRecord this_ptr_conv;
21999         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22000         this_ptr_conv.is_owned = false;
22001         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22002         LDKStr val_conv = str_ref_to_owned_c(val);
22003         Record_set_file(&this_ptr_conv, val_conv);
22004 }
22005
22006 int32_t  __attribute__((export_name("TS_Record_get_line"))) TS_Record_get_line(uint32_t this_ptr) {
22007         LDKRecord this_ptr_conv;
22008         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22009         this_ptr_conv.is_owned = false;
22010         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22011         int32_t ret_conv = Record_get_line(&this_ptr_conv);
22012         return ret_conv;
22013 }
22014
22015 void  __attribute__((export_name("TS_Record_set_line"))) TS_Record_set_line(uint32_t this_ptr, int32_t val) {
22016         LDKRecord this_ptr_conv;
22017         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22018         this_ptr_conv.is_owned = false;
22019         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22020         Record_set_line(&this_ptr_conv, val);
22021 }
22022
22023 static inline uintptr_t Record_clone_ptr(LDKRecord *NONNULL_PTR arg) {
22024         LDKRecord ret_var = Record_clone(arg);
22025 uint32_t ret_ref = 0;
22026 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22027 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22028 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22029 ret_ref = (uintptr_t)ret_var.inner;
22030 if (ret_var.is_owned) {
22031         ret_ref |= 1;
22032 }
22033         return ret_ref;
22034 }
22035 uint32_t  __attribute__((export_name("TS_Record_clone_ptr"))) TS_Record_clone_ptr(uint32_t arg) {
22036         LDKRecord arg_conv;
22037         arg_conv.inner = (void*)(arg & (~1));
22038         arg_conv.is_owned = false;
22039         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22040         uint32_t ret_conv = Record_clone_ptr(&arg_conv);
22041         return ret_conv;
22042 }
22043
22044 uint32_t  __attribute__((export_name("TS_Record_clone"))) TS_Record_clone(uint32_t orig) {
22045         LDKRecord orig_conv;
22046         orig_conv.inner = (void*)(orig & (~1));
22047         orig_conv.is_owned = false;
22048         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22049         LDKRecord ret_var = Record_clone(&orig_conv);
22050         uint32_t ret_ref = 0;
22051         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22052         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22053         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22054         ret_ref = (uintptr_t)ret_var.inner;
22055         if (ret_var.is_owned) {
22056                 ret_ref |= 1;
22057         }
22058         return ret_ref;
22059 }
22060
22061 void  __attribute__((export_name("TS_Logger_free"))) TS_Logger_free(uint32_t this_ptr) {
22062         if ((this_ptr & 1) != 0) return;
22063         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
22064         CHECK_ACCESS(this_ptr_ptr);
22065         LDKLogger this_ptr_conv = *(LDKLogger*)(this_ptr_ptr);
22066         FREE((void*)this_ptr);
22067         Logger_free(this_ptr_conv);
22068 }
22069
22070 void  __attribute__((export_name("TS_ChannelHandshakeConfig_free"))) TS_ChannelHandshakeConfig_free(uint32_t this_obj) {
22071         LDKChannelHandshakeConfig this_obj_conv;
22072         this_obj_conv.inner = (void*)(this_obj & (~1));
22073         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22074         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22075         ChannelHandshakeConfig_free(this_obj_conv);
22076 }
22077
22078 int32_t  __attribute__((export_name("TS_ChannelHandshakeConfig_get_minimum_depth"))) TS_ChannelHandshakeConfig_get_minimum_depth(uint32_t this_ptr) {
22079         LDKChannelHandshakeConfig this_ptr_conv;
22080         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22081         this_ptr_conv.is_owned = false;
22082         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22083         int32_t ret_conv = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
22084         return ret_conv;
22085 }
22086
22087 void  __attribute__((export_name("TS_ChannelHandshakeConfig_set_minimum_depth"))) TS_ChannelHandshakeConfig_set_minimum_depth(uint32_t this_ptr, int32_t val) {
22088         LDKChannelHandshakeConfig this_ptr_conv;
22089         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22090         this_ptr_conv.is_owned = false;
22091         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22092         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
22093 }
22094
22095 int16_t  __attribute__((export_name("TS_ChannelHandshakeConfig_get_our_to_self_delay"))) TS_ChannelHandshakeConfig_get_our_to_self_delay(uint32_t this_ptr) {
22096         LDKChannelHandshakeConfig this_ptr_conv;
22097         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22098         this_ptr_conv.is_owned = false;
22099         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22100         int16_t ret_conv = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
22101         return ret_conv;
22102 }
22103
22104 void  __attribute__((export_name("TS_ChannelHandshakeConfig_set_our_to_self_delay"))) TS_ChannelHandshakeConfig_set_our_to_self_delay(uint32_t this_ptr, int16_t val) {
22105         LDKChannelHandshakeConfig this_ptr_conv;
22106         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22107         this_ptr_conv.is_owned = false;
22108         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22109         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
22110 }
22111
22112 int64_t  __attribute__((export_name("TS_ChannelHandshakeConfig_get_our_htlc_minimum_msat"))) TS_ChannelHandshakeConfig_get_our_htlc_minimum_msat(uint32_t this_ptr) {
22113         LDKChannelHandshakeConfig this_ptr_conv;
22114         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22115         this_ptr_conv.is_owned = false;
22116         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22117         int64_t ret_conv = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
22118         return ret_conv;
22119 }
22120
22121 void  __attribute__((export_name("TS_ChannelHandshakeConfig_set_our_htlc_minimum_msat"))) TS_ChannelHandshakeConfig_set_our_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
22122         LDKChannelHandshakeConfig this_ptr_conv;
22123         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22124         this_ptr_conv.is_owned = false;
22125         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22126         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
22127 }
22128
22129 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(uint32_t this_ptr) {
22130         LDKChannelHandshakeConfig this_ptr_conv;
22131         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22132         this_ptr_conv.is_owned = false;
22133         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22134         int8_t ret_conv = ChannelHandshakeConfig_get_max_inbound_htlc_value_in_flight_percent_of_channel(&this_ptr_conv);
22135         return ret_conv;
22136 }
22137
22138 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(uint32_t this_ptr, int8_t val) {
22139         LDKChannelHandshakeConfig this_ptr_conv;
22140         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22141         this_ptr_conv.is_owned = false;
22142         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22143         ChannelHandshakeConfig_set_max_inbound_htlc_value_in_flight_percent_of_channel(&this_ptr_conv, val);
22144 }
22145
22146 jboolean  __attribute__((export_name("TS_ChannelHandshakeConfig_get_negotiate_scid_privacy"))) TS_ChannelHandshakeConfig_get_negotiate_scid_privacy(uint32_t this_ptr) {
22147         LDKChannelHandshakeConfig this_ptr_conv;
22148         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22149         this_ptr_conv.is_owned = false;
22150         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22151         jboolean ret_conv = ChannelHandshakeConfig_get_negotiate_scid_privacy(&this_ptr_conv);
22152         return ret_conv;
22153 }
22154
22155 void  __attribute__((export_name("TS_ChannelHandshakeConfig_set_negotiate_scid_privacy"))) TS_ChannelHandshakeConfig_set_negotiate_scid_privacy(uint32_t this_ptr, jboolean val) {
22156         LDKChannelHandshakeConfig this_ptr_conv;
22157         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22158         this_ptr_conv.is_owned = false;
22159         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22160         ChannelHandshakeConfig_set_negotiate_scid_privacy(&this_ptr_conv, val);
22161 }
22162
22163 jboolean  __attribute__((export_name("TS_ChannelHandshakeConfig_get_announced_channel"))) TS_ChannelHandshakeConfig_get_announced_channel(uint32_t this_ptr) {
22164         LDKChannelHandshakeConfig this_ptr_conv;
22165         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22166         this_ptr_conv.is_owned = false;
22167         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22168         jboolean ret_conv = ChannelHandshakeConfig_get_announced_channel(&this_ptr_conv);
22169         return ret_conv;
22170 }
22171
22172 void  __attribute__((export_name("TS_ChannelHandshakeConfig_set_announced_channel"))) TS_ChannelHandshakeConfig_set_announced_channel(uint32_t this_ptr, jboolean val) {
22173         LDKChannelHandshakeConfig this_ptr_conv;
22174         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22175         this_ptr_conv.is_owned = false;
22176         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22177         ChannelHandshakeConfig_set_announced_channel(&this_ptr_conv, val);
22178 }
22179
22180 jboolean  __attribute__((export_name("TS_ChannelHandshakeConfig_get_commit_upfront_shutdown_pubkey"))) TS_ChannelHandshakeConfig_get_commit_upfront_shutdown_pubkey(uint32_t this_ptr) {
22181         LDKChannelHandshakeConfig this_ptr_conv;
22182         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22183         this_ptr_conv.is_owned = false;
22184         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22185         jboolean ret_conv = ChannelHandshakeConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
22186         return ret_conv;
22187 }
22188
22189 void  __attribute__((export_name("TS_ChannelHandshakeConfig_set_commit_upfront_shutdown_pubkey"))) TS_ChannelHandshakeConfig_set_commit_upfront_shutdown_pubkey(uint32_t this_ptr, jboolean val) {
22190         LDKChannelHandshakeConfig this_ptr_conv;
22191         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22192         this_ptr_conv.is_owned = false;
22193         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22194         ChannelHandshakeConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
22195 }
22196
22197 uint32_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) {
22198         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);
22199         uint32_t ret_ref = 0;
22200         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22201         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22202         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22203         ret_ref = (uintptr_t)ret_var.inner;
22204         if (ret_var.is_owned) {
22205                 ret_ref |= 1;
22206         }
22207         return ret_ref;
22208 }
22209
22210 static inline uintptr_t ChannelHandshakeConfig_clone_ptr(LDKChannelHandshakeConfig *NONNULL_PTR arg) {
22211         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(arg);
22212 uint32_t ret_ref = 0;
22213 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22214 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22215 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22216 ret_ref = (uintptr_t)ret_var.inner;
22217 if (ret_var.is_owned) {
22218         ret_ref |= 1;
22219 }
22220         return ret_ref;
22221 }
22222 uint32_t  __attribute__((export_name("TS_ChannelHandshakeConfig_clone_ptr"))) TS_ChannelHandshakeConfig_clone_ptr(uint32_t arg) {
22223         LDKChannelHandshakeConfig arg_conv;
22224         arg_conv.inner = (void*)(arg & (~1));
22225         arg_conv.is_owned = false;
22226         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22227         uint32_t ret_conv = ChannelHandshakeConfig_clone_ptr(&arg_conv);
22228         return ret_conv;
22229 }
22230
22231 uint32_t  __attribute__((export_name("TS_ChannelHandshakeConfig_clone"))) TS_ChannelHandshakeConfig_clone(uint32_t orig) {
22232         LDKChannelHandshakeConfig orig_conv;
22233         orig_conv.inner = (void*)(orig & (~1));
22234         orig_conv.is_owned = false;
22235         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22236         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
22237         uint32_t ret_ref = 0;
22238         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22239         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22240         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22241         ret_ref = (uintptr_t)ret_var.inner;
22242         if (ret_var.is_owned) {
22243                 ret_ref |= 1;
22244         }
22245         return ret_ref;
22246 }
22247
22248 uint32_t  __attribute__((export_name("TS_ChannelHandshakeConfig_default"))) TS_ChannelHandshakeConfig_default() {
22249         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
22250         uint32_t ret_ref = 0;
22251         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22252         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22253         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22254         ret_ref = (uintptr_t)ret_var.inner;
22255         if (ret_var.is_owned) {
22256                 ret_ref |= 1;
22257         }
22258         return ret_ref;
22259 }
22260
22261 void  __attribute__((export_name("TS_ChannelHandshakeLimits_free"))) TS_ChannelHandshakeLimits_free(uint32_t this_obj) {
22262         LDKChannelHandshakeLimits this_obj_conv;
22263         this_obj_conv.inner = (void*)(this_obj & (~1));
22264         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22265         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22266         ChannelHandshakeLimits_free(this_obj_conv);
22267 }
22268
22269 int64_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_min_funding_satoshis"))) TS_ChannelHandshakeLimits_get_min_funding_satoshis(uint32_t this_ptr) {
22270         LDKChannelHandshakeLimits this_ptr_conv;
22271         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22272         this_ptr_conv.is_owned = false;
22273         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22274         int64_t ret_conv = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
22275         return ret_conv;
22276 }
22277
22278 void  __attribute__((export_name("TS_ChannelHandshakeLimits_set_min_funding_satoshis"))) TS_ChannelHandshakeLimits_set_min_funding_satoshis(uint32_t this_ptr, int64_t val) {
22279         LDKChannelHandshakeLimits this_ptr_conv;
22280         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22281         this_ptr_conv.is_owned = false;
22282         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22283         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
22284 }
22285
22286 int64_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_max_funding_satoshis"))) TS_ChannelHandshakeLimits_get_max_funding_satoshis(uint32_t this_ptr) {
22287         LDKChannelHandshakeLimits this_ptr_conv;
22288         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22289         this_ptr_conv.is_owned = false;
22290         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22291         int64_t ret_conv = ChannelHandshakeLimits_get_max_funding_satoshis(&this_ptr_conv);
22292         return ret_conv;
22293 }
22294
22295 void  __attribute__((export_name("TS_ChannelHandshakeLimits_set_max_funding_satoshis"))) TS_ChannelHandshakeLimits_set_max_funding_satoshis(uint32_t this_ptr, int64_t val) {
22296         LDKChannelHandshakeLimits this_ptr_conv;
22297         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22298         this_ptr_conv.is_owned = false;
22299         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22300         ChannelHandshakeLimits_set_max_funding_satoshis(&this_ptr_conv, val);
22301 }
22302
22303 int64_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_max_htlc_minimum_msat"))) TS_ChannelHandshakeLimits_get_max_htlc_minimum_msat(uint32_t this_ptr) {
22304         LDKChannelHandshakeLimits this_ptr_conv;
22305         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22306         this_ptr_conv.is_owned = false;
22307         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22308         int64_t ret_conv = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
22309         return ret_conv;
22310 }
22311
22312 void  __attribute__((export_name("TS_ChannelHandshakeLimits_set_max_htlc_minimum_msat"))) TS_ChannelHandshakeLimits_set_max_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
22313         LDKChannelHandshakeLimits this_ptr_conv;
22314         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22315         this_ptr_conv.is_owned = false;
22316         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22317         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
22318 }
22319
22320 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(uint32_t this_ptr) {
22321         LDKChannelHandshakeLimits this_ptr_conv;
22322         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22323         this_ptr_conv.is_owned = false;
22324         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22325         int64_t ret_conv = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
22326         return ret_conv;
22327 }
22328
22329 void  __attribute__((export_name("TS_ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat"))) TS_ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(uint32_t this_ptr, int64_t val) {
22330         LDKChannelHandshakeLimits this_ptr_conv;
22331         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22332         this_ptr_conv.is_owned = false;
22333         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22334         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
22335 }
22336
22337 int64_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_max_channel_reserve_satoshis"))) TS_ChannelHandshakeLimits_get_max_channel_reserve_satoshis(uint32_t this_ptr) {
22338         LDKChannelHandshakeLimits this_ptr_conv;
22339         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22340         this_ptr_conv.is_owned = false;
22341         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22342         int64_t ret_conv = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
22343         return ret_conv;
22344 }
22345
22346 void  __attribute__((export_name("TS_ChannelHandshakeLimits_set_max_channel_reserve_satoshis"))) TS_ChannelHandshakeLimits_set_max_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
22347         LDKChannelHandshakeLimits this_ptr_conv;
22348         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22349         this_ptr_conv.is_owned = false;
22350         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22351         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
22352 }
22353
22354 int16_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_min_max_accepted_htlcs"))) TS_ChannelHandshakeLimits_get_min_max_accepted_htlcs(uint32_t this_ptr) {
22355         LDKChannelHandshakeLimits this_ptr_conv;
22356         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22357         this_ptr_conv.is_owned = false;
22358         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22359         int16_t ret_conv = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
22360         return ret_conv;
22361 }
22362
22363 void  __attribute__((export_name("TS_ChannelHandshakeLimits_set_min_max_accepted_htlcs"))) TS_ChannelHandshakeLimits_set_min_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
22364         LDKChannelHandshakeLimits this_ptr_conv;
22365         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22366         this_ptr_conv.is_owned = false;
22367         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22368         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
22369 }
22370
22371 int32_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_max_minimum_depth"))) TS_ChannelHandshakeLimits_get_max_minimum_depth(uint32_t this_ptr) {
22372         LDKChannelHandshakeLimits this_ptr_conv;
22373         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22374         this_ptr_conv.is_owned = false;
22375         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22376         int32_t ret_conv = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
22377         return ret_conv;
22378 }
22379
22380 void  __attribute__((export_name("TS_ChannelHandshakeLimits_set_max_minimum_depth"))) TS_ChannelHandshakeLimits_set_max_minimum_depth(uint32_t this_ptr, int32_t val) {
22381         LDKChannelHandshakeLimits this_ptr_conv;
22382         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22383         this_ptr_conv.is_owned = false;
22384         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22385         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
22386 }
22387
22388 jboolean  __attribute__((export_name("TS_ChannelHandshakeLimits_get_trust_own_funding_0conf"))) TS_ChannelHandshakeLimits_get_trust_own_funding_0conf(uint32_t this_ptr) {
22389         LDKChannelHandshakeLimits this_ptr_conv;
22390         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22391         this_ptr_conv.is_owned = false;
22392         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22393         jboolean ret_conv = ChannelHandshakeLimits_get_trust_own_funding_0conf(&this_ptr_conv);
22394         return ret_conv;
22395 }
22396
22397 void  __attribute__((export_name("TS_ChannelHandshakeLimits_set_trust_own_funding_0conf"))) TS_ChannelHandshakeLimits_set_trust_own_funding_0conf(uint32_t this_ptr, jboolean val) {
22398         LDKChannelHandshakeLimits this_ptr_conv;
22399         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22400         this_ptr_conv.is_owned = false;
22401         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22402         ChannelHandshakeLimits_set_trust_own_funding_0conf(&this_ptr_conv, val);
22403 }
22404
22405 jboolean  __attribute__((export_name("TS_ChannelHandshakeLimits_get_force_announced_channel_preference"))) TS_ChannelHandshakeLimits_get_force_announced_channel_preference(uint32_t this_ptr) {
22406         LDKChannelHandshakeLimits this_ptr_conv;
22407         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22408         this_ptr_conv.is_owned = false;
22409         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22410         jboolean ret_conv = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
22411         return ret_conv;
22412 }
22413
22414 void  __attribute__((export_name("TS_ChannelHandshakeLimits_set_force_announced_channel_preference"))) TS_ChannelHandshakeLimits_set_force_announced_channel_preference(uint32_t this_ptr, jboolean val) {
22415         LDKChannelHandshakeLimits this_ptr_conv;
22416         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22417         this_ptr_conv.is_owned = false;
22418         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22419         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
22420 }
22421
22422 int16_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_their_to_self_delay"))) TS_ChannelHandshakeLimits_get_their_to_self_delay(uint32_t this_ptr) {
22423         LDKChannelHandshakeLimits this_ptr_conv;
22424         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22425         this_ptr_conv.is_owned = false;
22426         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22427         int16_t ret_conv = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
22428         return ret_conv;
22429 }
22430
22431 void  __attribute__((export_name("TS_ChannelHandshakeLimits_set_their_to_self_delay"))) TS_ChannelHandshakeLimits_set_their_to_self_delay(uint32_t this_ptr, int16_t val) {
22432         LDKChannelHandshakeLimits this_ptr_conv;
22433         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22434         this_ptr_conv.is_owned = false;
22435         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22436         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
22437 }
22438
22439 uint32_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) {
22440         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);
22441         uint32_t ret_ref = 0;
22442         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22443         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22444         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22445         ret_ref = (uintptr_t)ret_var.inner;
22446         if (ret_var.is_owned) {
22447                 ret_ref |= 1;
22448         }
22449         return ret_ref;
22450 }
22451
22452 static inline uintptr_t ChannelHandshakeLimits_clone_ptr(LDKChannelHandshakeLimits *NONNULL_PTR arg) {
22453         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(arg);
22454 uint32_t ret_ref = 0;
22455 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22456 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22457 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22458 ret_ref = (uintptr_t)ret_var.inner;
22459 if (ret_var.is_owned) {
22460         ret_ref |= 1;
22461 }
22462         return ret_ref;
22463 }
22464 uint32_t  __attribute__((export_name("TS_ChannelHandshakeLimits_clone_ptr"))) TS_ChannelHandshakeLimits_clone_ptr(uint32_t arg) {
22465         LDKChannelHandshakeLimits arg_conv;
22466         arg_conv.inner = (void*)(arg & (~1));
22467         arg_conv.is_owned = false;
22468         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22469         uint32_t ret_conv = ChannelHandshakeLimits_clone_ptr(&arg_conv);
22470         return ret_conv;
22471 }
22472
22473 uint32_t  __attribute__((export_name("TS_ChannelHandshakeLimits_clone"))) TS_ChannelHandshakeLimits_clone(uint32_t orig) {
22474         LDKChannelHandshakeLimits orig_conv;
22475         orig_conv.inner = (void*)(orig & (~1));
22476         orig_conv.is_owned = false;
22477         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22478         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
22479         uint32_t ret_ref = 0;
22480         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22481         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22482         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22483         ret_ref = (uintptr_t)ret_var.inner;
22484         if (ret_var.is_owned) {
22485                 ret_ref |= 1;
22486         }
22487         return ret_ref;
22488 }
22489
22490 uint32_t  __attribute__((export_name("TS_ChannelHandshakeLimits_default"))) TS_ChannelHandshakeLimits_default() {
22491         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
22492         uint32_t ret_ref = 0;
22493         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22494         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22495         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22496         ret_ref = (uintptr_t)ret_var.inner;
22497         if (ret_var.is_owned) {
22498                 ret_ref |= 1;
22499         }
22500         return ret_ref;
22501 }
22502
22503 void  __attribute__((export_name("TS_ChannelConfig_free"))) TS_ChannelConfig_free(uint32_t this_obj) {
22504         LDKChannelConfig this_obj_conv;
22505         this_obj_conv.inner = (void*)(this_obj & (~1));
22506         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22507         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22508         ChannelConfig_free(this_obj_conv);
22509 }
22510
22511 int32_t  __attribute__((export_name("TS_ChannelConfig_get_forwarding_fee_proportional_millionths"))) TS_ChannelConfig_get_forwarding_fee_proportional_millionths(uint32_t this_ptr) {
22512         LDKChannelConfig this_ptr_conv;
22513         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22514         this_ptr_conv.is_owned = false;
22515         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22516         int32_t ret_conv = ChannelConfig_get_forwarding_fee_proportional_millionths(&this_ptr_conv);
22517         return ret_conv;
22518 }
22519
22520 void  __attribute__((export_name("TS_ChannelConfig_set_forwarding_fee_proportional_millionths"))) TS_ChannelConfig_set_forwarding_fee_proportional_millionths(uint32_t this_ptr, int32_t val) {
22521         LDKChannelConfig this_ptr_conv;
22522         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22523         this_ptr_conv.is_owned = false;
22524         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22525         ChannelConfig_set_forwarding_fee_proportional_millionths(&this_ptr_conv, val);
22526 }
22527
22528 int32_t  __attribute__((export_name("TS_ChannelConfig_get_forwarding_fee_base_msat"))) TS_ChannelConfig_get_forwarding_fee_base_msat(uint32_t this_ptr) {
22529         LDKChannelConfig this_ptr_conv;
22530         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22531         this_ptr_conv.is_owned = false;
22532         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22533         int32_t ret_conv = ChannelConfig_get_forwarding_fee_base_msat(&this_ptr_conv);
22534         return ret_conv;
22535 }
22536
22537 void  __attribute__((export_name("TS_ChannelConfig_set_forwarding_fee_base_msat"))) TS_ChannelConfig_set_forwarding_fee_base_msat(uint32_t this_ptr, int32_t val) {
22538         LDKChannelConfig this_ptr_conv;
22539         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22540         this_ptr_conv.is_owned = false;
22541         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22542         ChannelConfig_set_forwarding_fee_base_msat(&this_ptr_conv, val);
22543 }
22544
22545 int16_t  __attribute__((export_name("TS_ChannelConfig_get_cltv_expiry_delta"))) TS_ChannelConfig_get_cltv_expiry_delta(uint32_t this_ptr) {
22546         LDKChannelConfig this_ptr_conv;
22547         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22548         this_ptr_conv.is_owned = false;
22549         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22550         int16_t ret_conv = ChannelConfig_get_cltv_expiry_delta(&this_ptr_conv);
22551         return ret_conv;
22552 }
22553
22554 void  __attribute__((export_name("TS_ChannelConfig_set_cltv_expiry_delta"))) TS_ChannelConfig_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
22555         LDKChannelConfig this_ptr_conv;
22556         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22557         this_ptr_conv.is_owned = false;
22558         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22559         ChannelConfig_set_cltv_expiry_delta(&this_ptr_conv, val);
22560 }
22561
22562 int64_t  __attribute__((export_name("TS_ChannelConfig_get_max_dust_htlc_exposure_msat"))) TS_ChannelConfig_get_max_dust_htlc_exposure_msat(uint32_t this_ptr) {
22563         LDKChannelConfig this_ptr_conv;
22564         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22565         this_ptr_conv.is_owned = false;
22566         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22567         int64_t ret_conv = ChannelConfig_get_max_dust_htlc_exposure_msat(&this_ptr_conv);
22568         return ret_conv;
22569 }
22570
22571 void  __attribute__((export_name("TS_ChannelConfig_set_max_dust_htlc_exposure_msat"))) TS_ChannelConfig_set_max_dust_htlc_exposure_msat(uint32_t this_ptr, int64_t val) {
22572         LDKChannelConfig this_ptr_conv;
22573         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22574         this_ptr_conv.is_owned = false;
22575         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22576         ChannelConfig_set_max_dust_htlc_exposure_msat(&this_ptr_conv, val);
22577 }
22578
22579 int64_t  __attribute__((export_name("TS_ChannelConfig_get_force_close_avoidance_max_fee_satoshis"))) TS_ChannelConfig_get_force_close_avoidance_max_fee_satoshis(uint32_t this_ptr) {
22580         LDKChannelConfig this_ptr_conv;
22581         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22582         this_ptr_conv.is_owned = false;
22583         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22584         int64_t ret_conv = ChannelConfig_get_force_close_avoidance_max_fee_satoshis(&this_ptr_conv);
22585         return ret_conv;
22586 }
22587
22588 void  __attribute__((export_name("TS_ChannelConfig_set_force_close_avoidance_max_fee_satoshis"))) TS_ChannelConfig_set_force_close_avoidance_max_fee_satoshis(uint32_t this_ptr, int64_t val) {
22589         LDKChannelConfig this_ptr_conv;
22590         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22591         this_ptr_conv.is_owned = false;
22592         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22593         ChannelConfig_set_force_close_avoidance_max_fee_satoshis(&this_ptr_conv, val);
22594 }
22595
22596 uint32_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) {
22597         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);
22598         uint32_t ret_ref = 0;
22599         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22600         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22601         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22602         ret_ref = (uintptr_t)ret_var.inner;
22603         if (ret_var.is_owned) {
22604                 ret_ref |= 1;
22605         }
22606         return ret_ref;
22607 }
22608
22609 static inline uintptr_t ChannelConfig_clone_ptr(LDKChannelConfig *NONNULL_PTR arg) {
22610         LDKChannelConfig ret_var = ChannelConfig_clone(arg);
22611 uint32_t ret_ref = 0;
22612 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22613 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22614 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22615 ret_ref = (uintptr_t)ret_var.inner;
22616 if (ret_var.is_owned) {
22617         ret_ref |= 1;
22618 }
22619         return ret_ref;
22620 }
22621 uint32_t  __attribute__((export_name("TS_ChannelConfig_clone_ptr"))) TS_ChannelConfig_clone_ptr(uint32_t arg) {
22622         LDKChannelConfig arg_conv;
22623         arg_conv.inner = (void*)(arg & (~1));
22624         arg_conv.is_owned = false;
22625         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22626         uint32_t ret_conv = ChannelConfig_clone_ptr(&arg_conv);
22627         return ret_conv;
22628 }
22629
22630 uint32_t  __attribute__((export_name("TS_ChannelConfig_clone"))) TS_ChannelConfig_clone(uint32_t orig) {
22631         LDKChannelConfig orig_conv;
22632         orig_conv.inner = (void*)(orig & (~1));
22633         orig_conv.is_owned = false;
22634         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22635         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
22636         uint32_t ret_ref = 0;
22637         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22638         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22639         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22640         ret_ref = (uintptr_t)ret_var.inner;
22641         if (ret_var.is_owned) {
22642                 ret_ref |= 1;
22643         }
22644         return ret_ref;
22645 }
22646
22647 uint32_t  __attribute__((export_name("TS_ChannelConfig_default"))) TS_ChannelConfig_default() {
22648         LDKChannelConfig ret_var = ChannelConfig_default();
22649         uint32_t ret_ref = 0;
22650         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22651         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22652         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22653         ret_ref = (uintptr_t)ret_var.inner;
22654         if (ret_var.is_owned) {
22655                 ret_ref |= 1;
22656         }
22657         return ret_ref;
22658 }
22659
22660 int8_tArray  __attribute__((export_name("TS_ChannelConfig_write"))) TS_ChannelConfig_write(uint32_t obj) {
22661         LDKChannelConfig obj_conv;
22662         obj_conv.inner = (void*)(obj & (~1));
22663         obj_conv.is_owned = false;
22664         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
22665         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
22666         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
22667         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
22668         CVec_u8Z_free(ret_var);
22669         return ret_arr;
22670 }
22671
22672 uint32_t  __attribute__((export_name("TS_ChannelConfig_read"))) TS_ChannelConfig_read(int8_tArray ser) {
22673         LDKu8slice ser_ref;
22674         ser_ref.datalen = ser->arr_len;
22675         ser_ref.data = ser->elems;
22676         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
22677         *ret_conv = ChannelConfig_read(ser_ref);
22678         FREE(ser);
22679         return (uint32_t)ret_conv;
22680 }
22681
22682 void  __attribute__((export_name("TS_UserConfig_free"))) TS_UserConfig_free(uint32_t this_obj) {
22683         LDKUserConfig this_obj_conv;
22684         this_obj_conv.inner = (void*)(this_obj & (~1));
22685         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22686         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22687         UserConfig_free(this_obj_conv);
22688 }
22689
22690 uint32_t  __attribute__((export_name("TS_UserConfig_get_channel_handshake_config"))) TS_UserConfig_get_channel_handshake_config(uint32_t this_ptr) {
22691         LDKUserConfig this_ptr_conv;
22692         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22693         this_ptr_conv.is_owned = false;
22694         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22695         LDKChannelHandshakeConfig ret_var = UserConfig_get_channel_handshake_config(&this_ptr_conv);
22696         uint32_t ret_ref = 0;
22697         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22698         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22699         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22700         ret_ref = (uintptr_t)ret_var.inner;
22701         if (ret_var.is_owned) {
22702                 ret_ref |= 1;
22703         }
22704         return ret_ref;
22705 }
22706
22707 void  __attribute__((export_name("TS_UserConfig_set_channel_handshake_config"))) TS_UserConfig_set_channel_handshake_config(uint32_t this_ptr, uint32_t val) {
22708         LDKUserConfig this_ptr_conv;
22709         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22710         this_ptr_conv.is_owned = false;
22711         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22712         LDKChannelHandshakeConfig val_conv;
22713         val_conv.inner = (void*)(val & (~1));
22714         val_conv.is_owned = (val & 1) || (val == 0);
22715         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
22716         val_conv = ChannelHandshakeConfig_clone(&val_conv);
22717         UserConfig_set_channel_handshake_config(&this_ptr_conv, val_conv);
22718 }
22719
22720 uint32_t  __attribute__((export_name("TS_UserConfig_get_channel_handshake_limits"))) TS_UserConfig_get_channel_handshake_limits(uint32_t this_ptr) {
22721         LDKUserConfig this_ptr_conv;
22722         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22723         this_ptr_conv.is_owned = false;
22724         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22725         LDKChannelHandshakeLimits ret_var = UserConfig_get_channel_handshake_limits(&this_ptr_conv);
22726         uint32_t ret_ref = 0;
22727         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22728         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22729         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22730         ret_ref = (uintptr_t)ret_var.inner;
22731         if (ret_var.is_owned) {
22732                 ret_ref |= 1;
22733         }
22734         return ret_ref;
22735 }
22736
22737 void  __attribute__((export_name("TS_UserConfig_set_channel_handshake_limits"))) TS_UserConfig_set_channel_handshake_limits(uint32_t this_ptr, uint32_t val) {
22738         LDKUserConfig this_ptr_conv;
22739         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22740         this_ptr_conv.is_owned = false;
22741         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22742         LDKChannelHandshakeLimits val_conv;
22743         val_conv.inner = (void*)(val & (~1));
22744         val_conv.is_owned = (val & 1) || (val == 0);
22745         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
22746         val_conv = ChannelHandshakeLimits_clone(&val_conv);
22747         UserConfig_set_channel_handshake_limits(&this_ptr_conv, val_conv);
22748 }
22749
22750 uint32_t  __attribute__((export_name("TS_UserConfig_get_channel_config"))) TS_UserConfig_get_channel_config(uint32_t this_ptr) {
22751         LDKUserConfig this_ptr_conv;
22752         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22753         this_ptr_conv.is_owned = false;
22754         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22755         LDKChannelConfig ret_var = UserConfig_get_channel_config(&this_ptr_conv);
22756         uint32_t ret_ref = 0;
22757         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22758         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22759         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22760         ret_ref = (uintptr_t)ret_var.inner;
22761         if (ret_var.is_owned) {
22762                 ret_ref |= 1;
22763         }
22764         return ret_ref;
22765 }
22766
22767 void  __attribute__((export_name("TS_UserConfig_set_channel_config"))) TS_UserConfig_set_channel_config(uint32_t this_ptr, uint32_t val) {
22768         LDKUserConfig this_ptr_conv;
22769         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22770         this_ptr_conv.is_owned = false;
22771         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22772         LDKChannelConfig val_conv;
22773         val_conv.inner = (void*)(val & (~1));
22774         val_conv.is_owned = (val & 1) || (val == 0);
22775         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
22776         val_conv = ChannelConfig_clone(&val_conv);
22777         UserConfig_set_channel_config(&this_ptr_conv, val_conv);
22778 }
22779
22780 jboolean  __attribute__((export_name("TS_UserConfig_get_accept_forwards_to_priv_channels"))) TS_UserConfig_get_accept_forwards_to_priv_channels(uint32_t this_ptr) {
22781         LDKUserConfig this_ptr_conv;
22782         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22783         this_ptr_conv.is_owned = false;
22784         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22785         jboolean ret_conv = UserConfig_get_accept_forwards_to_priv_channels(&this_ptr_conv);
22786         return ret_conv;
22787 }
22788
22789 void  __attribute__((export_name("TS_UserConfig_set_accept_forwards_to_priv_channels"))) TS_UserConfig_set_accept_forwards_to_priv_channels(uint32_t this_ptr, jboolean val) {
22790         LDKUserConfig this_ptr_conv;
22791         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22792         this_ptr_conv.is_owned = false;
22793         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22794         UserConfig_set_accept_forwards_to_priv_channels(&this_ptr_conv, val);
22795 }
22796
22797 jboolean  __attribute__((export_name("TS_UserConfig_get_accept_inbound_channels"))) TS_UserConfig_get_accept_inbound_channels(uint32_t this_ptr) {
22798         LDKUserConfig this_ptr_conv;
22799         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22800         this_ptr_conv.is_owned = false;
22801         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22802         jboolean ret_conv = UserConfig_get_accept_inbound_channels(&this_ptr_conv);
22803         return ret_conv;
22804 }
22805
22806 void  __attribute__((export_name("TS_UserConfig_set_accept_inbound_channels"))) TS_UserConfig_set_accept_inbound_channels(uint32_t this_ptr, jboolean val) {
22807         LDKUserConfig this_ptr_conv;
22808         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22809         this_ptr_conv.is_owned = false;
22810         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22811         UserConfig_set_accept_inbound_channels(&this_ptr_conv, val);
22812 }
22813
22814 jboolean  __attribute__((export_name("TS_UserConfig_get_manually_accept_inbound_channels"))) TS_UserConfig_get_manually_accept_inbound_channels(uint32_t this_ptr) {
22815         LDKUserConfig this_ptr_conv;
22816         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22817         this_ptr_conv.is_owned = false;
22818         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22819         jboolean ret_conv = UserConfig_get_manually_accept_inbound_channels(&this_ptr_conv);
22820         return ret_conv;
22821 }
22822
22823 void  __attribute__((export_name("TS_UserConfig_set_manually_accept_inbound_channels"))) TS_UserConfig_set_manually_accept_inbound_channels(uint32_t this_ptr, jboolean val) {
22824         LDKUserConfig this_ptr_conv;
22825         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22826         this_ptr_conv.is_owned = false;
22827         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22828         UserConfig_set_manually_accept_inbound_channels(&this_ptr_conv, val);
22829 }
22830
22831 uint32_t  __attribute__((export_name("TS_UserConfig_new"))) TS_UserConfig_new(uint32_t channel_handshake_config_arg, uint32_t channel_handshake_limits_arg, uint32_t channel_config_arg, jboolean accept_forwards_to_priv_channels_arg, jboolean accept_inbound_channels_arg, jboolean manually_accept_inbound_channels_arg) {
22832         LDKChannelHandshakeConfig channel_handshake_config_arg_conv;
22833         channel_handshake_config_arg_conv.inner = (void*)(channel_handshake_config_arg & (~1));
22834         channel_handshake_config_arg_conv.is_owned = (channel_handshake_config_arg & 1) || (channel_handshake_config_arg == 0);
22835         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_handshake_config_arg_conv);
22836         channel_handshake_config_arg_conv = ChannelHandshakeConfig_clone(&channel_handshake_config_arg_conv);
22837         LDKChannelHandshakeLimits channel_handshake_limits_arg_conv;
22838         channel_handshake_limits_arg_conv.inner = (void*)(channel_handshake_limits_arg & (~1));
22839         channel_handshake_limits_arg_conv.is_owned = (channel_handshake_limits_arg & 1) || (channel_handshake_limits_arg == 0);
22840         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_handshake_limits_arg_conv);
22841         channel_handshake_limits_arg_conv = ChannelHandshakeLimits_clone(&channel_handshake_limits_arg_conv);
22842         LDKChannelConfig channel_config_arg_conv;
22843         channel_config_arg_conv.inner = (void*)(channel_config_arg & (~1));
22844         channel_config_arg_conv.is_owned = (channel_config_arg & 1) || (channel_config_arg == 0);
22845         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_config_arg_conv);
22846         channel_config_arg_conv = ChannelConfig_clone(&channel_config_arg_conv);
22847         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);
22848         uint32_t ret_ref = 0;
22849         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22850         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22851         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22852         ret_ref = (uintptr_t)ret_var.inner;
22853         if (ret_var.is_owned) {
22854                 ret_ref |= 1;
22855         }
22856         return ret_ref;
22857 }
22858
22859 static inline uintptr_t UserConfig_clone_ptr(LDKUserConfig *NONNULL_PTR arg) {
22860         LDKUserConfig ret_var = UserConfig_clone(arg);
22861 uint32_t ret_ref = 0;
22862 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22863 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22864 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22865 ret_ref = (uintptr_t)ret_var.inner;
22866 if (ret_var.is_owned) {
22867         ret_ref |= 1;
22868 }
22869         return ret_ref;
22870 }
22871 uint32_t  __attribute__((export_name("TS_UserConfig_clone_ptr"))) TS_UserConfig_clone_ptr(uint32_t arg) {
22872         LDKUserConfig arg_conv;
22873         arg_conv.inner = (void*)(arg & (~1));
22874         arg_conv.is_owned = false;
22875         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22876         uint32_t ret_conv = UserConfig_clone_ptr(&arg_conv);
22877         return ret_conv;
22878 }
22879
22880 uint32_t  __attribute__((export_name("TS_UserConfig_clone"))) TS_UserConfig_clone(uint32_t orig) {
22881         LDKUserConfig orig_conv;
22882         orig_conv.inner = (void*)(orig & (~1));
22883         orig_conv.is_owned = false;
22884         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22885         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
22886         uint32_t ret_ref = 0;
22887         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22888         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22889         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22890         ret_ref = (uintptr_t)ret_var.inner;
22891         if (ret_var.is_owned) {
22892                 ret_ref |= 1;
22893         }
22894         return ret_ref;
22895 }
22896
22897 uint32_t  __attribute__((export_name("TS_UserConfig_default"))) TS_UserConfig_default() {
22898         LDKUserConfig ret_var = UserConfig_default();
22899         uint32_t ret_ref = 0;
22900         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22901         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22902         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22903         ret_ref = (uintptr_t)ret_var.inner;
22904         if (ret_var.is_owned) {
22905                 ret_ref |= 1;
22906         }
22907         return ret_ref;
22908 }
22909
22910 void  __attribute__((export_name("TS_BestBlock_free"))) TS_BestBlock_free(uint32_t this_obj) {
22911         LDKBestBlock this_obj_conv;
22912         this_obj_conv.inner = (void*)(this_obj & (~1));
22913         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22914         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22915         BestBlock_free(this_obj_conv);
22916 }
22917
22918 static inline uintptr_t BestBlock_clone_ptr(LDKBestBlock *NONNULL_PTR arg) {
22919         LDKBestBlock ret_var = BestBlock_clone(arg);
22920 uint32_t ret_ref = 0;
22921 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22922 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22923 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22924 ret_ref = (uintptr_t)ret_var.inner;
22925 if (ret_var.is_owned) {
22926         ret_ref |= 1;
22927 }
22928         return ret_ref;
22929 }
22930 uint32_t  __attribute__((export_name("TS_BestBlock_clone_ptr"))) TS_BestBlock_clone_ptr(uint32_t arg) {
22931         LDKBestBlock arg_conv;
22932         arg_conv.inner = (void*)(arg & (~1));
22933         arg_conv.is_owned = false;
22934         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22935         uint32_t ret_conv = BestBlock_clone_ptr(&arg_conv);
22936         return ret_conv;
22937 }
22938
22939 uint32_t  __attribute__((export_name("TS_BestBlock_clone"))) TS_BestBlock_clone(uint32_t orig) {
22940         LDKBestBlock orig_conv;
22941         orig_conv.inner = (void*)(orig & (~1));
22942         orig_conv.is_owned = false;
22943         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22944         LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
22945         uint32_t ret_ref = 0;
22946         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22947         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22948         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22949         ret_ref = (uintptr_t)ret_var.inner;
22950         if (ret_var.is_owned) {
22951                 ret_ref |= 1;
22952         }
22953         return ret_ref;
22954 }
22955
22956 uint32_t  __attribute__((export_name("TS_BestBlock_from_genesis"))) TS_BestBlock_from_genesis(uint32_t network) {
22957         LDKNetwork network_conv = LDKNetwork_from_js(network);
22958         LDKBestBlock ret_var = BestBlock_from_genesis(network_conv);
22959         uint32_t ret_ref = 0;
22960         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22961         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22962         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22963         ret_ref = (uintptr_t)ret_var.inner;
22964         if (ret_var.is_owned) {
22965                 ret_ref |= 1;
22966         }
22967         return ret_ref;
22968 }
22969
22970 uint32_t  __attribute__((export_name("TS_BestBlock_new"))) TS_BestBlock_new(int8_tArray block_hash, int32_t height) {
22971         LDKThirtyTwoBytes block_hash_ref;
22972         CHECK(block_hash->arr_len == 32);
22973         memcpy(block_hash_ref.data, block_hash->elems, 32); FREE(block_hash);
22974         LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
22975         uint32_t ret_ref = 0;
22976         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22977         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22978         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22979         ret_ref = (uintptr_t)ret_var.inner;
22980         if (ret_var.is_owned) {
22981                 ret_ref |= 1;
22982         }
22983         return ret_ref;
22984 }
22985
22986 int8_tArray  __attribute__((export_name("TS_BestBlock_block_hash"))) TS_BestBlock_block_hash(uint32_t this_arg) {
22987         LDKBestBlock this_arg_conv;
22988         this_arg_conv.inner = (void*)(this_arg & (~1));
22989         this_arg_conv.is_owned = false;
22990         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22991         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
22992         memcpy(ret_arr->elems, BestBlock_block_hash(&this_arg_conv).data, 32);
22993         return ret_arr;
22994 }
22995
22996 int32_t  __attribute__((export_name("TS_BestBlock_height"))) TS_BestBlock_height(uint32_t this_arg) {
22997         LDKBestBlock this_arg_conv;
22998         this_arg_conv.inner = (void*)(this_arg & (~1));
22999         this_arg_conv.is_owned = false;
23000         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23001         int32_t ret_conv = BestBlock_height(&this_arg_conv);
23002         return ret_conv;
23003 }
23004
23005 uint32_t  __attribute__((export_name("TS_AccessError_clone"))) TS_AccessError_clone(uint32_t orig) {
23006         LDKAccessError* orig_conv = (LDKAccessError*)(orig & ~1);
23007         uint32_t ret_conv = LDKAccessError_to_js(AccessError_clone(orig_conv));
23008         return ret_conv;
23009 }
23010
23011 uint32_t  __attribute__((export_name("TS_AccessError_unknown_chain"))) TS_AccessError_unknown_chain() {
23012         uint32_t ret_conv = LDKAccessError_to_js(AccessError_unknown_chain());
23013         return ret_conv;
23014 }
23015
23016 uint32_t  __attribute__((export_name("TS_AccessError_unknown_tx"))) TS_AccessError_unknown_tx() {
23017         uint32_t ret_conv = LDKAccessError_to_js(AccessError_unknown_tx());
23018         return ret_conv;
23019 }
23020
23021 void  __attribute__((export_name("TS_Access_free"))) TS_Access_free(uint32_t this_ptr) {
23022         if ((this_ptr & 1) != 0) return;
23023         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23024         CHECK_ACCESS(this_ptr_ptr);
23025         LDKAccess this_ptr_conv = *(LDKAccess*)(this_ptr_ptr);
23026         FREE((void*)this_ptr);
23027         Access_free(this_ptr_conv);
23028 }
23029
23030 void  __attribute__((export_name("TS_Listen_free"))) TS_Listen_free(uint32_t this_ptr) {
23031         if ((this_ptr & 1) != 0) return;
23032         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23033         CHECK_ACCESS(this_ptr_ptr);
23034         LDKListen this_ptr_conv = *(LDKListen*)(this_ptr_ptr);
23035         FREE((void*)this_ptr);
23036         Listen_free(this_ptr_conv);
23037 }
23038
23039 void  __attribute__((export_name("TS_Confirm_free"))) TS_Confirm_free(uint32_t this_ptr) {
23040         if ((this_ptr & 1) != 0) return;
23041         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23042         CHECK_ACCESS(this_ptr_ptr);
23043         LDKConfirm this_ptr_conv = *(LDKConfirm*)(this_ptr_ptr);
23044         FREE((void*)this_ptr);
23045         Confirm_free(this_ptr_conv);
23046 }
23047
23048 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdateErr_clone"))) TS_ChannelMonitorUpdateErr_clone(uint32_t orig) {
23049         LDKChannelMonitorUpdateErr* orig_conv = (LDKChannelMonitorUpdateErr*)(orig & ~1);
23050         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_clone(orig_conv));
23051         return ret_conv;
23052 }
23053
23054 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdateErr_temporary_failure"))) TS_ChannelMonitorUpdateErr_temporary_failure() {
23055         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_temporary_failure());
23056         return ret_conv;
23057 }
23058
23059 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdateErr_permanent_failure"))) TS_ChannelMonitorUpdateErr_permanent_failure() {
23060         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_permanent_failure());
23061         return ret_conv;
23062 }
23063
23064 void  __attribute__((export_name("TS_Watch_free"))) TS_Watch_free(uint32_t this_ptr) {
23065         if ((this_ptr & 1) != 0) return;
23066         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23067         CHECK_ACCESS(this_ptr_ptr);
23068         LDKWatch this_ptr_conv = *(LDKWatch*)(this_ptr_ptr);
23069         FREE((void*)this_ptr);
23070         Watch_free(this_ptr_conv);
23071 }
23072
23073 void  __attribute__((export_name("TS_Filter_free"))) TS_Filter_free(uint32_t this_ptr) {
23074         if ((this_ptr & 1) != 0) return;
23075         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23076         CHECK_ACCESS(this_ptr_ptr);
23077         LDKFilter this_ptr_conv = *(LDKFilter*)(this_ptr_ptr);
23078         FREE((void*)this_ptr);
23079         Filter_free(this_ptr_conv);
23080 }
23081
23082 void  __attribute__((export_name("TS_WatchedOutput_free"))) TS_WatchedOutput_free(uint32_t this_obj) {
23083         LDKWatchedOutput this_obj_conv;
23084         this_obj_conv.inner = (void*)(this_obj & (~1));
23085         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23086         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23087         WatchedOutput_free(this_obj_conv);
23088 }
23089
23090 int8_tArray  __attribute__((export_name("TS_WatchedOutput_get_block_hash"))) TS_WatchedOutput_get_block_hash(uint32_t this_ptr) {
23091         LDKWatchedOutput this_ptr_conv;
23092         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23093         this_ptr_conv.is_owned = false;
23094         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23095         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
23096         memcpy(ret_arr->elems, WatchedOutput_get_block_hash(&this_ptr_conv).data, 32);
23097         return ret_arr;
23098 }
23099
23100 void  __attribute__((export_name("TS_WatchedOutput_set_block_hash"))) TS_WatchedOutput_set_block_hash(uint32_t this_ptr, int8_tArray val) {
23101         LDKWatchedOutput this_ptr_conv;
23102         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23103         this_ptr_conv.is_owned = false;
23104         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23105         LDKThirtyTwoBytes val_ref;
23106         CHECK(val->arr_len == 32);
23107         memcpy(val_ref.data, val->elems, 32); FREE(val);
23108         WatchedOutput_set_block_hash(&this_ptr_conv, val_ref);
23109 }
23110
23111 uint32_t  __attribute__((export_name("TS_WatchedOutput_get_outpoint"))) TS_WatchedOutput_get_outpoint(uint32_t this_ptr) {
23112         LDKWatchedOutput this_ptr_conv;
23113         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23114         this_ptr_conv.is_owned = false;
23115         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23116         LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
23117         uint32_t ret_ref = 0;
23118         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23119         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23120         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23121         ret_ref = (uintptr_t)ret_var.inner;
23122         if (ret_var.is_owned) {
23123                 ret_ref |= 1;
23124         }
23125         return ret_ref;
23126 }
23127
23128 void  __attribute__((export_name("TS_WatchedOutput_set_outpoint"))) TS_WatchedOutput_set_outpoint(uint32_t this_ptr, uint32_t val) {
23129         LDKWatchedOutput this_ptr_conv;
23130         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23131         this_ptr_conv.is_owned = false;
23132         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23133         LDKOutPoint val_conv;
23134         val_conv.inner = (void*)(val & (~1));
23135         val_conv.is_owned = (val & 1) || (val == 0);
23136         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
23137         val_conv = OutPoint_clone(&val_conv);
23138         WatchedOutput_set_outpoint(&this_ptr_conv, val_conv);
23139 }
23140
23141 int8_tArray  __attribute__((export_name("TS_WatchedOutput_get_script_pubkey"))) TS_WatchedOutput_get_script_pubkey(uint32_t this_ptr) {
23142         LDKWatchedOutput this_ptr_conv;
23143         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23144         this_ptr_conv.is_owned = false;
23145         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23146         LDKu8slice ret_var = WatchedOutput_get_script_pubkey(&this_ptr_conv);
23147         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
23148         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
23149         return ret_arr;
23150 }
23151
23152 void  __attribute__((export_name("TS_WatchedOutput_set_script_pubkey"))) TS_WatchedOutput_set_script_pubkey(uint32_t this_ptr, int8_tArray val) {
23153         LDKWatchedOutput this_ptr_conv;
23154         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23155         this_ptr_conv.is_owned = false;
23156         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23157         LDKCVec_u8Z val_ref;
23158         val_ref.datalen = val->arr_len;
23159         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
23160         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
23161         WatchedOutput_set_script_pubkey(&this_ptr_conv, val_ref);
23162 }
23163
23164 uint32_t  __attribute__((export_name("TS_WatchedOutput_new"))) TS_WatchedOutput_new(int8_tArray block_hash_arg, uint32_t outpoint_arg, int8_tArray script_pubkey_arg) {
23165         LDKThirtyTwoBytes block_hash_arg_ref;
23166         CHECK(block_hash_arg->arr_len == 32);
23167         memcpy(block_hash_arg_ref.data, block_hash_arg->elems, 32); FREE(block_hash_arg);
23168         LDKOutPoint outpoint_arg_conv;
23169         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
23170         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
23171         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
23172         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
23173         LDKCVec_u8Z script_pubkey_arg_ref;
23174         script_pubkey_arg_ref.datalen = script_pubkey_arg->arr_len;
23175         script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
23176         memcpy(script_pubkey_arg_ref.data, script_pubkey_arg->elems, script_pubkey_arg_ref.datalen); FREE(script_pubkey_arg);
23177         LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
23178         uint32_t ret_ref = 0;
23179         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23180         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23181         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23182         ret_ref = (uintptr_t)ret_var.inner;
23183         if (ret_var.is_owned) {
23184                 ret_ref |= 1;
23185         }
23186         return ret_ref;
23187 }
23188
23189 static inline uintptr_t WatchedOutput_clone_ptr(LDKWatchedOutput *NONNULL_PTR arg) {
23190         LDKWatchedOutput ret_var = WatchedOutput_clone(arg);
23191 uint32_t ret_ref = 0;
23192 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23193 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23194 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23195 ret_ref = (uintptr_t)ret_var.inner;
23196 if (ret_var.is_owned) {
23197         ret_ref |= 1;
23198 }
23199         return ret_ref;
23200 }
23201 uint32_t  __attribute__((export_name("TS_WatchedOutput_clone_ptr"))) TS_WatchedOutput_clone_ptr(uint32_t arg) {
23202         LDKWatchedOutput arg_conv;
23203         arg_conv.inner = (void*)(arg & (~1));
23204         arg_conv.is_owned = false;
23205         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23206         uint32_t ret_conv = WatchedOutput_clone_ptr(&arg_conv);
23207         return ret_conv;
23208 }
23209
23210 uint32_t  __attribute__((export_name("TS_WatchedOutput_clone"))) TS_WatchedOutput_clone(uint32_t orig) {
23211         LDKWatchedOutput orig_conv;
23212         orig_conv.inner = (void*)(orig & (~1));
23213         orig_conv.is_owned = false;
23214         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23215         LDKWatchedOutput ret_var = WatchedOutput_clone(&orig_conv);
23216         uint32_t ret_ref = 0;
23217         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23218         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23219         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23220         ret_ref = (uintptr_t)ret_var.inner;
23221         if (ret_var.is_owned) {
23222                 ret_ref |= 1;
23223         }
23224         return ret_ref;
23225 }
23226
23227 int64_t  __attribute__((export_name("TS_WatchedOutput_hash"))) TS_WatchedOutput_hash(uint32_t o) {
23228         LDKWatchedOutput o_conv;
23229         o_conv.inner = (void*)(o & (~1));
23230         o_conv.is_owned = false;
23231         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23232         int64_t ret_conv = WatchedOutput_hash(&o_conv);
23233         return ret_conv;
23234 }
23235
23236 void  __attribute__((export_name("TS_BroadcasterInterface_free"))) TS_BroadcasterInterface_free(uint32_t this_ptr) {
23237         if ((this_ptr & 1) != 0) return;
23238         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23239         CHECK_ACCESS(this_ptr_ptr);
23240         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(this_ptr_ptr);
23241         FREE((void*)this_ptr);
23242         BroadcasterInterface_free(this_ptr_conv);
23243 }
23244
23245 uint32_t  __attribute__((export_name("TS_ConfirmationTarget_clone"))) TS_ConfirmationTarget_clone(uint32_t orig) {
23246         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)(orig & ~1);
23247         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_clone(orig_conv));
23248         return ret_conv;
23249 }
23250
23251 uint32_t  __attribute__((export_name("TS_ConfirmationTarget_background"))) TS_ConfirmationTarget_background() {
23252         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_background());
23253         return ret_conv;
23254 }
23255
23256 uint32_t  __attribute__((export_name("TS_ConfirmationTarget_normal"))) TS_ConfirmationTarget_normal() {
23257         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_normal());
23258         return ret_conv;
23259 }
23260
23261 uint32_t  __attribute__((export_name("TS_ConfirmationTarget_high_priority"))) TS_ConfirmationTarget_high_priority() {
23262         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_high_priority());
23263         return ret_conv;
23264 }
23265
23266 jboolean  __attribute__((export_name("TS_ConfirmationTarget_eq"))) TS_ConfirmationTarget_eq(uint32_t a, uint32_t b) {
23267         LDKConfirmationTarget* a_conv = (LDKConfirmationTarget*)(a & ~1);
23268         LDKConfirmationTarget* b_conv = (LDKConfirmationTarget*)(b & ~1);
23269         jboolean ret_conv = ConfirmationTarget_eq(a_conv, b_conv);
23270         return ret_conv;
23271 }
23272
23273 void  __attribute__((export_name("TS_FeeEstimator_free"))) TS_FeeEstimator_free(uint32_t this_ptr) {
23274         if ((this_ptr & 1) != 0) return;
23275         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23276         CHECK_ACCESS(this_ptr_ptr);
23277         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(this_ptr_ptr);
23278         FREE((void*)this_ptr);
23279         FeeEstimator_free(this_ptr_conv);
23280 }
23281
23282 void  __attribute__((export_name("TS_MonitorUpdateId_free"))) TS_MonitorUpdateId_free(uint32_t this_obj) {
23283         LDKMonitorUpdateId this_obj_conv;
23284         this_obj_conv.inner = (void*)(this_obj & (~1));
23285         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23286         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23287         MonitorUpdateId_free(this_obj_conv);
23288 }
23289
23290 static inline uintptr_t MonitorUpdateId_clone_ptr(LDKMonitorUpdateId *NONNULL_PTR arg) {
23291         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(arg);
23292 uint32_t ret_ref = 0;
23293 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23294 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23295 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23296 ret_ref = (uintptr_t)ret_var.inner;
23297 if (ret_var.is_owned) {
23298         ret_ref |= 1;
23299 }
23300         return ret_ref;
23301 }
23302 uint32_t  __attribute__((export_name("TS_MonitorUpdateId_clone_ptr"))) TS_MonitorUpdateId_clone_ptr(uint32_t arg) {
23303         LDKMonitorUpdateId arg_conv;
23304         arg_conv.inner = (void*)(arg & (~1));
23305         arg_conv.is_owned = false;
23306         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23307         uint32_t ret_conv = MonitorUpdateId_clone_ptr(&arg_conv);
23308         return ret_conv;
23309 }
23310
23311 uint32_t  __attribute__((export_name("TS_MonitorUpdateId_clone"))) TS_MonitorUpdateId_clone(uint32_t orig) {
23312         LDKMonitorUpdateId orig_conv;
23313         orig_conv.inner = (void*)(orig & (~1));
23314         orig_conv.is_owned = false;
23315         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23316         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(&orig_conv);
23317         uint32_t ret_ref = 0;
23318         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23319         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23320         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23321         ret_ref = (uintptr_t)ret_var.inner;
23322         if (ret_var.is_owned) {
23323                 ret_ref |= 1;
23324         }
23325         return ret_ref;
23326 }
23327
23328 int64_t  __attribute__((export_name("TS_MonitorUpdateId_hash"))) TS_MonitorUpdateId_hash(uint32_t o) {
23329         LDKMonitorUpdateId o_conv;
23330         o_conv.inner = (void*)(o & (~1));
23331         o_conv.is_owned = false;
23332         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23333         int64_t ret_conv = MonitorUpdateId_hash(&o_conv);
23334         return ret_conv;
23335 }
23336
23337 jboolean  __attribute__((export_name("TS_MonitorUpdateId_eq"))) TS_MonitorUpdateId_eq(uint32_t a, uint32_t b) {
23338         LDKMonitorUpdateId a_conv;
23339         a_conv.inner = (void*)(a & (~1));
23340         a_conv.is_owned = false;
23341         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
23342         LDKMonitorUpdateId b_conv;
23343         b_conv.inner = (void*)(b & (~1));
23344         b_conv.is_owned = false;
23345         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
23346         jboolean ret_conv = MonitorUpdateId_eq(&a_conv, &b_conv);
23347         return ret_conv;
23348 }
23349
23350 void  __attribute__((export_name("TS_Persist_free"))) TS_Persist_free(uint32_t this_ptr) {
23351         if ((this_ptr & 1) != 0) return;
23352         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23353         CHECK_ACCESS(this_ptr_ptr);
23354         LDKPersist this_ptr_conv = *(LDKPersist*)(this_ptr_ptr);
23355         FREE((void*)this_ptr);
23356         Persist_free(this_ptr_conv);
23357 }
23358
23359 void  __attribute__((export_name("TS_LockedChannelMonitor_free"))) TS_LockedChannelMonitor_free(uint32_t this_obj) {
23360         LDKLockedChannelMonitor this_obj_conv;
23361         this_obj_conv.inner = (void*)(this_obj & (~1));
23362         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23363         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23364         LockedChannelMonitor_free(this_obj_conv);
23365 }
23366
23367 void  __attribute__((export_name("TS_ChainMonitor_free"))) TS_ChainMonitor_free(uint32_t this_obj) {
23368         LDKChainMonitor this_obj_conv;
23369         this_obj_conv.inner = (void*)(this_obj & (~1));
23370         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23371         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23372         ChainMonitor_free(this_obj_conv);
23373 }
23374
23375 uint32_t  __attribute__((export_name("TS_ChainMonitor_new"))) TS_ChainMonitor_new(uint32_t chain_source, uint32_t broadcaster, uint32_t logger, uint32_t feeest, uint32_t persister) {
23376         void* chain_source_ptr = (void*)(((uintptr_t)chain_source) & ~1);
23377         CHECK_ACCESS(chain_source_ptr);
23378         LDKCOption_FilterZ chain_source_conv = *(LDKCOption_FilterZ*)(chain_source_ptr);
23379         // WARNING: we may need a move here but no clone is available for LDKCOption_FilterZ
23380         if (chain_source_conv.tag == LDKCOption_FilterZ_Some) {
23381                 // Manually implement clone for Java trait instances
23382                 if (chain_source_conv.some.free == LDKFilter_JCalls_free) {
23383                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23384                         LDKFilter_JCalls_cloned(&chain_source_conv.some);
23385                 }
23386         }
23387         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
23388         CHECK_ACCESS(broadcaster_ptr);
23389         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
23390         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
23391                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23392                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
23393         }
23394         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
23395         CHECK_ACCESS(logger_ptr);
23396         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
23397         if (logger_conv.free == LDKLogger_JCalls_free) {
23398                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23399                 LDKLogger_JCalls_cloned(&logger_conv);
23400         }
23401         void* feeest_ptr = (void*)(((uintptr_t)feeest) & ~1);
23402         CHECK_ACCESS(feeest_ptr);
23403         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(feeest_ptr);
23404         if (feeest_conv.free == LDKFeeEstimator_JCalls_free) {
23405                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23406                 LDKFeeEstimator_JCalls_cloned(&feeest_conv);
23407         }
23408         void* persister_ptr = (void*)(((uintptr_t)persister) & ~1);
23409         CHECK_ACCESS(persister_ptr);
23410         LDKPersist persister_conv = *(LDKPersist*)(persister_ptr);
23411         if (persister_conv.free == LDKPersist_JCalls_free) {
23412                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23413                 LDKPersist_JCalls_cloned(&persister_conv);
23414         }
23415         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
23416         uint32_t ret_ref = 0;
23417         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23418         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23419         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23420         ret_ref = (uintptr_t)ret_var.inner;
23421         if (ret_var.is_owned) {
23422                 ret_ref |= 1;
23423         }
23424         return ret_ref;
23425 }
23426
23427 uint32_tArray  __attribute__((export_name("TS_ChainMonitor_get_claimable_balances"))) TS_ChainMonitor_get_claimable_balances(uint32_t this_arg, uint32_tArray ignored_channels) {
23428         LDKChainMonitor this_arg_conv;
23429         this_arg_conv.inner = (void*)(this_arg & (~1));
23430         this_arg_conv.is_owned = false;
23431         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23432         LDKCVec_ChannelDetailsZ ignored_channels_constr;
23433         ignored_channels_constr.datalen = ignored_channels->arr_len;
23434         if (ignored_channels_constr.datalen > 0)
23435                 ignored_channels_constr.data = MALLOC(ignored_channels_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
23436         else
23437                 ignored_channels_constr.data = NULL;
23438         uint32_t* ignored_channels_vals = ignored_channels->elems;
23439         for (size_t q = 0; q < ignored_channels_constr.datalen; q++) {
23440                 uint32_t ignored_channels_conv_16 = ignored_channels_vals[q];
23441                 LDKChannelDetails ignored_channels_conv_16_conv;
23442                 ignored_channels_conv_16_conv.inner = (void*)(ignored_channels_conv_16 & (~1));
23443                 ignored_channels_conv_16_conv.is_owned = (ignored_channels_conv_16 & 1) || (ignored_channels_conv_16 == 0);
23444                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ignored_channels_conv_16_conv);
23445                 ignored_channels_conv_16_conv = ChannelDetails_clone(&ignored_channels_conv_16_conv);
23446                 ignored_channels_constr.data[q] = ignored_channels_conv_16_conv;
23447         }
23448         FREE(ignored_channels);
23449         LDKCVec_BalanceZ ret_var = ChainMonitor_get_claimable_balances(&this_arg_conv, ignored_channels_constr);
23450         uint32_tArray ret_arr = NULL;
23451         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
23452         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 8);
23453         for (size_t j = 0; j < ret_var.datalen; j++) {
23454                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
23455                 *ret_conv_9_copy = ret_var.data[j];
23456                 uint32_t ret_conv_9_ref = (uintptr_t)ret_conv_9_copy;
23457                 ret_arr_ptr[j] = ret_conv_9_ref;
23458         }
23459         
23460         FREE(ret_var.data);
23461         return ret_arr;
23462 }
23463
23464 uint32_t  __attribute__((export_name("TS_ChainMonitor_get_monitor"))) TS_ChainMonitor_get_monitor(uint32_t this_arg, uint32_t funding_txo) {
23465         LDKChainMonitor this_arg_conv;
23466         this_arg_conv.inner = (void*)(this_arg & (~1));
23467         this_arg_conv.is_owned = false;
23468         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23469         LDKOutPoint funding_txo_conv;
23470         funding_txo_conv.inner = (void*)(funding_txo & (~1));
23471         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
23472         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
23473         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
23474         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
23475         *ret_conv = ChainMonitor_get_monitor(&this_arg_conv, funding_txo_conv);
23476         return (uint32_t)ret_conv;
23477 }
23478
23479 uint32_tArray  __attribute__((export_name("TS_ChainMonitor_list_monitors"))) TS_ChainMonitor_list_monitors(uint32_t this_arg) {
23480         LDKChainMonitor this_arg_conv;
23481         this_arg_conv.inner = (void*)(this_arg & (~1));
23482         this_arg_conv.is_owned = false;
23483         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23484         LDKCVec_OutPointZ ret_var = ChainMonitor_list_monitors(&this_arg_conv);
23485         uint32_tArray ret_arr = NULL;
23486         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
23487         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 8);
23488         for (size_t k = 0; k < ret_var.datalen; k++) {
23489                 LDKOutPoint ret_conv_10_var = ret_var.data[k];
23490                 uint32_t ret_conv_10_ref = 0;
23491                 CHECK((((uintptr_t)ret_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23492                 CHECK((((uintptr_t)&ret_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23493                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_10_var);
23494                 ret_conv_10_ref = (uintptr_t)ret_conv_10_var.inner;
23495                 if (ret_conv_10_var.is_owned) {
23496                         ret_conv_10_ref |= 1;
23497                 }
23498                 ret_arr_ptr[k] = ret_conv_10_ref;
23499         }
23500         
23501         FREE(ret_var.data);
23502         return ret_arr;
23503 }
23504
23505 uint32_t  __attribute__((export_name("TS_ChainMonitor_channel_monitor_updated"))) TS_ChainMonitor_channel_monitor_updated(uint32_t this_arg, uint32_t funding_txo, uint32_t completed_update_id) {
23506         LDKChainMonitor this_arg_conv;
23507         this_arg_conv.inner = (void*)(this_arg & (~1));
23508         this_arg_conv.is_owned = false;
23509         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23510         LDKOutPoint funding_txo_conv;
23511         funding_txo_conv.inner = (void*)(funding_txo & (~1));
23512         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
23513         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
23514         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
23515         LDKMonitorUpdateId completed_update_id_conv;
23516         completed_update_id_conv.inner = (void*)(completed_update_id & (~1));
23517         completed_update_id_conv.is_owned = (completed_update_id & 1) || (completed_update_id == 0);
23518         CHECK_INNER_FIELD_ACCESS_OR_NULL(completed_update_id_conv);
23519         completed_update_id_conv = MonitorUpdateId_clone(&completed_update_id_conv);
23520         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
23521         *ret_conv = ChainMonitor_channel_monitor_updated(&this_arg_conv, funding_txo_conv, completed_update_id_conv);
23522         return (uint32_t)ret_conv;
23523 }
23524
23525 uint32_t  __attribute__((export_name("TS_ChainMonitor_as_Listen"))) TS_ChainMonitor_as_Listen(uint32_t this_arg) {
23526         LDKChainMonitor this_arg_conv;
23527         this_arg_conv.inner = (void*)(this_arg & (~1));
23528         this_arg_conv.is_owned = false;
23529         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23530         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
23531         *ret_ret = ChainMonitor_as_Listen(&this_arg_conv);
23532         return (uint32_t)ret_ret;
23533 }
23534
23535 uint32_t  __attribute__((export_name("TS_ChainMonitor_as_Confirm"))) TS_ChainMonitor_as_Confirm(uint32_t this_arg) {
23536         LDKChainMonitor this_arg_conv;
23537         this_arg_conv.inner = (void*)(this_arg & (~1));
23538         this_arg_conv.is_owned = false;
23539         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23540         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
23541         *ret_ret = ChainMonitor_as_Confirm(&this_arg_conv);
23542         return (uint32_t)ret_ret;
23543 }
23544
23545 uint32_t  __attribute__((export_name("TS_ChainMonitor_as_Watch"))) TS_ChainMonitor_as_Watch(uint32_t this_arg) {
23546         LDKChainMonitor this_arg_conv;
23547         this_arg_conv.inner = (void*)(this_arg & (~1));
23548         this_arg_conv.is_owned = false;
23549         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23550         LDKWatch* ret_ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
23551         *ret_ret = ChainMonitor_as_Watch(&this_arg_conv);
23552         return (uint32_t)ret_ret;
23553 }
23554
23555 uint32_t  __attribute__((export_name("TS_ChainMonitor_as_EventsProvider"))) TS_ChainMonitor_as_EventsProvider(uint32_t this_arg) {
23556         LDKChainMonitor this_arg_conv;
23557         this_arg_conv.inner = (void*)(this_arg & (~1));
23558         this_arg_conv.is_owned = false;
23559         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23560         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
23561         *ret_ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
23562         return (uint32_t)ret_ret;
23563 }
23564
23565 void  __attribute__((export_name("TS_ChannelMonitorUpdate_free"))) TS_ChannelMonitorUpdate_free(uint32_t this_obj) {
23566         LDKChannelMonitorUpdate this_obj_conv;
23567         this_obj_conv.inner = (void*)(this_obj & (~1));
23568         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23569         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23570         ChannelMonitorUpdate_free(this_obj_conv);
23571 }
23572
23573 int64_t  __attribute__((export_name("TS_ChannelMonitorUpdate_get_update_id"))) TS_ChannelMonitorUpdate_get_update_id(uint32_t this_ptr) {
23574         LDKChannelMonitorUpdate this_ptr_conv;
23575         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23576         this_ptr_conv.is_owned = false;
23577         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23578         int64_t ret_conv = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
23579         return ret_conv;
23580 }
23581
23582 void  __attribute__((export_name("TS_ChannelMonitorUpdate_set_update_id"))) TS_ChannelMonitorUpdate_set_update_id(uint32_t this_ptr, int64_t val) {
23583         LDKChannelMonitorUpdate this_ptr_conv;
23584         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23585         this_ptr_conv.is_owned = false;
23586         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23587         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
23588 }
23589
23590 static inline uintptr_t ChannelMonitorUpdate_clone_ptr(LDKChannelMonitorUpdate *NONNULL_PTR arg) {
23591         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(arg);
23592 uint32_t ret_ref = 0;
23593 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23594 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23595 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23596 ret_ref = (uintptr_t)ret_var.inner;
23597 if (ret_var.is_owned) {
23598         ret_ref |= 1;
23599 }
23600         return ret_ref;
23601 }
23602 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdate_clone_ptr"))) TS_ChannelMonitorUpdate_clone_ptr(uint32_t arg) {
23603         LDKChannelMonitorUpdate arg_conv;
23604         arg_conv.inner = (void*)(arg & (~1));
23605         arg_conv.is_owned = false;
23606         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23607         uint32_t ret_conv = ChannelMonitorUpdate_clone_ptr(&arg_conv);
23608         return ret_conv;
23609 }
23610
23611 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdate_clone"))) TS_ChannelMonitorUpdate_clone(uint32_t orig) {
23612         LDKChannelMonitorUpdate orig_conv;
23613         orig_conv.inner = (void*)(orig & (~1));
23614         orig_conv.is_owned = false;
23615         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23616         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
23617         uint32_t ret_ref = 0;
23618         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23619         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23620         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23621         ret_ref = (uintptr_t)ret_var.inner;
23622         if (ret_var.is_owned) {
23623                 ret_ref |= 1;
23624         }
23625         return ret_ref;
23626 }
23627
23628 int8_tArray  __attribute__((export_name("TS_ChannelMonitorUpdate_write"))) TS_ChannelMonitorUpdate_write(uint32_t obj) {
23629         LDKChannelMonitorUpdate obj_conv;
23630         obj_conv.inner = (void*)(obj & (~1));
23631         obj_conv.is_owned = false;
23632         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
23633         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
23634         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
23635         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
23636         CVec_u8Z_free(ret_var);
23637         return ret_arr;
23638 }
23639
23640 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdate_read"))) TS_ChannelMonitorUpdate_read(int8_tArray ser) {
23641         LDKu8slice ser_ref;
23642         ser_ref.datalen = ser->arr_len;
23643         ser_ref.data = ser->elems;
23644         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
23645         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
23646         FREE(ser);
23647         return (uint32_t)ret_conv;
23648 }
23649
23650 void  __attribute__((export_name("TS_MonitorEvent_free"))) TS_MonitorEvent_free(uint32_t this_ptr) {
23651         if ((this_ptr & 1) != 0) return;
23652         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23653         CHECK_ACCESS(this_ptr_ptr);
23654         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(this_ptr_ptr);
23655         FREE((void*)this_ptr);
23656         MonitorEvent_free(this_ptr_conv);
23657 }
23658
23659 static inline uintptr_t MonitorEvent_clone_ptr(LDKMonitorEvent *NONNULL_PTR arg) {
23660         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
23661         *ret_copy = MonitorEvent_clone(arg);
23662 uint32_t ret_ref = (uintptr_t)ret_copy;
23663         return ret_ref;
23664 }
23665 uint32_t  __attribute__((export_name("TS_MonitorEvent_clone_ptr"))) TS_MonitorEvent_clone_ptr(uint32_t arg) {
23666         LDKMonitorEvent* arg_conv = (LDKMonitorEvent*)arg;
23667         uint32_t ret_conv = MonitorEvent_clone_ptr(arg_conv);
23668         return ret_conv;
23669 }
23670
23671 uint32_t  __attribute__((export_name("TS_MonitorEvent_clone"))) TS_MonitorEvent_clone(uint32_t orig) {
23672         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)orig;
23673         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
23674         *ret_copy = MonitorEvent_clone(orig_conv);
23675         uint32_t ret_ref = (uintptr_t)ret_copy;
23676         return ret_ref;
23677 }
23678
23679 uint32_t  __attribute__((export_name("TS_MonitorEvent_htlcevent"))) TS_MonitorEvent_htlcevent(uint32_t a) {
23680         LDKHTLCUpdate a_conv;
23681         a_conv.inner = (void*)(a & (~1));
23682         a_conv.is_owned = (a & 1) || (a == 0);
23683         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
23684         a_conv = HTLCUpdate_clone(&a_conv);
23685         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
23686         *ret_copy = MonitorEvent_htlcevent(a_conv);
23687         uint32_t ret_ref = (uintptr_t)ret_copy;
23688         return ret_ref;
23689 }
23690
23691 uint32_t  __attribute__((export_name("TS_MonitorEvent_commitment_tx_confirmed"))) TS_MonitorEvent_commitment_tx_confirmed(uint32_t a) {
23692         LDKOutPoint a_conv;
23693         a_conv.inner = (void*)(a & (~1));
23694         a_conv.is_owned = (a & 1) || (a == 0);
23695         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
23696         a_conv = OutPoint_clone(&a_conv);
23697         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
23698         *ret_copy = MonitorEvent_commitment_tx_confirmed(a_conv);
23699         uint32_t ret_ref = (uintptr_t)ret_copy;
23700         return ret_ref;
23701 }
23702
23703 uint32_t  __attribute__((export_name("TS_MonitorEvent_update_completed"))) TS_MonitorEvent_update_completed(uint32_t funding_txo, int64_t monitor_update_id) {
23704         LDKOutPoint funding_txo_conv;
23705         funding_txo_conv.inner = (void*)(funding_txo & (~1));
23706         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
23707         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
23708         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
23709         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
23710         *ret_copy = MonitorEvent_update_completed(funding_txo_conv, monitor_update_id);
23711         uint32_t ret_ref = (uintptr_t)ret_copy;
23712         return ret_ref;
23713 }
23714
23715 uint32_t  __attribute__((export_name("TS_MonitorEvent_update_failed"))) TS_MonitorEvent_update_failed(uint32_t a) {
23716         LDKOutPoint a_conv;
23717         a_conv.inner = (void*)(a & (~1));
23718         a_conv.is_owned = (a & 1) || (a == 0);
23719         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
23720         a_conv = OutPoint_clone(&a_conv);
23721         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
23722         *ret_copy = MonitorEvent_update_failed(a_conv);
23723         uint32_t ret_ref = (uintptr_t)ret_copy;
23724         return ret_ref;
23725 }
23726
23727 int8_tArray  __attribute__((export_name("TS_MonitorEvent_write"))) TS_MonitorEvent_write(uint32_t obj) {
23728         LDKMonitorEvent* obj_conv = (LDKMonitorEvent*)obj;
23729         LDKCVec_u8Z ret_var = MonitorEvent_write(obj_conv);
23730         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
23731         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
23732         CVec_u8Z_free(ret_var);
23733         return ret_arr;
23734 }
23735
23736 uint32_t  __attribute__((export_name("TS_MonitorEvent_read"))) TS_MonitorEvent_read(int8_tArray ser) {
23737         LDKu8slice ser_ref;
23738         ser_ref.datalen = ser->arr_len;
23739         ser_ref.data = ser->elems;
23740         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
23741         *ret_conv = MonitorEvent_read(ser_ref);
23742         FREE(ser);
23743         return (uint32_t)ret_conv;
23744 }
23745
23746 void  __attribute__((export_name("TS_HTLCUpdate_free"))) TS_HTLCUpdate_free(uint32_t this_obj) {
23747         LDKHTLCUpdate this_obj_conv;
23748         this_obj_conv.inner = (void*)(this_obj & (~1));
23749         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23750         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23751         HTLCUpdate_free(this_obj_conv);
23752 }
23753
23754 static inline uintptr_t HTLCUpdate_clone_ptr(LDKHTLCUpdate *NONNULL_PTR arg) {
23755         LDKHTLCUpdate ret_var = HTLCUpdate_clone(arg);
23756 uint32_t ret_ref = 0;
23757 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23758 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23759 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23760 ret_ref = (uintptr_t)ret_var.inner;
23761 if (ret_var.is_owned) {
23762         ret_ref |= 1;
23763 }
23764         return ret_ref;
23765 }
23766 uint32_t  __attribute__((export_name("TS_HTLCUpdate_clone_ptr"))) TS_HTLCUpdate_clone_ptr(uint32_t arg) {
23767         LDKHTLCUpdate arg_conv;
23768         arg_conv.inner = (void*)(arg & (~1));
23769         arg_conv.is_owned = false;
23770         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23771         uint32_t ret_conv = HTLCUpdate_clone_ptr(&arg_conv);
23772         return ret_conv;
23773 }
23774
23775 uint32_t  __attribute__((export_name("TS_HTLCUpdate_clone"))) TS_HTLCUpdate_clone(uint32_t orig) {
23776         LDKHTLCUpdate orig_conv;
23777         orig_conv.inner = (void*)(orig & (~1));
23778         orig_conv.is_owned = false;
23779         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23780         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
23781         uint32_t ret_ref = 0;
23782         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23783         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23784         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23785         ret_ref = (uintptr_t)ret_var.inner;
23786         if (ret_var.is_owned) {
23787                 ret_ref |= 1;
23788         }
23789         return ret_ref;
23790 }
23791
23792 int8_tArray  __attribute__((export_name("TS_HTLCUpdate_write"))) TS_HTLCUpdate_write(uint32_t obj) {
23793         LDKHTLCUpdate obj_conv;
23794         obj_conv.inner = (void*)(obj & (~1));
23795         obj_conv.is_owned = false;
23796         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
23797         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
23798         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
23799         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
23800         CVec_u8Z_free(ret_var);
23801         return ret_arr;
23802 }
23803
23804 uint32_t  __attribute__((export_name("TS_HTLCUpdate_read"))) TS_HTLCUpdate_read(int8_tArray ser) {
23805         LDKu8slice ser_ref;
23806         ser_ref.datalen = ser->arr_len;
23807         ser_ref.data = ser->elems;
23808         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
23809         *ret_conv = HTLCUpdate_read(ser_ref);
23810         FREE(ser);
23811         return (uint32_t)ret_conv;
23812 }
23813
23814 void  __attribute__((export_name("TS_Balance_free"))) TS_Balance_free(uint32_t this_ptr) {
23815         if ((this_ptr & 1) != 0) return;
23816         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23817         CHECK_ACCESS(this_ptr_ptr);
23818         LDKBalance this_ptr_conv = *(LDKBalance*)(this_ptr_ptr);
23819         FREE((void*)this_ptr);
23820         Balance_free(this_ptr_conv);
23821 }
23822
23823 static inline uintptr_t Balance_clone_ptr(LDKBalance *NONNULL_PTR arg) {
23824         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
23825         *ret_copy = Balance_clone(arg);
23826 uint32_t ret_ref = (uintptr_t)ret_copy;
23827         return ret_ref;
23828 }
23829 uint32_t  __attribute__((export_name("TS_Balance_clone_ptr"))) TS_Balance_clone_ptr(uint32_t arg) {
23830         LDKBalance* arg_conv = (LDKBalance*)arg;
23831         uint32_t ret_conv = Balance_clone_ptr(arg_conv);
23832         return ret_conv;
23833 }
23834
23835 uint32_t  __attribute__((export_name("TS_Balance_clone"))) TS_Balance_clone(uint32_t orig) {
23836         LDKBalance* orig_conv = (LDKBalance*)orig;
23837         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
23838         *ret_copy = Balance_clone(orig_conv);
23839         uint32_t ret_ref = (uintptr_t)ret_copy;
23840         return ret_ref;
23841 }
23842
23843 uint32_t  __attribute__((export_name("TS_Balance_claimable_on_channel_close"))) TS_Balance_claimable_on_channel_close(int64_t claimable_amount_satoshis) {
23844         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
23845         *ret_copy = Balance_claimable_on_channel_close(claimable_amount_satoshis);
23846         uint32_t ret_ref = (uintptr_t)ret_copy;
23847         return ret_ref;
23848 }
23849
23850 uint32_t  __attribute__((export_name("TS_Balance_claimable_awaiting_confirmations"))) TS_Balance_claimable_awaiting_confirmations(int64_t claimable_amount_satoshis, int32_t confirmation_height) {
23851         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
23852         *ret_copy = Balance_claimable_awaiting_confirmations(claimable_amount_satoshis, confirmation_height);
23853         uint32_t ret_ref = (uintptr_t)ret_copy;
23854         return ret_ref;
23855 }
23856
23857 uint32_t  __attribute__((export_name("TS_Balance_contentious_claimable"))) TS_Balance_contentious_claimable(int64_t claimable_amount_satoshis, int32_t timeout_height) {
23858         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
23859         *ret_copy = Balance_contentious_claimable(claimable_amount_satoshis, timeout_height);
23860         uint32_t ret_ref = (uintptr_t)ret_copy;
23861         return ret_ref;
23862 }
23863
23864 uint32_t  __attribute__((export_name("TS_Balance_maybe_claimable_htlcawaiting_timeout"))) TS_Balance_maybe_claimable_htlcawaiting_timeout(int64_t claimable_amount_satoshis, int32_t claimable_height) {
23865         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
23866         *ret_copy = Balance_maybe_claimable_htlcawaiting_timeout(claimable_amount_satoshis, claimable_height);
23867         uint32_t ret_ref = (uintptr_t)ret_copy;
23868         return ret_ref;
23869 }
23870
23871 jboolean  __attribute__((export_name("TS_Balance_eq"))) TS_Balance_eq(uint32_t a, uint32_t b) {
23872         LDKBalance* a_conv = (LDKBalance*)a;
23873         LDKBalance* b_conv = (LDKBalance*)b;
23874         jboolean ret_conv = Balance_eq(a_conv, b_conv);
23875         return ret_conv;
23876 }
23877
23878 void  __attribute__((export_name("TS_ChannelMonitor_free"))) TS_ChannelMonitor_free(uint32_t this_obj) {
23879         LDKChannelMonitor this_obj_conv;
23880         this_obj_conv.inner = (void*)(this_obj & (~1));
23881         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23882         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23883         ChannelMonitor_free(this_obj_conv);
23884 }
23885
23886 static inline uintptr_t ChannelMonitor_clone_ptr(LDKChannelMonitor *NONNULL_PTR arg) {
23887         LDKChannelMonitor ret_var = ChannelMonitor_clone(arg);
23888 uint32_t ret_ref = 0;
23889 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23890 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23891 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23892 ret_ref = (uintptr_t)ret_var.inner;
23893 if (ret_var.is_owned) {
23894         ret_ref |= 1;
23895 }
23896         return ret_ref;
23897 }
23898 uint32_t  __attribute__((export_name("TS_ChannelMonitor_clone_ptr"))) TS_ChannelMonitor_clone_ptr(uint32_t arg) {
23899         LDKChannelMonitor arg_conv;
23900         arg_conv.inner = (void*)(arg & (~1));
23901         arg_conv.is_owned = false;
23902         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23903         uint32_t ret_conv = ChannelMonitor_clone_ptr(&arg_conv);
23904         return ret_conv;
23905 }
23906
23907 uint32_t  __attribute__((export_name("TS_ChannelMonitor_clone"))) TS_ChannelMonitor_clone(uint32_t orig) {
23908         LDKChannelMonitor orig_conv;
23909         orig_conv.inner = (void*)(orig & (~1));
23910         orig_conv.is_owned = false;
23911         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23912         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
23913         uint32_t ret_ref = 0;
23914         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23915         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23916         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23917         ret_ref = (uintptr_t)ret_var.inner;
23918         if (ret_var.is_owned) {
23919                 ret_ref |= 1;
23920         }
23921         return ret_ref;
23922 }
23923
23924 int8_tArray  __attribute__((export_name("TS_ChannelMonitor_write"))) TS_ChannelMonitor_write(uint32_t obj) {
23925         LDKChannelMonitor obj_conv;
23926         obj_conv.inner = (void*)(obj & (~1));
23927         obj_conv.is_owned = false;
23928         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
23929         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
23930         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
23931         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
23932         CVec_u8Z_free(ret_var);
23933         return ret_arr;
23934 }
23935
23936 uint32_t  __attribute__((export_name("TS_ChannelMonitor_update_monitor"))) TS_ChannelMonitor_update_monitor(uint32_t this_arg, uint32_t updates, uint32_t broadcaster, uint32_t fee_estimator, uint32_t logger) {
23937         LDKChannelMonitor this_arg_conv;
23938         this_arg_conv.inner = (void*)(this_arg & (~1));
23939         this_arg_conv.is_owned = false;
23940         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23941         LDKChannelMonitorUpdate updates_conv;
23942         updates_conv.inner = (void*)(updates & (~1));
23943         updates_conv.is_owned = false;
23944         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
23945         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
23946         if (!(broadcaster & 1)) { CHECK_ACCESS(broadcaster_ptr); }
23947         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)broadcaster_ptr;
23948         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
23949         CHECK_ACCESS(fee_estimator_ptr);
23950         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
23951         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
23952                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23953                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
23954         }
23955         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
23956         if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
23957         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
23958         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
23959         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
23960         return (uint32_t)ret_conv;
23961 }
23962
23963 int64_t  __attribute__((export_name("TS_ChannelMonitor_get_latest_update_id"))) TS_ChannelMonitor_get_latest_update_id(uint32_t this_arg) {
23964         LDKChannelMonitor this_arg_conv;
23965         this_arg_conv.inner = (void*)(this_arg & (~1));
23966         this_arg_conv.is_owned = false;
23967         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23968         int64_t ret_conv = ChannelMonitor_get_latest_update_id(&this_arg_conv);
23969         return ret_conv;
23970 }
23971
23972 uint32_t  __attribute__((export_name("TS_ChannelMonitor_get_funding_txo"))) TS_ChannelMonitor_get_funding_txo(uint32_t this_arg) {
23973         LDKChannelMonitor this_arg_conv;
23974         this_arg_conv.inner = (void*)(this_arg & (~1));
23975         this_arg_conv.is_owned = false;
23976         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23977         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
23978         *ret_conv = ChannelMonitor_get_funding_txo(&this_arg_conv);
23979         return ((uint32_t)ret_conv);
23980 }
23981
23982 uint32_tArray  __attribute__((export_name("TS_ChannelMonitor_get_outputs_to_watch"))) TS_ChannelMonitor_get_outputs_to_watch(uint32_t this_arg) {
23983         LDKChannelMonitor this_arg_conv;
23984         this_arg_conv.inner = (void*)(this_arg & (~1));
23985         this_arg_conv.is_owned = false;
23986         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23987         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
23988         uint32_tArray ret_arr = NULL;
23989         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
23990         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 8);
23991         for (size_t o = 0; o < ret_var.datalen; o++) {
23992                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_40_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
23993                 *ret_conv_40_conv = ret_var.data[o];
23994                 ret_arr_ptr[o] = ((uint32_t)ret_conv_40_conv);
23995         }
23996         
23997         FREE(ret_var.data);
23998         return ret_arr;
23999 }
24000
24001 void  __attribute__((export_name("TS_ChannelMonitor_load_outputs_to_watch"))) TS_ChannelMonitor_load_outputs_to_watch(uint32_t this_arg, uint32_t filter) {
24002         LDKChannelMonitor this_arg_conv;
24003         this_arg_conv.inner = (void*)(this_arg & (~1));
24004         this_arg_conv.is_owned = false;
24005         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24006         void* filter_ptr = (void*)(((uintptr_t)filter) & ~1);
24007         if (!(filter & 1)) { CHECK_ACCESS(filter_ptr); }
24008         LDKFilter* filter_conv = (LDKFilter*)filter_ptr;
24009         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
24010 }
24011
24012 uint32_tArray  __attribute__((export_name("TS_ChannelMonitor_get_and_clear_pending_monitor_events"))) TS_ChannelMonitor_get_and_clear_pending_monitor_events(uint32_t this_arg) {
24013         LDKChannelMonitor this_arg_conv;
24014         this_arg_conv.inner = (void*)(this_arg & (~1));
24015         this_arg_conv.is_owned = false;
24016         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24017         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
24018         uint32_tArray ret_arr = NULL;
24019         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
24020         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 8);
24021         for (size_t o = 0; o < ret_var.datalen; o++) {
24022                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
24023                 *ret_conv_14_copy = ret_var.data[o];
24024                 uint32_t ret_conv_14_ref = (uintptr_t)ret_conv_14_copy;
24025                 ret_arr_ptr[o] = ret_conv_14_ref;
24026         }
24027         
24028         FREE(ret_var.data);
24029         return ret_arr;
24030 }
24031
24032 uint32_tArray  __attribute__((export_name("TS_ChannelMonitor_get_and_clear_pending_events"))) TS_ChannelMonitor_get_and_clear_pending_events(uint32_t this_arg) {
24033         LDKChannelMonitor this_arg_conv;
24034         this_arg_conv.inner = (void*)(this_arg & (~1));
24035         this_arg_conv.is_owned = false;
24036         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24037         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
24038         uint32_tArray ret_arr = NULL;
24039         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
24040         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 8);
24041         for (size_t h = 0; h < ret_var.datalen; h++) {
24042                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24043                 *ret_conv_7_copy = ret_var.data[h];
24044                 uint32_t ret_conv_7_ref = (uintptr_t)ret_conv_7_copy;
24045                 ret_arr_ptr[h] = ret_conv_7_ref;
24046         }
24047         
24048         FREE(ret_var.data);
24049         return ret_arr;
24050 }
24051
24052 int8_tArray  __attribute__((export_name("TS_ChannelMonitor_get_counterparty_node_id"))) TS_ChannelMonitor_get_counterparty_node_id(uint32_t this_arg) {
24053         LDKChannelMonitor this_arg_conv;
24054         this_arg_conv.inner = (void*)(this_arg & (~1));
24055         this_arg_conv.is_owned = false;
24056         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24057         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
24058         memcpy(ret_arr->elems, ChannelMonitor_get_counterparty_node_id(&this_arg_conv).compressed_form, 33);
24059         return ret_arr;
24060 }
24061
24062 ptrArray  __attribute__((export_name("TS_ChannelMonitor_get_latest_holder_commitment_txn"))) TS_ChannelMonitor_get_latest_holder_commitment_txn(uint32_t this_arg, uint32_t logger) {
24063         LDKChannelMonitor this_arg_conv;
24064         this_arg_conv.inner = (void*)(this_arg & (~1));
24065         this_arg_conv.is_owned = false;
24066         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24067         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
24068         if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
24069         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
24070         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
24071         ptrArray ret_arr = NULL;
24072         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
24073         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 8);
24074         for (size_t m = 0; m < ret_var.datalen; m++) {
24075                 LDKTransaction ret_conv_12_var = ret_var.data[m];
24076                 int8_tArray ret_conv_12_arr = init_int8_tArray(ret_conv_12_var.datalen, __LINE__);
24077                 memcpy(ret_conv_12_arr->elems, ret_conv_12_var.data, ret_conv_12_var.datalen);
24078                 Transaction_free(ret_conv_12_var);
24079                 ret_arr_ptr[m] = ret_conv_12_arr;
24080         }
24081         
24082         FREE(ret_var.data);
24083         return ret_arr;
24084 }
24085
24086 uint32_tArray  __attribute__((export_name("TS_ChannelMonitor_block_connected"))) TS_ChannelMonitor_block_connected(uint32_t this_arg, int8_tArray header, uint32_tArray txdata, int32_t height, uint32_t broadcaster, uint32_t fee_estimator, uint32_t logger) {
24087         LDKChannelMonitor this_arg_conv;
24088         this_arg_conv.inner = (void*)(this_arg & (~1));
24089         this_arg_conv.is_owned = false;
24090         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24091         unsigned char header_arr[80];
24092         CHECK(header->arr_len == 80);
24093         memcpy(header_arr, header->elems, 80); FREE(header);
24094         unsigned char (*header_ref)[80] = &header_arr;
24095         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
24096         txdata_constr.datalen = txdata->arr_len;
24097         if (txdata_constr.datalen > 0)
24098                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
24099         else
24100                 txdata_constr.data = NULL;
24101         uint32_t* txdata_vals = txdata->elems;
24102         for (size_t c = 0; c < txdata_constr.datalen; c++) {
24103                 uint32_t txdata_conv_28 = txdata_vals[c];
24104                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
24105                 CHECK_ACCESS(txdata_conv_28_ptr);
24106                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
24107                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
24108                 txdata_constr.data[c] = txdata_conv_28_conv;
24109         }
24110         FREE(txdata);
24111         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
24112         CHECK_ACCESS(broadcaster_ptr);
24113         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
24114         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
24115                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24116                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
24117         }
24118         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
24119         CHECK_ACCESS(fee_estimator_ptr);
24120         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
24121         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
24122                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24123                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
24124         }
24125         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
24126         CHECK_ACCESS(logger_ptr);
24127         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
24128         if (logger_conv.free == LDKLogger_JCalls_free) {
24129                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24130                 LDKLogger_JCalls_cloned(&logger_conv);
24131         }
24132         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);
24133         uint32_tArray ret_arr = NULL;
24134         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
24135         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 8);
24136         for (size_t n = 0; n < ret_var.datalen; n++) {
24137                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
24138                 *ret_conv_39_conv = ret_var.data[n];
24139                 ret_arr_ptr[n] = ((uint32_t)ret_conv_39_conv);
24140         }
24141         
24142         FREE(ret_var.data);
24143         return ret_arr;
24144 }
24145
24146 void  __attribute__((export_name("TS_ChannelMonitor_block_disconnected"))) TS_ChannelMonitor_block_disconnected(uint32_t this_arg, int8_tArray header, int32_t height, uint32_t broadcaster, uint32_t fee_estimator, uint32_t logger) {
24147         LDKChannelMonitor this_arg_conv;
24148         this_arg_conv.inner = (void*)(this_arg & (~1));
24149         this_arg_conv.is_owned = false;
24150         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24151         unsigned char header_arr[80];
24152         CHECK(header->arr_len == 80);
24153         memcpy(header_arr, header->elems, 80); FREE(header);
24154         unsigned char (*header_ref)[80] = &header_arr;
24155         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
24156         CHECK_ACCESS(broadcaster_ptr);
24157         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
24158         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
24159                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24160                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
24161         }
24162         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
24163         CHECK_ACCESS(fee_estimator_ptr);
24164         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
24165         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
24166                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24167                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
24168         }
24169         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
24170         CHECK_ACCESS(logger_ptr);
24171         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
24172         if (logger_conv.free == LDKLogger_JCalls_free) {
24173                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24174                 LDKLogger_JCalls_cloned(&logger_conv);
24175         }
24176         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
24177 }
24178
24179 uint32_tArray  __attribute__((export_name("TS_ChannelMonitor_transactions_confirmed"))) TS_ChannelMonitor_transactions_confirmed(uint32_t this_arg, int8_tArray header, uint32_tArray txdata, int32_t height, uint32_t broadcaster, uint32_t fee_estimator, uint32_t logger) {
24180         LDKChannelMonitor this_arg_conv;
24181         this_arg_conv.inner = (void*)(this_arg & (~1));
24182         this_arg_conv.is_owned = false;
24183         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24184         unsigned char header_arr[80];
24185         CHECK(header->arr_len == 80);
24186         memcpy(header_arr, header->elems, 80); FREE(header);
24187         unsigned char (*header_ref)[80] = &header_arr;
24188         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
24189         txdata_constr.datalen = txdata->arr_len;
24190         if (txdata_constr.datalen > 0)
24191                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
24192         else
24193                 txdata_constr.data = NULL;
24194         uint32_t* txdata_vals = txdata->elems;
24195         for (size_t c = 0; c < txdata_constr.datalen; c++) {
24196                 uint32_t txdata_conv_28 = txdata_vals[c];
24197                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
24198                 CHECK_ACCESS(txdata_conv_28_ptr);
24199                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
24200                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
24201                 txdata_constr.data[c] = txdata_conv_28_conv;
24202         }
24203         FREE(txdata);
24204         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
24205         CHECK_ACCESS(broadcaster_ptr);
24206         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
24207         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
24208                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24209                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
24210         }
24211         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
24212         CHECK_ACCESS(fee_estimator_ptr);
24213         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
24214         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
24215                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24216                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
24217         }
24218         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
24219         CHECK_ACCESS(logger_ptr);
24220         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
24221         if (logger_conv.free == LDKLogger_JCalls_free) {
24222                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24223                 LDKLogger_JCalls_cloned(&logger_conv);
24224         }
24225         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);
24226         uint32_tArray ret_arr = NULL;
24227         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
24228         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 8);
24229         for (size_t n = 0; n < ret_var.datalen; n++) {
24230                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
24231                 *ret_conv_39_conv = ret_var.data[n];
24232                 ret_arr_ptr[n] = ((uint32_t)ret_conv_39_conv);
24233         }
24234         
24235         FREE(ret_var.data);
24236         return ret_arr;
24237 }
24238
24239 void  __attribute__((export_name("TS_ChannelMonitor_transaction_unconfirmed"))) TS_ChannelMonitor_transaction_unconfirmed(uint32_t this_arg, int8_tArray txid, uint32_t broadcaster, uint32_t fee_estimator, uint32_t logger) {
24240         LDKChannelMonitor this_arg_conv;
24241         this_arg_conv.inner = (void*)(this_arg & (~1));
24242         this_arg_conv.is_owned = false;
24243         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24244         unsigned char txid_arr[32];
24245         CHECK(txid->arr_len == 32);
24246         memcpy(txid_arr, txid->elems, 32); FREE(txid);
24247         unsigned char (*txid_ref)[32] = &txid_arr;
24248         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
24249         CHECK_ACCESS(broadcaster_ptr);
24250         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
24251         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
24252                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24253                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
24254         }
24255         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
24256         CHECK_ACCESS(fee_estimator_ptr);
24257         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
24258         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
24259                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24260                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
24261         }
24262         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
24263         CHECK_ACCESS(logger_ptr);
24264         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
24265         if (logger_conv.free == LDKLogger_JCalls_free) {
24266                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24267                 LDKLogger_JCalls_cloned(&logger_conv);
24268         }
24269         ChannelMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref, broadcaster_conv, fee_estimator_conv, logger_conv);
24270 }
24271
24272 uint32_tArray  __attribute__((export_name("TS_ChannelMonitor_best_block_updated"))) TS_ChannelMonitor_best_block_updated(uint32_t this_arg, int8_tArray header, int32_t height, uint32_t broadcaster, uint32_t fee_estimator, uint32_t logger) {
24273         LDKChannelMonitor this_arg_conv;
24274         this_arg_conv.inner = (void*)(this_arg & (~1));
24275         this_arg_conv.is_owned = false;
24276         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24277         unsigned char header_arr[80];
24278         CHECK(header->arr_len == 80);
24279         memcpy(header_arr, header->elems, 80); FREE(header);
24280         unsigned char (*header_ref)[80] = &header_arr;
24281         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
24282         CHECK_ACCESS(broadcaster_ptr);
24283         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
24284         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
24285                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24286                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
24287         }
24288         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
24289         CHECK_ACCESS(fee_estimator_ptr);
24290         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
24291         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
24292                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24293                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
24294         }
24295         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
24296         CHECK_ACCESS(logger_ptr);
24297         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
24298         if (logger_conv.free == LDKLogger_JCalls_free) {
24299                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24300                 LDKLogger_JCalls_cloned(&logger_conv);
24301         }
24302         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_best_block_updated(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
24303         uint32_tArray ret_arr = NULL;
24304         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
24305         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 8);
24306         for (size_t n = 0; n < ret_var.datalen; n++) {
24307                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
24308                 *ret_conv_39_conv = ret_var.data[n];
24309                 ret_arr_ptr[n] = ((uint32_t)ret_conv_39_conv);
24310         }
24311         
24312         FREE(ret_var.data);
24313         return ret_arr;
24314 }
24315
24316 ptrArray  __attribute__((export_name("TS_ChannelMonitor_get_relevant_txids"))) TS_ChannelMonitor_get_relevant_txids(uint32_t this_arg) {
24317         LDKChannelMonitor this_arg_conv;
24318         this_arg_conv.inner = (void*)(this_arg & (~1));
24319         this_arg_conv.is_owned = false;
24320         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24321         LDKCVec_TxidZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_conv);
24322         ptrArray ret_arr = NULL;
24323         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
24324         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 8);
24325         for (size_t m = 0; m < ret_var.datalen; m++) {
24326                 int8_tArray ret_conv_12_arr = init_int8_tArray(32, __LINE__);
24327                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].data, 32);
24328                 ret_arr_ptr[m] = ret_conv_12_arr;
24329         }
24330         
24331         FREE(ret_var.data);
24332         return ret_arr;
24333 }
24334
24335 uint32_t  __attribute__((export_name("TS_ChannelMonitor_current_best_block"))) TS_ChannelMonitor_current_best_block(uint32_t this_arg) {
24336         LDKChannelMonitor this_arg_conv;
24337         this_arg_conv.inner = (void*)(this_arg & (~1));
24338         this_arg_conv.is_owned = false;
24339         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24340         LDKBestBlock ret_var = ChannelMonitor_current_best_block(&this_arg_conv);
24341         uint32_t ret_ref = 0;
24342         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24343         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24344         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24345         ret_ref = (uintptr_t)ret_var.inner;
24346         if (ret_var.is_owned) {
24347                 ret_ref |= 1;
24348         }
24349         return ret_ref;
24350 }
24351
24352 uint32_tArray  __attribute__((export_name("TS_ChannelMonitor_get_claimable_balances"))) TS_ChannelMonitor_get_claimable_balances(uint32_t this_arg) {
24353         LDKChannelMonitor this_arg_conv;
24354         this_arg_conv.inner = (void*)(this_arg & (~1));
24355         this_arg_conv.is_owned = false;
24356         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24357         LDKCVec_BalanceZ ret_var = ChannelMonitor_get_claimable_balances(&this_arg_conv);
24358         uint32_tArray ret_arr = NULL;
24359         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
24360         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 8);
24361         for (size_t j = 0; j < ret_var.datalen; j++) {
24362                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
24363                 *ret_conv_9_copy = ret_var.data[j];
24364                 uint32_t ret_conv_9_ref = (uintptr_t)ret_conv_9_copy;
24365                 ret_arr_ptr[j] = ret_conv_9_ref;
24366         }
24367         
24368         FREE(ret_var.data);
24369         return ret_arr;
24370 }
24371
24372 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_read"))) TS_C2Tuple_BlockHashChannelMonitorZ_read(int8_tArray ser, uint32_t arg) {
24373         LDKu8slice ser_ref;
24374         ser_ref.datalen = ser->arr_len;
24375         ser_ref.data = ser->elems;
24376         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
24377         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
24378         LDKKeysInterface* arg_conv = (LDKKeysInterface*)arg_ptr;
24379         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
24380         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
24381         FREE(ser);
24382         return (uint32_t)ret_conv;
24383 }
24384
24385 void  __attribute__((export_name("TS_OutPoint_free"))) TS_OutPoint_free(uint32_t this_obj) {
24386         LDKOutPoint this_obj_conv;
24387         this_obj_conv.inner = (void*)(this_obj & (~1));
24388         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24389         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24390         OutPoint_free(this_obj_conv);
24391 }
24392
24393 int8_tArray  __attribute__((export_name("TS_OutPoint_get_txid"))) TS_OutPoint_get_txid(uint32_t this_ptr) {
24394         LDKOutPoint this_ptr_conv;
24395         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24396         this_ptr_conv.is_owned = false;
24397         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24398         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
24399         memcpy(ret_arr->elems, *OutPoint_get_txid(&this_ptr_conv), 32);
24400         return ret_arr;
24401 }
24402
24403 void  __attribute__((export_name("TS_OutPoint_set_txid"))) TS_OutPoint_set_txid(uint32_t this_ptr, int8_tArray val) {
24404         LDKOutPoint this_ptr_conv;
24405         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24406         this_ptr_conv.is_owned = false;
24407         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24408         LDKThirtyTwoBytes val_ref;
24409         CHECK(val->arr_len == 32);
24410         memcpy(val_ref.data, val->elems, 32); FREE(val);
24411         OutPoint_set_txid(&this_ptr_conv, val_ref);
24412 }
24413
24414 int16_t  __attribute__((export_name("TS_OutPoint_get_index"))) TS_OutPoint_get_index(uint32_t this_ptr) {
24415         LDKOutPoint this_ptr_conv;
24416         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24417         this_ptr_conv.is_owned = false;
24418         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24419         int16_t ret_conv = OutPoint_get_index(&this_ptr_conv);
24420         return ret_conv;
24421 }
24422
24423 void  __attribute__((export_name("TS_OutPoint_set_index"))) TS_OutPoint_set_index(uint32_t this_ptr, int16_t val) {
24424         LDKOutPoint this_ptr_conv;
24425         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24426         this_ptr_conv.is_owned = false;
24427         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24428         OutPoint_set_index(&this_ptr_conv, val);
24429 }
24430
24431 uint32_t  __attribute__((export_name("TS_OutPoint_new"))) TS_OutPoint_new(int8_tArray txid_arg, int16_t index_arg) {
24432         LDKThirtyTwoBytes txid_arg_ref;
24433         CHECK(txid_arg->arr_len == 32);
24434         memcpy(txid_arg_ref.data, txid_arg->elems, 32); FREE(txid_arg);
24435         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
24436         uint32_t ret_ref = 0;
24437         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24438         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24439         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24440         ret_ref = (uintptr_t)ret_var.inner;
24441         if (ret_var.is_owned) {
24442                 ret_ref |= 1;
24443         }
24444         return ret_ref;
24445 }
24446
24447 static inline uintptr_t OutPoint_clone_ptr(LDKOutPoint *NONNULL_PTR arg) {
24448         LDKOutPoint ret_var = OutPoint_clone(arg);
24449 uint32_t ret_ref = 0;
24450 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24451 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24452 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24453 ret_ref = (uintptr_t)ret_var.inner;
24454 if (ret_var.is_owned) {
24455         ret_ref |= 1;
24456 }
24457         return ret_ref;
24458 }
24459 uint32_t  __attribute__((export_name("TS_OutPoint_clone_ptr"))) TS_OutPoint_clone_ptr(uint32_t arg) {
24460         LDKOutPoint arg_conv;
24461         arg_conv.inner = (void*)(arg & (~1));
24462         arg_conv.is_owned = false;
24463         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24464         uint32_t ret_conv = OutPoint_clone_ptr(&arg_conv);
24465         return ret_conv;
24466 }
24467
24468 uint32_t  __attribute__((export_name("TS_OutPoint_clone"))) TS_OutPoint_clone(uint32_t orig) {
24469         LDKOutPoint orig_conv;
24470         orig_conv.inner = (void*)(orig & (~1));
24471         orig_conv.is_owned = false;
24472         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24473         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
24474         uint32_t ret_ref = 0;
24475         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24476         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24477         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24478         ret_ref = (uintptr_t)ret_var.inner;
24479         if (ret_var.is_owned) {
24480                 ret_ref |= 1;
24481         }
24482         return ret_ref;
24483 }
24484
24485 jboolean  __attribute__((export_name("TS_OutPoint_eq"))) TS_OutPoint_eq(uint32_t a, uint32_t b) {
24486         LDKOutPoint a_conv;
24487         a_conv.inner = (void*)(a & (~1));
24488         a_conv.is_owned = false;
24489         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
24490         LDKOutPoint b_conv;
24491         b_conv.inner = (void*)(b & (~1));
24492         b_conv.is_owned = false;
24493         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
24494         jboolean ret_conv = OutPoint_eq(&a_conv, &b_conv);
24495         return ret_conv;
24496 }
24497
24498 int64_t  __attribute__((export_name("TS_OutPoint_hash"))) TS_OutPoint_hash(uint32_t o) {
24499         LDKOutPoint o_conv;
24500         o_conv.inner = (void*)(o & (~1));
24501         o_conv.is_owned = false;
24502         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24503         int64_t ret_conv = OutPoint_hash(&o_conv);
24504         return ret_conv;
24505 }
24506
24507 int8_tArray  __attribute__((export_name("TS_OutPoint_to_channel_id"))) TS_OutPoint_to_channel_id(uint32_t this_arg) {
24508         LDKOutPoint this_arg_conv;
24509         this_arg_conv.inner = (void*)(this_arg & (~1));
24510         this_arg_conv.is_owned = false;
24511         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24512         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
24513         memcpy(ret_arr->elems, OutPoint_to_channel_id(&this_arg_conv).data, 32);
24514         return ret_arr;
24515 }
24516
24517 int8_tArray  __attribute__((export_name("TS_OutPoint_write"))) TS_OutPoint_write(uint32_t obj) {
24518         LDKOutPoint obj_conv;
24519         obj_conv.inner = (void*)(obj & (~1));
24520         obj_conv.is_owned = false;
24521         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
24522         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
24523         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
24524         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
24525         CVec_u8Z_free(ret_var);
24526         return ret_arr;
24527 }
24528
24529 uint32_t  __attribute__((export_name("TS_OutPoint_read"))) TS_OutPoint_read(int8_tArray ser) {
24530         LDKu8slice ser_ref;
24531         ser_ref.datalen = ser->arr_len;
24532         ser_ref.data = ser->elems;
24533         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
24534         *ret_conv = OutPoint_read(ser_ref);
24535         FREE(ser);
24536         return (uint32_t)ret_conv;
24537 }
24538
24539 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_free"))) TS_DelayedPaymentOutputDescriptor_free(uint32_t this_obj) {
24540         LDKDelayedPaymentOutputDescriptor this_obj_conv;
24541         this_obj_conv.inner = (void*)(this_obj & (~1));
24542         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24543         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24544         DelayedPaymentOutputDescriptor_free(this_obj_conv);
24545 }
24546
24547 uint32_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_outpoint"))) TS_DelayedPaymentOutputDescriptor_get_outpoint(uint32_t this_ptr) {
24548         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24549         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24550         this_ptr_conv.is_owned = false;
24551         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24552         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
24553         uint32_t ret_ref = 0;
24554         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24555         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24556         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24557         ret_ref = (uintptr_t)ret_var.inner;
24558         if (ret_var.is_owned) {
24559                 ret_ref |= 1;
24560         }
24561         return ret_ref;
24562 }
24563
24564 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_outpoint"))) TS_DelayedPaymentOutputDescriptor_set_outpoint(uint32_t this_ptr, uint32_t val) {
24565         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24566         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24567         this_ptr_conv.is_owned = false;
24568         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24569         LDKOutPoint val_conv;
24570         val_conv.inner = (void*)(val & (~1));
24571         val_conv.is_owned = (val & 1) || (val == 0);
24572         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
24573         val_conv = OutPoint_clone(&val_conv);
24574         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
24575 }
24576
24577 int8_tArray  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_per_commitment_point"))) TS_DelayedPaymentOutputDescriptor_get_per_commitment_point(uint32_t this_ptr) {
24578         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24579         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24580         this_ptr_conv.is_owned = false;
24581         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24582         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
24583         memcpy(ret_arr->elems, DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form, 33);
24584         return ret_arr;
24585 }
24586
24587 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_per_commitment_point"))) TS_DelayedPaymentOutputDescriptor_set_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
24588         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24589         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24590         this_ptr_conv.is_owned = false;
24591         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24592         LDKPublicKey val_ref;
24593         CHECK(val->arr_len == 33);
24594         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
24595         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
24596 }
24597
24598 int16_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_to_self_delay"))) TS_DelayedPaymentOutputDescriptor_get_to_self_delay(uint32_t this_ptr) {
24599         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24600         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24601         this_ptr_conv.is_owned = false;
24602         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24603         int16_t ret_conv = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
24604         return ret_conv;
24605 }
24606
24607 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_to_self_delay"))) TS_DelayedPaymentOutputDescriptor_set_to_self_delay(uint32_t this_ptr, int16_t val) {
24608         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24609         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24610         this_ptr_conv.is_owned = false;
24611         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24612         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
24613 }
24614
24615 uint32_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_output"))) TS_DelayedPaymentOutputDescriptor_get_output(uint32_t this_ptr) {
24616         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24617         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24618         this_ptr_conv.is_owned = false;
24619         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24620         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
24621         *ret_ref = DelayedPaymentOutputDescriptor_get_output(&this_ptr_conv);
24622         return (uint32_t)ret_ref;
24623 }
24624
24625 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_output"))) TS_DelayedPaymentOutputDescriptor_set_output(uint32_t this_ptr, uint32_t val) {
24626         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24627         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24628         this_ptr_conv.is_owned = false;
24629         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24630         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
24631         CHECK_ACCESS(val_ptr);
24632         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
24633         val_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)val) & ~1));
24634         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
24635 }
24636
24637 int8_tArray  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_revocation_pubkey"))) TS_DelayedPaymentOutputDescriptor_get_revocation_pubkey(uint32_t this_ptr) {
24638         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24639         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24640         this_ptr_conv.is_owned = false;
24641         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24642         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
24643         memcpy(ret_arr->elems, DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form, 33);
24644         return ret_arr;
24645 }
24646
24647 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_revocation_pubkey"))) TS_DelayedPaymentOutputDescriptor_set_revocation_pubkey(uint32_t this_ptr, int8_tArray val) {
24648         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24649         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24650         this_ptr_conv.is_owned = false;
24651         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24652         LDKPublicKey val_ref;
24653         CHECK(val->arr_len == 33);
24654         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
24655         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
24656 }
24657
24658 int8_tArray  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_channel_keys_id"))) TS_DelayedPaymentOutputDescriptor_get_channel_keys_id(uint32_t this_ptr) {
24659         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24660         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24661         this_ptr_conv.is_owned = false;
24662         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24663         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
24664         memcpy(ret_arr->elems, *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv), 32);
24665         return ret_arr;
24666 }
24667
24668 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_channel_keys_id"))) TS_DelayedPaymentOutputDescriptor_set_channel_keys_id(uint32_t this_ptr, int8_tArray val) {
24669         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24670         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24671         this_ptr_conv.is_owned = false;
24672         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24673         LDKThirtyTwoBytes val_ref;
24674         CHECK(val->arr_len == 32);
24675         memcpy(val_ref.data, val->elems, 32); FREE(val);
24676         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
24677 }
24678
24679 int64_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_channel_value_satoshis"))) TS_DelayedPaymentOutputDescriptor_get_channel_value_satoshis(uint32_t this_ptr) {
24680         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24681         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24682         this_ptr_conv.is_owned = false;
24683         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24684         int64_t ret_conv = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
24685         return ret_conv;
24686 }
24687
24688 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_channel_value_satoshis"))) TS_DelayedPaymentOutputDescriptor_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
24689         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24690         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24691         this_ptr_conv.is_owned = false;
24692         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24693         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
24694 }
24695
24696 uint32_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_new"))) TS_DelayedPaymentOutputDescriptor_new(uint32_t outpoint_arg, int8_tArray per_commitment_point_arg, int16_t to_self_delay_arg, uint32_t output_arg, int8_tArray revocation_pubkey_arg, int8_tArray channel_keys_id_arg, int64_t channel_value_satoshis_arg) {
24697         LDKOutPoint outpoint_arg_conv;
24698         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
24699         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
24700         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
24701         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
24702         LDKPublicKey per_commitment_point_arg_ref;
24703         CHECK(per_commitment_point_arg->arr_len == 33);
24704         memcpy(per_commitment_point_arg_ref.compressed_form, per_commitment_point_arg->elems, 33); FREE(per_commitment_point_arg);
24705         void* output_arg_ptr = (void*)(((uintptr_t)output_arg) & ~1);
24706         CHECK_ACCESS(output_arg_ptr);
24707         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
24708         output_arg_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output_arg) & ~1));
24709         LDKPublicKey revocation_pubkey_arg_ref;
24710         CHECK(revocation_pubkey_arg->arr_len == 33);
24711         memcpy(revocation_pubkey_arg_ref.compressed_form, revocation_pubkey_arg->elems, 33); FREE(revocation_pubkey_arg);
24712         LDKThirtyTwoBytes channel_keys_id_arg_ref;
24713         CHECK(channel_keys_id_arg->arr_len == 32);
24714         memcpy(channel_keys_id_arg_ref.data, channel_keys_id_arg->elems, 32); FREE(channel_keys_id_arg);
24715         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);
24716         uint32_t ret_ref = 0;
24717         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24718         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24719         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24720         ret_ref = (uintptr_t)ret_var.inner;
24721         if (ret_var.is_owned) {
24722                 ret_ref |= 1;
24723         }
24724         return ret_ref;
24725 }
24726
24727 static inline uintptr_t DelayedPaymentOutputDescriptor_clone_ptr(LDKDelayedPaymentOutputDescriptor *NONNULL_PTR arg) {
24728         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(arg);
24729 uint32_t ret_ref = 0;
24730 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24731 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24732 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24733 ret_ref = (uintptr_t)ret_var.inner;
24734 if (ret_var.is_owned) {
24735         ret_ref |= 1;
24736 }
24737         return ret_ref;
24738 }
24739 uint32_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_clone_ptr"))) TS_DelayedPaymentOutputDescriptor_clone_ptr(uint32_t arg) {
24740         LDKDelayedPaymentOutputDescriptor arg_conv;
24741         arg_conv.inner = (void*)(arg & (~1));
24742         arg_conv.is_owned = false;
24743         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24744         uint32_t ret_conv = DelayedPaymentOutputDescriptor_clone_ptr(&arg_conv);
24745         return ret_conv;
24746 }
24747
24748 uint32_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_clone"))) TS_DelayedPaymentOutputDescriptor_clone(uint32_t orig) {
24749         LDKDelayedPaymentOutputDescriptor orig_conv;
24750         orig_conv.inner = (void*)(orig & (~1));
24751         orig_conv.is_owned = false;
24752         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24753         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
24754         uint32_t ret_ref = 0;
24755         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24756         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24757         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24758         ret_ref = (uintptr_t)ret_var.inner;
24759         if (ret_var.is_owned) {
24760                 ret_ref |= 1;
24761         }
24762         return ret_ref;
24763 }
24764
24765 int8_tArray  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_write"))) TS_DelayedPaymentOutputDescriptor_write(uint32_t obj) {
24766         LDKDelayedPaymentOutputDescriptor obj_conv;
24767         obj_conv.inner = (void*)(obj & (~1));
24768         obj_conv.is_owned = false;
24769         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
24770         LDKCVec_u8Z ret_var = DelayedPaymentOutputDescriptor_write(&obj_conv);
24771         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
24772         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
24773         CVec_u8Z_free(ret_var);
24774         return ret_arr;
24775 }
24776
24777 uint32_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_read"))) TS_DelayedPaymentOutputDescriptor_read(int8_tArray ser) {
24778         LDKu8slice ser_ref;
24779         ser_ref.datalen = ser->arr_len;
24780         ser_ref.data = ser->elems;
24781         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
24782         *ret_conv = DelayedPaymentOutputDescriptor_read(ser_ref);
24783         FREE(ser);
24784         return (uint32_t)ret_conv;
24785 }
24786
24787 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_free"))) TS_StaticPaymentOutputDescriptor_free(uint32_t this_obj) {
24788         LDKStaticPaymentOutputDescriptor this_obj_conv;
24789         this_obj_conv.inner = (void*)(this_obj & (~1));
24790         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24791         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24792         StaticPaymentOutputDescriptor_free(this_obj_conv);
24793 }
24794
24795 uint32_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_get_outpoint"))) TS_StaticPaymentOutputDescriptor_get_outpoint(uint32_t this_ptr) {
24796         LDKStaticPaymentOutputDescriptor this_ptr_conv;
24797         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24798         this_ptr_conv.is_owned = false;
24799         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24800         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
24801         uint32_t ret_ref = 0;
24802         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24803         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24804         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24805         ret_ref = (uintptr_t)ret_var.inner;
24806         if (ret_var.is_owned) {
24807                 ret_ref |= 1;
24808         }
24809         return ret_ref;
24810 }
24811
24812 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_set_outpoint"))) TS_StaticPaymentOutputDescriptor_set_outpoint(uint32_t this_ptr, uint32_t val) {
24813         LDKStaticPaymentOutputDescriptor this_ptr_conv;
24814         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24815         this_ptr_conv.is_owned = false;
24816         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24817         LDKOutPoint val_conv;
24818         val_conv.inner = (void*)(val & (~1));
24819         val_conv.is_owned = (val & 1) || (val == 0);
24820         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
24821         val_conv = OutPoint_clone(&val_conv);
24822         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
24823 }
24824
24825 uint32_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_get_output"))) TS_StaticPaymentOutputDescriptor_get_output(uint32_t this_ptr) {
24826         LDKStaticPaymentOutputDescriptor this_ptr_conv;
24827         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24828         this_ptr_conv.is_owned = false;
24829         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24830         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
24831         *ret_ref = StaticPaymentOutputDescriptor_get_output(&this_ptr_conv);
24832         return (uint32_t)ret_ref;
24833 }
24834
24835 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_set_output"))) TS_StaticPaymentOutputDescriptor_set_output(uint32_t this_ptr, uint32_t val) {
24836         LDKStaticPaymentOutputDescriptor this_ptr_conv;
24837         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24838         this_ptr_conv.is_owned = false;
24839         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24840         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
24841         CHECK_ACCESS(val_ptr);
24842         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
24843         val_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)val) & ~1));
24844         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
24845 }
24846
24847 int8_tArray  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_get_channel_keys_id"))) TS_StaticPaymentOutputDescriptor_get_channel_keys_id(uint32_t this_ptr) {
24848         LDKStaticPaymentOutputDescriptor this_ptr_conv;
24849         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24850         this_ptr_conv.is_owned = false;
24851         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24852         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
24853         memcpy(ret_arr->elems, *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv), 32);
24854         return ret_arr;
24855 }
24856
24857 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_set_channel_keys_id"))) TS_StaticPaymentOutputDescriptor_set_channel_keys_id(uint32_t this_ptr, int8_tArray val) {
24858         LDKStaticPaymentOutputDescriptor this_ptr_conv;
24859         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24860         this_ptr_conv.is_owned = false;
24861         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24862         LDKThirtyTwoBytes val_ref;
24863         CHECK(val->arr_len == 32);
24864         memcpy(val_ref.data, val->elems, 32); FREE(val);
24865         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
24866 }
24867
24868 int64_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_get_channel_value_satoshis"))) TS_StaticPaymentOutputDescriptor_get_channel_value_satoshis(uint32_t this_ptr) {
24869         LDKStaticPaymentOutputDescriptor this_ptr_conv;
24870         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24871         this_ptr_conv.is_owned = false;
24872         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24873         int64_t ret_conv = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
24874         return ret_conv;
24875 }
24876
24877 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_set_channel_value_satoshis"))) TS_StaticPaymentOutputDescriptor_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
24878         LDKStaticPaymentOutputDescriptor this_ptr_conv;
24879         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24880         this_ptr_conv.is_owned = false;
24881         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24882         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
24883 }
24884
24885 uint32_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_new"))) TS_StaticPaymentOutputDescriptor_new(uint32_t outpoint_arg, uint32_t output_arg, int8_tArray channel_keys_id_arg, int64_t channel_value_satoshis_arg) {
24886         LDKOutPoint outpoint_arg_conv;
24887         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
24888         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
24889         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
24890         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
24891         void* output_arg_ptr = (void*)(((uintptr_t)output_arg) & ~1);
24892         CHECK_ACCESS(output_arg_ptr);
24893         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
24894         output_arg_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output_arg) & ~1));
24895         LDKThirtyTwoBytes channel_keys_id_arg_ref;
24896         CHECK(channel_keys_id_arg->arr_len == 32);
24897         memcpy(channel_keys_id_arg_ref.data, channel_keys_id_arg->elems, 32); FREE(channel_keys_id_arg);
24898         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
24899         uint32_t ret_ref = 0;
24900         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24901         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24902         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24903         ret_ref = (uintptr_t)ret_var.inner;
24904         if (ret_var.is_owned) {
24905                 ret_ref |= 1;
24906         }
24907         return ret_ref;
24908 }
24909
24910 static inline uintptr_t StaticPaymentOutputDescriptor_clone_ptr(LDKStaticPaymentOutputDescriptor *NONNULL_PTR arg) {
24911         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(arg);
24912 uint32_t ret_ref = 0;
24913 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24914 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24915 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24916 ret_ref = (uintptr_t)ret_var.inner;
24917 if (ret_var.is_owned) {
24918         ret_ref |= 1;
24919 }
24920         return ret_ref;
24921 }
24922 uint32_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_clone_ptr"))) TS_StaticPaymentOutputDescriptor_clone_ptr(uint32_t arg) {
24923         LDKStaticPaymentOutputDescriptor arg_conv;
24924         arg_conv.inner = (void*)(arg & (~1));
24925         arg_conv.is_owned = false;
24926         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24927         uint32_t ret_conv = StaticPaymentOutputDescriptor_clone_ptr(&arg_conv);
24928         return ret_conv;
24929 }
24930
24931 uint32_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_clone"))) TS_StaticPaymentOutputDescriptor_clone(uint32_t orig) {
24932         LDKStaticPaymentOutputDescriptor orig_conv;
24933         orig_conv.inner = (void*)(orig & (~1));
24934         orig_conv.is_owned = false;
24935         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24936         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
24937         uint32_t ret_ref = 0;
24938         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24939         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24940         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24941         ret_ref = (uintptr_t)ret_var.inner;
24942         if (ret_var.is_owned) {
24943                 ret_ref |= 1;
24944         }
24945         return ret_ref;
24946 }
24947
24948 int8_tArray  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_write"))) TS_StaticPaymentOutputDescriptor_write(uint32_t obj) {
24949         LDKStaticPaymentOutputDescriptor obj_conv;
24950         obj_conv.inner = (void*)(obj & (~1));
24951         obj_conv.is_owned = false;
24952         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
24953         LDKCVec_u8Z ret_var = StaticPaymentOutputDescriptor_write(&obj_conv);
24954         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
24955         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
24956         CVec_u8Z_free(ret_var);
24957         return ret_arr;
24958 }
24959
24960 uint32_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_read"))) TS_StaticPaymentOutputDescriptor_read(int8_tArray ser) {
24961         LDKu8slice ser_ref;
24962         ser_ref.datalen = ser->arr_len;
24963         ser_ref.data = ser->elems;
24964         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
24965         *ret_conv = StaticPaymentOutputDescriptor_read(ser_ref);
24966         FREE(ser);
24967         return (uint32_t)ret_conv;
24968 }
24969
24970 void  __attribute__((export_name("TS_SpendableOutputDescriptor_free"))) TS_SpendableOutputDescriptor_free(uint32_t this_ptr) {
24971         if ((this_ptr & 1) != 0) return;
24972         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
24973         CHECK_ACCESS(this_ptr_ptr);
24974         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(this_ptr_ptr);
24975         FREE((void*)this_ptr);
24976         SpendableOutputDescriptor_free(this_ptr_conv);
24977 }
24978
24979 static inline uintptr_t SpendableOutputDescriptor_clone_ptr(LDKSpendableOutputDescriptor *NONNULL_PTR arg) {
24980         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
24981         *ret_copy = SpendableOutputDescriptor_clone(arg);
24982 uint32_t ret_ref = (uintptr_t)ret_copy;
24983         return ret_ref;
24984 }
24985 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_clone_ptr"))) TS_SpendableOutputDescriptor_clone_ptr(uint32_t arg) {
24986         LDKSpendableOutputDescriptor* arg_conv = (LDKSpendableOutputDescriptor*)arg;
24987         uint32_t ret_conv = SpendableOutputDescriptor_clone_ptr(arg_conv);
24988         return ret_conv;
24989 }
24990
24991 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_clone"))) TS_SpendableOutputDescriptor_clone(uint32_t orig) {
24992         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)orig;
24993         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
24994         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
24995         uint32_t ret_ref = (uintptr_t)ret_copy;
24996         return ret_ref;
24997 }
24998
24999 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_static_output"))) TS_SpendableOutputDescriptor_static_output(uint32_t outpoint, uint32_t output) {
25000         LDKOutPoint outpoint_conv;
25001         outpoint_conv.inner = (void*)(outpoint & (~1));
25002         outpoint_conv.is_owned = (outpoint & 1) || (outpoint == 0);
25003         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_conv);
25004         outpoint_conv = OutPoint_clone(&outpoint_conv);
25005         void* output_ptr = (void*)(((uintptr_t)output) & ~1);
25006         CHECK_ACCESS(output_ptr);
25007         LDKTxOut output_conv = *(LDKTxOut*)(output_ptr);
25008         output_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output) & ~1));
25009         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
25010         *ret_copy = SpendableOutputDescriptor_static_output(outpoint_conv, output_conv);
25011         uint32_t ret_ref = (uintptr_t)ret_copy;
25012         return ret_ref;
25013 }
25014
25015 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_delayed_payment_output"))) TS_SpendableOutputDescriptor_delayed_payment_output(uint32_t a) {
25016         LDKDelayedPaymentOutputDescriptor a_conv;
25017         a_conv.inner = (void*)(a & (~1));
25018         a_conv.is_owned = (a & 1) || (a == 0);
25019         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
25020         a_conv = DelayedPaymentOutputDescriptor_clone(&a_conv);
25021         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
25022         *ret_copy = SpendableOutputDescriptor_delayed_payment_output(a_conv);
25023         uint32_t ret_ref = (uintptr_t)ret_copy;
25024         return ret_ref;
25025 }
25026
25027 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_static_payment_output"))) TS_SpendableOutputDescriptor_static_payment_output(uint32_t a) {
25028         LDKStaticPaymentOutputDescriptor a_conv;
25029         a_conv.inner = (void*)(a & (~1));
25030         a_conv.is_owned = (a & 1) || (a == 0);
25031         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
25032         a_conv = StaticPaymentOutputDescriptor_clone(&a_conv);
25033         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
25034         *ret_copy = SpendableOutputDescriptor_static_payment_output(a_conv);
25035         uint32_t ret_ref = (uintptr_t)ret_copy;
25036         return ret_ref;
25037 }
25038
25039 int8_tArray  __attribute__((export_name("TS_SpendableOutputDescriptor_write"))) TS_SpendableOutputDescriptor_write(uint32_t obj) {
25040         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)obj;
25041         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
25042         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
25043         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
25044         CVec_u8Z_free(ret_var);
25045         return ret_arr;
25046 }
25047
25048 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_read"))) TS_SpendableOutputDescriptor_read(int8_tArray ser) {
25049         LDKu8slice ser_ref;
25050         ser_ref.datalen = ser->arr_len;
25051         ser_ref.data = ser->elems;
25052         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
25053         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
25054         FREE(ser);
25055         return (uint32_t)ret_conv;
25056 }
25057
25058 void  __attribute__((export_name("TS_BaseSign_free"))) TS_BaseSign_free(uint32_t this_ptr) {
25059         if ((this_ptr & 1) != 0) return;
25060         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
25061         CHECK_ACCESS(this_ptr_ptr);
25062         LDKBaseSign this_ptr_conv = *(LDKBaseSign*)(this_ptr_ptr);
25063         FREE((void*)this_ptr);
25064         BaseSign_free(this_ptr_conv);
25065 }
25066
25067 static inline uintptr_t Sign_clone_ptr(LDKSign *NONNULL_PTR arg) {
25068         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
25069         *ret_ret = Sign_clone(arg);
25070         return (uint32_t)ret_ret;
25071 }
25072 uint32_t  __attribute__((export_name("TS_Sign_clone_ptr"))) TS_Sign_clone_ptr(uint32_t arg) {
25073         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
25074         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
25075         LDKSign* arg_conv = (LDKSign*)arg_ptr;
25076         uint32_t ret_conv = Sign_clone_ptr(arg_conv);
25077         return ret_conv;
25078 }
25079
25080 uint32_t  __attribute__((export_name("TS_Sign_clone"))) TS_Sign_clone(uint32_t orig) {
25081         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
25082         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
25083         LDKSign* orig_conv = (LDKSign*)orig_ptr;
25084         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
25085         *ret_ret = Sign_clone(orig_conv);
25086         return (uint32_t)ret_ret;
25087 }
25088
25089 void  __attribute__((export_name("TS_Sign_free"))) TS_Sign_free(uint32_t this_ptr) {
25090         if ((this_ptr & 1) != 0) return;
25091         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
25092         CHECK_ACCESS(this_ptr_ptr);
25093         LDKSign this_ptr_conv = *(LDKSign*)(this_ptr_ptr);
25094         FREE((void*)this_ptr);
25095         Sign_free(this_ptr_conv);
25096 }
25097
25098 uint32_t  __attribute__((export_name("TS_Recipient_clone"))) TS_Recipient_clone(uint32_t orig) {
25099         LDKRecipient* orig_conv = (LDKRecipient*)(orig & ~1);
25100         uint32_t ret_conv = LDKRecipient_to_js(Recipient_clone(orig_conv));
25101         return ret_conv;
25102 }
25103
25104 uint32_t  __attribute__((export_name("TS_Recipient_node"))) TS_Recipient_node() {
25105         uint32_t ret_conv = LDKRecipient_to_js(Recipient_node());
25106         return ret_conv;
25107 }
25108
25109 uint32_t  __attribute__((export_name("TS_Recipient_phantom_node"))) TS_Recipient_phantom_node() {
25110         uint32_t ret_conv = LDKRecipient_to_js(Recipient_phantom_node());
25111         return ret_conv;
25112 }
25113
25114 void  __attribute__((export_name("TS_KeysInterface_free"))) TS_KeysInterface_free(uint32_t this_ptr) {
25115         if ((this_ptr & 1) != 0) return;
25116         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
25117         CHECK_ACCESS(this_ptr_ptr);
25118         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(this_ptr_ptr);
25119         FREE((void*)this_ptr);
25120         KeysInterface_free(this_ptr_conv);
25121 }
25122
25123 void  __attribute__((export_name("TS_InMemorySigner_free"))) TS_InMemorySigner_free(uint32_t this_obj) {
25124         LDKInMemorySigner this_obj_conv;
25125         this_obj_conv.inner = (void*)(this_obj & (~1));
25126         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25127         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25128         InMemorySigner_free(this_obj_conv);
25129 }
25130
25131 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_funding_key"))) TS_InMemorySigner_get_funding_key(uint32_t this_ptr) {
25132         LDKInMemorySigner this_ptr_conv;
25133         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25134         this_ptr_conv.is_owned = false;
25135         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25136         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
25137         memcpy(ret_arr->elems, *InMemorySigner_get_funding_key(&this_ptr_conv), 32);
25138         return ret_arr;
25139 }
25140
25141 void  __attribute__((export_name("TS_InMemorySigner_set_funding_key"))) TS_InMemorySigner_set_funding_key(uint32_t this_ptr, int8_tArray val) {
25142         LDKInMemorySigner this_ptr_conv;
25143         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25144         this_ptr_conv.is_owned = false;
25145         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25146         LDKSecretKey val_ref;
25147         CHECK(val->arr_len == 32);
25148         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
25149         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
25150 }
25151
25152 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_revocation_base_key"))) TS_InMemorySigner_get_revocation_base_key(uint32_t this_ptr) {
25153         LDKInMemorySigner this_ptr_conv;
25154         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25155         this_ptr_conv.is_owned = false;
25156         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25157         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
25158         memcpy(ret_arr->elems, *InMemorySigner_get_revocation_base_key(&this_ptr_conv), 32);
25159         return ret_arr;
25160 }
25161
25162 void  __attribute__((export_name("TS_InMemorySigner_set_revocation_base_key"))) TS_InMemorySigner_set_revocation_base_key(uint32_t this_ptr, int8_tArray val) {
25163         LDKInMemorySigner this_ptr_conv;
25164         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25165         this_ptr_conv.is_owned = false;
25166         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25167         LDKSecretKey val_ref;
25168         CHECK(val->arr_len == 32);
25169         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
25170         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
25171 }
25172
25173 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_payment_key"))) TS_InMemorySigner_get_payment_key(uint32_t this_ptr) {
25174         LDKInMemorySigner this_ptr_conv;
25175         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25176         this_ptr_conv.is_owned = false;
25177         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25178         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
25179         memcpy(ret_arr->elems, *InMemorySigner_get_payment_key(&this_ptr_conv), 32);
25180         return ret_arr;
25181 }
25182
25183 void  __attribute__((export_name("TS_InMemorySigner_set_payment_key"))) TS_InMemorySigner_set_payment_key(uint32_t this_ptr, int8_tArray val) {
25184         LDKInMemorySigner this_ptr_conv;
25185         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25186         this_ptr_conv.is_owned = false;
25187         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25188         LDKSecretKey val_ref;
25189         CHECK(val->arr_len == 32);
25190         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
25191         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
25192 }
25193
25194 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_delayed_payment_base_key"))) TS_InMemorySigner_get_delayed_payment_base_key(uint32_t this_ptr) {
25195         LDKInMemorySigner this_ptr_conv;
25196         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25197         this_ptr_conv.is_owned = false;
25198         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25199         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
25200         memcpy(ret_arr->elems, *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv), 32);
25201         return ret_arr;
25202 }
25203
25204 void  __attribute__((export_name("TS_InMemorySigner_set_delayed_payment_base_key"))) TS_InMemorySigner_set_delayed_payment_base_key(uint32_t this_ptr, int8_tArray val) {
25205         LDKInMemorySigner this_ptr_conv;
25206         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25207         this_ptr_conv.is_owned = false;
25208         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25209         LDKSecretKey val_ref;
25210         CHECK(val->arr_len == 32);
25211         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
25212         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
25213 }
25214
25215 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_htlc_base_key"))) TS_InMemorySigner_get_htlc_base_key(uint32_t this_ptr) {
25216         LDKInMemorySigner this_ptr_conv;
25217         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25218         this_ptr_conv.is_owned = false;
25219         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25220         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
25221         memcpy(ret_arr->elems, *InMemorySigner_get_htlc_base_key(&this_ptr_conv), 32);
25222         return ret_arr;
25223 }
25224
25225 void  __attribute__((export_name("TS_InMemorySigner_set_htlc_base_key"))) TS_InMemorySigner_set_htlc_base_key(uint32_t this_ptr, int8_tArray val) {
25226         LDKInMemorySigner this_ptr_conv;
25227         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25228         this_ptr_conv.is_owned = false;
25229         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25230         LDKSecretKey val_ref;
25231         CHECK(val->arr_len == 32);
25232         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
25233         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
25234 }
25235
25236 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_commitment_seed"))) TS_InMemorySigner_get_commitment_seed(uint32_t this_ptr) {
25237         LDKInMemorySigner this_ptr_conv;
25238         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25239         this_ptr_conv.is_owned = false;
25240         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25241         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
25242         memcpy(ret_arr->elems, *InMemorySigner_get_commitment_seed(&this_ptr_conv), 32);
25243         return ret_arr;
25244 }
25245
25246 void  __attribute__((export_name("TS_InMemorySigner_set_commitment_seed"))) TS_InMemorySigner_set_commitment_seed(uint32_t this_ptr, int8_tArray val) {
25247         LDKInMemorySigner this_ptr_conv;
25248         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25249         this_ptr_conv.is_owned = false;
25250         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25251         LDKThirtyTwoBytes val_ref;
25252         CHECK(val->arr_len == 32);
25253         memcpy(val_ref.data, val->elems, 32); FREE(val);
25254         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
25255 }
25256
25257 static inline uintptr_t InMemorySigner_clone_ptr(LDKInMemorySigner *NONNULL_PTR arg) {
25258         LDKInMemorySigner ret_var = InMemorySigner_clone(arg);
25259 uint32_t ret_ref = 0;
25260 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25261 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25262 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25263 ret_ref = (uintptr_t)ret_var.inner;
25264 if (ret_var.is_owned) {
25265         ret_ref |= 1;
25266 }
25267         return ret_ref;
25268 }
25269 uint32_t  __attribute__((export_name("TS_InMemorySigner_clone_ptr"))) TS_InMemorySigner_clone_ptr(uint32_t arg) {
25270         LDKInMemorySigner arg_conv;
25271         arg_conv.inner = (void*)(arg & (~1));
25272         arg_conv.is_owned = false;
25273         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25274         uint32_t ret_conv = InMemorySigner_clone_ptr(&arg_conv);
25275         return ret_conv;
25276 }
25277
25278 uint32_t  __attribute__((export_name("TS_InMemorySigner_clone"))) TS_InMemorySigner_clone(uint32_t orig) {
25279         LDKInMemorySigner orig_conv;
25280         orig_conv.inner = (void*)(orig & (~1));
25281         orig_conv.is_owned = false;
25282         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25283         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
25284         uint32_t ret_ref = 0;
25285         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25286         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25287         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25288         ret_ref = (uintptr_t)ret_var.inner;
25289         if (ret_var.is_owned) {
25290                 ret_ref |= 1;
25291         }
25292         return ret_ref;
25293 }
25294
25295 uint32_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) {
25296         LDKSecretKey node_secret_ref;
25297         CHECK(node_secret->arr_len == 32);
25298         memcpy(node_secret_ref.bytes, node_secret->elems, 32); FREE(node_secret);
25299         LDKSecretKey funding_key_ref;
25300         CHECK(funding_key->arr_len == 32);
25301         memcpy(funding_key_ref.bytes, funding_key->elems, 32); FREE(funding_key);
25302         LDKSecretKey revocation_base_key_ref;
25303         CHECK(revocation_base_key->arr_len == 32);
25304         memcpy(revocation_base_key_ref.bytes, revocation_base_key->elems, 32); FREE(revocation_base_key);
25305         LDKSecretKey payment_key_ref;
25306         CHECK(payment_key->arr_len == 32);
25307         memcpy(payment_key_ref.bytes, payment_key->elems, 32); FREE(payment_key);
25308         LDKSecretKey delayed_payment_base_key_ref;
25309         CHECK(delayed_payment_base_key->arr_len == 32);
25310         memcpy(delayed_payment_base_key_ref.bytes, delayed_payment_base_key->elems, 32); FREE(delayed_payment_base_key);
25311         LDKSecretKey htlc_base_key_ref;
25312         CHECK(htlc_base_key->arr_len == 32);
25313         memcpy(htlc_base_key_ref.bytes, htlc_base_key->elems, 32); FREE(htlc_base_key);
25314         LDKThirtyTwoBytes commitment_seed_ref;
25315         CHECK(commitment_seed->arr_len == 32);
25316         memcpy(commitment_seed_ref.data, commitment_seed->elems, 32); FREE(commitment_seed);
25317         LDKThirtyTwoBytes channel_keys_id_ref;
25318         CHECK(channel_keys_id->arr_len == 32);
25319         memcpy(channel_keys_id_ref.data, channel_keys_id->elems, 32); FREE(channel_keys_id);
25320         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);
25321         uint32_t ret_ref = 0;
25322         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25323         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25324         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25325         ret_ref = (uintptr_t)ret_var.inner;
25326         if (ret_var.is_owned) {
25327                 ret_ref |= 1;
25328         }
25329         return ret_ref;
25330 }
25331
25332 uint32_t  __attribute__((export_name("TS_InMemorySigner_counterparty_pubkeys"))) TS_InMemorySigner_counterparty_pubkeys(uint32_t this_arg) {
25333         LDKInMemorySigner this_arg_conv;
25334         this_arg_conv.inner = (void*)(this_arg & (~1));
25335         this_arg_conv.is_owned = false;
25336         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25337         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
25338         uint32_t ret_ref = 0;
25339         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25340         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25341         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25342         ret_ref = (uintptr_t)ret_var.inner;
25343         if (ret_var.is_owned) {
25344                 ret_ref |= 1;
25345         }
25346         return ret_ref;
25347 }
25348
25349 int16_t  __attribute__((export_name("TS_InMemorySigner_counterparty_selected_contest_delay"))) TS_InMemorySigner_counterparty_selected_contest_delay(uint32_t this_arg) {
25350         LDKInMemorySigner this_arg_conv;
25351         this_arg_conv.inner = (void*)(this_arg & (~1));
25352         this_arg_conv.is_owned = false;
25353         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25354         int16_t ret_conv = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
25355         return ret_conv;
25356 }
25357
25358 int16_t  __attribute__((export_name("TS_InMemorySigner_holder_selected_contest_delay"))) TS_InMemorySigner_holder_selected_contest_delay(uint32_t this_arg) {
25359         LDKInMemorySigner this_arg_conv;
25360         this_arg_conv.inner = (void*)(this_arg & (~1));
25361         this_arg_conv.is_owned = false;
25362         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25363         int16_t ret_conv = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
25364         return ret_conv;
25365 }
25366
25367 jboolean  __attribute__((export_name("TS_InMemorySigner_is_outbound"))) TS_InMemorySigner_is_outbound(uint32_t this_arg) {
25368         LDKInMemorySigner this_arg_conv;
25369         this_arg_conv.inner = (void*)(this_arg & (~1));
25370         this_arg_conv.is_owned = false;
25371         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25372         jboolean ret_conv = InMemorySigner_is_outbound(&this_arg_conv);
25373         return ret_conv;
25374 }
25375
25376 uint32_t  __attribute__((export_name("TS_InMemorySigner_funding_outpoint"))) TS_InMemorySigner_funding_outpoint(uint32_t this_arg) {
25377         LDKInMemorySigner this_arg_conv;
25378         this_arg_conv.inner = (void*)(this_arg & (~1));
25379         this_arg_conv.is_owned = false;
25380         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25381         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
25382         uint32_t ret_ref = 0;
25383         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25384         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25385         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25386         ret_ref = (uintptr_t)ret_var.inner;
25387         if (ret_var.is_owned) {
25388                 ret_ref |= 1;
25389         }
25390         return ret_ref;
25391 }
25392
25393 uint32_t  __attribute__((export_name("TS_InMemorySigner_get_channel_parameters"))) TS_InMemorySigner_get_channel_parameters(uint32_t this_arg) {
25394         LDKInMemorySigner this_arg_conv;
25395         this_arg_conv.inner = (void*)(this_arg & (~1));
25396         this_arg_conv.is_owned = false;
25397         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25398         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
25399         uint32_t ret_ref = 0;
25400         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25401         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25402         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25403         ret_ref = (uintptr_t)ret_var.inner;
25404         if (ret_var.is_owned) {
25405                 ret_ref |= 1;
25406         }
25407         return ret_ref;
25408 }
25409
25410 jboolean  __attribute__((export_name("TS_InMemorySigner_opt_anchors"))) TS_InMemorySigner_opt_anchors(uint32_t this_arg) {
25411         LDKInMemorySigner this_arg_conv;
25412         this_arg_conv.inner = (void*)(this_arg & (~1));
25413         this_arg_conv.is_owned = false;
25414         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25415         jboolean ret_conv = InMemorySigner_opt_anchors(&this_arg_conv);
25416         return ret_conv;
25417 }
25418
25419 uint32_t  __attribute__((export_name("TS_InMemorySigner_sign_counterparty_payment_input"))) TS_InMemorySigner_sign_counterparty_payment_input(uint32_t this_arg, int8_tArray spend_tx, uint32_t input_idx, uint32_t descriptor) {
25420         LDKInMemorySigner this_arg_conv;
25421         this_arg_conv.inner = (void*)(this_arg & (~1));
25422         this_arg_conv.is_owned = false;
25423         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25424         LDKTransaction spend_tx_ref;
25425         spend_tx_ref.datalen = spend_tx->arr_len;
25426         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
25427         memcpy(spend_tx_ref.data, spend_tx->elems, spend_tx_ref.datalen); FREE(spend_tx);
25428         spend_tx_ref.data_is_owned = true;
25429         LDKStaticPaymentOutputDescriptor descriptor_conv;
25430         descriptor_conv.inner = (void*)(descriptor & (~1));
25431         descriptor_conv.is_owned = false;
25432         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
25433         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
25434         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
25435         return (uint32_t)ret_conv;
25436 }
25437
25438 uint32_t  __attribute__((export_name("TS_InMemorySigner_sign_dynamic_p2wsh_input"))) TS_InMemorySigner_sign_dynamic_p2wsh_input(uint32_t this_arg, int8_tArray spend_tx, uint32_t input_idx, uint32_t descriptor) {
25439         LDKInMemorySigner this_arg_conv;
25440         this_arg_conv.inner = (void*)(this_arg & (~1));
25441         this_arg_conv.is_owned = false;
25442         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25443         LDKTransaction spend_tx_ref;
25444         spend_tx_ref.datalen = spend_tx->arr_len;
25445         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
25446         memcpy(spend_tx_ref.data, spend_tx->elems, spend_tx_ref.datalen); FREE(spend_tx);
25447         spend_tx_ref.data_is_owned = true;
25448         LDKDelayedPaymentOutputDescriptor descriptor_conv;
25449         descriptor_conv.inner = (void*)(descriptor & (~1));
25450         descriptor_conv.is_owned = false;
25451         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
25452         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
25453         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
25454         return (uint32_t)ret_conv;
25455 }
25456
25457 uint32_t  __attribute__((export_name("TS_InMemorySigner_as_BaseSign"))) TS_InMemorySigner_as_BaseSign(uint32_t this_arg) {
25458         LDKInMemorySigner this_arg_conv;
25459         this_arg_conv.inner = (void*)(this_arg & (~1));
25460         this_arg_conv.is_owned = false;
25461         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25462         LDKBaseSign* ret_ret = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
25463         *ret_ret = InMemorySigner_as_BaseSign(&this_arg_conv);
25464         return (uint32_t)ret_ret;
25465 }
25466
25467 uint32_t  __attribute__((export_name("TS_InMemorySigner_as_Sign"))) TS_InMemorySigner_as_Sign(uint32_t this_arg) {
25468         LDKInMemorySigner this_arg_conv;
25469         this_arg_conv.inner = (void*)(this_arg & (~1));
25470         this_arg_conv.is_owned = false;
25471         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25472         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
25473         *ret_ret = InMemorySigner_as_Sign(&this_arg_conv);
25474         return (uint32_t)ret_ret;
25475 }
25476
25477 int8_tArray  __attribute__((export_name("TS_InMemorySigner_write"))) TS_InMemorySigner_write(uint32_t obj) {
25478         LDKInMemorySigner obj_conv;
25479         obj_conv.inner = (void*)(obj & (~1));
25480         obj_conv.is_owned = false;
25481         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
25482         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
25483         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
25484         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
25485         CVec_u8Z_free(ret_var);
25486         return ret_arr;
25487 }
25488
25489 uint32_t  __attribute__((export_name("TS_InMemorySigner_read"))) TS_InMemorySigner_read(int8_tArray ser, int8_tArray arg) {
25490         LDKu8slice ser_ref;
25491         ser_ref.datalen = ser->arr_len;
25492         ser_ref.data = ser->elems;
25493         LDKSecretKey arg_ref;
25494         CHECK(arg->arr_len == 32);
25495         memcpy(arg_ref.bytes, arg->elems, 32); FREE(arg);
25496         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
25497         *ret_conv = InMemorySigner_read(ser_ref, arg_ref);
25498         FREE(ser);
25499         return (uint32_t)ret_conv;
25500 }
25501
25502 void  __attribute__((export_name("TS_KeysManager_free"))) TS_KeysManager_free(uint32_t this_obj) {
25503         LDKKeysManager this_obj_conv;
25504         this_obj_conv.inner = (void*)(this_obj & (~1));
25505         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25506         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25507         KeysManager_free(this_obj_conv);
25508 }
25509
25510 uint32_t  __attribute__((export_name("TS_KeysManager_new"))) TS_KeysManager_new(int8_tArray seed, int64_t starting_time_secs, int32_t starting_time_nanos) {
25511         unsigned char seed_arr[32];
25512         CHECK(seed->arr_len == 32);
25513         memcpy(seed_arr, seed->elems, 32); FREE(seed);
25514         unsigned char (*seed_ref)[32] = &seed_arr;
25515         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
25516         uint32_t ret_ref = 0;
25517         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25518         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25519         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25520         ret_ref = (uintptr_t)ret_var.inner;
25521         if (ret_var.is_owned) {
25522                 ret_ref |= 1;
25523         }
25524         return ret_ref;
25525 }
25526
25527 uint32_t  __attribute__((export_name("TS_KeysManager_derive_channel_keys"))) TS_KeysManager_derive_channel_keys(uint32_t this_arg, int64_t channel_value_satoshis, int8_tArray params) {
25528         LDKKeysManager this_arg_conv;
25529         this_arg_conv.inner = (void*)(this_arg & (~1));
25530         this_arg_conv.is_owned = false;
25531         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25532         unsigned char params_arr[32];
25533         CHECK(params->arr_len == 32);
25534         memcpy(params_arr, params->elems, 32); FREE(params);
25535         unsigned char (*params_ref)[32] = &params_arr;
25536         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
25537         uint32_t ret_ref = 0;
25538         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25539         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25540         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25541         ret_ref = (uintptr_t)ret_var.inner;
25542         if (ret_var.is_owned) {
25543                 ret_ref |= 1;
25544         }
25545         return ret_ref;
25546 }
25547
25548 uint32_t  __attribute__((export_name("TS_KeysManager_spend_spendable_outputs"))) TS_KeysManager_spend_spendable_outputs(uint32_t this_arg, uint32_tArray descriptors, uint32_tArray outputs, int8_tArray change_destination_script, int32_t feerate_sat_per_1000_weight) {
25549         LDKKeysManager this_arg_conv;
25550         this_arg_conv.inner = (void*)(this_arg & (~1));
25551         this_arg_conv.is_owned = false;
25552         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25553         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
25554         descriptors_constr.datalen = descriptors->arr_len;
25555         if (descriptors_constr.datalen > 0)
25556                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
25557         else
25558                 descriptors_constr.data = NULL;
25559         uint32_t* descriptors_vals = descriptors->elems;
25560         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
25561                 uint32_t descriptors_conv_27 = descriptors_vals[b];
25562                 void* descriptors_conv_27_ptr = (void*)(((uintptr_t)descriptors_conv_27) & ~1);
25563                 CHECK_ACCESS(descriptors_conv_27_ptr);
25564                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
25565                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)descriptors_conv_27) & ~1));
25566                 descriptors_constr.data[b] = descriptors_conv_27_conv;
25567         }
25568         FREE(descriptors);
25569         LDKCVec_TxOutZ outputs_constr;
25570         outputs_constr.datalen = outputs->arr_len;
25571         if (outputs_constr.datalen > 0)
25572                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
25573         else
25574                 outputs_constr.data = NULL;
25575         uint32_t* outputs_vals = outputs->elems;
25576         for (size_t h = 0; h < outputs_constr.datalen; h++) {
25577                 uint32_t outputs_conv_7 = outputs_vals[h];
25578                 void* outputs_conv_7_ptr = (void*)(((uintptr_t)outputs_conv_7) & ~1);
25579                 CHECK_ACCESS(outputs_conv_7_ptr);
25580                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
25581                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)outputs_conv_7) & ~1));
25582                 outputs_constr.data[h] = outputs_conv_7_conv;
25583         }
25584         FREE(outputs);
25585         LDKCVec_u8Z change_destination_script_ref;
25586         change_destination_script_ref.datalen = change_destination_script->arr_len;
25587         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
25588         memcpy(change_destination_script_ref.data, change_destination_script->elems, change_destination_script_ref.datalen); FREE(change_destination_script);
25589         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
25590         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
25591         return (uint32_t)ret_conv;
25592 }
25593
25594 uint32_t  __attribute__((export_name("TS_KeysManager_as_KeysInterface"))) TS_KeysManager_as_KeysInterface(uint32_t this_arg) {
25595         LDKKeysManager this_arg_conv;
25596         this_arg_conv.inner = (void*)(this_arg & (~1));
25597         this_arg_conv.is_owned = false;
25598         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25599         LDKKeysInterface* ret_ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
25600         *ret_ret = KeysManager_as_KeysInterface(&this_arg_conv);
25601         return (uint32_t)ret_ret;
25602 }
25603
25604 void  __attribute__((export_name("TS_PhantomKeysManager_free"))) TS_PhantomKeysManager_free(uint32_t this_obj) {
25605         LDKPhantomKeysManager this_obj_conv;
25606         this_obj_conv.inner = (void*)(this_obj & (~1));
25607         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25608         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25609         PhantomKeysManager_free(this_obj_conv);
25610 }
25611
25612 uint32_t  __attribute__((export_name("TS_PhantomKeysManager_as_KeysInterface"))) TS_PhantomKeysManager_as_KeysInterface(uint32_t this_arg) {
25613         LDKPhantomKeysManager this_arg_conv;
25614         this_arg_conv.inner = (void*)(this_arg & (~1));
25615         this_arg_conv.is_owned = false;
25616         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25617         LDKKeysInterface* ret_ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
25618         *ret_ret = PhantomKeysManager_as_KeysInterface(&this_arg_conv);
25619         return (uint32_t)ret_ret;
25620 }
25621
25622 uint32_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) {
25623         unsigned char seed_arr[32];
25624         CHECK(seed->arr_len == 32);
25625         memcpy(seed_arr, seed->elems, 32); FREE(seed);
25626         unsigned char (*seed_ref)[32] = &seed_arr;
25627         unsigned char cross_node_seed_arr[32];
25628         CHECK(cross_node_seed->arr_len == 32);
25629         memcpy(cross_node_seed_arr, cross_node_seed->elems, 32); FREE(cross_node_seed);
25630         unsigned char (*cross_node_seed_ref)[32] = &cross_node_seed_arr;
25631         LDKPhantomKeysManager ret_var = PhantomKeysManager_new(seed_ref, starting_time_secs, starting_time_nanos, cross_node_seed_ref);
25632         uint32_t ret_ref = 0;
25633         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25634         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25635         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25636         ret_ref = (uintptr_t)ret_var.inner;
25637         if (ret_var.is_owned) {
25638                 ret_ref |= 1;
25639         }
25640         return ret_ref;
25641 }
25642
25643 uint32_t  __attribute__((export_name("TS_PhantomKeysManager_spend_spendable_outputs"))) TS_PhantomKeysManager_spend_spendable_outputs(uint32_t this_arg, uint32_tArray descriptors, uint32_tArray outputs, int8_tArray change_destination_script, int32_t feerate_sat_per_1000_weight) {
25644         LDKPhantomKeysManager this_arg_conv;
25645         this_arg_conv.inner = (void*)(this_arg & (~1));
25646         this_arg_conv.is_owned = false;
25647         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25648         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
25649         descriptors_constr.datalen = descriptors->arr_len;
25650         if (descriptors_constr.datalen > 0)
25651                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
25652         else
25653                 descriptors_constr.data = NULL;
25654         uint32_t* descriptors_vals = descriptors->elems;
25655         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
25656                 uint32_t descriptors_conv_27 = descriptors_vals[b];
25657                 void* descriptors_conv_27_ptr = (void*)(((uintptr_t)descriptors_conv_27) & ~1);
25658                 CHECK_ACCESS(descriptors_conv_27_ptr);
25659                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
25660                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)descriptors_conv_27) & ~1));
25661                 descriptors_constr.data[b] = descriptors_conv_27_conv;
25662         }
25663         FREE(descriptors);
25664         LDKCVec_TxOutZ outputs_constr;
25665         outputs_constr.datalen = outputs->arr_len;
25666         if (outputs_constr.datalen > 0)
25667                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
25668         else
25669                 outputs_constr.data = NULL;
25670         uint32_t* outputs_vals = outputs->elems;
25671         for (size_t h = 0; h < outputs_constr.datalen; h++) {
25672                 uint32_t outputs_conv_7 = outputs_vals[h];
25673                 void* outputs_conv_7_ptr = (void*)(((uintptr_t)outputs_conv_7) & ~1);
25674                 CHECK_ACCESS(outputs_conv_7_ptr);
25675                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
25676                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)outputs_conv_7) & ~1));
25677                 outputs_constr.data[h] = outputs_conv_7_conv;
25678         }
25679         FREE(outputs);
25680         LDKCVec_u8Z change_destination_script_ref;
25681         change_destination_script_ref.datalen = change_destination_script->arr_len;
25682         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
25683         memcpy(change_destination_script_ref.data, change_destination_script->elems, change_destination_script_ref.datalen); FREE(change_destination_script);
25684         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
25685         *ret_conv = PhantomKeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
25686         return (uint32_t)ret_conv;
25687 }
25688
25689 uint32_t  __attribute__((export_name("TS_PhantomKeysManager_derive_channel_keys"))) TS_PhantomKeysManager_derive_channel_keys(uint32_t this_arg, int64_t channel_value_satoshis, int8_tArray params) {
25690         LDKPhantomKeysManager this_arg_conv;
25691         this_arg_conv.inner = (void*)(this_arg & (~1));
25692         this_arg_conv.is_owned = false;
25693         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25694         unsigned char params_arr[32];
25695         CHECK(params->arr_len == 32);
25696         memcpy(params_arr, params->elems, 32); FREE(params);
25697         unsigned char (*params_ref)[32] = &params_arr;
25698         LDKInMemorySigner ret_var = PhantomKeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
25699         uint32_t ret_ref = 0;
25700         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25701         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25702         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25703         ret_ref = (uintptr_t)ret_var.inner;
25704         if (ret_var.is_owned) {
25705                 ret_ref |= 1;
25706         }
25707         return ret_ref;
25708 }
25709
25710 void  __attribute__((export_name("TS_ChannelManager_free"))) TS_ChannelManager_free(uint32_t this_obj) {
25711         LDKChannelManager this_obj_conv;
25712         this_obj_conv.inner = (void*)(this_obj & (~1));
25713         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25714         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25715         ChannelManager_free(this_obj_conv);
25716 }
25717
25718 void  __attribute__((export_name("TS_ChainParameters_free"))) TS_ChainParameters_free(uint32_t this_obj) {
25719         LDKChainParameters this_obj_conv;
25720         this_obj_conv.inner = (void*)(this_obj & (~1));
25721         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25722         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25723         ChainParameters_free(this_obj_conv);
25724 }
25725
25726 uint32_t  __attribute__((export_name("TS_ChainParameters_get_network"))) TS_ChainParameters_get_network(uint32_t this_ptr) {
25727         LDKChainParameters this_ptr_conv;
25728         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25729         this_ptr_conv.is_owned = false;
25730         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25731         uint32_t ret_conv = LDKNetwork_to_js(ChainParameters_get_network(&this_ptr_conv));
25732         return ret_conv;
25733 }
25734
25735 void  __attribute__((export_name("TS_ChainParameters_set_network"))) TS_ChainParameters_set_network(uint32_t this_ptr, uint32_t val) {
25736         LDKChainParameters this_ptr_conv;
25737         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25738         this_ptr_conv.is_owned = false;
25739         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25740         LDKNetwork val_conv = LDKNetwork_from_js(val);
25741         ChainParameters_set_network(&this_ptr_conv, val_conv);
25742 }
25743
25744 uint32_t  __attribute__((export_name("TS_ChainParameters_get_best_block"))) TS_ChainParameters_get_best_block(uint32_t this_ptr) {
25745         LDKChainParameters this_ptr_conv;
25746         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25747         this_ptr_conv.is_owned = false;
25748         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25749         LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
25750         uint32_t ret_ref = 0;
25751         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25752         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25753         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25754         ret_ref = (uintptr_t)ret_var.inner;
25755         if (ret_var.is_owned) {
25756                 ret_ref |= 1;
25757         }
25758         return ret_ref;
25759 }
25760
25761 void  __attribute__((export_name("TS_ChainParameters_set_best_block"))) TS_ChainParameters_set_best_block(uint32_t this_ptr, uint32_t val) {
25762         LDKChainParameters this_ptr_conv;
25763         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25764         this_ptr_conv.is_owned = false;
25765         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25766         LDKBestBlock val_conv;
25767         val_conv.inner = (void*)(val & (~1));
25768         val_conv.is_owned = (val & 1) || (val == 0);
25769         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
25770         val_conv = BestBlock_clone(&val_conv);
25771         ChainParameters_set_best_block(&this_ptr_conv, val_conv);
25772 }
25773
25774 uint32_t  __attribute__((export_name("TS_ChainParameters_new"))) TS_ChainParameters_new(uint32_t network_arg, uint32_t best_block_arg) {
25775         LDKNetwork network_arg_conv = LDKNetwork_from_js(network_arg);
25776         LDKBestBlock best_block_arg_conv;
25777         best_block_arg_conv.inner = (void*)(best_block_arg & (~1));
25778         best_block_arg_conv.is_owned = (best_block_arg & 1) || (best_block_arg == 0);
25779         CHECK_INNER_FIELD_ACCESS_OR_NULL(best_block_arg_conv);
25780         best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
25781         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
25782         uint32_t ret_ref = 0;
25783         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25784         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25785         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25786         ret_ref = (uintptr_t)ret_var.inner;
25787         if (ret_var.is_owned) {
25788                 ret_ref |= 1;
25789         }
25790         return ret_ref;
25791 }
25792
25793 static inline uintptr_t ChainParameters_clone_ptr(LDKChainParameters *NONNULL_PTR arg) {
25794         LDKChainParameters ret_var = ChainParameters_clone(arg);
25795 uint32_t ret_ref = 0;
25796 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25797 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25798 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25799 ret_ref = (uintptr_t)ret_var.inner;
25800 if (ret_var.is_owned) {
25801         ret_ref |= 1;
25802 }
25803         return ret_ref;
25804 }
25805 uint32_t  __attribute__((export_name("TS_ChainParameters_clone_ptr"))) TS_ChainParameters_clone_ptr(uint32_t arg) {
25806         LDKChainParameters arg_conv;
25807         arg_conv.inner = (void*)(arg & (~1));
25808         arg_conv.is_owned = false;
25809         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25810         uint32_t ret_conv = ChainParameters_clone_ptr(&arg_conv);
25811         return ret_conv;
25812 }
25813
25814 uint32_t  __attribute__((export_name("TS_ChainParameters_clone"))) TS_ChainParameters_clone(uint32_t orig) {
25815         LDKChainParameters orig_conv;
25816         orig_conv.inner = (void*)(orig & (~1));
25817         orig_conv.is_owned = false;
25818         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25819         LDKChainParameters ret_var = ChainParameters_clone(&orig_conv);
25820         uint32_t ret_ref = 0;
25821         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25822         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25823         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25824         ret_ref = (uintptr_t)ret_var.inner;
25825         if (ret_var.is_owned) {
25826                 ret_ref |= 1;
25827         }
25828         return ret_ref;
25829 }
25830
25831 void  __attribute__((export_name("TS_CounterpartyForwardingInfo_free"))) TS_CounterpartyForwardingInfo_free(uint32_t this_obj) {
25832         LDKCounterpartyForwardingInfo this_obj_conv;
25833         this_obj_conv.inner = (void*)(this_obj & (~1));
25834         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25835         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25836         CounterpartyForwardingInfo_free(this_obj_conv);
25837 }
25838
25839 int32_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_get_fee_base_msat"))) TS_CounterpartyForwardingInfo_get_fee_base_msat(uint32_t this_ptr) {
25840         LDKCounterpartyForwardingInfo this_ptr_conv;
25841         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25842         this_ptr_conv.is_owned = false;
25843         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25844         int32_t ret_conv = CounterpartyForwardingInfo_get_fee_base_msat(&this_ptr_conv);
25845         return ret_conv;
25846 }
25847
25848 void  __attribute__((export_name("TS_CounterpartyForwardingInfo_set_fee_base_msat"))) TS_CounterpartyForwardingInfo_set_fee_base_msat(uint32_t this_ptr, int32_t val) {
25849         LDKCounterpartyForwardingInfo this_ptr_conv;
25850         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25851         this_ptr_conv.is_owned = false;
25852         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25853         CounterpartyForwardingInfo_set_fee_base_msat(&this_ptr_conv, val);
25854 }
25855
25856 int32_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_get_fee_proportional_millionths"))) TS_CounterpartyForwardingInfo_get_fee_proportional_millionths(uint32_t this_ptr) {
25857         LDKCounterpartyForwardingInfo this_ptr_conv;
25858         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25859         this_ptr_conv.is_owned = false;
25860         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25861         int32_t ret_conv = CounterpartyForwardingInfo_get_fee_proportional_millionths(&this_ptr_conv);
25862         return ret_conv;
25863 }
25864
25865 void  __attribute__((export_name("TS_CounterpartyForwardingInfo_set_fee_proportional_millionths"))) TS_CounterpartyForwardingInfo_set_fee_proportional_millionths(uint32_t this_ptr, int32_t val) {
25866         LDKCounterpartyForwardingInfo this_ptr_conv;
25867         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25868         this_ptr_conv.is_owned = false;
25869         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25870         CounterpartyForwardingInfo_set_fee_proportional_millionths(&this_ptr_conv, val);
25871 }
25872
25873 int16_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_get_cltv_expiry_delta"))) TS_CounterpartyForwardingInfo_get_cltv_expiry_delta(uint32_t this_ptr) {
25874         LDKCounterpartyForwardingInfo this_ptr_conv;
25875         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25876         this_ptr_conv.is_owned = false;
25877         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25878         int16_t ret_conv = CounterpartyForwardingInfo_get_cltv_expiry_delta(&this_ptr_conv);
25879         return ret_conv;
25880 }
25881
25882 void  __attribute__((export_name("TS_CounterpartyForwardingInfo_set_cltv_expiry_delta"))) TS_CounterpartyForwardingInfo_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
25883         LDKCounterpartyForwardingInfo this_ptr_conv;
25884         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25885         this_ptr_conv.is_owned = false;
25886         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25887         CounterpartyForwardingInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
25888 }
25889
25890 uint32_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) {
25891         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_new(fee_base_msat_arg, fee_proportional_millionths_arg, cltv_expiry_delta_arg);
25892         uint32_t ret_ref = 0;
25893         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25894         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25895         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25896         ret_ref = (uintptr_t)ret_var.inner;
25897         if (ret_var.is_owned) {
25898                 ret_ref |= 1;
25899         }
25900         return ret_ref;
25901 }
25902
25903 static inline uintptr_t CounterpartyForwardingInfo_clone_ptr(LDKCounterpartyForwardingInfo *NONNULL_PTR arg) {
25904         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(arg);
25905 uint32_t ret_ref = 0;
25906 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25907 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25908 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25909 ret_ref = (uintptr_t)ret_var.inner;
25910 if (ret_var.is_owned) {
25911         ret_ref |= 1;
25912 }
25913         return ret_ref;
25914 }
25915 uint32_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_clone_ptr"))) TS_CounterpartyForwardingInfo_clone_ptr(uint32_t arg) {
25916         LDKCounterpartyForwardingInfo arg_conv;
25917         arg_conv.inner = (void*)(arg & (~1));
25918         arg_conv.is_owned = false;
25919         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25920         uint32_t ret_conv = CounterpartyForwardingInfo_clone_ptr(&arg_conv);
25921         return ret_conv;
25922 }
25923
25924 uint32_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_clone"))) TS_CounterpartyForwardingInfo_clone(uint32_t orig) {
25925         LDKCounterpartyForwardingInfo orig_conv;
25926         orig_conv.inner = (void*)(orig & (~1));
25927         orig_conv.is_owned = false;
25928         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25929         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(&orig_conv);
25930         uint32_t ret_ref = 0;
25931         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25932         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25933         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25934         ret_ref = (uintptr_t)ret_var.inner;
25935         if (ret_var.is_owned) {
25936                 ret_ref |= 1;
25937         }
25938         return ret_ref;
25939 }
25940
25941 void  __attribute__((export_name("TS_ChannelCounterparty_free"))) TS_ChannelCounterparty_free(uint32_t this_obj) {
25942         LDKChannelCounterparty this_obj_conv;
25943         this_obj_conv.inner = (void*)(this_obj & (~1));
25944         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25945         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25946         ChannelCounterparty_free(this_obj_conv);
25947 }
25948
25949 int8_tArray  __attribute__((export_name("TS_ChannelCounterparty_get_node_id"))) TS_ChannelCounterparty_get_node_id(uint32_t this_ptr) {
25950         LDKChannelCounterparty this_ptr_conv;
25951         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25952         this_ptr_conv.is_owned = false;
25953         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25954         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
25955         memcpy(ret_arr->elems, ChannelCounterparty_get_node_id(&this_ptr_conv).compressed_form, 33);
25956         return ret_arr;
25957 }
25958
25959 void  __attribute__((export_name("TS_ChannelCounterparty_set_node_id"))) TS_ChannelCounterparty_set_node_id(uint32_t this_ptr, int8_tArray val) {
25960         LDKChannelCounterparty this_ptr_conv;
25961         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25962         this_ptr_conv.is_owned = false;
25963         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25964         LDKPublicKey val_ref;
25965         CHECK(val->arr_len == 33);
25966         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
25967         ChannelCounterparty_set_node_id(&this_ptr_conv, val_ref);
25968 }
25969
25970 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_get_features"))) TS_ChannelCounterparty_get_features(uint32_t this_ptr) {
25971         LDKChannelCounterparty this_ptr_conv;
25972         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25973         this_ptr_conv.is_owned = false;
25974         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25975         LDKInitFeatures ret_var = ChannelCounterparty_get_features(&this_ptr_conv);
25976         uint32_t ret_ref = 0;
25977         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25978         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25979         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25980         ret_ref = (uintptr_t)ret_var.inner;
25981         if (ret_var.is_owned) {
25982                 ret_ref |= 1;
25983         }
25984         return ret_ref;
25985 }
25986
25987 void  __attribute__((export_name("TS_ChannelCounterparty_set_features"))) TS_ChannelCounterparty_set_features(uint32_t this_ptr, uint32_t val) {
25988         LDKChannelCounterparty this_ptr_conv;
25989         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25990         this_ptr_conv.is_owned = false;
25991         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25992         LDKInitFeatures val_conv;
25993         val_conv.inner = (void*)(val & (~1));
25994         val_conv.is_owned = (val & 1) || (val == 0);
25995         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
25996         val_conv = InitFeatures_clone(&val_conv);
25997         ChannelCounterparty_set_features(&this_ptr_conv, val_conv);
25998 }
25999
26000 int64_t  __attribute__((export_name("TS_ChannelCounterparty_get_unspendable_punishment_reserve"))) TS_ChannelCounterparty_get_unspendable_punishment_reserve(uint32_t this_ptr) {
26001         LDKChannelCounterparty this_ptr_conv;
26002         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26003         this_ptr_conv.is_owned = false;
26004         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26005         int64_t ret_conv = ChannelCounterparty_get_unspendable_punishment_reserve(&this_ptr_conv);
26006         return ret_conv;
26007 }
26008
26009 void  __attribute__((export_name("TS_ChannelCounterparty_set_unspendable_punishment_reserve"))) TS_ChannelCounterparty_set_unspendable_punishment_reserve(uint32_t this_ptr, int64_t val) {
26010         LDKChannelCounterparty this_ptr_conv;
26011         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26012         this_ptr_conv.is_owned = false;
26013         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26014         ChannelCounterparty_set_unspendable_punishment_reserve(&this_ptr_conv, val);
26015 }
26016
26017 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_get_forwarding_info"))) TS_ChannelCounterparty_get_forwarding_info(uint32_t this_ptr) {
26018         LDKChannelCounterparty this_ptr_conv;
26019         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26020         this_ptr_conv.is_owned = false;
26021         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26022         LDKCounterpartyForwardingInfo ret_var = ChannelCounterparty_get_forwarding_info(&this_ptr_conv);
26023         uint32_t ret_ref = 0;
26024         if ((uintptr_t)ret_var.inner > 4096) {
26025                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26026                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26027         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26028                 ret_ref = (uintptr_t)ret_var.inner;
26029                 if (ret_var.is_owned) {
26030                         ret_ref |= 1;
26031                 }
26032         }
26033         return ret_ref;
26034 }
26035
26036 void  __attribute__((export_name("TS_ChannelCounterparty_set_forwarding_info"))) TS_ChannelCounterparty_set_forwarding_info(uint32_t this_ptr, uint32_t val) {
26037         LDKChannelCounterparty this_ptr_conv;
26038         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26039         this_ptr_conv.is_owned = false;
26040         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26041         LDKCounterpartyForwardingInfo val_conv;
26042         val_conv.inner = (void*)(val & (~1));
26043         val_conv.is_owned = (val & 1) || (val == 0);
26044         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26045         val_conv = CounterpartyForwardingInfo_clone(&val_conv);
26046         ChannelCounterparty_set_forwarding_info(&this_ptr_conv, val_conv);
26047 }
26048
26049 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_get_outbound_htlc_minimum_msat"))) TS_ChannelCounterparty_get_outbound_htlc_minimum_msat(uint32_t this_ptr) {
26050         LDKChannelCounterparty this_ptr_conv;
26051         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26052         this_ptr_conv.is_owned = false;
26053         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26054         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
26055         *ret_copy = ChannelCounterparty_get_outbound_htlc_minimum_msat(&this_ptr_conv);
26056         uint32_t ret_ref = (uintptr_t)ret_copy;
26057         return ret_ref;
26058 }
26059
26060 void  __attribute__((export_name("TS_ChannelCounterparty_set_outbound_htlc_minimum_msat"))) TS_ChannelCounterparty_set_outbound_htlc_minimum_msat(uint32_t this_ptr, uint32_t val) {
26061         LDKChannelCounterparty this_ptr_conv;
26062         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26063         this_ptr_conv.is_owned = false;
26064         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26065         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
26066         CHECK_ACCESS(val_ptr);
26067         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
26068         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
26069         ChannelCounterparty_set_outbound_htlc_minimum_msat(&this_ptr_conv, val_conv);
26070 }
26071
26072 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_get_outbound_htlc_maximum_msat"))) TS_ChannelCounterparty_get_outbound_htlc_maximum_msat(uint32_t this_ptr) {
26073         LDKChannelCounterparty this_ptr_conv;
26074         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26075         this_ptr_conv.is_owned = false;
26076         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26077         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
26078         *ret_copy = ChannelCounterparty_get_outbound_htlc_maximum_msat(&this_ptr_conv);
26079         uint32_t ret_ref = (uintptr_t)ret_copy;
26080         return ret_ref;
26081 }
26082
26083 void  __attribute__((export_name("TS_ChannelCounterparty_set_outbound_htlc_maximum_msat"))) TS_ChannelCounterparty_set_outbound_htlc_maximum_msat(uint32_t this_ptr, uint32_t val) {
26084         LDKChannelCounterparty this_ptr_conv;
26085         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26086         this_ptr_conv.is_owned = false;
26087         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26088         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
26089         CHECK_ACCESS(val_ptr);
26090         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
26091         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
26092         ChannelCounterparty_set_outbound_htlc_maximum_msat(&this_ptr_conv, val_conv);
26093 }
26094
26095 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_new"))) TS_ChannelCounterparty_new(int8_tArray node_id_arg, uint32_t features_arg, int64_t unspendable_punishment_reserve_arg, uint32_t forwarding_info_arg, uint32_t outbound_htlc_minimum_msat_arg, uint32_t outbound_htlc_maximum_msat_arg) {
26096         LDKPublicKey node_id_arg_ref;
26097         CHECK(node_id_arg->arr_len == 33);
26098         memcpy(node_id_arg_ref.compressed_form, node_id_arg->elems, 33); FREE(node_id_arg);
26099         LDKInitFeatures features_arg_conv;
26100         features_arg_conv.inner = (void*)(features_arg & (~1));
26101         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
26102         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
26103         features_arg_conv = InitFeatures_clone(&features_arg_conv);
26104         LDKCounterpartyForwardingInfo forwarding_info_arg_conv;
26105         forwarding_info_arg_conv.inner = (void*)(forwarding_info_arg & (~1));
26106         forwarding_info_arg_conv.is_owned = (forwarding_info_arg & 1) || (forwarding_info_arg == 0);
26107         CHECK_INNER_FIELD_ACCESS_OR_NULL(forwarding_info_arg_conv);
26108         forwarding_info_arg_conv = CounterpartyForwardingInfo_clone(&forwarding_info_arg_conv);
26109         void* outbound_htlc_minimum_msat_arg_ptr = (void*)(((uintptr_t)outbound_htlc_minimum_msat_arg) & ~1);
26110         CHECK_ACCESS(outbound_htlc_minimum_msat_arg_ptr);
26111         LDKCOption_u64Z outbound_htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(outbound_htlc_minimum_msat_arg_ptr);
26112         outbound_htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)outbound_htlc_minimum_msat_arg) & ~1));
26113         void* outbound_htlc_maximum_msat_arg_ptr = (void*)(((uintptr_t)outbound_htlc_maximum_msat_arg) & ~1);
26114         CHECK_ACCESS(outbound_htlc_maximum_msat_arg_ptr);
26115         LDKCOption_u64Z outbound_htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(outbound_htlc_maximum_msat_arg_ptr);
26116         outbound_htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)outbound_htlc_maximum_msat_arg) & ~1));
26117         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);
26118         uint32_t ret_ref = 0;
26119         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26120         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26121         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26122         ret_ref = (uintptr_t)ret_var.inner;
26123         if (ret_var.is_owned) {
26124                 ret_ref |= 1;
26125         }
26126         return ret_ref;
26127 }
26128
26129 static inline uintptr_t ChannelCounterparty_clone_ptr(LDKChannelCounterparty *NONNULL_PTR arg) {
26130         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(arg);
26131 uint32_t ret_ref = 0;
26132 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26133 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26134 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26135 ret_ref = (uintptr_t)ret_var.inner;
26136 if (ret_var.is_owned) {
26137         ret_ref |= 1;
26138 }
26139         return ret_ref;
26140 }
26141 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_clone_ptr"))) TS_ChannelCounterparty_clone_ptr(uint32_t arg) {
26142         LDKChannelCounterparty arg_conv;
26143         arg_conv.inner = (void*)(arg & (~1));
26144         arg_conv.is_owned = false;
26145         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26146         uint32_t ret_conv = ChannelCounterparty_clone_ptr(&arg_conv);
26147         return ret_conv;
26148 }
26149
26150 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_clone"))) TS_ChannelCounterparty_clone(uint32_t orig) {
26151         LDKChannelCounterparty orig_conv;
26152         orig_conv.inner = (void*)(orig & (~1));
26153         orig_conv.is_owned = false;
26154         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26155         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(&orig_conv);
26156         uint32_t ret_ref = 0;
26157         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26158         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26159         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26160         ret_ref = (uintptr_t)ret_var.inner;
26161         if (ret_var.is_owned) {
26162                 ret_ref |= 1;
26163         }
26164         return ret_ref;
26165 }
26166
26167 void  __attribute__((export_name("TS_ChannelDetails_free"))) TS_ChannelDetails_free(uint32_t this_obj) {
26168         LDKChannelDetails this_obj_conv;
26169         this_obj_conv.inner = (void*)(this_obj & (~1));
26170         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26171         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26172         ChannelDetails_free(this_obj_conv);
26173 }
26174
26175 int8_tArray  __attribute__((export_name("TS_ChannelDetails_get_channel_id"))) TS_ChannelDetails_get_channel_id(uint32_t this_ptr) {
26176         LDKChannelDetails this_ptr_conv;
26177         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26178         this_ptr_conv.is_owned = false;
26179         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26180         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
26181         memcpy(ret_arr->elems, *ChannelDetails_get_channel_id(&this_ptr_conv), 32);
26182         return ret_arr;
26183 }
26184
26185 void  __attribute__((export_name("TS_ChannelDetails_set_channel_id"))) TS_ChannelDetails_set_channel_id(uint32_t this_ptr, int8_tArray val) {
26186         LDKChannelDetails this_ptr_conv;
26187         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26188         this_ptr_conv.is_owned = false;
26189         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26190         LDKThirtyTwoBytes val_ref;
26191         CHECK(val->arr_len == 32);
26192         memcpy(val_ref.data, val->elems, 32); FREE(val);
26193         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
26194 }
26195
26196 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_counterparty"))) TS_ChannelDetails_get_counterparty(uint32_t this_ptr) {
26197         LDKChannelDetails this_ptr_conv;
26198         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26199         this_ptr_conv.is_owned = false;
26200         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26201         LDKChannelCounterparty ret_var = ChannelDetails_get_counterparty(&this_ptr_conv);
26202         uint32_t ret_ref = 0;
26203         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26204         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26205         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26206         ret_ref = (uintptr_t)ret_var.inner;
26207         if (ret_var.is_owned) {
26208                 ret_ref |= 1;
26209         }
26210         return ret_ref;
26211 }
26212
26213 void  __attribute__((export_name("TS_ChannelDetails_set_counterparty"))) TS_ChannelDetails_set_counterparty(uint32_t this_ptr, uint32_t val) {
26214         LDKChannelDetails this_ptr_conv;
26215         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26216         this_ptr_conv.is_owned = false;
26217         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26218         LDKChannelCounterparty val_conv;
26219         val_conv.inner = (void*)(val & (~1));
26220         val_conv.is_owned = (val & 1) || (val == 0);
26221         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26222         val_conv = ChannelCounterparty_clone(&val_conv);
26223         ChannelDetails_set_counterparty(&this_ptr_conv, val_conv);
26224 }
26225
26226 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_funding_txo"))) TS_ChannelDetails_get_funding_txo(uint32_t this_ptr) {
26227         LDKChannelDetails this_ptr_conv;
26228         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26229         this_ptr_conv.is_owned = false;
26230         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26231         LDKOutPoint ret_var = ChannelDetails_get_funding_txo(&this_ptr_conv);
26232         uint32_t ret_ref = 0;
26233         if ((uintptr_t)ret_var.inner > 4096) {
26234                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26235                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26236         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26237                 ret_ref = (uintptr_t)ret_var.inner;
26238                 if (ret_var.is_owned) {
26239                         ret_ref |= 1;
26240                 }
26241         }
26242         return ret_ref;
26243 }
26244
26245 void  __attribute__((export_name("TS_ChannelDetails_set_funding_txo"))) TS_ChannelDetails_set_funding_txo(uint32_t this_ptr, uint32_t val) {
26246         LDKChannelDetails this_ptr_conv;
26247         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26248         this_ptr_conv.is_owned = false;
26249         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26250         LDKOutPoint val_conv;
26251         val_conv.inner = (void*)(val & (~1));
26252         val_conv.is_owned = (val & 1) || (val == 0);
26253         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26254         val_conv = OutPoint_clone(&val_conv);
26255         ChannelDetails_set_funding_txo(&this_ptr_conv, val_conv);
26256 }
26257
26258 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_channel_type"))) TS_ChannelDetails_get_channel_type(uint32_t this_ptr) {
26259         LDKChannelDetails this_ptr_conv;
26260         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26261         this_ptr_conv.is_owned = false;
26262         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26263         LDKChannelTypeFeatures ret_var = ChannelDetails_get_channel_type(&this_ptr_conv);
26264         uint32_t ret_ref = 0;
26265         if ((uintptr_t)ret_var.inner > 4096) {
26266                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26267                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26268         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26269                 ret_ref = (uintptr_t)ret_var.inner;
26270                 if (ret_var.is_owned) {
26271                         ret_ref |= 1;
26272                 }
26273         }
26274         return ret_ref;
26275 }
26276
26277 void  __attribute__((export_name("TS_ChannelDetails_set_channel_type"))) TS_ChannelDetails_set_channel_type(uint32_t this_ptr, uint32_t val) {
26278         LDKChannelDetails this_ptr_conv;
26279         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26280         this_ptr_conv.is_owned = false;
26281         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26282         LDKChannelTypeFeatures val_conv;
26283         val_conv.inner = (void*)(val & (~1));
26284         val_conv.is_owned = (val & 1) || (val == 0);
26285         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26286         val_conv = ChannelTypeFeatures_clone(&val_conv);
26287         ChannelDetails_set_channel_type(&this_ptr_conv, val_conv);
26288 }
26289
26290 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_short_channel_id"))) TS_ChannelDetails_get_short_channel_id(uint32_t this_ptr) {
26291         LDKChannelDetails this_ptr_conv;
26292         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26293         this_ptr_conv.is_owned = false;
26294         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26295         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
26296         *ret_copy = ChannelDetails_get_short_channel_id(&this_ptr_conv);
26297         uint32_t ret_ref = (uintptr_t)ret_copy;
26298         return ret_ref;
26299 }
26300
26301 void  __attribute__((export_name("TS_ChannelDetails_set_short_channel_id"))) TS_ChannelDetails_set_short_channel_id(uint32_t this_ptr, uint32_t val) {
26302         LDKChannelDetails this_ptr_conv;
26303         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26304         this_ptr_conv.is_owned = false;
26305         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26306         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
26307         CHECK_ACCESS(val_ptr);
26308         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
26309         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
26310         ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
26311 }
26312
26313 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_outbound_scid_alias"))) TS_ChannelDetails_get_outbound_scid_alias(uint32_t this_ptr) {
26314         LDKChannelDetails this_ptr_conv;
26315         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26316         this_ptr_conv.is_owned = false;
26317         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26318         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
26319         *ret_copy = ChannelDetails_get_outbound_scid_alias(&this_ptr_conv);
26320         uint32_t ret_ref = (uintptr_t)ret_copy;
26321         return ret_ref;
26322 }
26323
26324 void  __attribute__((export_name("TS_ChannelDetails_set_outbound_scid_alias"))) TS_ChannelDetails_set_outbound_scid_alias(uint32_t this_ptr, uint32_t val) {
26325         LDKChannelDetails this_ptr_conv;
26326         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26327         this_ptr_conv.is_owned = false;
26328         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26329         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
26330         CHECK_ACCESS(val_ptr);
26331         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
26332         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
26333         ChannelDetails_set_outbound_scid_alias(&this_ptr_conv, val_conv);
26334 }
26335
26336 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_inbound_scid_alias"))) TS_ChannelDetails_get_inbound_scid_alias(uint32_t this_ptr) {
26337         LDKChannelDetails this_ptr_conv;
26338         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26339         this_ptr_conv.is_owned = false;
26340         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26341         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
26342         *ret_copy = ChannelDetails_get_inbound_scid_alias(&this_ptr_conv);
26343         uint32_t ret_ref = (uintptr_t)ret_copy;
26344         return ret_ref;
26345 }
26346
26347 void  __attribute__((export_name("TS_ChannelDetails_set_inbound_scid_alias"))) TS_ChannelDetails_set_inbound_scid_alias(uint32_t this_ptr, uint32_t val) {
26348         LDKChannelDetails this_ptr_conv;
26349         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26350         this_ptr_conv.is_owned = false;
26351         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26352         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
26353         CHECK_ACCESS(val_ptr);
26354         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
26355         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
26356         ChannelDetails_set_inbound_scid_alias(&this_ptr_conv, val_conv);
26357 }
26358
26359 int64_t  __attribute__((export_name("TS_ChannelDetails_get_channel_value_satoshis"))) TS_ChannelDetails_get_channel_value_satoshis(uint32_t this_ptr) {
26360         LDKChannelDetails this_ptr_conv;
26361         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26362         this_ptr_conv.is_owned = false;
26363         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26364         int64_t ret_conv = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
26365         return ret_conv;
26366 }
26367
26368 void  __attribute__((export_name("TS_ChannelDetails_set_channel_value_satoshis"))) TS_ChannelDetails_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
26369         LDKChannelDetails this_ptr_conv;
26370         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26371         this_ptr_conv.is_owned = false;
26372         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26373         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
26374 }
26375
26376 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_unspendable_punishment_reserve"))) TS_ChannelDetails_get_unspendable_punishment_reserve(uint32_t this_ptr) {
26377         LDKChannelDetails this_ptr_conv;
26378         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26379         this_ptr_conv.is_owned = false;
26380         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26381         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
26382         *ret_copy = ChannelDetails_get_unspendable_punishment_reserve(&this_ptr_conv);
26383         uint32_t ret_ref = (uintptr_t)ret_copy;
26384         return ret_ref;
26385 }
26386
26387 void  __attribute__((export_name("TS_ChannelDetails_set_unspendable_punishment_reserve"))) TS_ChannelDetails_set_unspendable_punishment_reserve(uint32_t this_ptr, uint32_t val) {
26388         LDKChannelDetails this_ptr_conv;
26389         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26390         this_ptr_conv.is_owned = false;
26391         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26392         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
26393         CHECK_ACCESS(val_ptr);
26394         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
26395         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
26396         ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv);
26397 }
26398
26399 int64_t  __attribute__((export_name("TS_ChannelDetails_get_user_channel_id"))) TS_ChannelDetails_get_user_channel_id(uint32_t this_ptr) {
26400         LDKChannelDetails this_ptr_conv;
26401         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26402         this_ptr_conv.is_owned = false;
26403         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26404         int64_t ret_conv = ChannelDetails_get_user_channel_id(&this_ptr_conv);
26405         return ret_conv;
26406 }
26407
26408 void  __attribute__((export_name("TS_ChannelDetails_set_user_channel_id"))) TS_ChannelDetails_set_user_channel_id(uint32_t this_ptr, int64_t val) {
26409         LDKChannelDetails this_ptr_conv;
26410         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26411         this_ptr_conv.is_owned = false;
26412         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26413         ChannelDetails_set_user_channel_id(&this_ptr_conv, val);
26414 }
26415
26416 int64_t  __attribute__((export_name("TS_ChannelDetails_get_balance_msat"))) TS_ChannelDetails_get_balance_msat(uint32_t this_ptr) {
26417         LDKChannelDetails this_ptr_conv;
26418         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26419         this_ptr_conv.is_owned = false;
26420         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26421         int64_t ret_conv = ChannelDetails_get_balance_msat(&this_ptr_conv);
26422         return ret_conv;
26423 }
26424
26425 void  __attribute__((export_name("TS_ChannelDetails_set_balance_msat"))) TS_ChannelDetails_set_balance_msat(uint32_t this_ptr, int64_t val) {
26426         LDKChannelDetails this_ptr_conv;
26427         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26428         this_ptr_conv.is_owned = false;
26429         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26430         ChannelDetails_set_balance_msat(&this_ptr_conv, val);
26431 }
26432
26433 int64_t  __attribute__((export_name("TS_ChannelDetails_get_outbound_capacity_msat"))) TS_ChannelDetails_get_outbound_capacity_msat(uint32_t this_ptr) {
26434         LDKChannelDetails this_ptr_conv;
26435         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26436         this_ptr_conv.is_owned = false;
26437         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26438         int64_t ret_conv = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
26439         return ret_conv;
26440 }
26441
26442 void  __attribute__((export_name("TS_ChannelDetails_set_outbound_capacity_msat"))) TS_ChannelDetails_set_outbound_capacity_msat(uint32_t this_ptr, int64_t val) {
26443         LDKChannelDetails this_ptr_conv;
26444         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26445         this_ptr_conv.is_owned = false;
26446         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26447         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
26448 }
26449
26450 int64_t  __attribute__((export_name("TS_ChannelDetails_get_next_outbound_htlc_limit_msat"))) TS_ChannelDetails_get_next_outbound_htlc_limit_msat(uint32_t this_ptr) {
26451         LDKChannelDetails this_ptr_conv;
26452         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26453         this_ptr_conv.is_owned = false;
26454         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26455         int64_t ret_conv = ChannelDetails_get_next_outbound_htlc_limit_msat(&this_ptr_conv);
26456         return ret_conv;
26457 }
26458
26459 void  __attribute__((export_name("TS_ChannelDetails_set_next_outbound_htlc_limit_msat"))) TS_ChannelDetails_set_next_outbound_htlc_limit_msat(uint32_t this_ptr, int64_t val) {
26460         LDKChannelDetails this_ptr_conv;
26461         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26462         this_ptr_conv.is_owned = false;
26463         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26464         ChannelDetails_set_next_outbound_htlc_limit_msat(&this_ptr_conv, val);
26465 }
26466
26467 int64_t  __attribute__((export_name("TS_ChannelDetails_get_inbound_capacity_msat"))) TS_ChannelDetails_get_inbound_capacity_msat(uint32_t this_ptr) {
26468         LDKChannelDetails this_ptr_conv;
26469         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26470         this_ptr_conv.is_owned = false;
26471         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26472         int64_t ret_conv = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
26473         return ret_conv;
26474 }
26475
26476 void  __attribute__((export_name("TS_ChannelDetails_set_inbound_capacity_msat"))) TS_ChannelDetails_set_inbound_capacity_msat(uint32_t this_ptr, int64_t val) {
26477         LDKChannelDetails this_ptr_conv;
26478         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26479         this_ptr_conv.is_owned = false;
26480         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26481         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
26482 }
26483
26484 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_confirmations_required"))) TS_ChannelDetails_get_confirmations_required(uint32_t this_ptr) {
26485         LDKChannelDetails this_ptr_conv;
26486         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26487         this_ptr_conv.is_owned = false;
26488         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26489         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
26490         *ret_copy = ChannelDetails_get_confirmations_required(&this_ptr_conv);
26491         uint32_t ret_ref = (uintptr_t)ret_copy;
26492         return ret_ref;
26493 }
26494
26495 void  __attribute__((export_name("TS_ChannelDetails_set_confirmations_required"))) TS_ChannelDetails_set_confirmations_required(uint32_t this_ptr, uint32_t val) {
26496         LDKChannelDetails this_ptr_conv;
26497         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26498         this_ptr_conv.is_owned = false;
26499         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26500         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
26501         CHECK_ACCESS(val_ptr);
26502         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
26503         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)val) & ~1));
26504         ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv);
26505 }
26506
26507 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_force_close_spend_delay"))) TS_ChannelDetails_get_force_close_spend_delay(uint32_t this_ptr) {
26508         LDKChannelDetails this_ptr_conv;
26509         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26510         this_ptr_conv.is_owned = false;
26511         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26512         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
26513         *ret_copy = ChannelDetails_get_force_close_spend_delay(&this_ptr_conv);
26514         uint32_t ret_ref = (uintptr_t)ret_copy;
26515         return ret_ref;
26516 }
26517
26518 void  __attribute__((export_name("TS_ChannelDetails_set_force_close_spend_delay"))) TS_ChannelDetails_set_force_close_spend_delay(uint32_t this_ptr, uint32_t val) {
26519         LDKChannelDetails this_ptr_conv;
26520         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26521         this_ptr_conv.is_owned = false;
26522         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26523         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
26524         CHECK_ACCESS(val_ptr);
26525         LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(val_ptr);
26526         val_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uintptr_t)val) & ~1));
26527         ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv);
26528 }
26529
26530 jboolean  __attribute__((export_name("TS_ChannelDetails_get_is_outbound"))) TS_ChannelDetails_get_is_outbound(uint32_t this_ptr) {
26531         LDKChannelDetails this_ptr_conv;
26532         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26533         this_ptr_conv.is_owned = false;
26534         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26535         jboolean ret_conv = ChannelDetails_get_is_outbound(&this_ptr_conv);
26536         return ret_conv;
26537 }
26538
26539 void  __attribute__((export_name("TS_ChannelDetails_set_is_outbound"))) TS_ChannelDetails_set_is_outbound(uint32_t this_ptr, jboolean val) {
26540         LDKChannelDetails this_ptr_conv;
26541         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26542         this_ptr_conv.is_owned = false;
26543         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26544         ChannelDetails_set_is_outbound(&this_ptr_conv, val);
26545 }
26546
26547 jboolean  __attribute__((export_name("TS_ChannelDetails_get_is_channel_ready"))) TS_ChannelDetails_get_is_channel_ready(uint32_t this_ptr) {
26548         LDKChannelDetails this_ptr_conv;
26549         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26550         this_ptr_conv.is_owned = false;
26551         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26552         jboolean ret_conv = ChannelDetails_get_is_channel_ready(&this_ptr_conv);
26553         return ret_conv;
26554 }
26555
26556 void  __attribute__((export_name("TS_ChannelDetails_set_is_channel_ready"))) TS_ChannelDetails_set_is_channel_ready(uint32_t this_ptr, jboolean val) {
26557         LDKChannelDetails this_ptr_conv;
26558         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26559         this_ptr_conv.is_owned = false;
26560         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26561         ChannelDetails_set_is_channel_ready(&this_ptr_conv, val);
26562 }
26563
26564 jboolean  __attribute__((export_name("TS_ChannelDetails_get_is_usable"))) TS_ChannelDetails_get_is_usable(uint32_t this_ptr) {
26565         LDKChannelDetails this_ptr_conv;
26566         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26567         this_ptr_conv.is_owned = false;
26568         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26569         jboolean ret_conv = ChannelDetails_get_is_usable(&this_ptr_conv);
26570         return ret_conv;
26571 }
26572
26573 void  __attribute__((export_name("TS_ChannelDetails_set_is_usable"))) TS_ChannelDetails_set_is_usable(uint32_t this_ptr, jboolean val) {
26574         LDKChannelDetails this_ptr_conv;
26575         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26576         this_ptr_conv.is_owned = false;
26577         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26578         ChannelDetails_set_is_usable(&this_ptr_conv, val);
26579 }
26580
26581 jboolean  __attribute__((export_name("TS_ChannelDetails_get_is_public"))) TS_ChannelDetails_get_is_public(uint32_t this_ptr) {
26582         LDKChannelDetails this_ptr_conv;
26583         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26584         this_ptr_conv.is_owned = false;
26585         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26586         jboolean ret_conv = ChannelDetails_get_is_public(&this_ptr_conv);
26587         return ret_conv;
26588 }
26589
26590 void  __attribute__((export_name("TS_ChannelDetails_set_is_public"))) TS_ChannelDetails_set_is_public(uint32_t this_ptr, jboolean val) {
26591         LDKChannelDetails this_ptr_conv;
26592         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26593         this_ptr_conv.is_owned = false;
26594         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26595         ChannelDetails_set_is_public(&this_ptr_conv, val);
26596 }
26597
26598 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_inbound_htlc_minimum_msat"))) TS_ChannelDetails_get_inbound_htlc_minimum_msat(uint32_t this_ptr) {
26599         LDKChannelDetails this_ptr_conv;
26600         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26601         this_ptr_conv.is_owned = false;
26602         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26603         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
26604         *ret_copy = ChannelDetails_get_inbound_htlc_minimum_msat(&this_ptr_conv);
26605         uint32_t ret_ref = (uintptr_t)ret_copy;
26606         return ret_ref;
26607 }
26608
26609 void  __attribute__((export_name("TS_ChannelDetails_set_inbound_htlc_minimum_msat"))) TS_ChannelDetails_set_inbound_htlc_minimum_msat(uint32_t this_ptr, uint32_t val) {
26610         LDKChannelDetails this_ptr_conv;
26611         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26612         this_ptr_conv.is_owned = false;
26613         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26614         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
26615         CHECK_ACCESS(val_ptr);
26616         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
26617         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
26618         ChannelDetails_set_inbound_htlc_minimum_msat(&this_ptr_conv, val_conv);
26619 }
26620
26621 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_inbound_htlc_maximum_msat"))) TS_ChannelDetails_get_inbound_htlc_maximum_msat(uint32_t this_ptr) {
26622         LDKChannelDetails this_ptr_conv;
26623         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26624         this_ptr_conv.is_owned = false;
26625         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26626         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
26627         *ret_copy = ChannelDetails_get_inbound_htlc_maximum_msat(&this_ptr_conv);
26628         uint32_t ret_ref = (uintptr_t)ret_copy;
26629         return ret_ref;
26630 }
26631
26632 void  __attribute__((export_name("TS_ChannelDetails_set_inbound_htlc_maximum_msat"))) TS_ChannelDetails_set_inbound_htlc_maximum_msat(uint32_t this_ptr, uint32_t val) {
26633         LDKChannelDetails this_ptr_conv;
26634         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26635         this_ptr_conv.is_owned = false;
26636         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26637         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
26638         CHECK_ACCESS(val_ptr);
26639         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
26640         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
26641         ChannelDetails_set_inbound_htlc_maximum_msat(&this_ptr_conv, val_conv);
26642 }
26643
26644 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_config"))) TS_ChannelDetails_get_config(uint32_t this_ptr) {
26645         LDKChannelDetails this_ptr_conv;
26646         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26647         this_ptr_conv.is_owned = false;
26648         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26649         LDKChannelConfig ret_var = ChannelDetails_get_config(&this_ptr_conv);
26650         uint32_t ret_ref = 0;
26651         if ((uintptr_t)ret_var.inner > 4096) {
26652                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26653                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26654         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26655                 ret_ref = (uintptr_t)ret_var.inner;
26656                 if (ret_var.is_owned) {
26657                         ret_ref |= 1;
26658                 }
26659         }
26660         return ret_ref;
26661 }
26662
26663 void  __attribute__((export_name("TS_ChannelDetails_set_config"))) TS_ChannelDetails_set_config(uint32_t this_ptr, uint32_t val) {
26664         LDKChannelDetails this_ptr_conv;
26665         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26666         this_ptr_conv.is_owned = false;
26667         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26668         LDKChannelConfig val_conv;
26669         val_conv.inner = (void*)(val & (~1));
26670         val_conv.is_owned = (val & 1) || (val == 0);
26671         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26672         val_conv = ChannelConfig_clone(&val_conv);
26673         ChannelDetails_set_config(&this_ptr_conv, val_conv);
26674 }
26675
26676 uint32_t  __attribute__((export_name("TS_ChannelDetails_new"))) TS_ChannelDetails_new(int8_tArray channel_id_arg, uint32_t counterparty_arg, uint32_t funding_txo_arg, uint32_t channel_type_arg, uint32_t short_channel_id_arg, uint32_t outbound_scid_alias_arg, uint32_t inbound_scid_alias_arg, int64_t channel_value_satoshis_arg, uint32_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, uint32_t confirmations_required_arg, uint32_t force_close_spend_delay_arg, jboolean is_outbound_arg, jboolean is_channel_ready_arg, jboolean is_usable_arg, jboolean is_public_arg, uint32_t inbound_htlc_minimum_msat_arg, uint32_t inbound_htlc_maximum_msat_arg, uint32_t config_arg) {
26677         LDKThirtyTwoBytes channel_id_arg_ref;
26678         CHECK(channel_id_arg->arr_len == 32);
26679         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
26680         LDKChannelCounterparty counterparty_arg_conv;
26681         counterparty_arg_conv.inner = (void*)(counterparty_arg & (~1));
26682         counterparty_arg_conv.is_owned = (counterparty_arg & 1) || (counterparty_arg == 0);
26683         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_arg_conv);
26684         counterparty_arg_conv = ChannelCounterparty_clone(&counterparty_arg_conv);
26685         LDKOutPoint funding_txo_arg_conv;
26686         funding_txo_arg_conv.inner = (void*)(funding_txo_arg & (~1));
26687         funding_txo_arg_conv.is_owned = (funding_txo_arg & 1) || (funding_txo_arg == 0);
26688         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_arg_conv);
26689         funding_txo_arg_conv = OutPoint_clone(&funding_txo_arg_conv);
26690         LDKChannelTypeFeatures channel_type_arg_conv;
26691         channel_type_arg_conv.inner = (void*)(channel_type_arg & (~1));
26692         channel_type_arg_conv.is_owned = (channel_type_arg & 1) || (channel_type_arg == 0);
26693         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_arg_conv);
26694         channel_type_arg_conv = ChannelTypeFeatures_clone(&channel_type_arg_conv);
26695         void* short_channel_id_arg_ptr = (void*)(((uintptr_t)short_channel_id_arg) & ~1);
26696         CHECK_ACCESS(short_channel_id_arg_ptr);
26697         LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_arg_ptr);
26698         short_channel_id_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id_arg) & ~1));
26699         void* outbound_scid_alias_arg_ptr = (void*)(((uintptr_t)outbound_scid_alias_arg) & ~1);
26700         CHECK_ACCESS(outbound_scid_alias_arg_ptr);
26701         LDKCOption_u64Z outbound_scid_alias_arg_conv = *(LDKCOption_u64Z*)(outbound_scid_alias_arg_ptr);
26702         outbound_scid_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)outbound_scid_alias_arg) & ~1));
26703         void* inbound_scid_alias_arg_ptr = (void*)(((uintptr_t)inbound_scid_alias_arg) & ~1);
26704         CHECK_ACCESS(inbound_scid_alias_arg_ptr);
26705         LDKCOption_u64Z inbound_scid_alias_arg_conv = *(LDKCOption_u64Z*)(inbound_scid_alias_arg_ptr);
26706         inbound_scid_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)inbound_scid_alias_arg) & ~1));
26707         void* unspendable_punishment_reserve_arg_ptr = (void*)(((uintptr_t)unspendable_punishment_reserve_arg) & ~1);
26708         CHECK_ACCESS(unspendable_punishment_reserve_arg_ptr);
26709         LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(unspendable_punishment_reserve_arg_ptr);
26710         void* confirmations_required_arg_ptr = (void*)(((uintptr_t)confirmations_required_arg) & ~1);
26711         CHECK_ACCESS(confirmations_required_arg_ptr);
26712         LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(confirmations_required_arg_ptr);
26713         confirmations_required_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)confirmations_required_arg) & ~1));
26714         void* force_close_spend_delay_arg_ptr = (void*)(((uintptr_t)force_close_spend_delay_arg) & ~1);
26715         CHECK_ACCESS(force_close_spend_delay_arg_ptr);
26716         LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(force_close_spend_delay_arg_ptr);
26717         force_close_spend_delay_arg_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uintptr_t)force_close_spend_delay_arg) & ~1));
26718         void* inbound_htlc_minimum_msat_arg_ptr = (void*)(((uintptr_t)inbound_htlc_minimum_msat_arg) & ~1);
26719         CHECK_ACCESS(inbound_htlc_minimum_msat_arg_ptr);
26720         LDKCOption_u64Z inbound_htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(inbound_htlc_minimum_msat_arg_ptr);
26721         inbound_htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)inbound_htlc_minimum_msat_arg) & ~1));
26722         void* inbound_htlc_maximum_msat_arg_ptr = (void*)(((uintptr_t)inbound_htlc_maximum_msat_arg) & ~1);
26723         CHECK_ACCESS(inbound_htlc_maximum_msat_arg_ptr);
26724         LDKCOption_u64Z inbound_htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(inbound_htlc_maximum_msat_arg_ptr);
26725         inbound_htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)inbound_htlc_maximum_msat_arg) & ~1));
26726         LDKChannelConfig config_arg_conv;
26727         config_arg_conv.inner = (void*)(config_arg & (~1));
26728         config_arg_conv.is_owned = (config_arg & 1) || (config_arg == 0);
26729         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_arg_conv);
26730         config_arg_conv = ChannelConfig_clone(&config_arg_conv);
26731         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);
26732         uint32_t ret_ref = 0;
26733         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26734         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26735         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26736         ret_ref = (uintptr_t)ret_var.inner;
26737         if (ret_var.is_owned) {
26738                 ret_ref |= 1;
26739         }
26740         return ret_ref;
26741 }
26742
26743 static inline uintptr_t ChannelDetails_clone_ptr(LDKChannelDetails *NONNULL_PTR arg) {
26744         LDKChannelDetails ret_var = ChannelDetails_clone(arg);
26745 uint32_t ret_ref = 0;
26746 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26747 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26748 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26749 ret_ref = (uintptr_t)ret_var.inner;
26750 if (ret_var.is_owned) {
26751         ret_ref |= 1;
26752 }
26753         return ret_ref;
26754 }
26755 uint32_t  __attribute__((export_name("TS_ChannelDetails_clone_ptr"))) TS_ChannelDetails_clone_ptr(uint32_t arg) {
26756         LDKChannelDetails arg_conv;
26757         arg_conv.inner = (void*)(arg & (~1));
26758         arg_conv.is_owned = false;
26759         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26760         uint32_t ret_conv = ChannelDetails_clone_ptr(&arg_conv);
26761         return ret_conv;
26762 }
26763
26764 uint32_t  __attribute__((export_name("TS_ChannelDetails_clone"))) TS_ChannelDetails_clone(uint32_t orig) {
26765         LDKChannelDetails orig_conv;
26766         orig_conv.inner = (void*)(orig & (~1));
26767         orig_conv.is_owned = false;
26768         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26769         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
26770         uint32_t ret_ref = 0;
26771         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26772         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26773         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26774         ret_ref = (uintptr_t)ret_var.inner;
26775         if (ret_var.is_owned) {
26776                 ret_ref |= 1;
26777         }
26778         return ret_ref;
26779 }
26780
26781 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_inbound_payment_scid"))) TS_ChannelDetails_get_inbound_payment_scid(uint32_t this_arg) {
26782         LDKChannelDetails this_arg_conv;
26783         this_arg_conv.inner = (void*)(this_arg & (~1));
26784         this_arg_conv.is_owned = false;
26785         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26786         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
26787         *ret_copy = ChannelDetails_get_inbound_payment_scid(&this_arg_conv);
26788         uint32_t ret_ref = (uintptr_t)ret_copy;
26789         return ret_ref;
26790 }
26791
26792 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_outbound_payment_scid"))) TS_ChannelDetails_get_outbound_payment_scid(uint32_t this_arg) {
26793         LDKChannelDetails this_arg_conv;
26794         this_arg_conv.inner = (void*)(this_arg & (~1));
26795         this_arg_conv.is_owned = false;
26796         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26797         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
26798         *ret_copy = ChannelDetails_get_outbound_payment_scid(&this_arg_conv);
26799         uint32_t ret_ref = (uintptr_t)ret_copy;
26800         return ret_ref;
26801 }
26802
26803 void  __attribute__((export_name("TS_PaymentSendFailure_free"))) TS_PaymentSendFailure_free(uint32_t this_ptr) {
26804         if ((this_ptr & 1) != 0) return;
26805         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
26806         CHECK_ACCESS(this_ptr_ptr);
26807         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(this_ptr_ptr);
26808         FREE((void*)this_ptr);
26809         PaymentSendFailure_free(this_ptr_conv);
26810 }
26811
26812 static inline uintptr_t PaymentSendFailure_clone_ptr(LDKPaymentSendFailure *NONNULL_PTR arg) {
26813         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
26814         *ret_copy = PaymentSendFailure_clone(arg);
26815 uint32_t ret_ref = (uintptr_t)ret_copy;
26816         return ret_ref;
26817 }
26818 uint32_t  __attribute__((export_name("TS_PaymentSendFailure_clone_ptr"))) TS_PaymentSendFailure_clone_ptr(uint32_t arg) {
26819         LDKPaymentSendFailure* arg_conv = (LDKPaymentSendFailure*)arg;
26820         uint32_t ret_conv = PaymentSendFailure_clone_ptr(arg_conv);
26821         return ret_conv;
26822 }
26823
26824 uint32_t  __attribute__((export_name("TS_PaymentSendFailure_clone"))) TS_PaymentSendFailure_clone(uint32_t orig) {
26825         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)orig;
26826         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
26827         *ret_copy = PaymentSendFailure_clone(orig_conv);
26828         uint32_t ret_ref = (uintptr_t)ret_copy;
26829         return ret_ref;
26830 }
26831
26832 uint32_t  __attribute__((export_name("TS_PaymentSendFailure_parameter_error"))) TS_PaymentSendFailure_parameter_error(uint32_t a) {
26833         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
26834         CHECK_ACCESS(a_ptr);
26835         LDKAPIError a_conv = *(LDKAPIError*)(a_ptr);
26836         a_conv = APIError_clone((LDKAPIError*)(((uintptr_t)a) & ~1));
26837         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
26838         *ret_copy = PaymentSendFailure_parameter_error(a_conv);
26839         uint32_t ret_ref = (uintptr_t)ret_copy;
26840         return ret_ref;
26841 }
26842
26843 uint32_t  __attribute__((export_name("TS_PaymentSendFailure_path_parameter_error"))) TS_PaymentSendFailure_path_parameter_error(uint32_tArray a) {
26844         LDKCVec_CResult_NoneAPIErrorZZ a_constr;
26845         a_constr.datalen = a->arr_len;
26846         if (a_constr.datalen > 0)
26847                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
26848         else
26849                 a_constr.data = NULL;
26850         uint32_t* a_vals = a->elems;
26851         for (size_t w = 0; w < a_constr.datalen; w++) {
26852                 uint32_t a_conv_22 = a_vals[w];
26853                 void* a_conv_22_ptr = (void*)(((uintptr_t)a_conv_22) & ~1);
26854                 CHECK_ACCESS(a_conv_22_ptr);
26855                 LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(a_conv_22_ptr);
26856                 a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uintptr_t)a_conv_22) & ~1));
26857                 a_constr.data[w] = a_conv_22_conv;
26858         }
26859         FREE(a);
26860         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
26861         *ret_copy = PaymentSendFailure_path_parameter_error(a_constr);
26862         uint32_t ret_ref = (uintptr_t)ret_copy;
26863         return ret_ref;
26864 }
26865
26866 uint32_t  __attribute__((export_name("TS_PaymentSendFailure_all_failed_retry_safe"))) TS_PaymentSendFailure_all_failed_retry_safe(uint32_tArray a) {
26867         LDKCVec_APIErrorZ a_constr;
26868         a_constr.datalen = a->arr_len;
26869         if (a_constr.datalen > 0)
26870                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
26871         else
26872                 a_constr.data = NULL;
26873         uint32_t* a_vals = a->elems;
26874         for (size_t k = 0; k < a_constr.datalen; k++) {
26875                 uint32_t a_conv_10 = a_vals[k];
26876                 void* a_conv_10_ptr = (void*)(((uintptr_t)a_conv_10) & ~1);
26877                 CHECK_ACCESS(a_conv_10_ptr);
26878                 LDKAPIError a_conv_10_conv = *(LDKAPIError*)(a_conv_10_ptr);
26879                 a_conv_10_conv = APIError_clone((LDKAPIError*)(((uintptr_t)a_conv_10) & ~1));
26880                 a_constr.data[k] = a_conv_10_conv;
26881         }
26882         FREE(a);
26883         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
26884         *ret_copy = PaymentSendFailure_all_failed_retry_safe(a_constr);
26885         uint32_t ret_ref = (uintptr_t)ret_copy;
26886         return ret_ref;
26887 }
26888
26889 uint32_t  __attribute__((export_name("TS_PaymentSendFailure_partial_failure"))) TS_PaymentSendFailure_partial_failure(uint32_tArray results, uint32_t failed_paths_retry, int8_tArray payment_id) {
26890         LDKCVec_CResult_NoneAPIErrorZZ results_constr;
26891         results_constr.datalen = results->arr_len;
26892         if (results_constr.datalen > 0)
26893                 results_constr.data = MALLOC(results_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
26894         else
26895                 results_constr.data = NULL;
26896         uint32_t* results_vals = results->elems;
26897         for (size_t w = 0; w < results_constr.datalen; w++) {
26898                 uint32_t results_conv_22 = results_vals[w];
26899                 void* results_conv_22_ptr = (void*)(((uintptr_t)results_conv_22) & ~1);
26900                 CHECK_ACCESS(results_conv_22_ptr);
26901                 LDKCResult_NoneAPIErrorZ results_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(results_conv_22_ptr);
26902                 results_constr.data[w] = results_conv_22_conv;
26903         }
26904         FREE(results);
26905         LDKRouteParameters failed_paths_retry_conv;
26906         failed_paths_retry_conv.inner = (void*)(failed_paths_retry & (~1));
26907         failed_paths_retry_conv.is_owned = (failed_paths_retry & 1) || (failed_paths_retry == 0);
26908         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_conv);
26909         failed_paths_retry_conv = RouteParameters_clone(&failed_paths_retry_conv);
26910         LDKThirtyTwoBytes payment_id_ref;
26911         CHECK(payment_id->arr_len == 32);
26912         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
26913         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
26914         *ret_copy = PaymentSendFailure_partial_failure(results_constr, failed_paths_retry_conv, payment_id_ref);
26915         uint32_t ret_ref = (uintptr_t)ret_copy;
26916         return ret_ref;
26917 }
26918
26919 void  __attribute__((export_name("TS_PhantomRouteHints_free"))) TS_PhantomRouteHints_free(uint32_t this_obj) {
26920         LDKPhantomRouteHints this_obj_conv;
26921         this_obj_conv.inner = (void*)(this_obj & (~1));
26922         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26923         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26924         PhantomRouteHints_free(this_obj_conv);
26925 }
26926
26927 uint32_tArray  __attribute__((export_name("TS_PhantomRouteHints_get_channels"))) TS_PhantomRouteHints_get_channels(uint32_t this_ptr) {
26928         LDKPhantomRouteHints this_ptr_conv;
26929         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26930         this_ptr_conv.is_owned = false;
26931         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26932         LDKCVec_ChannelDetailsZ ret_var = PhantomRouteHints_get_channels(&this_ptr_conv);
26933         uint32_tArray ret_arr = NULL;
26934         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
26935         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 8);
26936         for (size_t q = 0; q < ret_var.datalen; q++) {
26937                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
26938                 uint32_t ret_conv_16_ref = 0;
26939                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26940                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26941                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
26942                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
26943                 if (ret_conv_16_var.is_owned) {
26944                         ret_conv_16_ref |= 1;
26945                 }
26946                 ret_arr_ptr[q] = ret_conv_16_ref;
26947         }
26948         
26949         FREE(ret_var.data);
26950         return ret_arr;
26951 }
26952
26953 void  __attribute__((export_name("TS_PhantomRouteHints_set_channels"))) TS_PhantomRouteHints_set_channels(uint32_t this_ptr, uint32_tArray val) {
26954         LDKPhantomRouteHints this_ptr_conv;
26955         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26956         this_ptr_conv.is_owned = false;
26957         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26958         LDKCVec_ChannelDetailsZ val_constr;
26959         val_constr.datalen = val->arr_len;
26960         if (val_constr.datalen > 0)
26961                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
26962         else
26963                 val_constr.data = NULL;
26964         uint32_t* val_vals = val->elems;
26965         for (size_t q = 0; q < val_constr.datalen; q++) {
26966                 uint32_t val_conv_16 = val_vals[q];
26967                 LDKChannelDetails val_conv_16_conv;
26968                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
26969                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
26970                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
26971                 val_conv_16_conv = ChannelDetails_clone(&val_conv_16_conv);
26972                 val_constr.data[q] = val_conv_16_conv;
26973         }
26974         FREE(val);
26975         PhantomRouteHints_set_channels(&this_ptr_conv, val_constr);
26976 }
26977
26978 int64_t  __attribute__((export_name("TS_PhantomRouteHints_get_phantom_scid"))) TS_PhantomRouteHints_get_phantom_scid(uint32_t this_ptr) {
26979         LDKPhantomRouteHints this_ptr_conv;
26980         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26981         this_ptr_conv.is_owned = false;
26982         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26983         int64_t ret_conv = PhantomRouteHints_get_phantom_scid(&this_ptr_conv);
26984         return ret_conv;
26985 }
26986
26987 void  __attribute__((export_name("TS_PhantomRouteHints_set_phantom_scid"))) TS_PhantomRouteHints_set_phantom_scid(uint32_t this_ptr, int64_t val) {
26988         LDKPhantomRouteHints this_ptr_conv;
26989         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26990         this_ptr_conv.is_owned = false;
26991         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26992         PhantomRouteHints_set_phantom_scid(&this_ptr_conv, val);
26993 }
26994
26995 int8_tArray  __attribute__((export_name("TS_PhantomRouteHints_get_real_node_pubkey"))) TS_PhantomRouteHints_get_real_node_pubkey(uint32_t this_ptr) {
26996         LDKPhantomRouteHints this_ptr_conv;
26997         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26998         this_ptr_conv.is_owned = false;
26999         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27000         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
27001         memcpy(ret_arr->elems, PhantomRouteHints_get_real_node_pubkey(&this_ptr_conv).compressed_form, 33);
27002         return ret_arr;
27003 }
27004
27005 void  __attribute__((export_name("TS_PhantomRouteHints_set_real_node_pubkey"))) TS_PhantomRouteHints_set_real_node_pubkey(uint32_t this_ptr, int8_tArray val) {
27006         LDKPhantomRouteHints this_ptr_conv;
27007         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27008         this_ptr_conv.is_owned = false;
27009         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27010         LDKPublicKey val_ref;
27011         CHECK(val->arr_len == 33);
27012         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
27013         PhantomRouteHints_set_real_node_pubkey(&this_ptr_conv, val_ref);
27014 }
27015
27016 uint32_t  __attribute__((export_name("TS_PhantomRouteHints_new"))) TS_PhantomRouteHints_new(uint32_tArray channels_arg, int64_t phantom_scid_arg, int8_tArray real_node_pubkey_arg) {
27017         LDKCVec_ChannelDetailsZ channels_arg_constr;
27018         channels_arg_constr.datalen = channels_arg->arr_len;
27019         if (channels_arg_constr.datalen > 0)
27020                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
27021         else
27022                 channels_arg_constr.data = NULL;
27023         uint32_t* channels_arg_vals = channels_arg->elems;
27024         for (size_t q = 0; q < channels_arg_constr.datalen; q++) {
27025                 uint32_t channels_arg_conv_16 = channels_arg_vals[q];
27026                 LDKChannelDetails channels_arg_conv_16_conv;
27027                 channels_arg_conv_16_conv.inner = (void*)(channels_arg_conv_16 & (~1));
27028                 channels_arg_conv_16_conv.is_owned = (channels_arg_conv_16 & 1) || (channels_arg_conv_16 == 0);
27029                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channels_arg_conv_16_conv);
27030                 channels_arg_conv_16_conv = ChannelDetails_clone(&channels_arg_conv_16_conv);
27031                 channels_arg_constr.data[q] = channels_arg_conv_16_conv;
27032         }
27033         FREE(channels_arg);
27034         LDKPublicKey real_node_pubkey_arg_ref;
27035         CHECK(real_node_pubkey_arg->arr_len == 33);
27036         memcpy(real_node_pubkey_arg_ref.compressed_form, real_node_pubkey_arg->elems, 33); FREE(real_node_pubkey_arg);
27037         LDKPhantomRouteHints ret_var = PhantomRouteHints_new(channels_arg_constr, phantom_scid_arg, real_node_pubkey_arg_ref);
27038         uint32_t ret_ref = 0;
27039         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27040         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27041         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27042         ret_ref = (uintptr_t)ret_var.inner;
27043         if (ret_var.is_owned) {
27044                 ret_ref |= 1;
27045         }
27046         return ret_ref;
27047 }
27048
27049 static inline uintptr_t PhantomRouteHints_clone_ptr(LDKPhantomRouteHints *NONNULL_PTR arg) {
27050         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(arg);
27051 uint32_t ret_ref = 0;
27052 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27053 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27054 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27055 ret_ref = (uintptr_t)ret_var.inner;
27056 if (ret_var.is_owned) {
27057         ret_ref |= 1;
27058 }
27059         return ret_ref;
27060 }
27061 uint32_t  __attribute__((export_name("TS_PhantomRouteHints_clone_ptr"))) TS_PhantomRouteHints_clone_ptr(uint32_t arg) {
27062         LDKPhantomRouteHints arg_conv;
27063         arg_conv.inner = (void*)(arg & (~1));
27064         arg_conv.is_owned = false;
27065         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27066         uint32_t ret_conv = PhantomRouteHints_clone_ptr(&arg_conv);
27067         return ret_conv;
27068 }
27069
27070 uint32_t  __attribute__((export_name("TS_PhantomRouteHints_clone"))) TS_PhantomRouteHints_clone(uint32_t orig) {
27071         LDKPhantomRouteHints orig_conv;
27072         orig_conv.inner = (void*)(orig & (~1));
27073         orig_conv.is_owned = false;
27074         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27075         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(&orig_conv);
27076         uint32_t ret_ref = 0;
27077         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27078         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27079         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27080         ret_ref = (uintptr_t)ret_var.inner;
27081         if (ret_var.is_owned) {
27082                 ret_ref |= 1;
27083         }
27084         return ret_ref;
27085 }
27086
27087 uint32_t  __attribute__((export_name("TS_ChannelManager_new"))) TS_ChannelManager_new(uint32_t fee_est, uint32_t chain_monitor, uint32_t tx_broadcaster, uint32_t logger, uint32_t keys_manager, uint32_t config, uint32_t params) {
27088         void* fee_est_ptr = (void*)(((uintptr_t)fee_est) & ~1);
27089         CHECK_ACCESS(fee_est_ptr);
27090         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(fee_est_ptr);
27091         if (fee_est_conv.free == LDKFeeEstimator_JCalls_free) {
27092                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27093                 LDKFeeEstimator_JCalls_cloned(&fee_est_conv);
27094         }
27095         void* chain_monitor_ptr = (void*)(((uintptr_t)chain_monitor) & ~1);
27096         CHECK_ACCESS(chain_monitor_ptr);
27097         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
27098         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
27099                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27100                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
27101         }
27102         void* tx_broadcaster_ptr = (void*)(((uintptr_t)tx_broadcaster) & ~1);
27103         CHECK_ACCESS(tx_broadcaster_ptr);
27104         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
27105         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
27106                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27107                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
27108         }
27109         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
27110         CHECK_ACCESS(logger_ptr);
27111         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
27112         if (logger_conv.free == LDKLogger_JCalls_free) {
27113                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27114                 LDKLogger_JCalls_cloned(&logger_conv);
27115         }
27116         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
27117         CHECK_ACCESS(keys_manager_ptr);
27118         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
27119         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
27120                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27121                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
27122         }
27123         LDKUserConfig config_conv;
27124         config_conv.inner = (void*)(config & (~1));
27125         config_conv.is_owned = (config & 1) || (config == 0);
27126         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_conv);
27127         config_conv = UserConfig_clone(&config_conv);
27128         LDKChainParameters params_conv;
27129         params_conv.inner = (void*)(params & (~1));
27130         params_conv.is_owned = (params & 1) || (params == 0);
27131         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
27132         params_conv = ChainParameters_clone(&params_conv);
27133         LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, params_conv);
27134         uint32_t ret_ref = 0;
27135         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27136         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27137         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27138         ret_ref = (uintptr_t)ret_var.inner;
27139         if (ret_var.is_owned) {
27140                 ret_ref |= 1;
27141         }
27142         return ret_ref;
27143 }
27144
27145 uint32_t  __attribute__((export_name("TS_ChannelManager_get_current_default_configuration"))) TS_ChannelManager_get_current_default_configuration(uint32_t this_arg) {
27146         LDKChannelManager this_arg_conv;
27147         this_arg_conv.inner = (void*)(this_arg & (~1));
27148         this_arg_conv.is_owned = false;
27149         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27150         LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
27151         uint32_t ret_ref = 0;
27152         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27153         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27154         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27155         ret_ref = (uintptr_t)ret_var.inner;
27156         if (ret_var.is_owned) {
27157                 ret_ref |= 1;
27158         }
27159         return ret_ref;
27160 }
27161
27162 uint32_t  __attribute__((export_name("TS_ChannelManager_create_channel"))) TS_ChannelManager_create_channel(uint32_t this_arg, int8_tArray their_network_key, int64_t channel_value_satoshis, int64_t push_msat, int64_t user_channel_id, uint32_t override_config) {
27163         LDKChannelManager this_arg_conv;
27164         this_arg_conv.inner = (void*)(this_arg & (~1));
27165         this_arg_conv.is_owned = false;
27166         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27167         LDKPublicKey their_network_key_ref;
27168         CHECK(their_network_key->arr_len == 33);
27169         memcpy(their_network_key_ref.compressed_form, their_network_key->elems, 33); FREE(their_network_key);
27170         LDKUserConfig override_config_conv;
27171         override_config_conv.inner = (void*)(override_config & (~1));
27172         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
27173         CHECK_INNER_FIELD_ACCESS_OR_NULL(override_config_conv);
27174         override_config_conv = UserConfig_clone(&override_config_conv);
27175         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
27176         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_channel_id, override_config_conv);
27177         return (uint32_t)ret_conv;
27178 }
27179
27180 uint32_tArray  __attribute__((export_name("TS_ChannelManager_list_channels"))) TS_ChannelManager_list_channels(uint32_t this_arg) {
27181         LDKChannelManager this_arg_conv;
27182         this_arg_conv.inner = (void*)(this_arg & (~1));
27183         this_arg_conv.is_owned = false;
27184         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27185         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
27186         uint32_tArray ret_arr = NULL;
27187         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
27188         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 8);
27189         for (size_t q = 0; q < ret_var.datalen; q++) {
27190                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
27191                 uint32_t ret_conv_16_ref = 0;
27192                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27193                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27194                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
27195                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
27196                 if (ret_conv_16_var.is_owned) {
27197                         ret_conv_16_ref |= 1;
27198                 }
27199                 ret_arr_ptr[q] = ret_conv_16_ref;
27200         }
27201         
27202         FREE(ret_var.data);
27203         return ret_arr;
27204 }
27205
27206 uint32_tArray  __attribute__((export_name("TS_ChannelManager_list_usable_channels"))) TS_ChannelManager_list_usable_channels(uint32_t this_arg) {
27207         LDKChannelManager this_arg_conv;
27208         this_arg_conv.inner = (void*)(this_arg & (~1));
27209         this_arg_conv.is_owned = false;
27210         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27211         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
27212         uint32_tArray ret_arr = NULL;
27213         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
27214         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 8);
27215         for (size_t q = 0; q < ret_var.datalen; q++) {
27216                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
27217                 uint32_t ret_conv_16_ref = 0;
27218                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27219                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27220                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
27221                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
27222                 if (ret_conv_16_var.is_owned) {
27223                         ret_conv_16_ref |= 1;
27224                 }
27225                 ret_arr_ptr[q] = ret_conv_16_ref;
27226         }
27227         
27228         FREE(ret_var.data);
27229         return ret_arr;
27230 }
27231
27232 uint32_t  __attribute__((export_name("TS_ChannelManager_close_channel"))) TS_ChannelManager_close_channel(uint32_t this_arg, int8_tArray channel_id, int8_tArray counterparty_node_id) {
27233         LDKChannelManager this_arg_conv;
27234         this_arg_conv.inner = (void*)(this_arg & (~1));
27235         this_arg_conv.is_owned = false;
27236         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27237         unsigned char channel_id_arr[32];
27238         CHECK(channel_id->arr_len == 32);
27239         memcpy(channel_id_arr, channel_id->elems, 32); FREE(channel_id);
27240         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
27241         LDKPublicKey counterparty_node_id_ref;
27242         CHECK(counterparty_node_id->arr_len == 33);
27243         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
27244         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
27245         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
27246         return (uint32_t)ret_conv;
27247 }
27248
27249 uint32_t  __attribute__((export_name("TS_ChannelManager_close_channel_with_target_feerate"))) TS_ChannelManager_close_channel_with_target_feerate(uint32_t this_arg, int8_tArray channel_id, int8_tArray counterparty_node_id, int32_t target_feerate_sats_per_1000_weight) {
27250         LDKChannelManager this_arg_conv;
27251         this_arg_conv.inner = (void*)(this_arg & (~1));
27252         this_arg_conv.is_owned = false;
27253         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27254         unsigned char channel_id_arr[32];
27255         CHECK(channel_id->arr_len == 32);
27256         memcpy(channel_id_arr, channel_id->elems, 32); FREE(channel_id);
27257         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
27258         LDKPublicKey counterparty_node_id_ref;
27259         CHECK(counterparty_node_id->arr_len == 33);
27260         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
27261         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
27262         *ret_conv = ChannelManager_close_channel_with_target_feerate(&this_arg_conv, channel_id_ref, counterparty_node_id_ref, target_feerate_sats_per_1000_weight);
27263         return (uint32_t)ret_conv;
27264 }
27265
27266 uint32_t  __attribute__((export_name("TS_ChannelManager_force_close_broadcasting_latest_txn"))) TS_ChannelManager_force_close_broadcasting_latest_txn(uint32_t this_arg, int8_tArray channel_id, int8_tArray counterparty_node_id) {
27267         LDKChannelManager this_arg_conv;
27268         this_arg_conv.inner = (void*)(this_arg & (~1));
27269         this_arg_conv.is_owned = false;
27270         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27271         unsigned char channel_id_arr[32];
27272         CHECK(channel_id->arr_len == 32);
27273         memcpy(channel_id_arr, channel_id->elems, 32); FREE(channel_id);
27274         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
27275         LDKPublicKey counterparty_node_id_ref;
27276         CHECK(counterparty_node_id->arr_len == 33);
27277         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
27278         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
27279         *ret_conv = ChannelManager_force_close_broadcasting_latest_txn(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
27280         return (uint32_t)ret_conv;
27281 }
27282
27283 uint32_t  __attribute__((export_name("TS_ChannelManager_force_close_without_broadcasting_txn"))) TS_ChannelManager_force_close_without_broadcasting_txn(uint32_t this_arg, int8_tArray channel_id, int8_tArray counterparty_node_id) {
27284         LDKChannelManager this_arg_conv;
27285         this_arg_conv.inner = (void*)(this_arg & (~1));
27286         this_arg_conv.is_owned = false;
27287         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27288         unsigned char channel_id_arr[32];
27289         CHECK(channel_id->arr_len == 32);
27290         memcpy(channel_id_arr, channel_id->elems, 32); FREE(channel_id);
27291         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
27292         LDKPublicKey counterparty_node_id_ref;
27293         CHECK(counterparty_node_id->arr_len == 33);
27294         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
27295         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
27296         *ret_conv = ChannelManager_force_close_without_broadcasting_txn(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
27297         return (uint32_t)ret_conv;
27298 }
27299
27300 void  __attribute__((export_name("TS_ChannelManager_force_close_all_channels_broadcasting_latest_txn"))) TS_ChannelManager_force_close_all_channels_broadcasting_latest_txn(uint32_t this_arg) {
27301         LDKChannelManager this_arg_conv;
27302         this_arg_conv.inner = (void*)(this_arg & (~1));
27303         this_arg_conv.is_owned = false;
27304         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27305         ChannelManager_force_close_all_channels_broadcasting_latest_txn(&this_arg_conv);
27306 }
27307
27308 void  __attribute__((export_name("TS_ChannelManager_force_close_all_channels_without_broadcasting_txn"))) TS_ChannelManager_force_close_all_channels_without_broadcasting_txn(uint32_t this_arg) {
27309         LDKChannelManager this_arg_conv;
27310         this_arg_conv.inner = (void*)(this_arg & (~1));
27311         this_arg_conv.is_owned = false;
27312         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27313         ChannelManager_force_close_all_channels_without_broadcasting_txn(&this_arg_conv);
27314 }
27315
27316 uint32_t  __attribute__((export_name("TS_ChannelManager_send_payment"))) TS_ChannelManager_send_payment(uint32_t this_arg, uint32_t route, int8_tArray payment_hash, int8_tArray payment_secret) {
27317         LDKChannelManager this_arg_conv;
27318         this_arg_conv.inner = (void*)(this_arg & (~1));
27319         this_arg_conv.is_owned = false;
27320         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27321         LDKRoute route_conv;
27322         route_conv.inner = (void*)(route & (~1));
27323         route_conv.is_owned = false;
27324         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
27325         LDKThirtyTwoBytes payment_hash_ref;
27326         CHECK(payment_hash->arr_len == 32);
27327         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
27328         LDKThirtyTwoBytes payment_secret_ref;
27329         CHECK(payment_secret->arr_len == 32);
27330         memcpy(payment_secret_ref.data, payment_secret->elems, 32); FREE(payment_secret);
27331         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
27332         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
27333         return (uint32_t)ret_conv;
27334 }
27335
27336 uint32_t  __attribute__((export_name("TS_ChannelManager_retry_payment"))) TS_ChannelManager_retry_payment(uint32_t this_arg, uint32_t route, int8_tArray payment_id) {
27337         LDKChannelManager this_arg_conv;
27338         this_arg_conv.inner = (void*)(this_arg & (~1));
27339         this_arg_conv.is_owned = false;
27340         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27341         LDKRoute route_conv;
27342         route_conv.inner = (void*)(route & (~1));
27343         route_conv.is_owned = false;
27344         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
27345         LDKThirtyTwoBytes payment_id_ref;
27346         CHECK(payment_id->arr_len == 32);
27347         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
27348         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
27349         *ret_conv = ChannelManager_retry_payment(&this_arg_conv, &route_conv, payment_id_ref);
27350         return (uint32_t)ret_conv;
27351 }
27352
27353 void  __attribute__((export_name("TS_ChannelManager_abandon_payment"))) TS_ChannelManager_abandon_payment(uint32_t this_arg, int8_tArray payment_id) {
27354         LDKChannelManager this_arg_conv;
27355         this_arg_conv.inner = (void*)(this_arg & (~1));
27356         this_arg_conv.is_owned = false;
27357         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27358         LDKThirtyTwoBytes payment_id_ref;
27359         CHECK(payment_id->arr_len == 32);
27360         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
27361         ChannelManager_abandon_payment(&this_arg_conv, payment_id_ref);
27362 }
27363
27364 uint32_t  __attribute__((export_name("TS_ChannelManager_send_spontaneous_payment"))) TS_ChannelManager_send_spontaneous_payment(uint32_t this_arg, uint32_t route, int8_tArray payment_preimage) {
27365         LDKChannelManager this_arg_conv;
27366         this_arg_conv.inner = (void*)(this_arg & (~1));
27367         this_arg_conv.is_owned = false;
27368         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27369         LDKRoute route_conv;
27370         route_conv.inner = (void*)(route & (~1));
27371         route_conv.is_owned = false;
27372         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
27373         LDKThirtyTwoBytes payment_preimage_ref;
27374         CHECK(payment_preimage->arr_len == 32);
27375         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
27376         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
27377         *ret_conv = ChannelManager_send_spontaneous_payment(&this_arg_conv, &route_conv, payment_preimage_ref);
27378         return (uint32_t)ret_conv;
27379 }
27380
27381 uint32_t  __attribute__((export_name("TS_ChannelManager_send_probe"))) TS_ChannelManager_send_probe(uint32_t this_arg, uint32_tArray hops) {
27382         LDKChannelManager this_arg_conv;
27383         this_arg_conv.inner = (void*)(this_arg & (~1));
27384         this_arg_conv.is_owned = false;
27385         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27386         LDKCVec_RouteHopZ hops_constr;
27387         hops_constr.datalen = hops->arr_len;
27388         if (hops_constr.datalen > 0)
27389                 hops_constr.data = MALLOC(hops_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
27390         else
27391                 hops_constr.data = NULL;
27392         uint32_t* hops_vals = hops->elems;
27393         for (size_t k = 0; k < hops_constr.datalen; k++) {
27394                 uint32_t hops_conv_10 = hops_vals[k];
27395                 LDKRouteHop hops_conv_10_conv;
27396                 hops_conv_10_conv.inner = (void*)(hops_conv_10 & (~1));
27397                 hops_conv_10_conv.is_owned = (hops_conv_10 & 1) || (hops_conv_10 == 0);
27398                 CHECK_INNER_FIELD_ACCESS_OR_NULL(hops_conv_10_conv);
27399                 hops_conv_10_conv = RouteHop_clone(&hops_conv_10_conv);
27400                 hops_constr.data[k] = hops_conv_10_conv;
27401         }
27402         FREE(hops);
27403         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
27404         *ret_conv = ChannelManager_send_probe(&this_arg_conv, hops_constr);
27405         return (uint32_t)ret_conv;
27406 }
27407
27408 uint32_t  __attribute__((export_name("TS_ChannelManager_funding_transaction_generated"))) TS_ChannelManager_funding_transaction_generated(uint32_t this_arg, int8_tArray temporary_channel_id, int8_tArray counterparty_node_id, int8_tArray funding_transaction) {
27409         LDKChannelManager this_arg_conv;
27410         this_arg_conv.inner = (void*)(this_arg & (~1));
27411         this_arg_conv.is_owned = false;
27412         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27413         unsigned char temporary_channel_id_arr[32];
27414         CHECK(temporary_channel_id->arr_len == 32);
27415         memcpy(temporary_channel_id_arr, temporary_channel_id->elems, 32); FREE(temporary_channel_id);
27416         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
27417         LDKPublicKey counterparty_node_id_ref;
27418         CHECK(counterparty_node_id->arr_len == 33);
27419         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
27420         LDKTransaction funding_transaction_ref;
27421         funding_transaction_ref.datalen = funding_transaction->arr_len;
27422         funding_transaction_ref.data = MALLOC(funding_transaction_ref.datalen, "LDKTransaction Bytes");
27423         memcpy(funding_transaction_ref.data, funding_transaction->elems, funding_transaction_ref.datalen); FREE(funding_transaction);
27424         funding_transaction_ref.data_is_owned = true;
27425         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
27426         *ret_conv = ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, counterparty_node_id_ref, funding_transaction_ref);
27427         return (uint32_t)ret_conv;
27428 }
27429
27430 void  __attribute__((export_name("TS_ChannelManager_broadcast_node_announcement"))) TS_ChannelManager_broadcast_node_announcement(uint32_t this_arg, int8_tArray rgb, int8_tArray alias, uint32_tArray addresses) {
27431         LDKChannelManager this_arg_conv;
27432         this_arg_conv.inner = (void*)(this_arg & (~1));
27433         this_arg_conv.is_owned = false;
27434         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27435         LDKThreeBytes rgb_ref;
27436         CHECK(rgb->arr_len == 3);
27437         memcpy(rgb_ref.data, rgb->elems, 3); FREE(rgb);
27438         LDKThirtyTwoBytes alias_ref;
27439         CHECK(alias->arr_len == 32);
27440         memcpy(alias_ref.data, alias->elems, 32); FREE(alias);
27441         LDKCVec_NetAddressZ addresses_constr;
27442         addresses_constr.datalen = addresses->arr_len;
27443         if (addresses_constr.datalen > 0)
27444                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
27445         else
27446                 addresses_constr.data = NULL;
27447         uint32_t* addresses_vals = addresses->elems;
27448         for (size_t m = 0; m < addresses_constr.datalen; m++) {
27449                 uint32_t addresses_conv_12 = addresses_vals[m];
27450                 void* addresses_conv_12_ptr = (void*)(((uintptr_t)addresses_conv_12) & ~1);
27451                 CHECK_ACCESS(addresses_conv_12_ptr);
27452                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(addresses_conv_12_ptr);
27453                 addresses_constr.data[m] = addresses_conv_12_conv;
27454         }
27455         FREE(addresses);
27456         ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
27457 }
27458
27459 uint32_t  __attribute__((export_name("TS_ChannelManager_update_channel_config"))) TS_ChannelManager_update_channel_config(uint32_t this_arg, int8_tArray counterparty_node_id, ptrArray channel_ids, uint32_t config) {
27460         LDKChannelManager this_arg_conv;
27461         this_arg_conv.inner = (void*)(this_arg & (~1));
27462         this_arg_conv.is_owned = false;
27463         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27464         LDKPublicKey counterparty_node_id_ref;
27465         CHECK(counterparty_node_id->arr_len == 33);
27466         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
27467         LDKCVec_ThirtyTwoBytesZ channel_ids_constr;
27468         channel_ids_constr.datalen = channel_ids->arr_len;
27469         if (channel_ids_constr.datalen > 0)
27470                 channel_ids_constr.data = MALLOC(channel_ids_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_ThirtyTwoBytesZ Elements");
27471         else
27472                 channel_ids_constr.data = NULL;
27473         int8_tArray* channel_ids_vals = (void*) channel_ids->elems;
27474         for (size_t m = 0; m < channel_ids_constr.datalen; m++) {
27475                 int8_tArray channel_ids_conv_12 = channel_ids_vals[m];
27476                 LDKThirtyTwoBytes channel_ids_conv_12_ref;
27477                 CHECK(channel_ids_conv_12->arr_len == 32);
27478                 memcpy(channel_ids_conv_12_ref.data, channel_ids_conv_12->elems, 32); FREE(channel_ids_conv_12);
27479                 channel_ids_constr.data[m] = channel_ids_conv_12_ref;
27480         }
27481         FREE(channel_ids);
27482         LDKChannelConfig config_conv;
27483         config_conv.inner = (void*)(config & (~1));
27484         config_conv.is_owned = false;
27485         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_conv);
27486         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
27487         *ret_conv = ChannelManager_update_channel_config(&this_arg_conv, counterparty_node_id_ref, channel_ids_constr, &config_conv);
27488         return (uint32_t)ret_conv;
27489 }
27490
27491 void  __attribute__((export_name("TS_ChannelManager_process_pending_htlc_forwards"))) TS_ChannelManager_process_pending_htlc_forwards(uint32_t this_arg) {
27492         LDKChannelManager this_arg_conv;
27493         this_arg_conv.inner = (void*)(this_arg & (~1));
27494         this_arg_conv.is_owned = false;
27495         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27496         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
27497 }
27498
27499 void  __attribute__((export_name("TS_ChannelManager_timer_tick_occurred"))) TS_ChannelManager_timer_tick_occurred(uint32_t this_arg) {
27500         LDKChannelManager this_arg_conv;
27501         this_arg_conv.inner = (void*)(this_arg & (~1));
27502         this_arg_conv.is_owned = false;
27503         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27504         ChannelManager_timer_tick_occurred(&this_arg_conv);
27505 }
27506
27507 void  __attribute__((export_name("TS_ChannelManager_fail_htlc_backwards"))) TS_ChannelManager_fail_htlc_backwards(uint32_t this_arg, int8_tArray payment_hash) {
27508         LDKChannelManager this_arg_conv;
27509         this_arg_conv.inner = (void*)(this_arg & (~1));
27510         this_arg_conv.is_owned = false;
27511         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27512         unsigned char payment_hash_arr[32];
27513         CHECK(payment_hash->arr_len == 32);
27514         memcpy(payment_hash_arr, payment_hash->elems, 32); FREE(payment_hash);
27515         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
27516         ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref);
27517 }
27518
27519 void  __attribute__((export_name("TS_ChannelManager_claim_funds"))) TS_ChannelManager_claim_funds(uint32_t this_arg, int8_tArray payment_preimage) {
27520         LDKChannelManager this_arg_conv;
27521         this_arg_conv.inner = (void*)(this_arg & (~1));
27522         this_arg_conv.is_owned = false;
27523         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27524         LDKThirtyTwoBytes payment_preimage_ref;
27525         CHECK(payment_preimage->arr_len == 32);
27526         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
27527         ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref);
27528 }
27529
27530 int8_tArray  __attribute__((export_name("TS_ChannelManager_get_our_node_id"))) TS_ChannelManager_get_our_node_id(uint32_t this_arg) {
27531         LDKChannelManager this_arg_conv;
27532         this_arg_conv.inner = (void*)(this_arg & (~1));
27533         this_arg_conv.is_owned = false;
27534         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27535         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
27536         memcpy(ret_arr->elems, ChannelManager_get_our_node_id(&this_arg_conv).compressed_form, 33);
27537         return ret_arr;
27538 }
27539
27540 uint32_t  __attribute__((export_name("TS_ChannelManager_accept_inbound_channel"))) TS_ChannelManager_accept_inbound_channel(uint32_t this_arg, int8_tArray temporary_channel_id, int8_tArray counterparty_node_id, int64_t user_channel_id) {
27541         LDKChannelManager this_arg_conv;
27542         this_arg_conv.inner = (void*)(this_arg & (~1));
27543         this_arg_conv.is_owned = false;
27544         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27545         unsigned char temporary_channel_id_arr[32];
27546         CHECK(temporary_channel_id->arr_len == 32);
27547         memcpy(temporary_channel_id_arr, temporary_channel_id->elems, 32); FREE(temporary_channel_id);
27548         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
27549         LDKPublicKey counterparty_node_id_ref;
27550         CHECK(counterparty_node_id->arr_len == 33);
27551         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
27552         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
27553         *ret_conv = ChannelManager_accept_inbound_channel(&this_arg_conv, temporary_channel_id_ref, counterparty_node_id_ref, user_channel_id);
27554         return (uint32_t)ret_conv;
27555 }
27556
27557 uint32_t  __attribute__((export_name("TS_ChannelManager_accept_inbound_channel_from_trusted_peer_0conf"))) TS_ChannelManager_accept_inbound_channel_from_trusted_peer_0conf(uint32_t this_arg, int8_tArray temporary_channel_id, int8_tArray counterparty_node_id, int64_t user_channel_id) {
27558         LDKChannelManager this_arg_conv;
27559         this_arg_conv.inner = (void*)(this_arg & (~1));
27560         this_arg_conv.is_owned = false;
27561         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27562         unsigned char temporary_channel_id_arr[32];
27563         CHECK(temporary_channel_id->arr_len == 32);
27564         memcpy(temporary_channel_id_arr, temporary_channel_id->elems, 32); FREE(temporary_channel_id);
27565         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
27566         LDKPublicKey counterparty_node_id_ref;
27567         CHECK(counterparty_node_id->arr_len == 33);
27568         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
27569         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
27570         *ret_conv = ChannelManager_accept_inbound_channel_from_trusted_peer_0conf(&this_arg_conv, temporary_channel_id_ref, counterparty_node_id_ref, user_channel_id);
27571         return (uint32_t)ret_conv;
27572 }
27573
27574 uint32_t  __attribute__((export_name("TS_ChannelManager_create_inbound_payment"))) TS_ChannelManager_create_inbound_payment(uint32_t this_arg, uint32_t min_value_msat, int32_t invoice_expiry_delta_secs) {
27575         LDKChannelManager this_arg_conv;
27576         this_arg_conv.inner = (void*)(this_arg & (~1));
27577         this_arg_conv.is_owned = false;
27578         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27579         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
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*)(((uintptr_t)min_value_msat) & ~1));
27583         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
27584         *ret_conv = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
27585         return (uint32_t)ret_conv;
27586 }
27587
27588 uint32_t  __attribute__((export_name("TS_ChannelManager_create_inbound_payment_legacy"))) TS_ChannelManager_create_inbound_payment_legacy(uint32_t this_arg, uint32_t min_value_msat, int32_t invoice_expiry_delta_secs) {
27589         LDKChannelManager this_arg_conv;
27590         this_arg_conv.inner = (void*)(this_arg & (~1));
27591         this_arg_conv.is_owned = false;
27592         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27593         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
27594         CHECK_ACCESS(min_value_msat_ptr);
27595         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
27596         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
27597         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
27598         *ret_conv = ChannelManager_create_inbound_payment_legacy(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
27599         return (uint32_t)ret_conv;
27600 }
27601
27602 uint32_t  __attribute__((export_name("TS_ChannelManager_create_inbound_payment_for_hash"))) TS_ChannelManager_create_inbound_payment_for_hash(uint32_t this_arg, int8_tArray payment_hash, uint32_t min_value_msat, int32_t invoice_expiry_delta_secs) {
27603         LDKChannelManager this_arg_conv;
27604         this_arg_conv.inner = (void*)(this_arg & (~1));
27605         this_arg_conv.is_owned = false;
27606         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27607         LDKThirtyTwoBytes payment_hash_ref;
27608         CHECK(payment_hash->arr_len == 32);
27609         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
27610         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
27611         CHECK_ACCESS(min_value_msat_ptr);
27612         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
27613         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
27614         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
27615         *ret_conv = ChannelManager_create_inbound_payment_for_hash(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
27616         return (uint32_t)ret_conv;
27617 }
27618
27619 uint32_t  __attribute__((export_name("TS_ChannelManager_create_inbound_payment_for_hash_legacy"))) TS_ChannelManager_create_inbound_payment_for_hash_legacy(uint32_t this_arg, int8_tArray payment_hash, uint32_t min_value_msat, int32_t invoice_expiry_delta_secs) {
27620         LDKChannelManager this_arg_conv;
27621         this_arg_conv.inner = (void*)(this_arg & (~1));
27622         this_arg_conv.is_owned = false;
27623         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27624         LDKThirtyTwoBytes payment_hash_ref;
27625         CHECK(payment_hash->arr_len == 32);
27626         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
27627         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
27628         CHECK_ACCESS(min_value_msat_ptr);
27629         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
27630         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
27631         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
27632         *ret_conv = ChannelManager_create_inbound_payment_for_hash_legacy(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
27633         return (uint32_t)ret_conv;
27634 }
27635
27636 uint32_t  __attribute__((export_name("TS_ChannelManager_get_payment_preimage"))) TS_ChannelManager_get_payment_preimage(uint32_t this_arg, int8_tArray payment_hash, int8_tArray payment_secret) {
27637         LDKChannelManager this_arg_conv;
27638         this_arg_conv.inner = (void*)(this_arg & (~1));
27639         this_arg_conv.is_owned = false;
27640         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27641         LDKThirtyTwoBytes payment_hash_ref;
27642         CHECK(payment_hash->arr_len == 32);
27643         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
27644         LDKThirtyTwoBytes payment_secret_ref;
27645         CHECK(payment_secret->arr_len == 32);
27646         memcpy(payment_secret_ref.data, payment_secret->elems, 32); FREE(payment_secret);
27647         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
27648         *ret_conv = ChannelManager_get_payment_preimage(&this_arg_conv, payment_hash_ref, payment_secret_ref);
27649         return (uint32_t)ret_conv;
27650 }
27651
27652 int64_t  __attribute__((export_name("TS_ChannelManager_get_phantom_scid"))) TS_ChannelManager_get_phantom_scid(uint32_t this_arg) {
27653         LDKChannelManager this_arg_conv;
27654         this_arg_conv.inner = (void*)(this_arg & (~1));
27655         this_arg_conv.is_owned = false;
27656         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27657         int64_t ret_conv = ChannelManager_get_phantom_scid(&this_arg_conv);
27658         return ret_conv;
27659 }
27660
27661 uint32_t  __attribute__((export_name("TS_ChannelManager_get_phantom_route_hints"))) TS_ChannelManager_get_phantom_route_hints(uint32_t this_arg) {
27662         LDKChannelManager this_arg_conv;
27663         this_arg_conv.inner = (void*)(this_arg & (~1));
27664         this_arg_conv.is_owned = false;
27665         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27666         LDKPhantomRouteHints ret_var = ChannelManager_get_phantom_route_hints(&this_arg_conv);
27667         uint32_t ret_ref = 0;
27668         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27669         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27670         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27671         ret_ref = (uintptr_t)ret_var.inner;
27672         if (ret_var.is_owned) {
27673                 ret_ref |= 1;
27674         }
27675         return ret_ref;
27676 }
27677
27678 uint32_t  __attribute__((export_name("TS_ChannelManager_as_MessageSendEventsProvider"))) TS_ChannelManager_as_MessageSendEventsProvider(uint32_t this_arg) {
27679         LDKChannelManager this_arg_conv;
27680         this_arg_conv.inner = (void*)(this_arg & (~1));
27681         this_arg_conv.is_owned = false;
27682         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27683         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
27684         *ret_ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
27685         return (uint32_t)ret_ret;
27686 }
27687
27688 uint32_t  __attribute__((export_name("TS_ChannelManager_as_EventsProvider"))) TS_ChannelManager_as_EventsProvider(uint32_t this_arg) {
27689         LDKChannelManager this_arg_conv;
27690         this_arg_conv.inner = (void*)(this_arg & (~1));
27691         this_arg_conv.is_owned = false;
27692         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27693         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
27694         *ret_ret = ChannelManager_as_EventsProvider(&this_arg_conv);
27695         return (uint32_t)ret_ret;
27696 }
27697
27698 uint32_t  __attribute__((export_name("TS_ChannelManager_as_Listen"))) TS_ChannelManager_as_Listen(uint32_t this_arg) {
27699         LDKChannelManager this_arg_conv;
27700         this_arg_conv.inner = (void*)(this_arg & (~1));
27701         this_arg_conv.is_owned = false;
27702         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27703         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
27704         *ret_ret = ChannelManager_as_Listen(&this_arg_conv);
27705         return (uint32_t)ret_ret;
27706 }
27707
27708 uint32_t  __attribute__((export_name("TS_ChannelManager_as_Confirm"))) TS_ChannelManager_as_Confirm(uint32_t this_arg) {
27709         LDKChannelManager this_arg_conv;
27710         this_arg_conv.inner = (void*)(this_arg & (~1));
27711         this_arg_conv.is_owned = false;
27712         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27713         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
27714         *ret_ret = ChannelManager_as_Confirm(&this_arg_conv);
27715         return (uint32_t)ret_ret;
27716 }
27717
27718 void  __attribute__((export_name("TS_ChannelManager_await_persistable_update"))) TS_ChannelManager_await_persistable_update(uint32_t this_arg) {
27719         LDKChannelManager this_arg_conv;
27720         this_arg_conv.inner = (void*)(this_arg & (~1));
27721         this_arg_conv.is_owned = false;
27722         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27723         ChannelManager_await_persistable_update(&this_arg_conv);
27724 }
27725
27726 uint32_t  __attribute__((export_name("TS_ChannelManager_current_best_block"))) TS_ChannelManager_current_best_block(uint32_t this_arg) {
27727         LDKChannelManager this_arg_conv;
27728         this_arg_conv.inner = (void*)(this_arg & (~1));
27729         this_arg_conv.is_owned = false;
27730         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27731         LDKBestBlock ret_var = ChannelManager_current_best_block(&this_arg_conv);
27732         uint32_t ret_ref = 0;
27733         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27734         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27735         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27736         ret_ref = (uintptr_t)ret_var.inner;
27737         if (ret_var.is_owned) {
27738                 ret_ref |= 1;
27739         }
27740         return ret_ref;
27741 }
27742
27743 uint32_t  __attribute__((export_name("TS_ChannelManager_as_ChannelMessageHandler"))) TS_ChannelManager_as_ChannelMessageHandler(uint32_t this_arg) {
27744         LDKChannelManager this_arg_conv;
27745         this_arg_conv.inner = (void*)(this_arg & (~1));
27746         this_arg_conv.is_owned = false;
27747         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27748         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
27749         *ret_ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
27750         return (uint32_t)ret_ret;
27751 }
27752
27753 int8_tArray  __attribute__((export_name("TS_CounterpartyForwardingInfo_write"))) TS_CounterpartyForwardingInfo_write(uint32_t obj) {
27754         LDKCounterpartyForwardingInfo obj_conv;
27755         obj_conv.inner = (void*)(obj & (~1));
27756         obj_conv.is_owned = false;
27757         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27758         LDKCVec_u8Z ret_var = CounterpartyForwardingInfo_write(&obj_conv);
27759         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
27760         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27761         CVec_u8Z_free(ret_var);
27762         return ret_arr;
27763 }
27764
27765 uint32_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_read"))) TS_CounterpartyForwardingInfo_read(int8_tArray ser) {
27766         LDKu8slice ser_ref;
27767         ser_ref.datalen = ser->arr_len;
27768         ser_ref.data = ser->elems;
27769         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
27770         *ret_conv = CounterpartyForwardingInfo_read(ser_ref);
27771         FREE(ser);
27772         return (uint32_t)ret_conv;
27773 }
27774
27775 int8_tArray  __attribute__((export_name("TS_ChannelCounterparty_write"))) TS_ChannelCounterparty_write(uint32_t obj) {
27776         LDKChannelCounterparty obj_conv;
27777         obj_conv.inner = (void*)(obj & (~1));
27778         obj_conv.is_owned = false;
27779         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27780         LDKCVec_u8Z ret_var = ChannelCounterparty_write(&obj_conv);
27781         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
27782         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27783         CVec_u8Z_free(ret_var);
27784         return ret_arr;
27785 }
27786
27787 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_read"))) TS_ChannelCounterparty_read(int8_tArray ser) {
27788         LDKu8slice ser_ref;
27789         ser_ref.datalen = ser->arr_len;
27790         ser_ref.data = ser->elems;
27791         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
27792         *ret_conv = ChannelCounterparty_read(ser_ref);
27793         FREE(ser);
27794         return (uint32_t)ret_conv;
27795 }
27796
27797 int8_tArray  __attribute__((export_name("TS_ChannelDetails_write"))) TS_ChannelDetails_write(uint32_t obj) {
27798         LDKChannelDetails obj_conv;
27799         obj_conv.inner = (void*)(obj & (~1));
27800         obj_conv.is_owned = false;
27801         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27802         LDKCVec_u8Z ret_var = ChannelDetails_write(&obj_conv);
27803         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
27804         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27805         CVec_u8Z_free(ret_var);
27806         return ret_arr;
27807 }
27808
27809 uint32_t  __attribute__((export_name("TS_ChannelDetails_read"))) TS_ChannelDetails_read(int8_tArray ser) {
27810         LDKu8slice ser_ref;
27811         ser_ref.datalen = ser->arr_len;
27812         ser_ref.data = ser->elems;
27813         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
27814         *ret_conv = ChannelDetails_read(ser_ref);
27815         FREE(ser);
27816         return (uint32_t)ret_conv;
27817 }
27818
27819 int8_tArray  __attribute__((export_name("TS_PhantomRouteHints_write"))) TS_PhantomRouteHints_write(uint32_t obj) {
27820         LDKPhantomRouteHints obj_conv;
27821         obj_conv.inner = (void*)(obj & (~1));
27822         obj_conv.is_owned = false;
27823         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27824         LDKCVec_u8Z ret_var = PhantomRouteHints_write(&obj_conv);
27825         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
27826         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27827         CVec_u8Z_free(ret_var);
27828         return ret_arr;
27829 }
27830
27831 uint32_t  __attribute__((export_name("TS_PhantomRouteHints_read"))) TS_PhantomRouteHints_read(int8_tArray ser) {
27832         LDKu8slice ser_ref;
27833         ser_ref.datalen = ser->arr_len;
27834         ser_ref.data = ser->elems;
27835         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
27836         *ret_conv = PhantomRouteHints_read(ser_ref);
27837         FREE(ser);
27838         return (uint32_t)ret_conv;
27839 }
27840
27841 int8_tArray  __attribute__((export_name("TS_ChannelManager_write"))) TS_ChannelManager_write(uint32_t obj) {
27842         LDKChannelManager obj_conv;
27843         obj_conv.inner = (void*)(obj & (~1));
27844         obj_conv.is_owned = false;
27845         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27846         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
27847         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
27848         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27849         CVec_u8Z_free(ret_var);
27850         return ret_arr;
27851 }
27852
27853 void  __attribute__((export_name("TS_ChannelManagerReadArgs_free"))) TS_ChannelManagerReadArgs_free(uint32_t this_obj) {
27854         LDKChannelManagerReadArgs this_obj_conv;
27855         this_obj_conv.inner = (void*)(this_obj & (~1));
27856         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27857         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27858         ChannelManagerReadArgs_free(this_obj_conv);
27859 }
27860
27861 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_keys_manager"))) TS_ChannelManagerReadArgs_get_keys_manager(uint32_t this_ptr) {
27862         LDKChannelManagerReadArgs this_ptr_conv;
27863         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27864         this_ptr_conv.is_owned = false;
27865         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27866         // WARNING: This object doesn't live past this scope, needs clone!
27867         uint32_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv)) | 1;
27868         return ret_ret;
27869 }
27870
27871 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_keys_manager"))) TS_ChannelManagerReadArgs_set_keys_manager(uint32_t this_ptr, uint32_t val) {
27872         LDKChannelManagerReadArgs this_ptr_conv;
27873         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27874         this_ptr_conv.is_owned = false;
27875         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27876         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
27877         CHECK_ACCESS(val_ptr);
27878         LDKKeysInterface val_conv = *(LDKKeysInterface*)(val_ptr);
27879         if (val_conv.free == LDKKeysInterface_JCalls_free) {
27880                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27881                 LDKKeysInterface_JCalls_cloned(&val_conv);
27882         }
27883         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
27884 }
27885
27886 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_fee_estimator"))) TS_ChannelManagerReadArgs_get_fee_estimator(uint32_t this_ptr) {
27887         LDKChannelManagerReadArgs this_ptr_conv;
27888         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27889         this_ptr_conv.is_owned = false;
27890         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27891         // WARNING: This object doesn't live past this scope, needs clone!
27892         uint32_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv)) | 1;
27893         return ret_ret;
27894 }
27895
27896 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_fee_estimator"))) TS_ChannelManagerReadArgs_set_fee_estimator(uint32_t this_ptr, uint32_t val) {
27897         LDKChannelManagerReadArgs this_ptr_conv;
27898         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27899         this_ptr_conv.is_owned = false;
27900         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27901         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
27902         CHECK_ACCESS(val_ptr);
27903         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(val_ptr);
27904         if (val_conv.free == LDKFeeEstimator_JCalls_free) {
27905                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27906                 LDKFeeEstimator_JCalls_cloned(&val_conv);
27907         }
27908         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
27909 }
27910
27911 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_chain_monitor"))) TS_ChannelManagerReadArgs_get_chain_monitor(uint32_t this_ptr) {
27912         LDKChannelManagerReadArgs this_ptr_conv;
27913         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27914         this_ptr_conv.is_owned = false;
27915         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27916         // WARNING: This object doesn't live past this scope, needs clone!
27917         uint32_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv)) | 1;
27918         return ret_ret;
27919 }
27920
27921 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_chain_monitor"))) TS_ChannelManagerReadArgs_set_chain_monitor(uint32_t this_ptr, uint32_t val) {
27922         LDKChannelManagerReadArgs this_ptr_conv;
27923         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27924         this_ptr_conv.is_owned = false;
27925         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27926         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
27927         CHECK_ACCESS(val_ptr);
27928         LDKWatch val_conv = *(LDKWatch*)(val_ptr);
27929         if (val_conv.free == LDKWatch_JCalls_free) {
27930                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27931                 LDKWatch_JCalls_cloned(&val_conv);
27932         }
27933         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
27934 }
27935
27936 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_tx_broadcaster"))) TS_ChannelManagerReadArgs_get_tx_broadcaster(uint32_t this_ptr) {
27937         LDKChannelManagerReadArgs this_ptr_conv;
27938         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27939         this_ptr_conv.is_owned = false;
27940         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27941         // WARNING: This object doesn't live past this scope, needs clone!
27942         uint32_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv)) | 1;
27943         return ret_ret;
27944 }
27945
27946 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_tx_broadcaster"))) TS_ChannelManagerReadArgs_set_tx_broadcaster(uint32_t this_ptr, uint32_t val) {
27947         LDKChannelManagerReadArgs this_ptr_conv;
27948         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27949         this_ptr_conv.is_owned = false;
27950         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27951         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
27952         CHECK_ACCESS(val_ptr);
27953         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(val_ptr);
27954         if (val_conv.free == LDKBroadcasterInterface_JCalls_free) {
27955                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27956                 LDKBroadcasterInterface_JCalls_cloned(&val_conv);
27957         }
27958         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
27959 }
27960
27961 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_logger"))) TS_ChannelManagerReadArgs_get_logger(uint32_t this_ptr) {
27962         LDKChannelManagerReadArgs this_ptr_conv;
27963         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27964         this_ptr_conv.is_owned = false;
27965         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27966         // WARNING: This object doesn't live past this scope, needs clone!
27967         uint32_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_logger(&this_ptr_conv)) | 1;
27968         return ret_ret;
27969 }
27970
27971 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_logger"))) TS_ChannelManagerReadArgs_set_logger(uint32_t this_ptr, uint32_t val) {
27972         LDKChannelManagerReadArgs this_ptr_conv;
27973         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27974         this_ptr_conv.is_owned = false;
27975         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27976         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
27977         CHECK_ACCESS(val_ptr);
27978         LDKLogger val_conv = *(LDKLogger*)(val_ptr);
27979         if (val_conv.free == LDKLogger_JCalls_free) {
27980                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27981                 LDKLogger_JCalls_cloned(&val_conv);
27982         }
27983         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
27984 }
27985
27986 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_default_config"))) TS_ChannelManagerReadArgs_get_default_config(uint32_t this_ptr) {
27987         LDKChannelManagerReadArgs this_ptr_conv;
27988         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27989         this_ptr_conv.is_owned = false;
27990         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27991         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
27992         uint32_t ret_ref = 0;
27993         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27994         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27995         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27996         ret_ref = (uintptr_t)ret_var.inner;
27997         if (ret_var.is_owned) {
27998                 ret_ref |= 1;
27999         }
28000         return ret_ref;
28001 }
28002
28003 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_default_config"))) TS_ChannelManagerReadArgs_set_default_config(uint32_t this_ptr, uint32_t val) {
28004         LDKChannelManagerReadArgs this_ptr_conv;
28005         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28006         this_ptr_conv.is_owned = false;
28007         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28008         LDKUserConfig val_conv;
28009         val_conv.inner = (void*)(val & (~1));
28010         val_conv.is_owned = (val & 1) || (val == 0);
28011         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28012         val_conv = UserConfig_clone(&val_conv);
28013         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
28014 }
28015
28016 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_new"))) TS_ChannelManagerReadArgs_new(uint32_t keys_manager, uint32_t fee_estimator, uint32_t chain_monitor, uint32_t tx_broadcaster, uint32_t logger, uint32_t default_config, uint32_tArray channel_monitors) {
28017         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
28018         CHECK_ACCESS(keys_manager_ptr);
28019         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
28020         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
28021                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28022                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
28023         }
28024         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
28025         CHECK_ACCESS(fee_estimator_ptr);
28026         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
28027         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
28028                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28029                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
28030         }
28031         void* chain_monitor_ptr = (void*)(((uintptr_t)chain_monitor) & ~1);
28032         CHECK_ACCESS(chain_monitor_ptr);
28033         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
28034         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
28035                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28036                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
28037         }
28038         void* tx_broadcaster_ptr = (void*)(((uintptr_t)tx_broadcaster) & ~1);
28039         CHECK_ACCESS(tx_broadcaster_ptr);
28040         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
28041         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
28042                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28043                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
28044         }
28045         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
28046         CHECK_ACCESS(logger_ptr);
28047         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
28048         if (logger_conv.free == LDKLogger_JCalls_free) {
28049                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28050                 LDKLogger_JCalls_cloned(&logger_conv);
28051         }
28052         LDKUserConfig default_config_conv;
28053         default_config_conv.inner = (void*)(default_config & (~1));
28054         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
28055         CHECK_INNER_FIELD_ACCESS_OR_NULL(default_config_conv);
28056         default_config_conv = UserConfig_clone(&default_config_conv);
28057         LDKCVec_ChannelMonitorZ channel_monitors_constr;
28058         channel_monitors_constr.datalen = channel_monitors->arr_len;
28059         if (channel_monitors_constr.datalen > 0)
28060                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
28061         else
28062                 channel_monitors_constr.data = NULL;
28063         uint32_t* channel_monitors_vals = channel_monitors->elems;
28064         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
28065                 uint32_t channel_monitors_conv_16 = channel_monitors_vals[q];
28066                 LDKChannelMonitor channel_monitors_conv_16_conv;
28067                 channel_monitors_conv_16_conv.inner = (void*)(channel_monitors_conv_16 & (~1));
28068                 channel_monitors_conv_16_conv.is_owned = (channel_monitors_conv_16 & 1) || (channel_monitors_conv_16 == 0);
28069                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_monitors_conv_16_conv);
28070                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
28071         }
28072         FREE(channel_monitors);
28073         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);
28074         uint32_t ret_ref = 0;
28075         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28076         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28077         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28078         ret_ref = (uintptr_t)ret_var.inner;
28079         if (ret_var.is_owned) {
28080                 ret_ref |= 1;
28081         }
28082         return ret_ref;
28083 }
28084
28085 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_read"))) TS_C2Tuple_BlockHashChannelManagerZ_read(int8_tArray ser, uint32_t arg) {
28086         LDKu8slice ser_ref;
28087         ser_ref.datalen = ser->arr_len;
28088         ser_ref.data = ser->elems;
28089         LDKChannelManagerReadArgs arg_conv;
28090         arg_conv.inner = (void*)(arg & (~1));
28091         arg_conv.is_owned = (arg & 1) || (arg == 0);
28092         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28093         // WARNING: we need a move here but no clone is available for LDKChannelManagerReadArgs
28094         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
28095         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
28096         FREE(ser);
28097         return (uint32_t)ret_conv;
28098 }
28099
28100 void  __attribute__((export_name("TS_ExpandedKey_free"))) TS_ExpandedKey_free(uint32_t this_obj) {
28101         LDKExpandedKey this_obj_conv;
28102         this_obj_conv.inner = (void*)(this_obj & (~1));
28103         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28104         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28105         ExpandedKey_free(this_obj_conv);
28106 }
28107
28108 uint32_t  __attribute__((export_name("TS_ExpandedKey_new"))) TS_ExpandedKey_new(int8_tArray key_material) {
28109         unsigned char key_material_arr[32];
28110         CHECK(key_material->arr_len == 32);
28111         memcpy(key_material_arr, key_material->elems, 32); FREE(key_material);
28112         unsigned char (*key_material_ref)[32] = &key_material_arr;
28113         LDKExpandedKey ret_var = ExpandedKey_new(key_material_ref);
28114         uint32_t ret_ref = 0;
28115         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28116         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28117         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28118         ret_ref = (uintptr_t)ret_var.inner;
28119         if (ret_var.is_owned) {
28120                 ret_ref |= 1;
28121         }
28122         return ret_ref;
28123 }
28124
28125 uint32_t  __attribute__((export_name("TS_create"))) TS_create(uint32_t keys, uint32_t min_value_msat, int32_t invoice_expiry_delta_secs, uint32_t keys_manager, int64_t current_time) {
28126         LDKExpandedKey keys_conv;
28127         keys_conv.inner = (void*)(keys & (~1));
28128         keys_conv.is_owned = false;
28129         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
28130         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
28131         CHECK_ACCESS(min_value_msat_ptr);
28132         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
28133         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
28134         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
28135         if (!(keys_manager & 1)) { CHECK_ACCESS(keys_manager_ptr); }
28136         LDKKeysInterface* keys_manager_conv = (LDKKeysInterface*)keys_manager_ptr;
28137         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
28138         *ret_conv = create(&keys_conv, min_value_msat_conv, invoice_expiry_delta_secs, keys_manager_conv, current_time);
28139         return (uint32_t)ret_conv;
28140 }
28141
28142 uint32_t  __attribute__((export_name("TS_create_from_hash"))) TS_create_from_hash(uint32_t keys, uint32_t min_value_msat, int8_tArray payment_hash, int32_t invoice_expiry_delta_secs, int64_t current_time) {
28143         LDKExpandedKey keys_conv;
28144         keys_conv.inner = (void*)(keys & (~1));
28145         keys_conv.is_owned = false;
28146         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
28147         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
28148         CHECK_ACCESS(min_value_msat_ptr);
28149         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
28150         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
28151         LDKThirtyTwoBytes payment_hash_ref;
28152         CHECK(payment_hash->arr_len == 32);
28153         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
28154         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
28155         *ret_conv = create_from_hash(&keys_conv, min_value_msat_conv, payment_hash_ref, invoice_expiry_delta_secs, current_time);
28156         return (uint32_t)ret_conv;
28157 }
28158
28159 void  __attribute__((export_name("TS_DecodeError_free"))) TS_DecodeError_free(uint32_t this_obj) {
28160         LDKDecodeError this_obj_conv;
28161         this_obj_conv.inner = (void*)(this_obj & (~1));
28162         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28163         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28164         DecodeError_free(this_obj_conv);
28165 }
28166
28167 static inline uintptr_t DecodeError_clone_ptr(LDKDecodeError *NONNULL_PTR arg) {
28168         LDKDecodeError ret_var = DecodeError_clone(arg);
28169 uint32_t ret_ref = 0;
28170 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28171 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28172 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28173 ret_ref = (uintptr_t)ret_var.inner;
28174 if (ret_var.is_owned) {
28175         ret_ref |= 1;
28176 }
28177         return ret_ref;
28178 }
28179 uint32_t  __attribute__((export_name("TS_DecodeError_clone_ptr"))) TS_DecodeError_clone_ptr(uint32_t arg) {
28180         LDKDecodeError arg_conv;
28181         arg_conv.inner = (void*)(arg & (~1));
28182         arg_conv.is_owned = false;
28183         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28184         uint32_t ret_conv = DecodeError_clone_ptr(&arg_conv);
28185         return ret_conv;
28186 }
28187
28188 uint32_t  __attribute__((export_name("TS_DecodeError_clone"))) TS_DecodeError_clone(uint32_t orig) {
28189         LDKDecodeError orig_conv;
28190         orig_conv.inner = (void*)(orig & (~1));
28191         orig_conv.is_owned = false;
28192         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28193         LDKDecodeError ret_var = DecodeError_clone(&orig_conv);
28194         uint32_t ret_ref = 0;
28195         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28196         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28197         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28198         ret_ref = (uintptr_t)ret_var.inner;
28199         if (ret_var.is_owned) {
28200                 ret_ref |= 1;
28201         }
28202         return ret_ref;
28203 }
28204
28205 void  __attribute__((export_name("TS_Init_free"))) TS_Init_free(uint32_t this_obj) {
28206         LDKInit this_obj_conv;
28207         this_obj_conv.inner = (void*)(this_obj & (~1));
28208         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28209         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28210         Init_free(this_obj_conv);
28211 }
28212
28213 uint32_t  __attribute__((export_name("TS_Init_get_features"))) TS_Init_get_features(uint32_t this_ptr) {
28214         LDKInit this_ptr_conv;
28215         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28216         this_ptr_conv.is_owned = false;
28217         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28218         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
28219         uint32_t ret_ref = 0;
28220         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28221         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28222         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28223         ret_ref = (uintptr_t)ret_var.inner;
28224         if (ret_var.is_owned) {
28225                 ret_ref |= 1;
28226         }
28227         return ret_ref;
28228 }
28229
28230 void  __attribute__((export_name("TS_Init_set_features"))) TS_Init_set_features(uint32_t this_ptr, uint32_t val) {
28231         LDKInit this_ptr_conv;
28232         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28233         this_ptr_conv.is_owned = false;
28234         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28235         LDKInitFeatures val_conv;
28236         val_conv.inner = (void*)(val & (~1));
28237         val_conv.is_owned = (val & 1) || (val == 0);
28238         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28239         val_conv = InitFeatures_clone(&val_conv);
28240         Init_set_features(&this_ptr_conv, val_conv);
28241 }
28242
28243 uint32_t  __attribute__((export_name("TS_Init_get_remote_network_address"))) TS_Init_get_remote_network_address(uint32_t this_ptr) {
28244         LDKInit this_ptr_conv;
28245         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28246         this_ptr_conv.is_owned = false;
28247         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28248         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
28249         *ret_copy = Init_get_remote_network_address(&this_ptr_conv);
28250         uint32_t ret_ref = (uintptr_t)ret_copy;
28251         return ret_ref;
28252 }
28253
28254 void  __attribute__((export_name("TS_Init_set_remote_network_address"))) TS_Init_set_remote_network_address(uint32_t this_ptr, uint32_t val) {
28255         LDKInit this_ptr_conv;
28256         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28257         this_ptr_conv.is_owned = false;
28258         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28259         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
28260         CHECK_ACCESS(val_ptr);
28261         LDKCOption_NetAddressZ val_conv = *(LDKCOption_NetAddressZ*)(val_ptr);
28262         val_conv = COption_NetAddressZ_clone((LDKCOption_NetAddressZ*)(((uintptr_t)val) & ~1));
28263         Init_set_remote_network_address(&this_ptr_conv, val_conv);
28264 }
28265
28266 uint32_t  __attribute__((export_name("TS_Init_new"))) TS_Init_new(uint32_t features_arg, uint32_t remote_network_address_arg) {
28267         LDKInitFeatures features_arg_conv;
28268         features_arg_conv.inner = (void*)(features_arg & (~1));
28269         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
28270         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
28271         features_arg_conv = InitFeatures_clone(&features_arg_conv);
28272         void* remote_network_address_arg_ptr = (void*)(((uintptr_t)remote_network_address_arg) & ~1);
28273         CHECK_ACCESS(remote_network_address_arg_ptr);
28274         LDKCOption_NetAddressZ remote_network_address_arg_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_arg_ptr);
28275         LDKInit ret_var = Init_new(features_arg_conv, remote_network_address_arg_conv);
28276         uint32_t ret_ref = 0;
28277         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28278         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28279         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28280         ret_ref = (uintptr_t)ret_var.inner;
28281         if (ret_var.is_owned) {
28282                 ret_ref |= 1;
28283         }
28284         return ret_ref;
28285 }
28286
28287 static inline uintptr_t Init_clone_ptr(LDKInit *NONNULL_PTR arg) {
28288         LDKInit ret_var = Init_clone(arg);
28289 uint32_t ret_ref = 0;
28290 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28291 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28292 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28293 ret_ref = (uintptr_t)ret_var.inner;
28294 if (ret_var.is_owned) {
28295         ret_ref |= 1;
28296 }
28297         return ret_ref;
28298 }
28299 uint32_t  __attribute__((export_name("TS_Init_clone_ptr"))) TS_Init_clone_ptr(uint32_t arg) {
28300         LDKInit arg_conv;
28301         arg_conv.inner = (void*)(arg & (~1));
28302         arg_conv.is_owned = false;
28303         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28304         uint32_t ret_conv = Init_clone_ptr(&arg_conv);
28305         return ret_conv;
28306 }
28307
28308 uint32_t  __attribute__((export_name("TS_Init_clone"))) TS_Init_clone(uint32_t orig) {
28309         LDKInit orig_conv;
28310         orig_conv.inner = (void*)(orig & (~1));
28311         orig_conv.is_owned = false;
28312         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28313         LDKInit ret_var = Init_clone(&orig_conv);
28314         uint32_t ret_ref = 0;
28315         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28316         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28317         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28318         ret_ref = (uintptr_t)ret_var.inner;
28319         if (ret_var.is_owned) {
28320                 ret_ref |= 1;
28321         }
28322         return ret_ref;
28323 }
28324
28325 void  __attribute__((export_name("TS_ErrorMessage_free"))) TS_ErrorMessage_free(uint32_t this_obj) {
28326         LDKErrorMessage this_obj_conv;
28327         this_obj_conv.inner = (void*)(this_obj & (~1));
28328         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28329         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28330         ErrorMessage_free(this_obj_conv);
28331 }
28332
28333 int8_tArray  __attribute__((export_name("TS_ErrorMessage_get_channel_id"))) TS_ErrorMessage_get_channel_id(uint32_t this_ptr) {
28334         LDKErrorMessage this_ptr_conv;
28335         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28336         this_ptr_conv.is_owned = false;
28337         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28338         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28339         memcpy(ret_arr->elems, *ErrorMessage_get_channel_id(&this_ptr_conv), 32);
28340         return ret_arr;
28341 }
28342
28343 void  __attribute__((export_name("TS_ErrorMessage_set_channel_id"))) TS_ErrorMessage_set_channel_id(uint32_t this_ptr, int8_tArray val) {
28344         LDKErrorMessage this_ptr_conv;
28345         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28346         this_ptr_conv.is_owned = false;
28347         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28348         LDKThirtyTwoBytes val_ref;
28349         CHECK(val->arr_len == 32);
28350         memcpy(val_ref.data, val->elems, 32); FREE(val);
28351         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
28352 }
28353
28354 jstring  __attribute__((export_name("TS_ErrorMessage_get_data"))) TS_ErrorMessage_get_data(uint32_t this_ptr) {
28355         LDKErrorMessage this_ptr_conv;
28356         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28357         this_ptr_conv.is_owned = false;
28358         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28359         LDKStr ret_str = ErrorMessage_get_data(&this_ptr_conv);
28360         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
28361         Str_free(ret_str);
28362         return ret_conv;
28363 }
28364
28365 void  __attribute__((export_name("TS_ErrorMessage_set_data"))) TS_ErrorMessage_set_data(uint32_t this_ptr, jstring val) {
28366         LDKErrorMessage this_ptr_conv;
28367         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28368         this_ptr_conv.is_owned = false;
28369         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28370         LDKStr val_conv = str_ref_to_owned_c(val);
28371         ErrorMessage_set_data(&this_ptr_conv, val_conv);
28372 }
28373
28374 uint32_t  __attribute__((export_name("TS_ErrorMessage_new"))) TS_ErrorMessage_new(int8_tArray channel_id_arg, jstring data_arg) {
28375         LDKThirtyTwoBytes channel_id_arg_ref;
28376         CHECK(channel_id_arg->arr_len == 32);
28377         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
28378         LDKStr data_arg_conv = str_ref_to_owned_c(data_arg);
28379         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
28380         uint32_t ret_ref = 0;
28381         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28382         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28383         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28384         ret_ref = (uintptr_t)ret_var.inner;
28385         if (ret_var.is_owned) {
28386                 ret_ref |= 1;
28387         }
28388         return ret_ref;
28389 }
28390
28391 static inline uintptr_t ErrorMessage_clone_ptr(LDKErrorMessage *NONNULL_PTR arg) {
28392         LDKErrorMessage ret_var = ErrorMessage_clone(arg);
28393 uint32_t ret_ref = 0;
28394 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28395 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28396 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28397 ret_ref = (uintptr_t)ret_var.inner;
28398 if (ret_var.is_owned) {
28399         ret_ref |= 1;
28400 }
28401         return ret_ref;
28402 }
28403 uint32_t  __attribute__((export_name("TS_ErrorMessage_clone_ptr"))) TS_ErrorMessage_clone_ptr(uint32_t arg) {
28404         LDKErrorMessage arg_conv;
28405         arg_conv.inner = (void*)(arg & (~1));
28406         arg_conv.is_owned = false;
28407         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28408         uint32_t ret_conv = ErrorMessage_clone_ptr(&arg_conv);
28409         return ret_conv;
28410 }
28411
28412 uint32_t  __attribute__((export_name("TS_ErrorMessage_clone"))) TS_ErrorMessage_clone(uint32_t orig) {
28413         LDKErrorMessage orig_conv;
28414         orig_conv.inner = (void*)(orig & (~1));
28415         orig_conv.is_owned = false;
28416         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28417         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
28418         uint32_t ret_ref = 0;
28419         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28420         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28421         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28422         ret_ref = (uintptr_t)ret_var.inner;
28423         if (ret_var.is_owned) {
28424                 ret_ref |= 1;
28425         }
28426         return ret_ref;
28427 }
28428
28429 void  __attribute__((export_name("TS_WarningMessage_free"))) TS_WarningMessage_free(uint32_t this_obj) {
28430         LDKWarningMessage this_obj_conv;
28431         this_obj_conv.inner = (void*)(this_obj & (~1));
28432         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28433         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28434         WarningMessage_free(this_obj_conv);
28435 }
28436
28437 int8_tArray  __attribute__((export_name("TS_WarningMessage_get_channel_id"))) TS_WarningMessage_get_channel_id(uint32_t this_ptr) {
28438         LDKWarningMessage this_ptr_conv;
28439         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28440         this_ptr_conv.is_owned = false;
28441         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28442         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28443         memcpy(ret_arr->elems, *WarningMessage_get_channel_id(&this_ptr_conv), 32);
28444         return ret_arr;
28445 }
28446
28447 void  __attribute__((export_name("TS_WarningMessage_set_channel_id"))) TS_WarningMessage_set_channel_id(uint32_t this_ptr, int8_tArray val) {
28448         LDKWarningMessage this_ptr_conv;
28449         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28450         this_ptr_conv.is_owned = false;
28451         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28452         LDKThirtyTwoBytes val_ref;
28453         CHECK(val->arr_len == 32);
28454         memcpy(val_ref.data, val->elems, 32); FREE(val);
28455         WarningMessage_set_channel_id(&this_ptr_conv, val_ref);
28456 }
28457
28458 jstring  __attribute__((export_name("TS_WarningMessage_get_data"))) TS_WarningMessage_get_data(uint32_t this_ptr) {
28459         LDKWarningMessage this_ptr_conv;
28460         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28461         this_ptr_conv.is_owned = false;
28462         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28463         LDKStr ret_str = WarningMessage_get_data(&this_ptr_conv);
28464         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
28465         Str_free(ret_str);
28466         return ret_conv;
28467 }
28468
28469 void  __attribute__((export_name("TS_WarningMessage_set_data"))) TS_WarningMessage_set_data(uint32_t this_ptr, jstring val) {
28470         LDKWarningMessage this_ptr_conv;
28471         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28472         this_ptr_conv.is_owned = false;
28473         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28474         LDKStr val_conv = str_ref_to_owned_c(val);
28475         WarningMessage_set_data(&this_ptr_conv, val_conv);
28476 }
28477
28478 uint32_t  __attribute__((export_name("TS_WarningMessage_new"))) TS_WarningMessage_new(int8_tArray channel_id_arg, jstring data_arg) {
28479         LDKThirtyTwoBytes channel_id_arg_ref;
28480         CHECK(channel_id_arg->arr_len == 32);
28481         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
28482         LDKStr data_arg_conv = str_ref_to_owned_c(data_arg);
28483         LDKWarningMessage ret_var = WarningMessage_new(channel_id_arg_ref, data_arg_conv);
28484         uint32_t ret_ref = 0;
28485         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28486         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28487         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28488         ret_ref = (uintptr_t)ret_var.inner;
28489         if (ret_var.is_owned) {
28490                 ret_ref |= 1;
28491         }
28492         return ret_ref;
28493 }
28494
28495 static inline uintptr_t WarningMessage_clone_ptr(LDKWarningMessage *NONNULL_PTR arg) {
28496         LDKWarningMessage ret_var = WarningMessage_clone(arg);
28497 uint32_t ret_ref = 0;
28498 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28499 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28500 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28501 ret_ref = (uintptr_t)ret_var.inner;
28502 if (ret_var.is_owned) {
28503         ret_ref |= 1;
28504 }
28505         return ret_ref;
28506 }
28507 uint32_t  __attribute__((export_name("TS_WarningMessage_clone_ptr"))) TS_WarningMessage_clone_ptr(uint32_t arg) {
28508         LDKWarningMessage arg_conv;
28509         arg_conv.inner = (void*)(arg & (~1));
28510         arg_conv.is_owned = false;
28511         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28512         uint32_t ret_conv = WarningMessage_clone_ptr(&arg_conv);
28513         return ret_conv;
28514 }
28515
28516 uint32_t  __attribute__((export_name("TS_WarningMessage_clone"))) TS_WarningMessage_clone(uint32_t orig) {
28517         LDKWarningMessage orig_conv;
28518         orig_conv.inner = (void*)(orig & (~1));
28519         orig_conv.is_owned = false;
28520         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28521         LDKWarningMessage ret_var = WarningMessage_clone(&orig_conv);
28522         uint32_t ret_ref = 0;
28523         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28524         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28525         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28526         ret_ref = (uintptr_t)ret_var.inner;
28527         if (ret_var.is_owned) {
28528                 ret_ref |= 1;
28529         }
28530         return ret_ref;
28531 }
28532
28533 void  __attribute__((export_name("TS_Ping_free"))) TS_Ping_free(uint32_t this_obj) {
28534         LDKPing this_obj_conv;
28535         this_obj_conv.inner = (void*)(this_obj & (~1));
28536         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28537         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28538         Ping_free(this_obj_conv);
28539 }
28540
28541 int16_t  __attribute__((export_name("TS_Ping_get_ponglen"))) TS_Ping_get_ponglen(uint32_t this_ptr) {
28542         LDKPing this_ptr_conv;
28543         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28544         this_ptr_conv.is_owned = false;
28545         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28546         int16_t ret_conv = Ping_get_ponglen(&this_ptr_conv);
28547         return ret_conv;
28548 }
28549
28550 void  __attribute__((export_name("TS_Ping_set_ponglen"))) TS_Ping_set_ponglen(uint32_t this_ptr, int16_t val) {
28551         LDKPing this_ptr_conv;
28552         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28553         this_ptr_conv.is_owned = false;
28554         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28555         Ping_set_ponglen(&this_ptr_conv, val);
28556 }
28557
28558 int16_t  __attribute__((export_name("TS_Ping_get_byteslen"))) TS_Ping_get_byteslen(uint32_t this_ptr) {
28559         LDKPing this_ptr_conv;
28560         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28561         this_ptr_conv.is_owned = false;
28562         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28563         int16_t ret_conv = Ping_get_byteslen(&this_ptr_conv);
28564         return ret_conv;
28565 }
28566
28567 void  __attribute__((export_name("TS_Ping_set_byteslen"))) TS_Ping_set_byteslen(uint32_t this_ptr, int16_t val) {
28568         LDKPing this_ptr_conv;
28569         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28570         this_ptr_conv.is_owned = false;
28571         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28572         Ping_set_byteslen(&this_ptr_conv, val);
28573 }
28574
28575 uint32_t  __attribute__((export_name("TS_Ping_new"))) TS_Ping_new(int16_t ponglen_arg, int16_t byteslen_arg) {
28576         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
28577         uint32_t ret_ref = 0;
28578         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28579         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28580         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28581         ret_ref = (uintptr_t)ret_var.inner;
28582         if (ret_var.is_owned) {
28583                 ret_ref |= 1;
28584         }
28585         return ret_ref;
28586 }
28587
28588 static inline uintptr_t Ping_clone_ptr(LDKPing *NONNULL_PTR arg) {
28589         LDKPing ret_var = Ping_clone(arg);
28590 uint32_t ret_ref = 0;
28591 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28592 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28593 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28594 ret_ref = (uintptr_t)ret_var.inner;
28595 if (ret_var.is_owned) {
28596         ret_ref |= 1;
28597 }
28598         return ret_ref;
28599 }
28600 uint32_t  __attribute__((export_name("TS_Ping_clone_ptr"))) TS_Ping_clone_ptr(uint32_t arg) {
28601         LDKPing arg_conv;
28602         arg_conv.inner = (void*)(arg & (~1));
28603         arg_conv.is_owned = false;
28604         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28605         uint32_t ret_conv = Ping_clone_ptr(&arg_conv);
28606         return ret_conv;
28607 }
28608
28609 uint32_t  __attribute__((export_name("TS_Ping_clone"))) TS_Ping_clone(uint32_t orig) {
28610         LDKPing orig_conv;
28611         orig_conv.inner = (void*)(orig & (~1));
28612         orig_conv.is_owned = false;
28613         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28614         LDKPing ret_var = Ping_clone(&orig_conv);
28615         uint32_t ret_ref = 0;
28616         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28617         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28618         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28619         ret_ref = (uintptr_t)ret_var.inner;
28620         if (ret_var.is_owned) {
28621                 ret_ref |= 1;
28622         }
28623         return ret_ref;
28624 }
28625
28626 void  __attribute__((export_name("TS_Pong_free"))) TS_Pong_free(uint32_t this_obj) {
28627         LDKPong this_obj_conv;
28628         this_obj_conv.inner = (void*)(this_obj & (~1));
28629         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28630         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28631         Pong_free(this_obj_conv);
28632 }
28633
28634 int16_t  __attribute__((export_name("TS_Pong_get_byteslen"))) TS_Pong_get_byteslen(uint32_t this_ptr) {
28635         LDKPong this_ptr_conv;
28636         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28637         this_ptr_conv.is_owned = false;
28638         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28639         int16_t ret_conv = Pong_get_byteslen(&this_ptr_conv);
28640         return ret_conv;
28641 }
28642
28643 void  __attribute__((export_name("TS_Pong_set_byteslen"))) TS_Pong_set_byteslen(uint32_t this_ptr, int16_t val) {
28644         LDKPong this_ptr_conv;
28645         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28646         this_ptr_conv.is_owned = false;
28647         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28648         Pong_set_byteslen(&this_ptr_conv, val);
28649 }
28650
28651 uint32_t  __attribute__((export_name("TS_Pong_new"))) TS_Pong_new(int16_t byteslen_arg) {
28652         LDKPong ret_var = Pong_new(byteslen_arg);
28653         uint32_t ret_ref = 0;
28654         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28655         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28656         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28657         ret_ref = (uintptr_t)ret_var.inner;
28658         if (ret_var.is_owned) {
28659                 ret_ref |= 1;
28660         }
28661         return ret_ref;
28662 }
28663
28664 static inline uintptr_t Pong_clone_ptr(LDKPong *NONNULL_PTR arg) {
28665         LDKPong ret_var = Pong_clone(arg);
28666 uint32_t ret_ref = 0;
28667 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28668 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28669 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28670 ret_ref = (uintptr_t)ret_var.inner;
28671 if (ret_var.is_owned) {
28672         ret_ref |= 1;
28673 }
28674         return ret_ref;
28675 }
28676 uint32_t  __attribute__((export_name("TS_Pong_clone_ptr"))) TS_Pong_clone_ptr(uint32_t arg) {
28677         LDKPong arg_conv;
28678         arg_conv.inner = (void*)(arg & (~1));
28679         arg_conv.is_owned = false;
28680         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28681         uint32_t ret_conv = Pong_clone_ptr(&arg_conv);
28682         return ret_conv;
28683 }
28684
28685 uint32_t  __attribute__((export_name("TS_Pong_clone"))) TS_Pong_clone(uint32_t orig) {
28686         LDKPong orig_conv;
28687         orig_conv.inner = (void*)(orig & (~1));
28688         orig_conv.is_owned = false;
28689         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28690         LDKPong ret_var = Pong_clone(&orig_conv);
28691         uint32_t ret_ref = 0;
28692         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28693         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28694         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28695         ret_ref = (uintptr_t)ret_var.inner;
28696         if (ret_var.is_owned) {
28697                 ret_ref |= 1;
28698         }
28699         return ret_ref;
28700 }
28701
28702 void  __attribute__((export_name("TS_OpenChannel_free"))) TS_OpenChannel_free(uint32_t this_obj) {
28703         LDKOpenChannel this_obj_conv;
28704         this_obj_conv.inner = (void*)(this_obj & (~1));
28705         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28706         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28707         OpenChannel_free(this_obj_conv);
28708 }
28709
28710 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_chain_hash"))) TS_OpenChannel_get_chain_hash(uint32_t this_ptr) {
28711         LDKOpenChannel this_ptr_conv;
28712         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28713         this_ptr_conv.is_owned = false;
28714         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28715         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28716         memcpy(ret_arr->elems, *OpenChannel_get_chain_hash(&this_ptr_conv), 32);
28717         return ret_arr;
28718 }
28719
28720 void  __attribute__((export_name("TS_OpenChannel_set_chain_hash"))) TS_OpenChannel_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
28721         LDKOpenChannel this_ptr_conv;
28722         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28723         this_ptr_conv.is_owned = false;
28724         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28725         LDKThirtyTwoBytes val_ref;
28726         CHECK(val->arr_len == 32);
28727         memcpy(val_ref.data, val->elems, 32); FREE(val);
28728         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
28729 }
28730
28731 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_temporary_channel_id"))) TS_OpenChannel_get_temporary_channel_id(uint32_t this_ptr) {
28732         LDKOpenChannel this_ptr_conv;
28733         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28734         this_ptr_conv.is_owned = false;
28735         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28736         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28737         memcpy(ret_arr->elems, *OpenChannel_get_temporary_channel_id(&this_ptr_conv), 32);
28738         return ret_arr;
28739 }
28740
28741 void  __attribute__((export_name("TS_OpenChannel_set_temporary_channel_id"))) TS_OpenChannel_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
28742         LDKOpenChannel this_ptr_conv;
28743         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28744         this_ptr_conv.is_owned = false;
28745         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28746         LDKThirtyTwoBytes val_ref;
28747         CHECK(val->arr_len == 32);
28748         memcpy(val_ref.data, val->elems, 32); FREE(val);
28749         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
28750 }
28751
28752 int64_t  __attribute__((export_name("TS_OpenChannel_get_funding_satoshis"))) TS_OpenChannel_get_funding_satoshis(uint32_t this_ptr) {
28753         LDKOpenChannel this_ptr_conv;
28754         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28755         this_ptr_conv.is_owned = false;
28756         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28757         int64_t ret_conv = OpenChannel_get_funding_satoshis(&this_ptr_conv);
28758         return ret_conv;
28759 }
28760
28761 void  __attribute__((export_name("TS_OpenChannel_set_funding_satoshis"))) TS_OpenChannel_set_funding_satoshis(uint32_t this_ptr, int64_t val) {
28762         LDKOpenChannel this_ptr_conv;
28763         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28764         this_ptr_conv.is_owned = false;
28765         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28766         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
28767 }
28768
28769 int64_t  __attribute__((export_name("TS_OpenChannel_get_push_msat"))) TS_OpenChannel_get_push_msat(uint32_t this_ptr) {
28770         LDKOpenChannel this_ptr_conv;
28771         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28772         this_ptr_conv.is_owned = false;
28773         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28774         int64_t ret_conv = OpenChannel_get_push_msat(&this_ptr_conv);
28775         return ret_conv;
28776 }
28777
28778 void  __attribute__((export_name("TS_OpenChannel_set_push_msat"))) TS_OpenChannel_set_push_msat(uint32_t this_ptr, int64_t val) {
28779         LDKOpenChannel this_ptr_conv;
28780         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28781         this_ptr_conv.is_owned = false;
28782         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28783         OpenChannel_set_push_msat(&this_ptr_conv, val);
28784 }
28785
28786 int64_t  __attribute__((export_name("TS_OpenChannel_get_dust_limit_satoshis"))) TS_OpenChannel_get_dust_limit_satoshis(uint32_t this_ptr) {
28787         LDKOpenChannel this_ptr_conv;
28788         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28789         this_ptr_conv.is_owned = false;
28790         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28791         int64_t ret_conv = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
28792         return ret_conv;
28793 }
28794
28795 void  __attribute__((export_name("TS_OpenChannel_set_dust_limit_satoshis"))) TS_OpenChannel_set_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
28796         LDKOpenChannel this_ptr_conv;
28797         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28798         this_ptr_conv.is_owned = false;
28799         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28800         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
28801 }
28802
28803 int64_t  __attribute__((export_name("TS_OpenChannel_get_max_htlc_value_in_flight_msat"))) TS_OpenChannel_get_max_htlc_value_in_flight_msat(uint32_t this_ptr) {
28804         LDKOpenChannel this_ptr_conv;
28805         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28806         this_ptr_conv.is_owned = false;
28807         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28808         int64_t ret_conv = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
28809         return ret_conv;
28810 }
28811
28812 void  __attribute__((export_name("TS_OpenChannel_set_max_htlc_value_in_flight_msat"))) TS_OpenChannel_set_max_htlc_value_in_flight_msat(uint32_t this_ptr, int64_t val) {
28813         LDKOpenChannel this_ptr_conv;
28814         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28815         this_ptr_conv.is_owned = false;
28816         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28817         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
28818 }
28819
28820 int64_t  __attribute__((export_name("TS_OpenChannel_get_channel_reserve_satoshis"))) TS_OpenChannel_get_channel_reserve_satoshis(uint32_t this_ptr) {
28821         LDKOpenChannel this_ptr_conv;
28822         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28823         this_ptr_conv.is_owned = false;
28824         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28825         int64_t ret_conv = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
28826         return ret_conv;
28827 }
28828
28829 void  __attribute__((export_name("TS_OpenChannel_set_channel_reserve_satoshis"))) TS_OpenChannel_set_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
28830         LDKOpenChannel this_ptr_conv;
28831         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28832         this_ptr_conv.is_owned = false;
28833         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28834         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
28835 }
28836
28837 int64_t  __attribute__((export_name("TS_OpenChannel_get_htlc_minimum_msat"))) TS_OpenChannel_get_htlc_minimum_msat(uint32_t this_ptr) {
28838         LDKOpenChannel this_ptr_conv;
28839         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28840         this_ptr_conv.is_owned = false;
28841         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28842         int64_t ret_conv = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
28843         return ret_conv;
28844 }
28845
28846 void  __attribute__((export_name("TS_OpenChannel_set_htlc_minimum_msat"))) TS_OpenChannel_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
28847         LDKOpenChannel this_ptr_conv;
28848         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28849         this_ptr_conv.is_owned = false;
28850         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28851         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
28852 }
28853
28854 int32_t  __attribute__((export_name("TS_OpenChannel_get_feerate_per_kw"))) TS_OpenChannel_get_feerate_per_kw(uint32_t this_ptr) {
28855         LDKOpenChannel this_ptr_conv;
28856         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28857         this_ptr_conv.is_owned = false;
28858         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28859         int32_t ret_conv = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
28860         return ret_conv;
28861 }
28862
28863 void  __attribute__((export_name("TS_OpenChannel_set_feerate_per_kw"))) TS_OpenChannel_set_feerate_per_kw(uint32_t this_ptr, int32_t val) {
28864         LDKOpenChannel this_ptr_conv;
28865         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28866         this_ptr_conv.is_owned = false;
28867         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28868         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
28869 }
28870
28871 int16_t  __attribute__((export_name("TS_OpenChannel_get_to_self_delay"))) TS_OpenChannel_get_to_self_delay(uint32_t this_ptr) {
28872         LDKOpenChannel this_ptr_conv;
28873         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28874         this_ptr_conv.is_owned = false;
28875         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28876         int16_t ret_conv = OpenChannel_get_to_self_delay(&this_ptr_conv);
28877         return ret_conv;
28878 }
28879
28880 void  __attribute__((export_name("TS_OpenChannel_set_to_self_delay"))) TS_OpenChannel_set_to_self_delay(uint32_t this_ptr, int16_t val) {
28881         LDKOpenChannel this_ptr_conv;
28882         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28883         this_ptr_conv.is_owned = false;
28884         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28885         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
28886 }
28887
28888 int16_t  __attribute__((export_name("TS_OpenChannel_get_max_accepted_htlcs"))) TS_OpenChannel_get_max_accepted_htlcs(uint32_t this_ptr) {
28889         LDKOpenChannel this_ptr_conv;
28890         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28891         this_ptr_conv.is_owned = false;
28892         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28893         int16_t ret_conv = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
28894         return ret_conv;
28895 }
28896
28897 void  __attribute__((export_name("TS_OpenChannel_set_max_accepted_htlcs"))) TS_OpenChannel_set_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
28898         LDKOpenChannel this_ptr_conv;
28899         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28900         this_ptr_conv.is_owned = false;
28901         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28902         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
28903 }
28904
28905 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_funding_pubkey"))) TS_OpenChannel_get_funding_pubkey(uint32_t this_ptr) {
28906         LDKOpenChannel this_ptr_conv;
28907         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28908         this_ptr_conv.is_owned = false;
28909         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28910         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
28911         memcpy(ret_arr->elems, OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
28912         return ret_arr;
28913 }
28914
28915 void  __attribute__((export_name("TS_OpenChannel_set_funding_pubkey"))) TS_OpenChannel_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
28916         LDKOpenChannel this_ptr_conv;
28917         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28918         this_ptr_conv.is_owned = false;
28919         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28920         LDKPublicKey val_ref;
28921         CHECK(val->arr_len == 33);
28922         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
28923         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
28924 }
28925
28926 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_revocation_basepoint"))) TS_OpenChannel_get_revocation_basepoint(uint32_t this_ptr) {
28927         LDKOpenChannel this_ptr_conv;
28928         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28929         this_ptr_conv.is_owned = false;
28930         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28931         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
28932         memcpy(ret_arr->elems, OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
28933         return ret_arr;
28934 }
28935
28936 void  __attribute__((export_name("TS_OpenChannel_set_revocation_basepoint"))) TS_OpenChannel_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
28937         LDKOpenChannel this_ptr_conv;
28938         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28939         this_ptr_conv.is_owned = false;
28940         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28941         LDKPublicKey val_ref;
28942         CHECK(val->arr_len == 33);
28943         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
28944         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
28945 }
28946
28947 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_payment_point"))) TS_OpenChannel_get_payment_point(uint32_t this_ptr) {
28948         LDKOpenChannel this_ptr_conv;
28949         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28950         this_ptr_conv.is_owned = false;
28951         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28952         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
28953         memcpy(ret_arr->elems, OpenChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
28954         return ret_arr;
28955 }
28956
28957 void  __attribute__((export_name("TS_OpenChannel_set_payment_point"))) TS_OpenChannel_set_payment_point(uint32_t this_ptr, int8_tArray val) {
28958         LDKOpenChannel this_ptr_conv;
28959         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28960         this_ptr_conv.is_owned = false;
28961         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28962         LDKPublicKey val_ref;
28963         CHECK(val->arr_len == 33);
28964         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
28965         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
28966 }
28967
28968 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_delayed_payment_basepoint"))) TS_OpenChannel_get_delayed_payment_basepoint(uint32_t this_ptr) {
28969         LDKOpenChannel this_ptr_conv;
28970         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28971         this_ptr_conv.is_owned = false;
28972         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28973         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
28974         memcpy(ret_arr->elems, OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
28975         return ret_arr;
28976 }
28977
28978 void  __attribute__((export_name("TS_OpenChannel_set_delayed_payment_basepoint"))) TS_OpenChannel_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
28979         LDKOpenChannel this_ptr_conv;
28980         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28981         this_ptr_conv.is_owned = false;
28982         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28983         LDKPublicKey val_ref;
28984         CHECK(val->arr_len == 33);
28985         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
28986         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
28987 }
28988
28989 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_htlc_basepoint"))) TS_OpenChannel_get_htlc_basepoint(uint32_t this_ptr) {
28990         LDKOpenChannel this_ptr_conv;
28991         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28992         this_ptr_conv.is_owned = false;
28993         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28994         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
28995         memcpy(ret_arr->elems, OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
28996         return ret_arr;
28997 }
28998
28999 void  __attribute__((export_name("TS_OpenChannel_set_htlc_basepoint"))) TS_OpenChannel_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
29000         LDKOpenChannel this_ptr_conv;
29001         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29002         this_ptr_conv.is_owned = false;
29003         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29004         LDKPublicKey val_ref;
29005         CHECK(val->arr_len == 33);
29006         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29007         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
29008 }
29009
29010 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_first_per_commitment_point"))) TS_OpenChannel_get_first_per_commitment_point(uint32_t this_ptr) {
29011         LDKOpenChannel this_ptr_conv;
29012         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29013         this_ptr_conv.is_owned = false;
29014         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29015         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29016         memcpy(ret_arr->elems, OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
29017         return ret_arr;
29018 }
29019
29020 void  __attribute__((export_name("TS_OpenChannel_set_first_per_commitment_point"))) TS_OpenChannel_set_first_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
29021         LDKOpenChannel this_ptr_conv;
29022         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29023         this_ptr_conv.is_owned = false;
29024         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29025         LDKPublicKey val_ref;
29026         CHECK(val->arr_len == 33);
29027         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29028         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
29029 }
29030
29031 int8_t  __attribute__((export_name("TS_OpenChannel_get_channel_flags"))) TS_OpenChannel_get_channel_flags(uint32_t this_ptr) {
29032         LDKOpenChannel this_ptr_conv;
29033         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29034         this_ptr_conv.is_owned = false;
29035         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29036         int8_t ret_conv = OpenChannel_get_channel_flags(&this_ptr_conv);
29037         return ret_conv;
29038 }
29039
29040 void  __attribute__((export_name("TS_OpenChannel_set_channel_flags"))) TS_OpenChannel_set_channel_flags(uint32_t this_ptr, int8_t val) {
29041         LDKOpenChannel this_ptr_conv;
29042         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29043         this_ptr_conv.is_owned = false;
29044         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29045         OpenChannel_set_channel_flags(&this_ptr_conv, val);
29046 }
29047
29048 uint32_t  __attribute__((export_name("TS_OpenChannel_get_channel_type"))) TS_OpenChannel_get_channel_type(uint32_t this_ptr) {
29049         LDKOpenChannel this_ptr_conv;
29050         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29051         this_ptr_conv.is_owned = false;
29052         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29053         LDKChannelTypeFeatures ret_var = OpenChannel_get_channel_type(&this_ptr_conv);
29054         uint32_t ret_ref = 0;
29055         if ((uintptr_t)ret_var.inner > 4096) {
29056                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29057                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29058         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29059                 ret_ref = (uintptr_t)ret_var.inner;
29060                 if (ret_var.is_owned) {
29061                         ret_ref |= 1;
29062                 }
29063         }
29064         return ret_ref;
29065 }
29066
29067 void  __attribute__((export_name("TS_OpenChannel_set_channel_type"))) TS_OpenChannel_set_channel_type(uint32_t this_ptr, uint32_t val) {
29068         LDKOpenChannel this_ptr_conv;
29069         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29070         this_ptr_conv.is_owned = false;
29071         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29072         LDKChannelTypeFeatures val_conv;
29073         val_conv.inner = (void*)(val & (~1));
29074         val_conv.is_owned = (val & 1) || (val == 0);
29075         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29076         val_conv = ChannelTypeFeatures_clone(&val_conv);
29077         OpenChannel_set_channel_type(&this_ptr_conv, val_conv);
29078 }
29079
29080 static inline uintptr_t OpenChannel_clone_ptr(LDKOpenChannel *NONNULL_PTR arg) {
29081         LDKOpenChannel ret_var = OpenChannel_clone(arg);
29082 uint32_t ret_ref = 0;
29083 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29084 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29085 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29086 ret_ref = (uintptr_t)ret_var.inner;
29087 if (ret_var.is_owned) {
29088         ret_ref |= 1;
29089 }
29090         return ret_ref;
29091 }
29092 uint32_t  __attribute__((export_name("TS_OpenChannel_clone_ptr"))) TS_OpenChannel_clone_ptr(uint32_t arg) {
29093         LDKOpenChannel arg_conv;
29094         arg_conv.inner = (void*)(arg & (~1));
29095         arg_conv.is_owned = false;
29096         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29097         uint32_t ret_conv = OpenChannel_clone_ptr(&arg_conv);
29098         return ret_conv;
29099 }
29100
29101 uint32_t  __attribute__((export_name("TS_OpenChannel_clone"))) TS_OpenChannel_clone(uint32_t orig) {
29102         LDKOpenChannel orig_conv;
29103         orig_conv.inner = (void*)(orig & (~1));
29104         orig_conv.is_owned = false;
29105         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29106         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
29107         uint32_t ret_ref = 0;
29108         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29109         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29110         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29111         ret_ref = (uintptr_t)ret_var.inner;
29112         if (ret_var.is_owned) {
29113                 ret_ref |= 1;
29114         }
29115         return ret_ref;
29116 }
29117
29118 void  __attribute__((export_name("TS_AcceptChannel_free"))) TS_AcceptChannel_free(uint32_t this_obj) {
29119         LDKAcceptChannel this_obj_conv;
29120         this_obj_conv.inner = (void*)(this_obj & (~1));
29121         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29122         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29123         AcceptChannel_free(this_obj_conv);
29124 }
29125
29126 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_temporary_channel_id"))) TS_AcceptChannel_get_temporary_channel_id(uint32_t this_ptr) {
29127         LDKAcceptChannel this_ptr_conv;
29128         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29129         this_ptr_conv.is_owned = false;
29130         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29131         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29132         memcpy(ret_arr->elems, *AcceptChannel_get_temporary_channel_id(&this_ptr_conv), 32);
29133         return ret_arr;
29134 }
29135
29136 void  __attribute__((export_name("TS_AcceptChannel_set_temporary_channel_id"))) TS_AcceptChannel_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
29137         LDKAcceptChannel this_ptr_conv;
29138         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29139         this_ptr_conv.is_owned = false;
29140         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29141         LDKThirtyTwoBytes val_ref;
29142         CHECK(val->arr_len == 32);
29143         memcpy(val_ref.data, val->elems, 32); FREE(val);
29144         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
29145 }
29146
29147 int64_t  __attribute__((export_name("TS_AcceptChannel_get_dust_limit_satoshis"))) TS_AcceptChannel_get_dust_limit_satoshis(uint32_t this_ptr) {
29148         LDKAcceptChannel this_ptr_conv;
29149         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29150         this_ptr_conv.is_owned = false;
29151         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29152         int64_t ret_conv = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
29153         return ret_conv;
29154 }
29155
29156 void  __attribute__((export_name("TS_AcceptChannel_set_dust_limit_satoshis"))) TS_AcceptChannel_set_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
29157         LDKAcceptChannel this_ptr_conv;
29158         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29159         this_ptr_conv.is_owned = false;
29160         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29161         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
29162 }
29163
29164 int64_t  __attribute__((export_name("TS_AcceptChannel_get_max_htlc_value_in_flight_msat"))) TS_AcceptChannel_get_max_htlc_value_in_flight_msat(uint32_t this_ptr) {
29165         LDKAcceptChannel this_ptr_conv;
29166         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29167         this_ptr_conv.is_owned = false;
29168         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29169         int64_t ret_conv = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
29170         return ret_conv;
29171 }
29172
29173 void  __attribute__((export_name("TS_AcceptChannel_set_max_htlc_value_in_flight_msat"))) TS_AcceptChannel_set_max_htlc_value_in_flight_msat(uint32_t this_ptr, int64_t val) {
29174         LDKAcceptChannel this_ptr_conv;
29175         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29176         this_ptr_conv.is_owned = false;
29177         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29178         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
29179 }
29180
29181 int64_t  __attribute__((export_name("TS_AcceptChannel_get_channel_reserve_satoshis"))) TS_AcceptChannel_get_channel_reserve_satoshis(uint32_t this_ptr) {
29182         LDKAcceptChannel this_ptr_conv;
29183         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29184         this_ptr_conv.is_owned = false;
29185         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29186         int64_t ret_conv = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
29187         return ret_conv;
29188 }
29189
29190 void  __attribute__((export_name("TS_AcceptChannel_set_channel_reserve_satoshis"))) TS_AcceptChannel_set_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
29191         LDKAcceptChannel this_ptr_conv;
29192         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29193         this_ptr_conv.is_owned = false;
29194         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29195         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
29196 }
29197
29198 int64_t  __attribute__((export_name("TS_AcceptChannel_get_htlc_minimum_msat"))) TS_AcceptChannel_get_htlc_minimum_msat(uint32_t this_ptr) {
29199         LDKAcceptChannel this_ptr_conv;
29200         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29201         this_ptr_conv.is_owned = false;
29202         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29203         int64_t ret_conv = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
29204         return ret_conv;
29205 }
29206
29207 void  __attribute__((export_name("TS_AcceptChannel_set_htlc_minimum_msat"))) TS_AcceptChannel_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
29208         LDKAcceptChannel this_ptr_conv;
29209         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29210         this_ptr_conv.is_owned = false;
29211         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29212         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
29213 }
29214
29215 int32_t  __attribute__((export_name("TS_AcceptChannel_get_minimum_depth"))) TS_AcceptChannel_get_minimum_depth(uint32_t this_ptr) {
29216         LDKAcceptChannel this_ptr_conv;
29217         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29218         this_ptr_conv.is_owned = false;
29219         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29220         int32_t ret_conv = AcceptChannel_get_minimum_depth(&this_ptr_conv);
29221         return ret_conv;
29222 }
29223
29224 void  __attribute__((export_name("TS_AcceptChannel_set_minimum_depth"))) TS_AcceptChannel_set_minimum_depth(uint32_t this_ptr, int32_t val) {
29225         LDKAcceptChannel this_ptr_conv;
29226         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29227         this_ptr_conv.is_owned = false;
29228         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29229         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
29230 }
29231
29232 int16_t  __attribute__((export_name("TS_AcceptChannel_get_to_self_delay"))) TS_AcceptChannel_get_to_self_delay(uint32_t this_ptr) {
29233         LDKAcceptChannel this_ptr_conv;
29234         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29235         this_ptr_conv.is_owned = false;
29236         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29237         int16_t ret_conv = AcceptChannel_get_to_self_delay(&this_ptr_conv);
29238         return ret_conv;
29239 }
29240
29241 void  __attribute__((export_name("TS_AcceptChannel_set_to_self_delay"))) TS_AcceptChannel_set_to_self_delay(uint32_t this_ptr, int16_t val) {
29242         LDKAcceptChannel this_ptr_conv;
29243         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29244         this_ptr_conv.is_owned = false;
29245         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29246         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
29247 }
29248
29249 int16_t  __attribute__((export_name("TS_AcceptChannel_get_max_accepted_htlcs"))) TS_AcceptChannel_get_max_accepted_htlcs(uint32_t this_ptr) {
29250         LDKAcceptChannel this_ptr_conv;
29251         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29252         this_ptr_conv.is_owned = false;
29253         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29254         int16_t ret_conv = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
29255         return ret_conv;
29256 }
29257
29258 void  __attribute__((export_name("TS_AcceptChannel_set_max_accepted_htlcs"))) TS_AcceptChannel_set_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
29259         LDKAcceptChannel this_ptr_conv;
29260         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29261         this_ptr_conv.is_owned = false;
29262         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29263         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
29264 }
29265
29266 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_funding_pubkey"))) TS_AcceptChannel_get_funding_pubkey(uint32_t this_ptr) {
29267         LDKAcceptChannel this_ptr_conv;
29268         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29269         this_ptr_conv.is_owned = false;
29270         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29271         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29272         memcpy(ret_arr->elems, AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
29273         return ret_arr;
29274 }
29275
29276 void  __attribute__((export_name("TS_AcceptChannel_set_funding_pubkey"))) TS_AcceptChannel_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
29277         LDKAcceptChannel this_ptr_conv;
29278         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29279         this_ptr_conv.is_owned = false;
29280         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29281         LDKPublicKey val_ref;
29282         CHECK(val->arr_len == 33);
29283         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29284         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
29285 }
29286
29287 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_revocation_basepoint"))) TS_AcceptChannel_get_revocation_basepoint(uint32_t this_ptr) {
29288         LDKAcceptChannel this_ptr_conv;
29289         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29290         this_ptr_conv.is_owned = false;
29291         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29292         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29293         memcpy(ret_arr->elems, AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
29294         return ret_arr;
29295 }
29296
29297 void  __attribute__((export_name("TS_AcceptChannel_set_revocation_basepoint"))) TS_AcceptChannel_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
29298         LDKAcceptChannel this_ptr_conv;
29299         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29300         this_ptr_conv.is_owned = false;
29301         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29302         LDKPublicKey val_ref;
29303         CHECK(val->arr_len == 33);
29304         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29305         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
29306 }
29307
29308 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_payment_point"))) TS_AcceptChannel_get_payment_point(uint32_t this_ptr) {
29309         LDKAcceptChannel this_ptr_conv;
29310         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29311         this_ptr_conv.is_owned = false;
29312         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29313         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29314         memcpy(ret_arr->elems, AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
29315         return ret_arr;
29316 }
29317
29318 void  __attribute__((export_name("TS_AcceptChannel_set_payment_point"))) TS_AcceptChannel_set_payment_point(uint32_t this_ptr, int8_tArray val) {
29319         LDKAcceptChannel this_ptr_conv;
29320         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29321         this_ptr_conv.is_owned = false;
29322         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29323         LDKPublicKey val_ref;
29324         CHECK(val->arr_len == 33);
29325         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29326         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
29327 }
29328
29329 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_delayed_payment_basepoint"))) TS_AcceptChannel_get_delayed_payment_basepoint(uint32_t this_ptr) {
29330         LDKAcceptChannel this_ptr_conv;
29331         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29332         this_ptr_conv.is_owned = false;
29333         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29334         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29335         memcpy(ret_arr->elems, AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
29336         return ret_arr;
29337 }
29338
29339 void  __attribute__((export_name("TS_AcceptChannel_set_delayed_payment_basepoint"))) TS_AcceptChannel_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
29340         LDKAcceptChannel this_ptr_conv;
29341         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29342         this_ptr_conv.is_owned = false;
29343         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29344         LDKPublicKey val_ref;
29345         CHECK(val->arr_len == 33);
29346         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29347         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
29348 }
29349
29350 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_htlc_basepoint"))) TS_AcceptChannel_get_htlc_basepoint(uint32_t this_ptr) {
29351         LDKAcceptChannel this_ptr_conv;
29352         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29353         this_ptr_conv.is_owned = false;
29354         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29355         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29356         memcpy(ret_arr->elems, AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
29357         return ret_arr;
29358 }
29359
29360 void  __attribute__((export_name("TS_AcceptChannel_set_htlc_basepoint"))) TS_AcceptChannel_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
29361         LDKAcceptChannel this_ptr_conv;
29362         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29363         this_ptr_conv.is_owned = false;
29364         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29365         LDKPublicKey val_ref;
29366         CHECK(val->arr_len == 33);
29367         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29368         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
29369 }
29370
29371 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_first_per_commitment_point"))) TS_AcceptChannel_get_first_per_commitment_point(uint32_t this_ptr) {
29372         LDKAcceptChannel this_ptr_conv;
29373         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29374         this_ptr_conv.is_owned = false;
29375         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29376         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29377         memcpy(ret_arr->elems, AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
29378         return ret_arr;
29379 }
29380
29381 void  __attribute__((export_name("TS_AcceptChannel_set_first_per_commitment_point"))) TS_AcceptChannel_set_first_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
29382         LDKAcceptChannel this_ptr_conv;
29383         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29384         this_ptr_conv.is_owned = false;
29385         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29386         LDKPublicKey val_ref;
29387         CHECK(val->arr_len == 33);
29388         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29389         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
29390 }
29391
29392 uint32_t  __attribute__((export_name("TS_AcceptChannel_get_channel_type"))) TS_AcceptChannel_get_channel_type(uint32_t this_ptr) {
29393         LDKAcceptChannel this_ptr_conv;
29394         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29395         this_ptr_conv.is_owned = false;
29396         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29397         LDKChannelTypeFeatures ret_var = AcceptChannel_get_channel_type(&this_ptr_conv);
29398         uint32_t ret_ref = 0;
29399         if ((uintptr_t)ret_var.inner > 4096) {
29400                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29401                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29402         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29403                 ret_ref = (uintptr_t)ret_var.inner;
29404                 if (ret_var.is_owned) {
29405                         ret_ref |= 1;
29406                 }
29407         }
29408         return ret_ref;
29409 }
29410
29411 void  __attribute__((export_name("TS_AcceptChannel_set_channel_type"))) TS_AcceptChannel_set_channel_type(uint32_t this_ptr, uint32_t val) {
29412         LDKAcceptChannel this_ptr_conv;
29413         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29414         this_ptr_conv.is_owned = false;
29415         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29416         LDKChannelTypeFeatures val_conv;
29417         val_conv.inner = (void*)(val & (~1));
29418         val_conv.is_owned = (val & 1) || (val == 0);
29419         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29420         val_conv = ChannelTypeFeatures_clone(&val_conv);
29421         AcceptChannel_set_channel_type(&this_ptr_conv, val_conv);
29422 }
29423
29424 static inline uintptr_t AcceptChannel_clone_ptr(LDKAcceptChannel *NONNULL_PTR arg) {
29425         LDKAcceptChannel ret_var = AcceptChannel_clone(arg);
29426 uint32_t ret_ref = 0;
29427 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29428 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29429 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29430 ret_ref = (uintptr_t)ret_var.inner;
29431 if (ret_var.is_owned) {
29432         ret_ref |= 1;
29433 }
29434         return ret_ref;
29435 }
29436 uint32_t  __attribute__((export_name("TS_AcceptChannel_clone_ptr"))) TS_AcceptChannel_clone_ptr(uint32_t arg) {
29437         LDKAcceptChannel arg_conv;
29438         arg_conv.inner = (void*)(arg & (~1));
29439         arg_conv.is_owned = false;
29440         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29441         uint32_t ret_conv = AcceptChannel_clone_ptr(&arg_conv);
29442         return ret_conv;
29443 }
29444
29445 uint32_t  __attribute__((export_name("TS_AcceptChannel_clone"))) TS_AcceptChannel_clone(uint32_t orig) {
29446         LDKAcceptChannel orig_conv;
29447         orig_conv.inner = (void*)(orig & (~1));
29448         orig_conv.is_owned = false;
29449         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29450         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
29451         uint32_t ret_ref = 0;
29452         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29453         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29454         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29455         ret_ref = (uintptr_t)ret_var.inner;
29456         if (ret_var.is_owned) {
29457                 ret_ref |= 1;
29458         }
29459         return ret_ref;
29460 }
29461
29462 void  __attribute__((export_name("TS_FundingCreated_free"))) TS_FundingCreated_free(uint32_t this_obj) {
29463         LDKFundingCreated this_obj_conv;
29464         this_obj_conv.inner = (void*)(this_obj & (~1));
29465         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29466         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29467         FundingCreated_free(this_obj_conv);
29468 }
29469
29470 int8_tArray  __attribute__((export_name("TS_FundingCreated_get_temporary_channel_id"))) TS_FundingCreated_get_temporary_channel_id(uint32_t this_ptr) {
29471         LDKFundingCreated this_ptr_conv;
29472         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29473         this_ptr_conv.is_owned = false;
29474         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29475         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29476         memcpy(ret_arr->elems, *FundingCreated_get_temporary_channel_id(&this_ptr_conv), 32);
29477         return ret_arr;
29478 }
29479
29480 void  __attribute__((export_name("TS_FundingCreated_set_temporary_channel_id"))) TS_FundingCreated_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
29481         LDKFundingCreated this_ptr_conv;
29482         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29483         this_ptr_conv.is_owned = false;
29484         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29485         LDKThirtyTwoBytes val_ref;
29486         CHECK(val->arr_len == 32);
29487         memcpy(val_ref.data, val->elems, 32); FREE(val);
29488         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
29489 }
29490
29491 int8_tArray  __attribute__((export_name("TS_FundingCreated_get_funding_txid"))) TS_FundingCreated_get_funding_txid(uint32_t this_ptr) {
29492         LDKFundingCreated this_ptr_conv;
29493         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29494         this_ptr_conv.is_owned = false;
29495         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29496         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29497         memcpy(ret_arr->elems, *FundingCreated_get_funding_txid(&this_ptr_conv), 32);
29498         return ret_arr;
29499 }
29500
29501 void  __attribute__((export_name("TS_FundingCreated_set_funding_txid"))) TS_FundingCreated_set_funding_txid(uint32_t this_ptr, int8_tArray val) {
29502         LDKFundingCreated this_ptr_conv;
29503         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29504         this_ptr_conv.is_owned = false;
29505         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29506         LDKThirtyTwoBytes val_ref;
29507         CHECK(val->arr_len == 32);
29508         memcpy(val_ref.data, val->elems, 32); FREE(val);
29509         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
29510 }
29511
29512 int16_t  __attribute__((export_name("TS_FundingCreated_get_funding_output_index"))) TS_FundingCreated_get_funding_output_index(uint32_t this_ptr) {
29513         LDKFundingCreated this_ptr_conv;
29514         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29515         this_ptr_conv.is_owned = false;
29516         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29517         int16_t ret_conv = FundingCreated_get_funding_output_index(&this_ptr_conv);
29518         return ret_conv;
29519 }
29520
29521 void  __attribute__((export_name("TS_FundingCreated_set_funding_output_index"))) TS_FundingCreated_set_funding_output_index(uint32_t this_ptr, int16_t val) {
29522         LDKFundingCreated this_ptr_conv;
29523         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29524         this_ptr_conv.is_owned = false;
29525         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29526         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
29527 }
29528
29529 int8_tArray  __attribute__((export_name("TS_FundingCreated_get_signature"))) TS_FundingCreated_get_signature(uint32_t this_ptr) {
29530         LDKFundingCreated this_ptr_conv;
29531         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29532         this_ptr_conv.is_owned = false;
29533         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29534         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
29535         memcpy(ret_arr->elems, FundingCreated_get_signature(&this_ptr_conv).compact_form, 64);
29536         return ret_arr;
29537 }
29538
29539 void  __attribute__((export_name("TS_FundingCreated_set_signature"))) TS_FundingCreated_set_signature(uint32_t this_ptr, int8_tArray val) {
29540         LDKFundingCreated this_ptr_conv;
29541         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29542         this_ptr_conv.is_owned = false;
29543         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29544         LDKSignature val_ref;
29545         CHECK(val->arr_len == 64);
29546         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
29547         FundingCreated_set_signature(&this_ptr_conv, val_ref);
29548 }
29549
29550 uint32_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) {
29551         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
29552         CHECK(temporary_channel_id_arg->arr_len == 32);
29553         memcpy(temporary_channel_id_arg_ref.data, temporary_channel_id_arg->elems, 32); FREE(temporary_channel_id_arg);
29554         LDKThirtyTwoBytes funding_txid_arg_ref;
29555         CHECK(funding_txid_arg->arr_len == 32);
29556         memcpy(funding_txid_arg_ref.data, funding_txid_arg->elems, 32); FREE(funding_txid_arg);
29557         LDKSignature signature_arg_ref;
29558         CHECK(signature_arg->arr_len == 64);
29559         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
29560         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
29561         uint32_t ret_ref = 0;
29562         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29563         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29564         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29565         ret_ref = (uintptr_t)ret_var.inner;
29566         if (ret_var.is_owned) {
29567                 ret_ref |= 1;
29568         }
29569         return ret_ref;
29570 }
29571
29572 static inline uintptr_t FundingCreated_clone_ptr(LDKFundingCreated *NONNULL_PTR arg) {
29573         LDKFundingCreated ret_var = FundingCreated_clone(arg);
29574 uint32_t ret_ref = 0;
29575 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29576 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29577 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29578 ret_ref = (uintptr_t)ret_var.inner;
29579 if (ret_var.is_owned) {
29580         ret_ref |= 1;
29581 }
29582         return ret_ref;
29583 }
29584 uint32_t  __attribute__((export_name("TS_FundingCreated_clone_ptr"))) TS_FundingCreated_clone_ptr(uint32_t arg) {
29585         LDKFundingCreated arg_conv;
29586         arg_conv.inner = (void*)(arg & (~1));
29587         arg_conv.is_owned = false;
29588         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29589         uint32_t ret_conv = FundingCreated_clone_ptr(&arg_conv);
29590         return ret_conv;
29591 }
29592
29593 uint32_t  __attribute__((export_name("TS_FundingCreated_clone"))) TS_FundingCreated_clone(uint32_t orig) {
29594         LDKFundingCreated orig_conv;
29595         orig_conv.inner = (void*)(orig & (~1));
29596         orig_conv.is_owned = false;
29597         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29598         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
29599         uint32_t ret_ref = 0;
29600         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29601         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29602         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29603         ret_ref = (uintptr_t)ret_var.inner;
29604         if (ret_var.is_owned) {
29605                 ret_ref |= 1;
29606         }
29607         return ret_ref;
29608 }
29609
29610 void  __attribute__((export_name("TS_FundingSigned_free"))) TS_FundingSigned_free(uint32_t this_obj) {
29611         LDKFundingSigned this_obj_conv;
29612         this_obj_conv.inner = (void*)(this_obj & (~1));
29613         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29614         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29615         FundingSigned_free(this_obj_conv);
29616 }
29617
29618 int8_tArray  __attribute__((export_name("TS_FundingSigned_get_channel_id"))) TS_FundingSigned_get_channel_id(uint32_t this_ptr) {
29619         LDKFundingSigned this_ptr_conv;
29620         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29621         this_ptr_conv.is_owned = false;
29622         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29623         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29624         memcpy(ret_arr->elems, *FundingSigned_get_channel_id(&this_ptr_conv), 32);
29625         return ret_arr;
29626 }
29627
29628 void  __attribute__((export_name("TS_FundingSigned_set_channel_id"))) TS_FundingSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
29629         LDKFundingSigned this_ptr_conv;
29630         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29631         this_ptr_conv.is_owned = false;
29632         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29633         LDKThirtyTwoBytes val_ref;
29634         CHECK(val->arr_len == 32);
29635         memcpy(val_ref.data, val->elems, 32); FREE(val);
29636         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
29637 }
29638
29639 int8_tArray  __attribute__((export_name("TS_FundingSigned_get_signature"))) TS_FundingSigned_get_signature(uint32_t this_ptr) {
29640         LDKFundingSigned this_ptr_conv;
29641         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29642         this_ptr_conv.is_owned = false;
29643         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29644         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
29645         memcpy(ret_arr->elems, FundingSigned_get_signature(&this_ptr_conv).compact_form, 64);
29646         return ret_arr;
29647 }
29648
29649 void  __attribute__((export_name("TS_FundingSigned_set_signature"))) TS_FundingSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
29650         LDKFundingSigned this_ptr_conv;
29651         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29652         this_ptr_conv.is_owned = false;
29653         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29654         LDKSignature val_ref;
29655         CHECK(val->arr_len == 64);
29656         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
29657         FundingSigned_set_signature(&this_ptr_conv, val_ref);
29658 }
29659
29660 uint32_t  __attribute__((export_name("TS_FundingSigned_new"))) TS_FundingSigned_new(int8_tArray channel_id_arg, int8_tArray signature_arg) {
29661         LDKThirtyTwoBytes channel_id_arg_ref;
29662         CHECK(channel_id_arg->arr_len == 32);
29663         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
29664         LDKSignature signature_arg_ref;
29665         CHECK(signature_arg->arr_len == 64);
29666         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
29667         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
29668         uint32_t ret_ref = 0;
29669         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29670         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29671         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29672         ret_ref = (uintptr_t)ret_var.inner;
29673         if (ret_var.is_owned) {
29674                 ret_ref |= 1;
29675         }
29676         return ret_ref;
29677 }
29678
29679 static inline uintptr_t FundingSigned_clone_ptr(LDKFundingSigned *NONNULL_PTR arg) {
29680         LDKFundingSigned ret_var = FundingSigned_clone(arg);
29681 uint32_t ret_ref = 0;
29682 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29683 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29684 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29685 ret_ref = (uintptr_t)ret_var.inner;
29686 if (ret_var.is_owned) {
29687         ret_ref |= 1;
29688 }
29689         return ret_ref;
29690 }
29691 uint32_t  __attribute__((export_name("TS_FundingSigned_clone_ptr"))) TS_FundingSigned_clone_ptr(uint32_t arg) {
29692         LDKFundingSigned arg_conv;
29693         arg_conv.inner = (void*)(arg & (~1));
29694         arg_conv.is_owned = false;
29695         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29696         uint32_t ret_conv = FundingSigned_clone_ptr(&arg_conv);
29697         return ret_conv;
29698 }
29699
29700 uint32_t  __attribute__((export_name("TS_FundingSigned_clone"))) TS_FundingSigned_clone(uint32_t orig) {
29701         LDKFundingSigned orig_conv;
29702         orig_conv.inner = (void*)(orig & (~1));
29703         orig_conv.is_owned = false;
29704         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29705         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
29706         uint32_t ret_ref = 0;
29707         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29708         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29709         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29710         ret_ref = (uintptr_t)ret_var.inner;
29711         if (ret_var.is_owned) {
29712                 ret_ref |= 1;
29713         }
29714         return ret_ref;
29715 }
29716
29717 void  __attribute__((export_name("TS_ChannelReady_free"))) TS_ChannelReady_free(uint32_t this_obj) {
29718         LDKChannelReady this_obj_conv;
29719         this_obj_conv.inner = (void*)(this_obj & (~1));
29720         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29721         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29722         ChannelReady_free(this_obj_conv);
29723 }
29724
29725 int8_tArray  __attribute__((export_name("TS_ChannelReady_get_channel_id"))) TS_ChannelReady_get_channel_id(uint32_t this_ptr) {
29726         LDKChannelReady this_ptr_conv;
29727         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29728         this_ptr_conv.is_owned = false;
29729         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29730         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29731         memcpy(ret_arr->elems, *ChannelReady_get_channel_id(&this_ptr_conv), 32);
29732         return ret_arr;
29733 }
29734
29735 void  __attribute__((export_name("TS_ChannelReady_set_channel_id"))) TS_ChannelReady_set_channel_id(uint32_t this_ptr, int8_tArray val) {
29736         LDKChannelReady this_ptr_conv;
29737         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29738         this_ptr_conv.is_owned = false;
29739         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29740         LDKThirtyTwoBytes val_ref;
29741         CHECK(val->arr_len == 32);
29742         memcpy(val_ref.data, val->elems, 32); FREE(val);
29743         ChannelReady_set_channel_id(&this_ptr_conv, val_ref);
29744 }
29745
29746 int8_tArray  __attribute__((export_name("TS_ChannelReady_get_next_per_commitment_point"))) TS_ChannelReady_get_next_per_commitment_point(uint32_t this_ptr) {
29747         LDKChannelReady this_ptr_conv;
29748         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29749         this_ptr_conv.is_owned = false;
29750         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29751         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29752         memcpy(ret_arr->elems, ChannelReady_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
29753         return ret_arr;
29754 }
29755
29756 void  __attribute__((export_name("TS_ChannelReady_set_next_per_commitment_point"))) TS_ChannelReady_set_next_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
29757         LDKChannelReady this_ptr_conv;
29758         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29759         this_ptr_conv.is_owned = false;
29760         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29761         LDKPublicKey val_ref;
29762         CHECK(val->arr_len == 33);
29763         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29764         ChannelReady_set_next_per_commitment_point(&this_ptr_conv, val_ref);
29765 }
29766
29767 uint32_t  __attribute__((export_name("TS_ChannelReady_get_short_channel_id_alias"))) TS_ChannelReady_get_short_channel_id_alias(uint32_t this_ptr) {
29768         LDKChannelReady this_ptr_conv;
29769         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29770         this_ptr_conv.is_owned = false;
29771         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29772         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
29773         *ret_copy = ChannelReady_get_short_channel_id_alias(&this_ptr_conv);
29774         uint32_t ret_ref = (uintptr_t)ret_copy;
29775         return ret_ref;
29776 }
29777
29778 void  __attribute__((export_name("TS_ChannelReady_set_short_channel_id_alias"))) TS_ChannelReady_set_short_channel_id_alias(uint32_t this_ptr, uint32_t val) {
29779         LDKChannelReady this_ptr_conv;
29780         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29781         this_ptr_conv.is_owned = false;
29782         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29783         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29784         CHECK_ACCESS(val_ptr);
29785         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
29786         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
29787         ChannelReady_set_short_channel_id_alias(&this_ptr_conv, val_conv);
29788 }
29789
29790 uint32_t  __attribute__((export_name("TS_ChannelReady_new"))) TS_ChannelReady_new(int8_tArray channel_id_arg, int8_tArray next_per_commitment_point_arg, uint32_t short_channel_id_alias_arg) {
29791         LDKThirtyTwoBytes channel_id_arg_ref;
29792         CHECK(channel_id_arg->arr_len == 32);
29793         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
29794         LDKPublicKey next_per_commitment_point_arg_ref;
29795         CHECK(next_per_commitment_point_arg->arr_len == 33);
29796         memcpy(next_per_commitment_point_arg_ref.compressed_form, next_per_commitment_point_arg->elems, 33); FREE(next_per_commitment_point_arg);
29797         void* short_channel_id_alias_arg_ptr = (void*)(((uintptr_t)short_channel_id_alias_arg) & ~1);
29798         CHECK_ACCESS(short_channel_id_alias_arg_ptr);
29799         LDKCOption_u64Z short_channel_id_alias_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_alias_arg_ptr);
29800         short_channel_id_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id_alias_arg) & ~1));
29801         LDKChannelReady ret_var = ChannelReady_new(channel_id_arg_ref, next_per_commitment_point_arg_ref, short_channel_id_alias_arg_conv);
29802         uint32_t ret_ref = 0;
29803         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29804         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29805         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29806         ret_ref = (uintptr_t)ret_var.inner;
29807         if (ret_var.is_owned) {
29808                 ret_ref |= 1;
29809         }
29810         return ret_ref;
29811 }
29812
29813 static inline uintptr_t ChannelReady_clone_ptr(LDKChannelReady *NONNULL_PTR arg) {
29814         LDKChannelReady ret_var = ChannelReady_clone(arg);
29815 uint32_t ret_ref = 0;
29816 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29817 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29818 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29819 ret_ref = (uintptr_t)ret_var.inner;
29820 if (ret_var.is_owned) {
29821         ret_ref |= 1;
29822 }
29823         return ret_ref;
29824 }
29825 uint32_t  __attribute__((export_name("TS_ChannelReady_clone_ptr"))) TS_ChannelReady_clone_ptr(uint32_t arg) {
29826         LDKChannelReady arg_conv;
29827         arg_conv.inner = (void*)(arg & (~1));
29828         arg_conv.is_owned = false;
29829         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29830         uint32_t ret_conv = ChannelReady_clone_ptr(&arg_conv);
29831         return ret_conv;
29832 }
29833
29834 uint32_t  __attribute__((export_name("TS_ChannelReady_clone"))) TS_ChannelReady_clone(uint32_t orig) {
29835         LDKChannelReady orig_conv;
29836         orig_conv.inner = (void*)(orig & (~1));
29837         orig_conv.is_owned = false;
29838         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29839         LDKChannelReady ret_var = ChannelReady_clone(&orig_conv);
29840         uint32_t ret_ref = 0;
29841         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29842         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29843         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29844         ret_ref = (uintptr_t)ret_var.inner;
29845         if (ret_var.is_owned) {
29846                 ret_ref |= 1;
29847         }
29848         return ret_ref;
29849 }
29850
29851 void  __attribute__((export_name("TS_Shutdown_free"))) TS_Shutdown_free(uint32_t this_obj) {
29852         LDKShutdown this_obj_conv;
29853         this_obj_conv.inner = (void*)(this_obj & (~1));
29854         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29855         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29856         Shutdown_free(this_obj_conv);
29857 }
29858
29859 int8_tArray  __attribute__((export_name("TS_Shutdown_get_channel_id"))) TS_Shutdown_get_channel_id(uint32_t this_ptr) {
29860         LDKShutdown this_ptr_conv;
29861         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29862         this_ptr_conv.is_owned = false;
29863         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29864         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29865         memcpy(ret_arr->elems, *Shutdown_get_channel_id(&this_ptr_conv), 32);
29866         return ret_arr;
29867 }
29868
29869 void  __attribute__((export_name("TS_Shutdown_set_channel_id"))) TS_Shutdown_set_channel_id(uint32_t this_ptr, int8_tArray val) {
29870         LDKShutdown this_ptr_conv;
29871         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29872         this_ptr_conv.is_owned = false;
29873         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29874         LDKThirtyTwoBytes val_ref;
29875         CHECK(val->arr_len == 32);
29876         memcpy(val_ref.data, val->elems, 32); FREE(val);
29877         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
29878 }
29879
29880 int8_tArray  __attribute__((export_name("TS_Shutdown_get_scriptpubkey"))) TS_Shutdown_get_scriptpubkey(uint32_t this_ptr) {
29881         LDKShutdown this_ptr_conv;
29882         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29883         this_ptr_conv.is_owned = false;
29884         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29885         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
29886         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
29887         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
29888         return ret_arr;
29889 }
29890
29891 void  __attribute__((export_name("TS_Shutdown_set_scriptpubkey"))) TS_Shutdown_set_scriptpubkey(uint32_t this_ptr, int8_tArray val) {
29892         LDKShutdown this_ptr_conv;
29893         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29894         this_ptr_conv.is_owned = false;
29895         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29896         LDKCVec_u8Z val_ref;
29897         val_ref.datalen = val->arr_len;
29898         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
29899         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
29900         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
29901 }
29902
29903 uint32_t  __attribute__((export_name("TS_Shutdown_new"))) TS_Shutdown_new(int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
29904         LDKThirtyTwoBytes channel_id_arg_ref;
29905         CHECK(channel_id_arg->arr_len == 32);
29906         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
29907         LDKCVec_u8Z scriptpubkey_arg_ref;
29908         scriptpubkey_arg_ref.datalen = scriptpubkey_arg->arr_len;
29909         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
29910         memcpy(scriptpubkey_arg_ref.data, scriptpubkey_arg->elems, scriptpubkey_arg_ref.datalen); FREE(scriptpubkey_arg);
29911         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
29912         uint32_t ret_ref = 0;
29913         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29914         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29915         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29916         ret_ref = (uintptr_t)ret_var.inner;
29917         if (ret_var.is_owned) {
29918                 ret_ref |= 1;
29919         }
29920         return ret_ref;
29921 }
29922
29923 static inline uintptr_t Shutdown_clone_ptr(LDKShutdown *NONNULL_PTR arg) {
29924         LDKShutdown ret_var = Shutdown_clone(arg);
29925 uint32_t ret_ref = 0;
29926 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29927 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29928 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29929 ret_ref = (uintptr_t)ret_var.inner;
29930 if (ret_var.is_owned) {
29931         ret_ref |= 1;
29932 }
29933         return ret_ref;
29934 }
29935 uint32_t  __attribute__((export_name("TS_Shutdown_clone_ptr"))) TS_Shutdown_clone_ptr(uint32_t arg) {
29936         LDKShutdown arg_conv;
29937         arg_conv.inner = (void*)(arg & (~1));
29938         arg_conv.is_owned = false;
29939         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29940         uint32_t ret_conv = Shutdown_clone_ptr(&arg_conv);
29941         return ret_conv;
29942 }
29943
29944 uint32_t  __attribute__((export_name("TS_Shutdown_clone"))) TS_Shutdown_clone(uint32_t orig) {
29945         LDKShutdown orig_conv;
29946         orig_conv.inner = (void*)(orig & (~1));
29947         orig_conv.is_owned = false;
29948         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29949         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
29950         uint32_t ret_ref = 0;
29951         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29952         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29953         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29954         ret_ref = (uintptr_t)ret_var.inner;
29955         if (ret_var.is_owned) {
29956                 ret_ref |= 1;
29957         }
29958         return ret_ref;
29959 }
29960
29961 void  __attribute__((export_name("TS_ClosingSignedFeeRange_free"))) TS_ClosingSignedFeeRange_free(uint32_t this_obj) {
29962         LDKClosingSignedFeeRange this_obj_conv;
29963         this_obj_conv.inner = (void*)(this_obj & (~1));
29964         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29965         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29966         ClosingSignedFeeRange_free(this_obj_conv);
29967 }
29968
29969 int64_t  __attribute__((export_name("TS_ClosingSignedFeeRange_get_min_fee_satoshis"))) TS_ClosingSignedFeeRange_get_min_fee_satoshis(uint32_t this_ptr) {
29970         LDKClosingSignedFeeRange this_ptr_conv;
29971         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29972         this_ptr_conv.is_owned = false;
29973         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29974         int64_t ret_conv = ClosingSignedFeeRange_get_min_fee_satoshis(&this_ptr_conv);
29975         return ret_conv;
29976 }
29977
29978 void  __attribute__((export_name("TS_ClosingSignedFeeRange_set_min_fee_satoshis"))) TS_ClosingSignedFeeRange_set_min_fee_satoshis(uint32_t this_ptr, int64_t val) {
29979         LDKClosingSignedFeeRange this_ptr_conv;
29980         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29981         this_ptr_conv.is_owned = false;
29982         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29983         ClosingSignedFeeRange_set_min_fee_satoshis(&this_ptr_conv, val);
29984 }
29985
29986 int64_t  __attribute__((export_name("TS_ClosingSignedFeeRange_get_max_fee_satoshis"))) TS_ClosingSignedFeeRange_get_max_fee_satoshis(uint32_t this_ptr) {
29987         LDKClosingSignedFeeRange this_ptr_conv;
29988         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29989         this_ptr_conv.is_owned = false;
29990         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29991         int64_t ret_conv = ClosingSignedFeeRange_get_max_fee_satoshis(&this_ptr_conv);
29992         return ret_conv;
29993 }
29994
29995 void  __attribute__((export_name("TS_ClosingSignedFeeRange_set_max_fee_satoshis"))) TS_ClosingSignedFeeRange_set_max_fee_satoshis(uint32_t this_ptr, int64_t val) {
29996         LDKClosingSignedFeeRange this_ptr_conv;
29997         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29998         this_ptr_conv.is_owned = false;
29999         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30000         ClosingSignedFeeRange_set_max_fee_satoshis(&this_ptr_conv, val);
30001 }
30002
30003 uint32_t  __attribute__((export_name("TS_ClosingSignedFeeRange_new"))) TS_ClosingSignedFeeRange_new(int64_t min_fee_satoshis_arg, int64_t max_fee_satoshis_arg) {
30004         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_new(min_fee_satoshis_arg, max_fee_satoshis_arg);
30005         uint32_t ret_ref = 0;
30006         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30007         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30008         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30009         ret_ref = (uintptr_t)ret_var.inner;
30010         if (ret_var.is_owned) {
30011                 ret_ref |= 1;
30012         }
30013         return ret_ref;
30014 }
30015
30016 static inline uintptr_t ClosingSignedFeeRange_clone_ptr(LDKClosingSignedFeeRange *NONNULL_PTR arg) {
30017         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(arg);
30018 uint32_t ret_ref = 0;
30019 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30020 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30021 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30022 ret_ref = (uintptr_t)ret_var.inner;
30023 if (ret_var.is_owned) {
30024         ret_ref |= 1;
30025 }
30026         return ret_ref;
30027 }
30028 uint32_t  __attribute__((export_name("TS_ClosingSignedFeeRange_clone_ptr"))) TS_ClosingSignedFeeRange_clone_ptr(uint32_t arg) {
30029         LDKClosingSignedFeeRange arg_conv;
30030         arg_conv.inner = (void*)(arg & (~1));
30031         arg_conv.is_owned = false;
30032         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30033         uint32_t ret_conv = ClosingSignedFeeRange_clone_ptr(&arg_conv);
30034         return ret_conv;
30035 }
30036
30037 uint32_t  __attribute__((export_name("TS_ClosingSignedFeeRange_clone"))) TS_ClosingSignedFeeRange_clone(uint32_t orig) {
30038         LDKClosingSignedFeeRange orig_conv;
30039         orig_conv.inner = (void*)(orig & (~1));
30040         orig_conv.is_owned = false;
30041         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30042         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(&orig_conv);
30043         uint32_t ret_ref = 0;
30044         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30045         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30046         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30047         ret_ref = (uintptr_t)ret_var.inner;
30048         if (ret_var.is_owned) {
30049                 ret_ref |= 1;
30050         }
30051         return ret_ref;
30052 }
30053
30054 void  __attribute__((export_name("TS_ClosingSigned_free"))) TS_ClosingSigned_free(uint32_t this_obj) {
30055         LDKClosingSigned this_obj_conv;
30056         this_obj_conv.inner = (void*)(this_obj & (~1));
30057         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30058         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30059         ClosingSigned_free(this_obj_conv);
30060 }
30061
30062 int8_tArray  __attribute__((export_name("TS_ClosingSigned_get_channel_id"))) TS_ClosingSigned_get_channel_id(uint32_t this_ptr) {
30063         LDKClosingSigned this_ptr_conv;
30064         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30065         this_ptr_conv.is_owned = false;
30066         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30067         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30068         memcpy(ret_arr->elems, *ClosingSigned_get_channel_id(&this_ptr_conv), 32);
30069         return ret_arr;
30070 }
30071
30072 void  __attribute__((export_name("TS_ClosingSigned_set_channel_id"))) TS_ClosingSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
30073         LDKClosingSigned this_ptr_conv;
30074         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30075         this_ptr_conv.is_owned = false;
30076         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30077         LDKThirtyTwoBytes val_ref;
30078         CHECK(val->arr_len == 32);
30079         memcpy(val_ref.data, val->elems, 32); FREE(val);
30080         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
30081 }
30082
30083 int64_t  __attribute__((export_name("TS_ClosingSigned_get_fee_satoshis"))) TS_ClosingSigned_get_fee_satoshis(uint32_t this_ptr) {
30084         LDKClosingSigned this_ptr_conv;
30085         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30086         this_ptr_conv.is_owned = false;
30087         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30088         int64_t ret_conv = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
30089         return ret_conv;
30090 }
30091
30092 void  __attribute__((export_name("TS_ClosingSigned_set_fee_satoshis"))) TS_ClosingSigned_set_fee_satoshis(uint32_t this_ptr, int64_t val) {
30093         LDKClosingSigned this_ptr_conv;
30094         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30095         this_ptr_conv.is_owned = false;
30096         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30097         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
30098 }
30099
30100 int8_tArray  __attribute__((export_name("TS_ClosingSigned_get_signature"))) TS_ClosingSigned_get_signature(uint32_t this_ptr) {
30101         LDKClosingSigned this_ptr_conv;
30102         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30103         this_ptr_conv.is_owned = false;
30104         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30105         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
30106         memcpy(ret_arr->elems, ClosingSigned_get_signature(&this_ptr_conv).compact_form, 64);
30107         return ret_arr;
30108 }
30109
30110 void  __attribute__((export_name("TS_ClosingSigned_set_signature"))) TS_ClosingSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
30111         LDKClosingSigned this_ptr_conv;
30112         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30113         this_ptr_conv.is_owned = false;
30114         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30115         LDKSignature val_ref;
30116         CHECK(val->arr_len == 64);
30117         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
30118         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
30119 }
30120
30121 uint32_t  __attribute__((export_name("TS_ClosingSigned_get_fee_range"))) TS_ClosingSigned_get_fee_range(uint32_t this_ptr) {
30122         LDKClosingSigned this_ptr_conv;
30123         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30124         this_ptr_conv.is_owned = false;
30125         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30126         LDKClosingSignedFeeRange ret_var = ClosingSigned_get_fee_range(&this_ptr_conv);
30127         uint32_t ret_ref = 0;
30128         if ((uintptr_t)ret_var.inner > 4096) {
30129                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30130                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30131         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30132                 ret_ref = (uintptr_t)ret_var.inner;
30133                 if (ret_var.is_owned) {
30134                         ret_ref |= 1;
30135                 }
30136         }
30137         return ret_ref;
30138 }
30139
30140 void  __attribute__((export_name("TS_ClosingSigned_set_fee_range"))) TS_ClosingSigned_set_fee_range(uint32_t this_ptr, uint32_t val) {
30141         LDKClosingSigned this_ptr_conv;
30142         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30143         this_ptr_conv.is_owned = false;
30144         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30145         LDKClosingSignedFeeRange val_conv;
30146         val_conv.inner = (void*)(val & (~1));
30147         val_conv.is_owned = (val & 1) || (val == 0);
30148         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30149         val_conv = ClosingSignedFeeRange_clone(&val_conv);
30150         ClosingSigned_set_fee_range(&this_ptr_conv, val_conv);
30151 }
30152
30153 uint32_t  __attribute__((export_name("TS_ClosingSigned_new"))) TS_ClosingSigned_new(int8_tArray channel_id_arg, int64_t fee_satoshis_arg, int8_tArray signature_arg, uint32_t fee_range_arg) {
30154         LDKThirtyTwoBytes channel_id_arg_ref;
30155         CHECK(channel_id_arg->arr_len == 32);
30156         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
30157         LDKSignature signature_arg_ref;
30158         CHECK(signature_arg->arr_len == 64);
30159         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
30160         LDKClosingSignedFeeRange fee_range_arg_conv;
30161         fee_range_arg_conv.inner = (void*)(fee_range_arg & (~1));
30162         fee_range_arg_conv.is_owned = (fee_range_arg & 1) || (fee_range_arg == 0);
30163         CHECK_INNER_FIELD_ACCESS_OR_NULL(fee_range_arg_conv);
30164         fee_range_arg_conv = ClosingSignedFeeRange_clone(&fee_range_arg_conv);
30165         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref, fee_range_arg_conv);
30166         uint32_t ret_ref = 0;
30167         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30168         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30169         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30170         ret_ref = (uintptr_t)ret_var.inner;
30171         if (ret_var.is_owned) {
30172                 ret_ref |= 1;
30173         }
30174         return ret_ref;
30175 }
30176
30177 static inline uintptr_t ClosingSigned_clone_ptr(LDKClosingSigned *NONNULL_PTR arg) {
30178         LDKClosingSigned ret_var = ClosingSigned_clone(arg);
30179 uint32_t ret_ref = 0;
30180 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30181 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30182 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30183 ret_ref = (uintptr_t)ret_var.inner;
30184 if (ret_var.is_owned) {
30185         ret_ref |= 1;
30186 }
30187         return ret_ref;
30188 }
30189 uint32_t  __attribute__((export_name("TS_ClosingSigned_clone_ptr"))) TS_ClosingSigned_clone_ptr(uint32_t arg) {
30190         LDKClosingSigned arg_conv;
30191         arg_conv.inner = (void*)(arg & (~1));
30192         arg_conv.is_owned = false;
30193         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30194         uint32_t ret_conv = ClosingSigned_clone_ptr(&arg_conv);
30195         return ret_conv;
30196 }
30197
30198 uint32_t  __attribute__((export_name("TS_ClosingSigned_clone"))) TS_ClosingSigned_clone(uint32_t orig) {
30199         LDKClosingSigned orig_conv;
30200         orig_conv.inner = (void*)(orig & (~1));
30201         orig_conv.is_owned = false;
30202         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30203         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
30204         uint32_t ret_ref = 0;
30205         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30206         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30207         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30208         ret_ref = (uintptr_t)ret_var.inner;
30209         if (ret_var.is_owned) {
30210                 ret_ref |= 1;
30211         }
30212         return ret_ref;
30213 }
30214
30215 void  __attribute__((export_name("TS_UpdateAddHTLC_free"))) TS_UpdateAddHTLC_free(uint32_t this_obj) {
30216         LDKUpdateAddHTLC this_obj_conv;
30217         this_obj_conv.inner = (void*)(this_obj & (~1));
30218         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30219         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30220         UpdateAddHTLC_free(this_obj_conv);
30221 }
30222
30223 int8_tArray  __attribute__((export_name("TS_UpdateAddHTLC_get_channel_id"))) TS_UpdateAddHTLC_get_channel_id(uint32_t this_ptr) {
30224         LDKUpdateAddHTLC this_ptr_conv;
30225         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30226         this_ptr_conv.is_owned = false;
30227         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30228         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30229         memcpy(ret_arr->elems, *UpdateAddHTLC_get_channel_id(&this_ptr_conv), 32);
30230         return ret_arr;
30231 }
30232
30233 void  __attribute__((export_name("TS_UpdateAddHTLC_set_channel_id"))) TS_UpdateAddHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
30234         LDKUpdateAddHTLC this_ptr_conv;
30235         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30236         this_ptr_conv.is_owned = false;
30237         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30238         LDKThirtyTwoBytes val_ref;
30239         CHECK(val->arr_len == 32);
30240         memcpy(val_ref.data, val->elems, 32); FREE(val);
30241         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
30242 }
30243
30244 int64_t  __attribute__((export_name("TS_UpdateAddHTLC_get_htlc_id"))) TS_UpdateAddHTLC_get_htlc_id(uint32_t this_ptr) {
30245         LDKUpdateAddHTLC this_ptr_conv;
30246         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30247         this_ptr_conv.is_owned = false;
30248         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30249         int64_t ret_conv = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
30250         return ret_conv;
30251 }
30252
30253 void  __attribute__((export_name("TS_UpdateAddHTLC_set_htlc_id"))) TS_UpdateAddHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
30254         LDKUpdateAddHTLC this_ptr_conv;
30255         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30256         this_ptr_conv.is_owned = false;
30257         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30258         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
30259 }
30260
30261 int64_t  __attribute__((export_name("TS_UpdateAddHTLC_get_amount_msat"))) TS_UpdateAddHTLC_get_amount_msat(uint32_t this_ptr) {
30262         LDKUpdateAddHTLC this_ptr_conv;
30263         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30264         this_ptr_conv.is_owned = false;
30265         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30266         int64_t ret_conv = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
30267         return ret_conv;
30268 }
30269
30270 void  __attribute__((export_name("TS_UpdateAddHTLC_set_amount_msat"))) TS_UpdateAddHTLC_set_amount_msat(uint32_t this_ptr, int64_t val) {
30271         LDKUpdateAddHTLC this_ptr_conv;
30272         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30273         this_ptr_conv.is_owned = false;
30274         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30275         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
30276 }
30277
30278 int8_tArray  __attribute__((export_name("TS_UpdateAddHTLC_get_payment_hash"))) TS_UpdateAddHTLC_get_payment_hash(uint32_t this_ptr) {
30279         LDKUpdateAddHTLC this_ptr_conv;
30280         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30281         this_ptr_conv.is_owned = false;
30282         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30283         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30284         memcpy(ret_arr->elems, *UpdateAddHTLC_get_payment_hash(&this_ptr_conv), 32);
30285         return ret_arr;
30286 }
30287
30288 void  __attribute__((export_name("TS_UpdateAddHTLC_set_payment_hash"))) TS_UpdateAddHTLC_set_payment_hash(uint32_t this_ptr, int8_tArray val) {
30289         LDKUpdateAddHTLC this_ptr_conv;
30290         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30291         this_ptr_conv.is_owned = false;
30292         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30293         LDKThirtyTwoBytes val_ref;
30294         CHECK(val->arr_len == 32);
30295         memcpy(val_ref.data, val->elems, 32); FREE(val);
30296         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
30297 }
30298
30299 int32_t  __attribute__((export_name("TS_UpdateAddHTLC_get_cltv_expiry"))) TS_UpdateAddHTLC_get_cltv_expiry(uint32_t this_ptr) {
30300         LDKUpdateAddHTLC this_ptr_conv;
30301         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30302         this_ptr_conv.is_owned = false;
30303         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30304         int32_t ret_conv = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
30305         return ret_conv;
30306 }
30307
30308 void  __attribute__((export_name("TS_UpdateAddHTLC_set_cltv_expiry"))) TS_UpdateAddHTLC_set_cltv_expiry(uint32_t this_ptr, int32_t val) {
30309         LDKUpdateAddHTLC this_ptr_conv;
30310         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30311         this_ptr_conv.is_owned = false;
30312         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30313         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
30314 }
30315
30316 static inline uintptr_t UpdateAddHTLC_clone_ptr(LDKUpdateAddHTLC *NONNULL_PTR arg) {
30317         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(arg);
30318 uint32_t ret_ref = 0;
30319 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30320 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30321 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30322 ret_ref = (uintptr_t)ret_var.inner;
30323 if (ret_var.is_owned) {
30324         ret_ref |= 1;
30325 }
30326         return ret_ref;
30327 }
30328 uint32_t  __attribute__((export_name("TS_UpdateAddHTLC_clone_ptr"))) TS_UpdateAddHTLC_clone_ptr(uint32_t arg) {
30329         LDKUpdateAddHTLC arg_conv;
30330         arg_conv.inner = (void*)(arg & (~1));
30331         arg_conv.is_owned = false;
30332         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30333         uint32_t ret_conv = UpdateAddHTLC_clone_ptr(&arg_conv);
30334         return ret_conv;
30335 }
30336
30337 uint32_t  __attribute__((export_name("TS_UpdateAddHTLC_clone"))) TS_UpdateAddHTLC_clone(uint32_t orig) {
30338         LDKUpdateAddHTLC orig_conv;
30339         orig_conv.inner = (void*)(orig & (~1));
30340         orig_conv.is_owned = false;
30341         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30342         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
30343         uint32_t ret_ref = 0;
30344         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30345         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30346         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30347         ret_ref = (uintptr_t)ret_var.inner;
30348         if (ret_var.is_owned) {
30349                 ret_ref |= 1;
30350         }
30351         return ret_ref;
30352 }
30353
30354 void  __attribute__((export_name("TS_UpdateFulfillHTLC_free"))) TS_UpdateFulfillHTLC_free(uint32_t this_obj) {
30355         LDKUpdateFulfillHTLC this_obj_conv;
30356         this_obj_conv.inner = (void*)(this_obj & (~1));
30357         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30358         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30359         UpdateFulfillHTLC_free(this_obj_conv);
30360 }
30361
30362 int8_tArray  __attribute__((export_name("TS_UpdateFulfillHTLC_get_channel_id"))) TS_UpdateFulfillHTLC_get_channel_id(uint32_t this_ptr) {
30363         LDKUpdateFulfillHTLC this_ptr_conv;
30364         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30365         this_ptr_conv.is_owned = false;
30366         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30367         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30368         memcpy(ret_arr->elems, *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv), 32);
30369         return ret_arr;
30370 }
30371
30372 void  __attribute__((export_name("TS_UpdateFulfillHTLC_set_channel_id"))) TS_UpdateFulfillHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
30373         LDKUpdateFulfillHTLC this_ptr_conv;
30374         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30375         this_ptr_conv.is_owned = false;
30376         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30377         LDKThirtyTwoBytes val_ref;
30378         CHECK(val->arr_len == 32);
30379         memcpy(val_ref.data, val->elems, 32); FREE(val);
30380         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
30381 }
30382
30383 int64_t  __attribute__((export_name("TS_UpdateFulfillHTLC_get_htlc_id"))) TS_UpdateFulfillHTLC_get_htlc_id(uint32_t this_ptr) {
30384         LDKUpdateFulfillHTLC this_ptr_conv;
30385         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30386         this_ptr_conv.is_owned = false;
30387         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30388         int64_t ret_conv = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
30389         return ret_conv;
30390 }
30391
30392 void  __attribute__((export_name("TS_UpdateFulfillHTLC_set_htlc_id"))) TS_UpdateFulfillHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
30393         LDKUpdateFulfillHTLC this_ptr_conv;
30394         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30395         this_ptr_conv.is_owned = false;
30396         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30397         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
30398 }
30399
30400 int8_tArray  __attribute__((export_name("TS_UpdateFulfillHTLC_get_payment_preimage"))) TS_UpdateFulfillHTLC_get_payment_preimage(uint32_t this_ptr) {
30401         LDKUpdateFulfillHTLC this_ptr_conv;
30402         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30403         this_ptr_conv.is_owned = false;
30404         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30405         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30406         memcpy(ret_arr->elems, *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv), 32);
30407         return ret_arr;
30408 }
30409
30410 void  __attribute__((export_name("TS_UpdateFulfillHTLC_set_payment_preimage"))) TS_UpdateFulfillHTLC_set_payment_preimage(uint32_t this_ptr, int8_tArray val) {
30411         LDKUpdateFulfillHTLC this_ptr_conv;
30412         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30413         this_ptr_conv.is_owned = false;
30414         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30415         LDKThirtyTwoBytes val_ref;
30416         CHECK(val->arr_len == 32);
30417         memcpy(val_ref.data, val->elems, 32); FREE(val);
30418         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
30419 }
30420
30421 uint32_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) {
30422         LDKThirtyTwoBytes channel_id_arg_ref;
30423         CHECK(channel_id_arg->arr_len == 32);
30424         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
30425         LDKThirtyTwoBytes payment_preimage_arg_ref;
30426         CHECK(payment_preimage_arg->arr_len == 32);
30427         memcpy(payment_preimage_arg_ref.data, payment_preimage_arg->elems, 32); FREE(payment_preimage_arg);
30428         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
30429         uint32_t ret_ref = 0;
30430         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30431         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30432         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30433         ret_ref = (uintptr_t)ret_var.inner;
30434         if (ret_var.is_owned) {
30435                 ret_ref |= 1;
30436         }
30437         return ret_ref;
30438 }
30439
30440 static inline uintptr_t UpdateFulfillHTLC_clone_ptr(LDKUpdateFulfillHTLC *NONNULL_PTR arg) {
30441         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(arg);
30442 uint32_t ret_ref = 0;
30443 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30444 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30445 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30446 ret_ref = (uintptr_t)ret_var.inner;
30447 if (ret_var.is_owned) {
30448         ret_ref |= 1;
30449 }
30450         return ret_ref;
30451 }
30452 uint32_t  __attribute__((export_name("TS_UpdateFulfillHTLC_clone_ptr"))) TS_UpdateFulfillHTLC_clone_ptr(uint32_t arg) {
30453         LDKUpdateFulfillHTLC arg_conv;
30454         arg_conv.inner = (void*)(arg & (~1));
30455         arg_conv.is_owned = false;
30456         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30457         uint32_t ret_conv = UpdateFulfillHTLC_clone_ptr(&arg_conv);
30458         return ret_conv;
30459 }
30460
30461 uint32_t  __attribute__((export_name("TS_UpdateFulfillHTLC_clone"))) TS_UpdateFulfillHTLC_clone(uint32_t orig) {
30462         LDKUpdateFulfillHTLC orig_conv;
30463         orig_conv.inner = (void*)(orig & (~1));
30464         orig_conv.is_owned = false;
30465         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30466         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
30467         uint32_t ret_ref = 0;
30468         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30469         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30470         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30471         ret_ref = (uintptr_t)ret_var.inner;
30472         if (ret_var.is_owned) {
30473                 ret_ref |= 1;
30474         }
30475         return ret_ref;
30476 }
30477
30478 void  __attribute__((export_name("TS_UpdateFailHTLC_free"))) TS_UpdateFailHTLC_free(uint32_t this_obj) {
30479         LDKUpdateFailHTLC this_obj_conv;
30480         this_obj_conv.inner = (void*)(this_obj & (~1));
30481         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30482         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30483         UpdateFailHTLC_free(this_obj_conv);
30484 }
30485
30486 int8_tArray  __attribute__((export_name("TS_UpdateFailHTLC_get_channel_id"))) TS_UpdateFailHTLC_get_channel_id(uint32_t this_ptr) {
30487         LDKUpdateFailHTLC this_ptr_conv;
30488         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30489         this_ptr_conv.is_owned = false;
30490         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30491         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30492         memcpy(ret_arr->elems, *UpdateFailHTLC_get_channel_id(&this_ptr_conv), 32);
30493         return ret_arr;
30494 }
30495
30496 void  __attribute__((export_name("TS_UpdateFailHTLC_set_channel_id"))) TS_UpdateFailHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
30497         LDKUpdateFailHTLC this_ptr_conv;
30498         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30499         this_ptr_conv.is_owned = false;
30500         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30501         LDKThirtyTwoBytes val_ref;
30502         CHECK(val->arr_len == 32);
30503         memcpy(val_ref.data, val->elems, 32); FREE(val);
30504         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
30505 }
30506
30507 int64_t  __attribute__((export_name("TS_UpdateFailHTLC_get_htlc_id"))) TS_UpdateFailHTLC_get_htlc_id(uint32_t this_ptr) {
30508         LDKUpdateFailHTLC this_ptr_conv;
30509         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30510         this_ptr_conv.is_owned = false;
30511         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30512         int64_t ret_conv = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
30513         return ret_conv;
30514 }
30515
30516 void  __attribute__((export_name("TS_UpdateFailHTLC_set_htlc_id"))) TS_UpdateFailHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
30517         LDKUpdateFailHTLC this_ptr_conv;
30518         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30519         this_ptr_conv.is_owned = false;
30520         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30521         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
30522 }
30523
30524 static inline uintptr_t UpdateFailHTLC_clone_ptr(LDKUpdateFailHTLC *NONNULL_PTR arg) {
30525         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(arg);
30526 uint32_t ret_ref = 0;
30527 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30528 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30529 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30530 ret_ref = (uintptr_t)ret_var.inner;
30531 if (ret_var.is_owned) {
30532         ret_ref |= 1;
30533 }
30534         return ret_ref;
30535 }
30536 uint32_t  __attribute__((export_name("TS_UpdateFailHTLC_clone_ptr"))) TS_UpdateFailHTLC_clone_ptr(uint32_t arg) {
30537         LDKUpdateFailHTLC arg_conv;
30538         arg_conv.inner = (void*)(arg & (~1));
30539         arg_conv.is_owned = false;
30540         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30541         uint32_t ret_conv = UpdateFailHTLC_clone_ptr(&arg_conv);
30542         return ret_conv;
30543 }
30544
30545 uint32_t  __attribute__((export_name("TS_UpdateFailHTLC_clone"))) TS_UpdateFailHTLC_clone(uint32_t orig) {
30546         LDKUpdateFailHTLC orig_conv;
30547         orig_conv.inner = (void*)(orig & (~1));
30548         orig_conv.is_owned = false;
30549         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30550         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
30551         uint32_t ret_ref = 0;
30552         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30553         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30554         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30555         ret_ref = (uintptr_t)ret_var.inner;
30556         if (ret_var.is_owned) {
30557                 ret_ref |= 1;
30558         }
30559         return ret_ref;
30560 }
30561
30562 void  __attribute__((export_name("TS_UpdateFailMalformedHTLC_free"))) TS_UpdateFailMalformedHTLC_free(uint32_t this_obj) {
30563         LDKUpdateFailMalformedHTLC this_obj_conv;
30564         this_obj_conv.inner = (void*)(this_obj & (~1));
30565         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30566         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30567         UpdateFailMalformedHTLC_free(this_obj_conv);
30568 }
30569
30570 int8_tArray  __attribute__((export_name("TS_UpdateFailMalformedHTLC_get_channel_id"))) TS_UpdateFailMalformedHTLC_get_channel_id(uint32_t this_ptr) {
30571         LDKUpdateFailMalformedHTLC this_ptr_conv;
30572         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30573         this_ptr_conv.is_owned = false;
30574         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30575         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30576         memcpy(ret_arr->elems, *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv), 32);
30577         return ret_arr;
30578 }
30579
30580 void  __attribute__((export_name("TS_UpdateFailMalformedHTLC_set_channel_id"))) TS_UpdateFailMalformedHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
30581         LDKUpdateFailMalformedHTLC this_ptr_conv;
30582         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30583         this_ptr_conv.is_owned = false;
30584         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30585         LDKThirtyTwoBytes val_ref;
30586         CHECK(val->arr_len == 32);
30587         memcpy(val_ref.data, val->elems, 32); FREE(val);
30588         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
30589 }
30590
30591 int64_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_get_htlc_id"))) TS_UpdateFailMalformedHTLC_get_htlc_id(uint32_t this_ptr) {
30592         LDKUpdateFailMalformedHTLC this_ptr_conv;
30593         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30594         this_ptr_conv.is_owned = false;
30595         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30596         int64_t ret_conv = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
30597         return ret_conv;
30598 }
30599
30600 void  __attribute__((export_name("TS_UpdateFailMalformedHTLC_set_htlc_id"))) TS_UpdateFailMalformedHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
30601         LDKUpdateFailMalformedHTLC this_ptr_conv;
30602         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30603         this_ptr_conv.is_owned = false;
30604         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30605         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
30606 }
30607
30608 int16_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_get_failure_code"))) TS_UpdateFailMalformedHTLC_get_failure_code(uint32_t this_ptr) {
30609         LDKUpdateFailMalformedHTLC this_ptr_conv;
30610         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30611         this_ptr_conv.is_owned = false;
30612         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30613         int16_t ret_conv = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
30614         return ret_conv;
30615 }
30616
30617 void  __attribute__((export_name("TS_UpdateFailMalformedHTLC_set_failure_code"))) TS_UpdateFailMalformedHTLC_set_failure_code(uint32_t this_ptr, int16_t val) {
30618         LDKUpdateFailMalformedHTLC this_ptr_conv;
30619         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30620         this_ptr_conv.is_owned = false;
30621         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30622         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
30623 }
30624
30625 static inline uintptr_t UpdateFailMalformedHTLC_clone_ptr(LDKUpdateFailMalformedHTLC *NONNULL_PTR arg) {
30626         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(arg);
30627 uint32_t ret_ref = 0;
30628 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30629 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30630 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30631 ret_ref = (uintptr_t)ret_var.inner;
30632 if (ret_var.is_owned) {
30633         ret_ref |= 1;
30634 }
30635         return ret_ref;
30636 }
30637 uint32_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_clone_ptr"))) TS_UpdateFailMalformedHTLC_clone_ptr(uint32_t arg) {
30638         LDKUpdateFailMalformedHTLC arg_conv;
30639         arg_conv.inner = (void*)(arg & (~1));
30640         arg_conv.is_owned = false;
30641         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30642         uint32_t ret_conv = UpdateFailMalformedHTLC_clone_ptr(&arg_conv);
30643         return ret_conv;
30644 }
30645
30646 uint32_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_clone"))) TS_UpdateFailMalformedHTLC_clone(uint32_t orig) {
30647         LDKUpdateFailMalformedHTLC orig_conv;
30648         orig_conv.inner = (void*)(orig & (~1));
30649         orig_conv.is_owned = false;
30650         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30651         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
30652         uint32_t ret_ref = 0;
30653         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30654         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30655         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30656         ret_ref = (uintptr_t)ret_var.inner;
30657         if (ret_var.is_owned) {
30658                 ret_ref |= 1;
30659         }
30660         return ret_ref;
30661 }
30662
30663 void  __attribute__((export_name("TS_CommitmentSigned_free"))) TS_CommitmentSigned_free(uint32_t this_obj) {
30664         LDKCommitmentSigned this_obj_conv;
30665         this_obj_conv.inner = (void*)(this_obj & (~1));
30666         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30667         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30668         CommitmentSigned_free(this_obj_conv);
30669 }
30670
30671 int8_tArray  __attribute__((export_name("TS_CommitmentSigned_get_channel_id"))) TS_CommitmentSigned_get_channel_id(uint32_t this_ptr) {
30672         LDKCommitmentSigned this_ptr_conv;
30673         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30674         this_ptr_conv.is_owned = false;
30675         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30676         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30677         memcpy(ret_arr->elems, *CommitmentSigned_get_channel_id(&this_ptr_conv), 32);
30678         return ret_arr;
30679 }
30680
30681 void  __attribute__((export_name("TS_CommitmentSigned_set_channel_id"))) TS_CommitmentSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
30682         LDKCommitmentSigned this_ptr_conv;
30683         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30684         this_ptr_conv.is_owned = false;
30685         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30686         LDKThirtyTwoBytes val_ref;
30687         CHECK(val->arr_len == 32);
30688         memcpy(val_ref.data, val->elems, 32); FREE(val);
30689         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
30690 }
30691
30692 int8_tArray  __attribute__((export_name("TS_CommitmentSigned_get_signature"))) TS_CommitmentSigned_get_signature(uint32_t this_ptr) {
30693         LDKCommitmentSigned this_ptr_conv;
30694         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30695         this_ptr_conv.is_owned = false;
30696         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30697         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
30698         memcpy(ret_arr->elems, CommitmentSigned_get_signature(&this_ptr_conv).compact_form, 64);
30699         return ret_arr;
30700 }
30701
30702 void  __attribute__((export_name("TS_CommitmentSigned_set_signature"))) TS_CommitmentSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
30703         LDKCommitmentSigned this_ptr_conv;
30704         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30705         this_ptr_conv.is_owned = false;
30706         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30707         LDKSignature val_ref;
30708         CHECK(val->arr_len == 64);
30709         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
30710         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
30711 }
30712
30713 ptrArray  __attribute__((export_name("TS_CommitmentSigned_get_htlc_signatures"))) TS_CommitmentSigned_get_htlc_signatures(uint32_t this_ptr) {
30714         LDKCommitmentSigned this_ptr_conv;
30715         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30716         this_ptr_conv.is_owned = false;
30717         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30718         LDKCVec_SignatureZ ret_var = CommitmentSigned_get_htlc_signatures(&this_ptr_conv);
30719         ptrArray ret_arr = NULL;
30720         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
30721         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 8);
30722         for (size_t m = 0; m < ret_var.datalen; m++) {
30723                 int8_tArray ret_conv_12_arr = init_int8_tArray(64, __LINE__);
30724                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].compact_form, 64);
30725                 ret_arr_ptr[m] = ret_conv_12_arr;
30726         }
30727         
30728         FREE(ret_var.data);
30729         return ret_arr;
30730 }
30731
30732 void  __attribute__((export_name("TS_CommitmentSigned_set_htlc_signatures"))) TS_CommitmentSigned_set_htlc_signatures(uint32_t this_ptr, ptrArray val) {
30733         LDKCommitmentSigned this_ptr_conv;
30734         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30735         this_ptr_conv.is_owned = false;
30736         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30737         LDKCVec_SignatureZ val_constr;
30738         val_constr.datalen = val->arr_len;
30739         if (val_constr.datalen > 0)
30740                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
30741         else
30742                 val_constr.data = NULL;
30743         int8_tArray* val_vals = (void*) val->elems;
30744         for (size_t m = 0; m < val_constr.datalen; m++) {
30745                 int8_tArray val_conv_12 = val_vals[m];
30746                 LDKSignature val_conv_12_ref;
30747                 CHECK(val_conv_12->arr_len == 64);
30748                 memcpy(val_conv_12_ref.compact_form, val_conv_12->elems, 64); FREE(val_conv_12);
30749                 val_constr.data[m] = val_conv_12_ref;
30750         }
30751         FREE(val);
30752         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
30753 }
30754
30755 uint32_t  __attribute__((export_name("TS_CommitmentSigned_new"))) TS_CommitmentSigned_new(int8_tArray channel_id_arg, int8_tArray signature_arg, ptrArray htlc_signatures_arg) {
30756         LDKThirtyTwoBytes channel_id_arg_ref;
30757         CHECK(channel_id_arg->arr_len == 32);
30758         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
30759         LDKSignature signature_arg_ref;
30760         CHECK(signature_arg->arr_len == 64);
30761         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
30762         LDKCVec_SignatureZ htlc_signatures_arg_constr;
30763         htlc_signatures_arg_constr.datalen = htlc_signatures_arg->arr_len;
30764         if (htlc_signatures_arg_constr.datalen > 0)
30765                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
30766         else
30767                 htlc_signatures_arg_constr.data = NULL;
30768         int8_tArray* htlc_signatures_arg_vals = (void*) htlc_signatures_arg->elems;
30769         for (size_t m = 0; m < htlc_signatures_arg_constr.datalen; m++) {
30770                 int8_tArray htlc_signatures_arg_conv_12 = htlc_signatures_arg_vals[m];
30771                 LDKSignature htlc_signatures_arg_conv_12_ref;
30772                 CHECK(htlc_signatures_arg_conv_12->arr_len == 64);
30773                 memcpy(htlc_signatures_arg_conv_12_ref.compact_form, htlc_signatures_arg_conv_12->elems, 64); FREE(htlc_signatures_arg_conv_12);
30774                 htlc_signatures_arg_constr.data[m] = htlc_signatures_arg_conv_12_ref;
30775         }
30776         FREE(htlc_signatures_arg);
30777         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
30778         uint32_t ret_ref = 0;
30779         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30780         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30781         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30782         ret_ref = (uintptr_t)ret_var.inner;
30783         if (ret_var.is_owned) {
30784                 ret_ref |= 1;
30785         }
30786         return ret_ref;
30787 }
30788
30789 static inline uintptr_t CommitmentSigned_clone_ptr(LDKCommitmentSigned *NONNULL_PTR arg) {
30790         LDKCommitmentSigned ret_var = CommitmentSigned_clone(arg);
30791 uint32_t ret_ref = 0;
30792 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30793 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30794 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30795 ret_ref = (uintptr_t)ret_var.inner;
30796 if (ret_var.is_owned) {
30797         ret_ref |= 1;
30798 }
30799         return ret_ref;
30800 }
30801 uint32_t  __attribute__((export_name("TS_CommitmentSigned_clone_ptr"))) TS_CommitmentSigned_clone_ptr(uint32_t arg) {
30802         LDKCommitmentSigned arg_conv;
30803         arg_conv.inner = (void*)(arg & (~1));
30804         arg_conv.is_owned = false;
30805         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30806         uint32_t ret_conv = CommitmentSigned_clone_ptr(&arg_conv);
30807         return ret_conv;
30808 }
30809
30810 uint32_t  __attribute__((export_name("TS_CommitmentSigned_clone"))) TS_CommitmentSigned_clone(uint32_t orig) {
30811         LDKCommitmentSigned orig_conv;
30812         orig_conv.inner = (void*)(orig & (~1));
30813         orig_conv.is_owned = false;
30814         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30815         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
30816         uint32_t ret_ref = 0;
30817         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30818         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30819         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30820         ret_ref = (uintptr_t)ret_var.inner;
30821         if (ret_var.is_owned) {
30822                 ret_ref |= 1;
30823         }
30824         return ret_ref;
30825 }
30826
30827 void  __attribute__((export_name("TS_RevokeAndACK_free"))) TS_RevokeAndACK_free(uint32_t this_obj) {
30828         LDKRevokeAndACK this_obj_conv;
30829         this_obj_conv.inner = (void*)(this_obj & (~1));
30830         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30831         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30832         RevokeAndACK_free(this_obj_conv);
30833 }
30834
30835 int8_tArray  __attribute__((export_name("TS_RevokeAndACK_get_channel_id"))) TS_RevokeAndACK_get_channel_id(uint32_t this_ptr) {
30836         LDKRevokeAndACK this_ptr_conv;
30837         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30838         this_ptr_conv.is_owned = false;
30839         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30840         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30841         memcpy(ret_arr->elems, *RevokeAndACK_get_channel_id(&this_ptr_conv), 32);
30842         return ret_arr;
30843 }
30844
30845 void  __attribute__((export_name("TS_RevokeAndACK_set_channel_id"))) TS_RevokeAndACK_set_channel_id(uint32_t this_ptr, int8_tArray val) {
30846         LDKRevokeAndACK this_ptr_conv;
30847         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30848         this_ptr_conv.is_owned = false;
30849         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30850         LDKThirtyTwoBytes val_ref;
30851         CHECK(val->arr_len == 32);
30852         memcpy(val_ref.data, val->elems, 32); FREE(val);
30853         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
30854 }
30855
30856 int8_tArray  __attribute__((export_name("TS_RevokeAndACK_get_per_commitment_secret"))) TS_RevokeAndACK_get_per_commitment_secret(uint32_t this_ptr) {
30857         LDKRevokeAndACK this_ptr_conv;
30858         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30859         this_ptr_conv.is_owned = false;
30860         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30861         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30862         memcpy(ret_arr->elems, *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv), 32);
30863         return ret_arr;
30864 }
30865
30866 void  __attribute__((export_name("TS_RevokeAndACK_set_per_commitment_secret"))) TS_RevokeAndACK_set_per_commitment_secret(uint32_t this_ptr, int8_tArray val) {
30867         LDKRevokeAndACK this_ptr_conv;
30868         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30869         this_ptr_conv.is_owned = false;
30870         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30871         LDKThirtyTwoBytes val_ref;
30872         CHECK(val->arr_len == 32);
30873         memcpy(val_ref.data, val->elems, 32); FREE(val);
30874         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
30875 }
30876
30877 int8_tArray  __attribute__((export_name("TS_RevokeAndACK_get_next_per_commitment_point"))) TS_RevokeAndACK_get_next_per_commitment_point(uint32_t this_ptr) {
30878         LDKRevokeAndACK this_ptr_conv;
30879         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30880         this_ptr_conv.is_owned = false;
30881         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30882         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
30883         memcpy(ret_arr->elems, RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
30884         return ret_arr;
30885 }
30886
30887 void  __attribute__((export_name("TS_RevokeAndACK_set_next_per_commitment_point"))) TS_RevokeAndACK_set_next_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
30888         LDKRevokeAndACK this_ptr_conv;
30889         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30890         this_ptr_conv.is_owned = false;
30891         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30892         LDKPublicKey val_ref;
30893         CHECK(val->arr_len == 33);
30894         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
30895         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
30896 }
30897
30898 uint32_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) {
30899         LDKThirtyTwoBytes channel_id_arg_ref;
30900         CHECK(channel_id_arg->arr_len == 32);
30901         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
30902         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
30903         CHECK(per_commitment_secret_arg->arr_len == 32);
30904         memcpy(per_commitment_secret_arg_ref.data, per_commitment_secret_arg->elems, 32); FREE(per_commitment_secret_arg);
30905         LDKPublicKey next_per_commitment_point_arg_ref;
30906         CHECK(next_per_commitment_point_arg->arr_len == 33);
30907         memcpy(next_per_commitment_point_arg_ref.compressed_form, next_per_commitment_point_arg->elems, 33); FREE(next_per_commitment_point_arg);
30908         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
30909         uint32_t ret_ref = 0;
30910         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30911         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30912         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30913         ret_ref = (uintptr_t)ret_var.inner;
30914         if (ret_var.is_owned) {
30915                 ret_ref |= 1;
30916         }
30917         return ret_ref;
30918 }
30919
30920 static inline uintptr_t RevokeAndACK_clone_ptr(LDKRevokeAndACK *NONNULL_PTR arg) {
30921         LDKRevokeAndACK ret_var = RevokeAndACK_clone(arg);
30922 uint32_t ret_ref = 0;
30923 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30924 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30925 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30926 ret_ref = (uintptr_t)ret_var.inner;
30927 if (ret_var.is_owned) {
30928         ret_ref |= 1;
30929 }
30930         return ret_ref;
30931 }
30932 uint32_t  __attribute__((export_name("TS_RevokeAndACK_clone_ptr"))) TS_RevokeAndACK_clone_ptr(uint32_t arg) {
30933         LDKRevokeAndACK arg_conv;
30934         arg_conv.inner = (void*)(arg & (~1));
30935         arg_conv.is_owned = false;
30936         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30937         uint32_t ret_conv = RevokeAndACK_clone_ptr(&arg_conv);
30938         return ret_conv;
30939 }
30940
30941 uint32_t  __attribute__((export_name("TS_RevokeAndACK_clone"))) TS_RevokeAndACK_clone(uint32_t orig) {
30942         LDKRevokeAndACK orig_conv;
30943         orig_conv.inner = (void*)(orig & (~1));
30944         orig_conv.is_owned = false;
30945         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30946         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
30947         uint32_t ret_ref = 0;
30948         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30949         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30950         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30951         ret_ref = (uintptr_t)ret_var.inner;
30952         if (ret_var.is_owned) {
30953                 ret_ref |= 1;
30954         }
30955         return ret_ref;
30956 }
30957
30958 void  __attribute__((export_name("TS_UpdateFee_free"))) TS_UpdateFee_free(uint32_t this_obj) {
30959         LDKUpdateFee this_obj_conv;
30960         this_obj_conv.inner = (void*)(this_obj & (~1));
30961         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30962         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30963         UpdateFee_free(this_obj_conv);
30964 }
30965
30966 int8_tArray  __attribute__((export_name("TS_UpdateFee_get_channel_id"))) TS_UpdateFee_get_channel_id(uint32_t this_ptr) {
30967         LDKUpdateFee this_ptr_conv;
30968         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30969         this_ptr_conv.is_owned = false;
30970         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30971         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30972         memcpy(ret_arr->elems, *UpdateFee_get_channel_id(&this_ptr_conv), 32);
30973         return ret_arr;
30974 }
30975
30976 void  __attribute__((export_name("TS_UpdateFee_set_channel_id"))) TS_UpdateFee_set_channel_id(uint32_t this_ptr, int8_tArray val) {
30977         LDKUpdateFee this_ptr_conv;
30978         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30979         this_ptr_conv.is_owned = false;
30980         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30981         LDKThirtyTwoBytes val_ref;
30982         CHECK(val->arr_len == 32);
30983         memcpy(val_ref.data, val->elems, 32); FREE(val);
30984         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
30985 }
30986
30987 int32_t  __attribute__((export_name("TS_UpdateFee_get_feerate_per_kw"))) TS_UpdateFee_get_feerate_per_kw(uint32_t this_ptr) {
30988         LDKUpdateFee this_ptr_conv;
30989         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30990         this_ptr_conv.is_owned = false;
30991         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30992         int32_t ret_conv = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
30993         return ret_conv;
30994 }
30995
30996 void  __attribute__((export_name("TS_UpdateFee_set_feerate_per_kw"))) TS_UpdateFee_set_feerate_per_kw(uint32_t this_ptr, int32_t val) {
30997         LDKUpdateFee this_ptr_conv;
30998         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30999         this_ptr_conv.is_owned = false;
31000         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31001         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
31002 }
31003
31004 uint32_t  __attribute__((export_name("TS_UpdateFee_new"))) TS_UpdateFee_new(int8_tArray channel_id_arg, int32_t feerate_per_kw_arg) {
31005         LDKThirtyTwoBytes channel_id_arg_ref;
31006         CHECK(channel_id_arg->arr_len == 32);
31007         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
31008         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
31009         uint32_t ret_ref = 0;
31010         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31011         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31012         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31013         ret_ref = (uintptr_t)ret_var.inner;
31014         if (ret_var.is_owned) {
31015                 ret_ref |= 1;
31016         }
31017         return ret_ref;
31018 }
31019
31020 static inline uintptr_t UpdateFee_clone_ptr(LDKUpdateFee *NONNULL_PTR arg) {
31021         LDKUpdateFee ret_var = UpdateFee_clone(arg);
31022 uint32_t ret_ref = 0;
31023 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31024 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31025 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31026 ret_ref = (uintptr_t)ret_var.inner;
31027 if (ret_var.is_owned) {
31028         ret_ref |= 1;
31029 }
31030         return ret_ref;
31031 }
31032 uint32_t  __attribute__((export_name("TS_UpdateFee_clone_ptr"))) TS_UpdateFee_clone_ptr(uint32_t arg) {
31033         LDKUpdateFee arg_conv;
31034         arg_conv.inner = (void*)(arg & (~1));
31035         arg_conv.is_owned = false;
31036         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31037         uint32_t ret_conv = UpdateFee_clone_ptr(&arg_conv);
31038         return ret_conv;
31039 }
31040
31041 uint32_t  __attribute__((export_name("TS_UpdateFee_clone"))) TS_UpdateFee_clone(uint32_t orig) {
31042         LDKUpdateFee orig_conv;
31043         orig_conv.inner = (void*)(orig & (~1));
31044         orig_conv.is_owned = false;
31045         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31046         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
31047         uint32_t ret_ref = 0;
31048         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31049         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31050         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31051         ret_ref = (uintptr_t)ret_var.inner;
31052         if (ret_var.is_owned) {
31053                 ret_ref |= 1;
31054         }
31055         return ret_ref;
31056 }
31057
31058 void  __attribute__((export_name("TS_DataLossProtect_free"))) TS_DataLossProtect_free(uint32_t this_obj) {
31059         LDKDataLossProtect this_obj_conv;
31060         this_obj_conv.inner = (void*)(this_obj & (~1));
31061         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31062         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31063         DataLossProtect_free(this_obj_conv);
31064 }
31065
31066 int8_tArray  __attribute__((export_name("TS_DataLossProtect_get_your_last_per_commitment_secret"))) TS_DataLossProtect_get_your_last_per_commitment_secret(uint32_t this_ptr) {
31067         LDKDataLossProtect this_ptr_conv;
31068         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31069         this_ptr_conv.is_owned = false;
31070         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31071         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
31072         memcpy(ret_arr->elems, *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv), 32);
31073         return ret_arr;
31074 }
31075
31076 void  __attribute__((export_name("TS_DataLossProtect_set_your_last_per_commitment_secret"))) TS_DataLossProtect_set_your_last_per_commitment_secret(uint32_t this_ptr, int8_tArray val) {
31077         LDKDataLossProtect this_ptr_conv;
31078         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31079         this_ptr_conv.is_owned = false;
31080         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31081         LDKThirtyTwoBytes val_ref;
31082         CHECK(val->arr_len == 32);
31083         memcpy(val_ref.data, val->elems, 32); FREE(val);
31084         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
31085 }
31086
31087 int8_tArray  __attribute__((export_name("TS_DataLossProtect_get_my_current_per_commitment_point"))) TS_DataLossProtect_get_my_current_per_commitment_point(uint32_t this_ptr) {
31088         LDKDataLossProtect this_ptr_conv;
31089         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31090         this_ptr_conv.is_owned = false;
31091         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31092         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
31093         memcpy(ret_arr->elems, DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form, 33);
31094         return ret_arr;
31095 }
31096
31097 void  __attribute__((export_name("TS_DataLossProtect_set_my_current_per_commitment_point"))) TS_DataLossProtect_set_my_current_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
31098         LDKDataLossProtect this_ptr_conv;
31099         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31100         this_ptr_conv.is_owned = false;
31101         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31102         LDKPublicKey val_ref;
31103         CHECK(val->arr_len == 33);
31104         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
31105         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
31106 }
31107
31108 uint32_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) {
31109         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
31110         CHECK(your_last_per_commitment_secret_arg->arr_len == 32);
31111         memcpy(your_last_per_commitment_secret_arg_ref.data, your_last_per_commitment_secret_arg->elems, 32); FREE(your_last_per_commitment_secret_arg);
31112         LDKPublicKey my_current_per_commitment_point_arg_ref;
31113         CHECK(my_current_per_commitment_point_arg->arr_len == 33);
31114         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);
31115         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
31116         uint32_t ret_ref = 0;
31117         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31118         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31119         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31120         ret_ref = (uintptr_t)ret_var.inner;
31121         if (ret_var.is_owned) {
31122                 ret_ref |= 1;
31123         }
31124         return ret_ref;
31125 }
31126
31127 static inline uintptr_t DataLossProtect_clone_ptr(LDKDataLossProtect *NONNULL_PTR arg) {
31128         LDKDataLossProtect ret_var = DataLossProtect_clone(arg);
31129 uint32_t ret_ref = 0;
31130 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31131 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31132 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31133 ret_ref = (uintptr_t)ret_var.inner;
31134 if (ret_var.is_owned) {
31135         ret_ref |= 1;
31136 }
31137         return ret_ref;
31138 }
31139 uint32_t  __attribute__((export_name("TS_DataLossProtect_clone_ptr"))) TS_DataLossProtect_clone_ptr(uint32_t arg) {
31140         LDKDataLossProtect arg_conv;
31141         arg_conv.inner = (void*)(arg & (~1));
31142         arg_conv.is_owned = false;
31143         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31144         uint32_t ret_conv = DataLossProtect_clone_ptr(&arg_conv);
31145         return ret_conv;
31146 }
31147
31148 uint32_t  __attribute__((export_name("TS_DataLossProtect_clone"))) TS_DataLossProtect_clone(uint32_t orig) {
31149         LDKDataLossProtect orig_conv;
31150         orig_conv.inner = (void*)(orig & (~1));
31151         orig_conv.is_owned = false;
31152         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31153         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
31154         uint32_t ret_ref = 0;
31155         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31156         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31157         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31158         ret_ref = (uintptr_t)ret_var.inner;
31159         if (ret_var.is_owned) {
31160                 ret_ref |= 1;
31161         }
31162         return ret_ref;
31163 }
31164
31165 void  __attribute__((export_name("TS_ChannelReestablish_free"))) TS_ChannelReestablish_free(uint32_t this_obj) {
31166         LDKChannelReestablish this_obj_conv;
31167         this_obj_conv.inner = (void*)(this_obj & (~1));
31168         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31169         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31170         ChannelReestablish_free(this_obj_conv);
31171 }
31172
31173 int8_tArray  __attribute__((export_name("TS_ChannelReestablish_get_channel_id"))) TS_ChannelReestablish_get_channel_id(uint32_t this_ptr) {
31174         LDKChannelReestablish this_ptr_conv;
31175         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31176         this_ptr_conv.is_owned = false;
31177         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31178         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
31179         memcpy(ret_arr->elems, *ChannelReestablish_get_channel_id(&this_ptr_conv), 32);
31180         return ret_arr;
31181 }
31182
31183 void  __attribute__((export_name("TS_ChannelReestablish_set_channel_id"))) TS_ChannelReestablish_set_channel_id(uint32_t this_ptr, int8_tArray val) {
31184         LDKChannelReestablish this_ptr_conv;
31185         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31186         this_ptr_conv.is_owned = false;
31187         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31188         LDKThirtyTwoBytes val_ref;
31189         CHECK(val->arr_len == 32);
31190         memcpy(val_ref.data, val->elems, 32); FREE(val);
31191         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
31192 }
31193
31194 int64_t  __attribute__((export_name("TS_ChannelReestablish_get_next_local_commitment_number"))) TS_ChannelReestablish_get_next_local_commitment_number(uint32_t this_ptr) {
31195         LDKChannelReestablish this_ptr_conv;
31196         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31197         this_ptr_conv.is_owned = false;
31198         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31199         int64_t ret_conv = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
31200         return ret_conv;
31201 }
31202
31203 void  __attribute__((export_name("TS_ChannelReestablish_set_next_local_commitment_number"))) TS_ChannelReestablish_set_next_local_commitment_number(uint32_t this_ptr, int64_t val) {
31204         LDKChannelReestablish this_ptr_conv;
31205         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31206         this_ptr_conv.is_owned = false;
31207         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31208         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
31209 }
31210
31211 int64_t  __attribute__((export_name("TS_ChannelReestablish_get_next_remote_commitment_number"))) TS_ChannelReestablish_get_next_remote_commitment_number(uint32_t this_ptr) {
31212         LDKChannelReestablish this_ptr_conv;
31213         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31214         this_ptr_conv.is_owned = false;
31215         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31216         int64_t ret_conv = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
31217         return ret_conv;
31218 }
31219
31220 void  __attribute__((export_name("TS_ChannelReestablish_set_next_remote_commitment_number"))) TS_ChannelReestablish_set_next_remote_commitment_number(uint32_t this_ptr, int64_t val) {
31221         LDKChannelReestablish this_ptr_conv;
31222         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31223         this_ptr_conv.is_owned = false;
31224         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31225         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
31226 }
31227
31228 static inline uintptr_t ChannelReestablish_clone_ptr(LDKChannelReestablish *NONNULL_PTR arg) {
31229         LDKChannelReestablish ret_var = ChannelReestablish_clone(arg);
31230 uint32_t ret_ref = 0;
31231 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31232 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31233 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31234 ret_ref = (uintptr_t)ret_var.inner;
31235 if (ret_var.is_owned) {
31236         ret_ref |= 1;
31237 }
31238         return ret_ref;
31239 }
31240 uint32_t  __attribute__((export_name("TS_ChannelReestablish_clone_ptr"))) TS_ChannelReestablish_clone_ptr(uint32_t arg) {
31241         LDKChannelReestablish arg_conv;
31242         arg_conv.inner = (void*)(arg & (~1));
31243         arg_conv.is_owned = false;
31244         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31245         uint32_t ret_conv = ChannelReestablish_clone_ptr(&arg_conv);
31246         return ret_conv;
31247 }
31248
31249 uint32_t  __attribute__((export_name("TS_ChannelReestablish_clone"))) TS_ChannelReestablish_clone(uint32_t orig) {
31250         LDKChannelReestablish orig_conv;
31251         orig_conv.inner = (void*)(orig & (~1));
31252         orig_conv.is_owned = false;
31253         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31254         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
31255         uint32_t ret_ref = 0;
31256         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31257         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31258         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31259         ret_ref = (uintptr_t)ret_var.inner;
31260         if (ret_var.is_owned) {
31261                 ret_ref |= 1;
31262         }
31263         return ret_ref;
31264 }
31265
31266 void  __attribute__((export_name("TS_AnnouncementSignatures_free"))) TS_AnnouncementSignatures_free(uint32_t this_obj) {
31267         LDKAnnouncementSignatures this_obj_conv;
31268         this_obj_conv.inner = (void*)(this_obj & (~1));
31269         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31270         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31271         AnnouncementSignatures_free(this_obj_conv);
31272 }
31273
31274 int8_tArray  __attribute__((export_name("TS_AnnouncementSignatures_get_channel_id"))) TS_AnnouncementSignatures_get_channel_id(uint32_t this_ptr) {
31275         LDKAnnouncementSignatures this_ptr_conv;
31276         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31277         this_ptr_conv.is_owned = false;
31278         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31279         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
31280         memcpy(ret_arr->elems, *AnnouncementSignatures_get_channel_id(&this_ptr_conv), 32);
31281         return ret_arr;
31282 }
31283
31284 void  __attribute__((export_name("TS_AnnouncementSignatures_set_channel_id"))) TS_AnnouncementSignatures_set_channel_id(uint32_t this_ptr, int8_tArray val) {
31285         LDKAnnouncementSignatures this_ptr_conv;
31286         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31287         this_ptr_conv.is_owned = false;
31288         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31289         LDKThirtyTwoBytes val_ref;
31290         CHECK(val->arr_len == 32);
31291         memcpy(val_ref.data, val->elems, 32); FREE(val);
31292         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
31293 }
31294
31295 int64_t  __attribute__((export_name("TS_AnnouncementSignatures_get_short_channel_id"))) TS_AnnouncementSignatures_get_short_channel_id(uint32_t this_ptr) {
31296         LDKAnnouncementSignatures this_ptr_conv;
31297         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31298         this_ptr_conv.is_owned = false;
31299         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31300         int64_t ret_conv = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
31301         return ret_conv;
31302 }
31303
31304 void  __attribute__((export_name("TS_AnnouncementSignatures_set_short_channel_id"))) TS_AnnouncementSignatures_set_short_channel_id(uint32_t this_ptr, int64_t val) {
31305         LDKAnnouncementSignatures this_ptr_conv;
31306         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31307         this_ptr_conv.is_owned = false;
31308         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31309         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
31310 }
31311
31312 int8_tArray  __attribute__((export_name("TS_AnnouncementSignatures_get_node_signature"))) TS_AnnouncementSignatures_get_node_signature(uint32_t this_ptr) {
31313         LDKAnnouncementSignatures this_ptr_conv;
31314         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31315         this_ptr_conv.is_owned = false;
31316         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31317         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
31318         memcpy(ret_arr->elems, AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form, 64);
31319         return ret_arr;
31320 }
31321
31322 void  __attribute__((export_name("TS_AnnouncementSignatures_set_node_signature"))) TS_AnnouncementSignatures_set_node_signature(uint32_t this_ptr, int8_tArray val) {
31323         LDKAnnouncementSignatures this_ptr_conv;
31324         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31325         this_ptr_conv.is_owned = false;
31326         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31327         LDKSignature val_ref;
31328         CHECK(val->arr_len == 64);
31329         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
31330         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
31331 }
31332
31333 int8_tArray  __attribute__((export_name("TS_AnnouncementSignatures_get_bitcoin_signature"))) TS_AnnouncementSignatures_get_bitcoin_signature(uint32_t this_ptr) {
31334         LDKAnnouncementSignatures this_ptr_conv;
31335         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31336         this_ptr_conv.is_owned = false;
31337         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31338         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
31339         memcpy(ret_arr->elems, AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form, 64);
31340         return ret_arr;
31341 }
31342
31343 void  __attribute__((export_name("TS_AnnouncementSignatures_set_bitcoin_signature"))) TS_AnnouncementSignatures_set_bitcoin_signature(uint32_t this_ptr, int8_tArray val) {
31344         LDKAnnouncementSignatures this_ptr_conv;
31345         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31346         this_ptr_conv.is_owned = false;
31347         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31348         LDKSignature val_ref;
31349         CHECK(val->arr_len == 64);
31350         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
31351         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
31352 }
31353
31354 uint32_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) {
31355         LDKThirtyTwoBytes channel_id_arg_ref;
31356         CHECK(channel_id_arg->arr_len == 32);
31357         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
31358         LDKSignature node_signature_arg_ref;
31359         CHECK(node_signature_arg->arr_len == 64);
31360         memcpy(node_signature_arg_ref.compact_form, node_signature_arg->elems, 64); FREE(node_signature_arg);
31361         LDKSignature bitcoin_signature_arg_ref;
31362         CHECK(bitcoin_signature_arg->arr_len == 64);
31363         memcpy(bitcoin_signature_arg_ref.compact_form, bitcoin_signature_arg->elems, 64); FREE(bitcoin_signature_arg);
31364         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
31365         uint32_t ret_ref = 0;
31366         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31367         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31368         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31369         ret_ref = (uintptr_t)ret_var.inner;
31370         if (ret_var.is_owned) {
31371                 ret_ref |= 1;
31372         }
31373         return ret_ref;
31374 }
31375
31376 static inline uintptr_t AnnouncementSignatures_clone_ptr(LDKAnnouncementSignatures *NONNULL_PTR arg) {
31377         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(arg);
31378 uint32_t ret_ref = 0;
31379 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31380 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31381 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31382 ret_ref = (uintptr_t)ret_var.inner;
31383 if (ret_var.is_owned) {
31384         ret_ref |= 1;
31385 }
31386         return ret_ref;
31387 }
31388 uint32_t  __attribute__((export_name("TS_AnnouncementSignatures_clone_ptr"))) TS_AnnouncementSignatures_clone_ptr(uint32_t arg) {
31389         LDKAnnouncementSignatures arg_conv;
31390         arg_conv.inner = (void*)(arg & (~1));
31391         arg_conv.is_owned = false;
31392         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31393         uint32_t ret_conv = AnnouncementSignatures_clone_ptr(&arg_conv);
31394         return ret_conv;
31395 }
31396
31397 uint32_t  __attribute__((export_name("TS_AnnouncementSignatures_clone"))) TS_AnnouncementSignatures_clone(uint32_t orig) {
31398         LDKAnnouncementSignatures orig_conv;
31399         orig_conv.inner = (void*)(orig & (~1));
31400         orig_conv.is_owned = false;
31401         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31402         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
31403         uint32_t ret_ref = 0;
31404         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31405         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31406         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31407         ret_ref = (uintptr_t)ret_var.inner;
31408         if (ret_var.is_owned) {
31409                 ret_ref |= 1;
31410         }
31411         return ret_ref;
31412 }
31413
31414 void  __attribute__((export_name("TS_NetAddress_free"))) TS_NetAddress_free(uint32_t this_ptr) {
31415         if ((this_ptr & 1) != 0) return;
31416         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
31417         CHECK_ACCESS(this_ptr_ptr);
31418         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(this_ptr_ptr);
31419         FREE((void*)this_ptr);
31420         NetAddress_free(this_ptr_conv);
31421 }
31422
31423 static inline uintptr_t NetAddress_clone_ptr(LDKNetAddress *NONNULL_PTR arg) {
31424         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
31425         *ret_copy = NetAddress_clone(arg);
31426 uint32_t ret_ref = (uintptr_t)ret_copy;
31427         return ret_ref;
31428 }
31429 uint32_t  __attribute__((export_name("TS_NetAddress_clone_ptr"))) TS_NetAddress_clone_ptr(uint32_t arg) {
31430         LDKNetAddress* arg_conv = (LDKNetAddress*)arg;
31431         uint32_t ret_conv = NetAddress_clone_ptr(arg_conv);
31432         return ret_conv;
31433 }
31434
31435 uint32_t  __attribute__((export_name("TS_NetAddress_clone"))) TS_NetAddress_clone(uint32_t orig) {
31436         LDKNetAddress* orig_conv = (LDKNetAddress*)orig;
31437         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
31438         *ret_copy = NetAddress_clone(orig_conv);
31439         uint32_t ret_ref = (uintptr_t)ret_copy;
31440         return ret_ref;
31441 }
31442
31443 uint32_t  __attribute__((export_name("TS_NetAddress_ipv4"))) TS_NetAddress_ipv4(int8_tArray addr, int16_t port) {
31444         LDKFourBytes addr_ref;
31445         CHECK(addr->arr_len == 4);
31446         memcpy(addr_ref.data, addr->elems, 4); FREE(addr);
31447         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
31448         *ret_copy = NetAddress_ipv4(addr_ref, port);
31449         uint32_t ret_ref = (uintptr_t)ret_copy;
31450         return ret_ref;
31451 }
31452
31453 uint32_t  __attribute__((export_name("TS_NetAddress_ipv6"))) TS_NetAddress_ipv6(int8_tArray addr, int16_t port) {
31454         LDKSixteenBytes addr_ref;
31455         CHECK(addr->arr_len == 16);
31456         memcpy(addr_ref.data, addr->elems, 16); FREE(addr);
31457         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
31458         *ret_copy = NetAddress_ipv6(addr_ref, port);
31459         uint32_t ret_ref = (uintptr_t)ret_copy;
31460         return ret_ref;
31461 }
31462
31463 uint32_t  __attribute__((export_name("TS_NetAddress_onion_v2"))) TS_NetAddress_onion_v2(int8_tArray a) {
31464         LDKTwelveBytes a_ref;
31465         CHECK(a->arr_len == 12);
31466         memcpy(a_ref.data, a->elems, 12); FREE(a);
31467         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
31468         *ret_copy = NetAddress_onion_v2(a_ref);
31469         uint32_t ret_ref = (uintptr_t)ret_copy;
31470         return ret_ref;
31471 }
31472
31473 uint32_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) {
31474         LDKThirtyTwoBytes ed25519_pubkey_ref;
31475         CHECK(ed25519_pubkey->arr_len == 32);
31476         memcpy(ed25519_pubkey_ref.data, ed25519_pubkey->elems, 32); FREE(ed25519_pubkey);
31477         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
31478         *ret_copy = NetAddress_onion_v3(ed25519_pubkey_ref, checksum, version, port);
31479         uint32_t ret_ref = (uintptr_t)ret_copy;
31480         return ret_ref;
31481 }
31482
31483 uint32_t  __attribute__((export_name("TS_NetAddress_hostname"))) TS_NetAddress_hostname(uint32_t hostname, int16_t port) {
31484         LDKHostname hostname_conv;
31485         hostname_conv.inner = (void*)(hostname & (~1));
31486         hostname_conv.is_owned = (hostname & 1) || (hostname == 0);
31487         CHECK_INNER_FIELD_ACCESS_OR_NULL(hostname_conv);
31488         hostname_conv = Hostname_clone(&hostname_conv);
31489         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
31490         *ret_copy = NetAddress_hostname(hostname_conv, port);
31491         uint32_t ret_ref = (uintptr_t)ret_copy;
31492         return ret_ref;
31493 }
31494
31495 int8_tArray  __attribute__((export_name("TS_NetAddress_write"))) TS_NetAddress_write(uint32_t obj) {
31496         LDKNetAddress* obj_conv = (LDKNetAddress*)obj;
31497         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
31498         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31499         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31500         CVec_u8Z_free(ret_var);
31501         return ret_arr;
31502 }
31503
31504 uint32_t  __attribute__((export_name("TS_NetAddress_read"))) TS_NetAddress_read(int8_tArray ser) {
31505         LDKu8slice ser_ref;
31506         ser_ref.datalen = ser->arr_len;
31507         ser_ref.data = ser->elems;
31508         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
31509         *ret_conv = NetAddress_read(ser_ref);
31510         FREE(ser);
31511         return (uint32_t)ret_conv;
31512 }
31513
31514 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_free"))) TS_UnsignedNodeAnnouncement_free(uint32_t this_obj) {
31515         LDKUnsignedNodeAnnouncement this_obj_conv;
31516         this_obj_conv.inner = (void*)(this_obj & (~1));
31517         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31518         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31519         UnsignedNodeAnnouncement_free(this_obj_conv);
31520 }
31521
31522 uint32_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_features"))) TS_UnsignedNodeAnnouncement_get_features(uint32_t this_ptr) {
31523         LDKUnsignedNodeAnnouncement this_ptr_conv;
31524         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31525         this_ptr_conv.is_owned = false;
31526         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31527         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
31528         uint32_t ret_ref = 0;
31529         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31530         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31531         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31532         ret_ref = (uintptr_t)ret_var.inner;
31533         if (ret_var.is_owned) {
31534                 ret_ref |= 1;
31535         }
31536         return ret_ref;
31537 }
31538
31539 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_features"))) TS_UnsignedNodeAnnouncement_set_features(uint32_t this_ptr, uint32_t val) {
31540         LDKUnsignedNodeAnnouncement this_ptr_conv;
31541         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31542         this_ptr_conv.is_owned = false;
31543         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31544         LDKNodeFeatures val_conv;
31545         val_conv.inner = (void*)(val & (~1));
31546         val_conv.is_owned = (val & 1) || (val == 0);
31547         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31548         val_conv = NodeFeatures_clone(&val_conv);
31549         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
31550 }
31551
31552 int32_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_timestamp"))) TS_UnsignedNodeAnnouncement_get_timestamp(uint32_t this_ptr) {
31553         LDKUnsignedNodeAnnouncement this_ptr_conv;
31554         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31555         this_ptr_conv.is_owned = false;
31556         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31557         int32_t ret_conv = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
31558         return ret_conv;
31559 }
31560
31561 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_timestamp"))) TS_UnsignedNodeAnnouncement_set_timestamp(uint32_t this_ptr, int32_t val) {
31562         LDKUnsignedNodeAnnouncement this_ptr_conv;
31563         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31564         this_ptr_conv.is_owned = false;
31565         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31566         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
31567 }
31568
31569 int8_tArray  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_node_id"))) TS_UnsignedNodeAnnouncement_get_node_id(uint32_t this_ptr) {
31570         LDKUnsignedNodeAnnouncement this_ptr_conv;
31571         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31572         this_ptr_conv.is_owned = false;
31573         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31574         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
31575         memcpy(ret_arr->elems, UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form, 33);
31576         return ret_arr;
31577 }
31578
31579 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_node_id"))) TS_UnsignedNodeAnnouncement_set_node_id(uint32_t this_ptr, int8_tArray val) {
31580         LDKUnsignedNodeAnnouncement this_ptr_conv;
31581         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31582         this_ptr_conv.is_owned = false;
31583         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31584         LDKPublicKey val_ref;
31585         CHECK(val->arr_len == 33);
31586         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
31587         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
31588 }
31589
31590 int8_tArray  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_rgb"))) TS_UnsignedNodeAnnouncement_get_rgb(uint32_t this_ptr) {
31591         LDKUnsignedNodeAnnouncement this_ptr_conv;
31592         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31593         this_ptr_conv.is_owned = false;
31594         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31595         int8_tArray ret_arr = init_int8_tArray(3, __LINE__);
31596         memcpy(ret_arr->elems, *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv), 3);
31597         return ret_arr;
31598 }
31599
31600 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_rgb"))) TS_UnsignedNodeAnnouncement_set_rgb(uint32_t this_ptr, int8_tArray val) {
31601         LDKUnsignedNodeAnnouncement this_ptr_conv;
31602         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31603         this_ptr_conv.is_owned = false;
31604         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31605         LDKThreeBytes val_ref;
31606         CHECK(val->arr_len == 3);
31607         memcpy(val_ref.data, val->elems, 3); FREE(val);
31608         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
31609 }
31610
31611 int8_tArray  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_alias"))) TS_UnsignedNodeAnnouncement_get_alias(uint32_t this_ptr) {
31612         LDKUnsignedNodeAnnouncement this_ptr_conv;
31613         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31614         this_ptr_conv.is_owned = false;
31615         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31616         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
31617         memcpy(ret_arr->elems, *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv), 32);
31618         return ret_arr;
31619 }
31620
31621 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_alias"))) TS_UnsignedNodeAnnouncement_set_alias(uint32_t this_ptr, int8_tArray val) {
31622         LDKUnsignedNodeAnnouncement this_ptr_conv;
31623         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31624         this_ptr_conv.is_owned = false;
31625         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31626         LDKThirtyTwoBytes val_ref;
31627         CHECK(val->arr_len == 32);
31628         memcpy(val_ref.data, val->elems, 32); FREE(val);
31629         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
31630 }
31631
31632 uint32_tArray  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_addresses"))) TS_UnsignedNodeAnnouncement_get_addresses(uint32_t this_ptr) {
31633         LDKUnsignedNodeAnnouncement this_ptr_conv;
31634         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31635         this_ptr_conv.is_owned = false;
31636         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31637         LDKCVec_NetAddressZ ret_var = UnsignedNodeAnnouncement_get_addresses(&this_ptr_conv);
31638         uint32_tArray ret_arr = NULL;
31639         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
31640         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 8);
31641         for (size_t m = 0; m < ret_var.datalen; m++) {
31642                 LDKNetAddress *ret_conv_12_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
31643                 *ret_conv_12_copy = ret_var.data[m];
31644                 uint32_t ret_conv_12_ref = (uintptr_t)ret_conv_12_copy;
31645                 ret_arr_ptr[m] = ret_conv_12_ref;
31646         }
31647         
31648         FREE(ret_var.data);
31649         return ret_arr;
31650 }
31651
31652 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_addresses"))) TS_UnsignedNodeAnnouncement_set_addresses(uint32_t this_ptr, uint32_tArray val) {
31653         LDKUnsignedNodeAnnouncement this_ptr_conv;
31654         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31655         this_ptr_conv.is_owned = false;
31656         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31657         LDKCVec_NetAddressZ val_constr;
31658         val_constr.datalen = val->arr_len;
31659         if (val_constr.datalen > 0)
31660                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
31661         else
31662                 val_constr.data = NULL;
31663         uint32_t* val_vals = val->elems;
31664         for (size_t m = 0; m < val_constr.datalen; m++) {
31665                 uint32_t val_conv_12 = val_vals[m];
31666                 void* val_conv_12_ptr = (void*)(((uintptr_t)val_conv_12) & ~1);
31667                 CHECK_ACCESS(val_conv_12_ptr);
31668                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
31669                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)val_conv_12) & ~1));
31670                 val_constr.data[m] = val_conv_12_conv;
31671         }
31672         FREE(val);
31673         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
31674 }
31675
31676 static inline uintptr_t UnsignedNodeAnnouncement_clone_ptr(LDKUnsignedNodeAnnouncement *NONNULL_PTR arg) {
31677         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(arg);
31678 uint32_t ret_ref = 0;
31679 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31680 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31681 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31682 ret_ref = (uintptr_t)ret_var.inner;
31683 if (ret_var.is_owned) {
31684         ret_ref |= 1;
31685 }
31686         return ret_ref;
31687 }
31688 uint32_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_clone_ptr"))) TS_UnsignedNodeAnnouncement_clone_ptr(uint32_t arg) {
31689         LDKUnsignedNodeAnnouncement arg_conv;
31690         arg_conv.inner = (void*)(arg & (~1));
31691         arg_conv.is_owned = false;
31692         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31693         uint32_t ret_conv = UnsignedNodeAnnouncement_clone_ptr(&arg_conv);
31694         return ret_conv;
31695 }
31696
31697 uint32_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_clone"))) TS_UnsignedNodeAnnouncement_clone(uint32_t orig) {
31698         LDKUnsignedNodeAnnouncement orig_conv;
31699         orig_conv.inner = (void*)(orig & (~1));
31700         orig_conv.is_owned = false;
31701         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31702         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
31703         uint32_t ret_ref = 0;
31704         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31705         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31706         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31707         ret_ref = (uintptr_t)ret_var.inner;
31708         if (ret_var.is_owned) {
31709                 ret_ref |= 1;
31710         }
31711         return ret_ref;
31712 }
31713
31714 void  __attribute__((export_name("TS_NodeAnnouncement_free"))) TS_NodeAnnouncement_free(uint32_t this_obj) {
31715         LDKNodeAnnouncement this_obj_conv;
31716         this_obj_conv.inner = (void*)(this_obj & (~1));
31717         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31718         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31719         NodeAnnouncement_free(this_obj_conv);
31720 }
31721
31722 int8_tArray  __attribute__((export_name("TS_NodeAnnouncement_get_signature"))) TS_NodeAnnouncement_get_signature(uint32_t this_ptr) {
31723         LDKNodeAnnouncement this_ptr_conv;
31724         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31725         this_ptr_conv.is_owned = false;
31726         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31727         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
31728         memcpy(ret_arr->elems, NodeAnnouncement_get_signature(&this_ptr_conv).compact_form, 64);
31729         return ret_arr;
31730 }
31731
31732 void  __attribute__((export_name("TS_NodeAnnouncement_set_signature"))) TS_NodeAnnouncement_set_signature(uint32_t this_ptr, int8_tArray val) {
31733         LDKNodeAnnouncement this_ptr_conv;
31734         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31735         this_ptr_conv.is_owned = false;
31736         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31737         LDKSignature val_ref;
31738         CHECK(val->arr_len == 64);
31739         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
31740         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
31741 }
31742
31743 uint32_t  __attribute__((export_name("TS_NodeAnnouncement_get_contents"))) TS_NodeAnnouncement_get_contents(uint32_t this_ptr) {
31744         LDKNodeAnnouncement this_ptr_conv;
31745         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31746         this_ptr_conv.is_owned = false;
31747         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31748         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
31749         uint32_t ret_ref = 0;
31750         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31751         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31752         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31753         ret_ref = (uintptr_t)ret_var.inner;
31754         if (ret_var.is_owned) {
31755                 ret_ref |= 1;
31756         }
31757         return ret_ref;
31758 }
31759
31760 void  __attribute__((export_name("TS_NodeAnnouncement_set_contents"))) TS_NodeAnnouncement_set_contents(uint32_t this_ptr, uint32_t val) {
31761         LDKNodeAnnouncement this_ptr_conv;
31762         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31763         this_ptr_conv.is_owned = false;
31764         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31765         LDKUnsignedNodeAnnouncement val_conv;
31766         val_conv.inner = (void*)(val & (~1));
31767         val_conv.is_owned = (val & 1) || (val == 0);
31768         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31769         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
31770         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
31771 }
31772
31773 uint32_t  __attribute__((export_name("TS_NodeAnnouncement_new"))) TS_NodeAnnouncement_new(int8_tArray signature_arg, uint32_t contents_arg) {
31774         LDKSignature signature_arg_ref;
31775         CHECK(signature_arg->arr_len == 64);
31776         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
31777         LDKUnsignedNodeAnnouncement contents_arg_conv;
31778         contents_arg_conv.inner = (void*)(contents_arg & (~1));
31779         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
31780         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
31781         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
31782         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
31783         uint32_t ret_ref = 0;
31784         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31785         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31786         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31787         ret_ref = (uintptr_t)ret_var.inner;
31788         if (ret_var.is_owned) {
31789                 ret_ref |= 1;
31790         }
31791         return ret_ref;
31792 }
31793
31794 static inline uintptr_t NodeAnnouncement_clone_ptr(LDKNodeAnnouncement *NONNULL_PTR arg) {
31795         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(arg);
31796 uint32_t ret_ref = 0;
31797 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31798 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31799 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31800 ret_ref = (uintptr_t)ret_var.inner;
31801 if (ret_var.is_owned) {
31802         ret_ref |= 1;
31803 }
31804         return ret_ref;
31805 }
31806 uint32_t  __attribute__((export_name("TS_NodeAnnouncement_clone_ptr"))) TS_NodeAnnouncement_clone_ptr(uint32_t arg) {
31807         LDKNodeAnnouncement arg_conv;
31808         arg_conv.inner = (void*)(arg & (~1));
31809         arg_conv.is_owned = false;
31810         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31811         uint32_t ret_conv = NodeAnnouncement_clone_ptr(&arg_conv);
31812         return ret_conv;
31813 }
31814
31815 uint32_t  __attribute__((export_name("TS_NodeAnnouncement_clone"))) TS_NodeAnnouncement_clone(uint32_t orig) {
31816         LDKNodeAnnouncement orig_conv;
31817         orig_conv.inner = (void*)(orig & (~1));
31818         orig_conv.is_owned = false;
31819         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31820         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
31821         uint32_t ret_ref = 0;
31822         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31823         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31824         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31825         ret_ref = (uintptr_t)ret_var.inner;
31826         if (ret_var.is_owned) {
31827                 ret_ref |= 1;
31828         }
31829         return ret_ref;
31830 }
31831
31832 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_free"))) TS_UnsignedChannelAnnouncement_free(uint32_t this_obj) {
31833         LDKUnsignedChannelAnnouncement this_obj_conv;
31834         this_obj_conv.inner = (void*)(this_obj & (~1));
31835         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31836         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31837         UnsignedChannelAnnouncement_free(this_obj_conv);
31838 }
31839
31840 uint32_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_features"))) TS_UnsignedChannelAnnouncement_get_features(uint32_t this_ptr) {
31841         LDKUnsignedChannelAnnouncement this_ptr_conv;
31842         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31843         this_ptr_conv.is_owned = false;
31844         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31845         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
31846         uint32_t ret_ref = 0;
31847         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31848         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31849         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31850         ret_ref = (uintptr_t)ret_var.inner;
31851         if (ret_var.is_owned) {
31852                 ret_ref |= 1;
31853         }
31854         return ret_ref;
31855 }
31856
31857 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_features"))) TS_UnsignedChannelAnnouncement_set_features(uint32_t this_ptr, uint32_t val) {
31858         LDKUnsignedChannelAnnouncement this_ptr_conv;
31859         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31860         this_ptr_conv.is_owned = false;
31861         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31862         LDKChannelFeatures val_conv;
31863         val_conv.inner = (void*)(val & (~1));
31864         val_conv.is_owned = (val & 1) || (val == 0);
31865         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31866         val_conv = ChannelFeatures_clone(&val_conv);
31867         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
31868 }
31869
31870 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_chain_hash"))) TS_UnsignedChannelAnnouncement_get_chain_hash(uint32_t this_ptr) {
31871         LDKUnsignedChannelAnnouncement this_ptr_conv;
31872         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31873         this_ptr_conv.is_owned = false;
31874         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31875         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
31876         memcpy(ret_arr->elems, *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv), 32);
31877         return ret_arr;
31878 }
31879
31880 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_chain_hash"))) TS_UnsignedChannelAnnouncement_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
31881         LDKUnsignedChannelAnnouncement this_ptr_conv;
31882         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31883         this_ptr_conv.is_owned = false;
31884         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31885         LDKThirtyTwoBytes val_ref;
31886         CHECK(val->arr_len == 32);
31887         memcpy(val_ref.data, val->elems, 32); FREE(val);
31888         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
31889 }
31890
31891 int64_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_short_channel_id"))) TS_UnsignedChannelAnnouncement_get_short_channel_id(uint32_t this_ptr) {
31892         LDKUnsignedChannelAnnouncement this_ptr_conv;
31893         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31894         this_ptr_conv.is_owned = false;
31895         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31896         int64_t ret_conv = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
31897         return ret_conv;
31898 }
31899
31900 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_short_channel_id"))) TS_UnsignedChannelAnnouncement_set_short_channel_id(uint32_t this_ptr, int64_t val) {
31901         LDKUnsignedChannelAnnouncement this_ptr_conv;
31902         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31903         this_ptr_conv.is_owned = false;
31904         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31905         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
31906 }
31907
31908 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_node_id_1"))) TS_UnsignedChannelAnnouncement_get_node_id_1(uint32_t this_ptr) {
31909         LDKUnsignedChannelAnnouncement this_ptr_conv;
31910         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31911         this_ptr_conv.is_owned = false;
31912         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31913         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
31914         memcpy(ret_arr->elems, UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form, 33);
31915         return ret_arr;
31916 }
31917
31918 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_node_id_1"))) TS_UnsignedChannelAnnouncement_set_node_id_1(uint32_t this_ptr, int8_tArray val) {
31919         LDKUnsignedChannelAnnouncement this_ptr_conv;
31920         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31921         this_ptr_conv.is_owned = false;
31922         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31923         LDKPublicKey val_ref;
31924         CHECK(val->arr_len == 33);
31925         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
31926         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
31927 }
31928
31929 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_node_id_2"))) TS_UnsignedChannelAnnouncement_get_node_id_2(uint32_t this_ptr) {
31930         LDKUnsignedChannelAnnouncement this_ptr_conv;
31931         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31932         this_ptr_conv.is_owned = false;
31933         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31934         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
31935         memcpy(ret_arr->elems, UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form, 33);
31936         return ret_arr;
31937 }
31938
31939 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_node_id_2"))) TS_UnsignedChannelAnnouncement_set_node_id_2(uint32_t this_ptr, int8_tArray val) {
31940         LDKUnsignedChannelAnnouncement this_ptr_conv;
31941         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31942         this_ptr_conv.is_owned = false;
31943         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31944         LDKPublicKey val_ref;
31945         CHECK(val->arr_len == 33);
31946         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
31947         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
31948 }
31949
31950 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_bitcoin_key_1"))) TS_UnsignedChannelAnnouncement_get_bitcoin_key_1(uint32_t this_ptr) {
31951         LDKUnsignedChannelAnnouncement this_ptr_conv;
31952         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31953         this_ptr_conv.is_owned = false;
31954         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31955         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
31956         memcpy(ret_arr->elems, UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form, 33);
31957         return ret_arr;
31958 }
31959
31960 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_bitcoin_key_1"))) TS_UnsignedChannelAnnouncement_set_bitcoin_key_1(uint32_t this_ptr, int8_tArray val) {
31961         LDKUnsignedChannelAnnouncement this_ptr_conv;
31962         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31963         this_ptr_conv.is_owned = false;
31964         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31965         LDKPublicKey val_ref;
31966         CHECK(val->arr_len == 33);
31967         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
31968         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
31969 }
31970
31971 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_bitcoin_key_2"))) TS_UnsignedChannelAnnouncement_get_bitcoin_key_2(uint32_t this_ptr) {
31972         LDKUnsignedChannelAnnouncement this_ptr_conv;
31973         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31974         this_ptr_conv.is_owned = false;
31975         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31976         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
31977         memcpy(ret_arr->elems, UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form, 33);
31978         return ret_arr;
31979 }
31980
31981 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_bitcoin_key_2"))) TS_UnsignedChannelAnnouncement_set_bitcoin_key_2(uint32_t this_ptr, int8_tArray val) {
31982         LDKUnsignedChannelAnnouncement this_ptr_conv;
31983         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31984         this_ptr_conv.is_owned = false;
31985         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31986         LDKPublicKey val_ref;
31987         CHECK(val->arr_len == 33);
31988         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
31989         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
31990 }
31991
31992 static inline uintptr_t UnsignedChannelAnnouncement_clone_ptr(LDKUnsignedChannelAnnouncement *NONNULL_PTR arg) {
31993         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(arg);
31994 uint32_t ret_ref = 0;
31995 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31996 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31997 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31998 ret_ref = (uintptr_t)ret_var.inner;
31999 if (ret_var.is_owned) {
32000         ret_ref |= 1;
32001 }
32002         return ret_ref;
32003 }
32004 uint32_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_clone_ptr"))) TS_UnsignedChannelAnnouncement_clone_ptr(uint32_t arg) {
32005         LDKUnsignedChannelAnnouncement arg_conv;
32006         arg_conv.inner = (void*)(arg & (~1));
32007         arg_conv.is_owned = false;
32008         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32009         uint32_t ret_conv = UnsignedChannelAnnouncement_clone_ptr(&arg_conv);
32010         return ret_conv;
32011 }
32012
32013 uint32_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_clone"))) TS_UnsignedChannelAnnouncement_clone(uint32_t orig) {
32014         LDKUnsignedChannelAnnouncement orig_conv;
32015         orig_conv.inner = (void*)(orig & (~1));
32016         orig_conv.is_owned = false;
32017         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32018         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
32019         uint32_t ret_ref = 0;
32020         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32021         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32022         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32023         ret_ref = (uintptr_t)ret_var.inner;
32024         if (ret_var.is_owned) {
32025                 ret_ref |= 1;
32026         }
32027         return ret_ref;
32028 }
32029
32030 void  __attribute__((export_name("TS_ChannelAnnouncement_free"))) TS_ChannelAnnouncement_free(uint32_t this_obj) {
32031         LDKChannelAnnouncement this_obj_conv;
32032         this_obj_conv.inner = (void*)(this_obj & (~1));
32033         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32034         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32035         ChannelAnnouncement_free(this_obj_conv);
32036 }
32037
32038 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_get_node_signature_1"))) TS_ChannelAnnouncement_get_node_signature_1(uint32_t this_ptr) {
32039         LDKChannelAnnouncement this_ptr_conv;
32040         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32041         this_ptr_conv.is_owned = false;
32042         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32043         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
32044         memcpy(ret_arr->elems, ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form, 64);
32045         return ret_arr;
32046 }
32047
32048 void  __attribute__((export_name("TS_ChannelAnnouncement_set_node_signature_1"))) TS_ChannelAnnouncement_set_node_signature_1(uint32_t this_ptr, int8_tArray val) {
32049         LDKChannelAnnouncement this_ptr_conv;
32050         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32051         this_ptr_conv.is_owned = false;
32052         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32053         LDKSignature val_ref;
32054         CHECK(val->arr_len == 64);
32055         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
32056         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
32057 }
32058
32059 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_get_node_signature_2"))) TS_ChannelAnnouncement_get_node_signature_2(uint32_t this_ptr) {
32060         LDKChannelAnnouncement this_ptr_conv;
32061         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32062         this_ptr_conv.is_owned = false;
32063         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32064         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
32065         memcpy(ret_arr->elems, ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form, 64);
32066         return ret_arr;
32067 }
32068
32069 void  __attribute__((export_name("TS_ChannelAnnouncement_set_node_signature_2"))) TS_ChannelAnnouncement_set_node_signature_2(uint32_t this_ptr, int8_tArray val) {
32070         LDKChannelAnnouncement this_ptr_conv;
32071         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32072         this_ptr_conv.is_owned = false;
32073         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32074         LDKSignature val_ref;
32075         CHECK(val->arr_len == 64);
32076         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
32077         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
32078 }
32079
32080 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_get_bitcoin_signature_1"))) TS_ChannelAnnouncement_get_bitcoin_signature_1(uint32_t this_ptr) {
32081         LDKChannelAnnouncement this_ptr_conv;
32082         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32083         this_ptr_conv.is_owned = false;
32084         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32085         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
32086         memcpy(ret_arr->elems, ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form, 64);
32087         return ret_arr;
32088 }
32089
32090 void  __attribute__((export_name("TS_ChannelAnnouncement_set_bitcoin_signature_1"))) TS_ChannelAnnouncement_set_bitcoin_signature_1(uint32_t this_ptr, int8_tArray val) {
32091         LDKChannelAnnouncement this_ptr_conv;
32092         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32093         this_ptr_conv.is_owned = false;
32094         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32095         LDKSignature val_ref;
32096         CHECK(val->arr_len == 64);
32097         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
32098         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
32099 }
32100
32101 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_get_bitcoin_signature_2"))) TS_ChannelAnnouncement_get_bitcoin_signature_2(uint32_t this_ptr) {
32102         LDKChannelAnnouncement this_ptr_conv;
32103         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32104         this_ptr_conv.is_owned = false;
32105         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32106         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
32107         memcpy(ret_arr->elems, ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form, 64);
32108         return ret_arr;
32109 }
32110
32111 void  __attribute__((export_name("TS_ChannelAnnouncement_set_bitcoin_signature_2"))) TS_ChannelAnnouncement_set_bitcoin_signature_2(uint32_t this_ptr, int8_tArray val) {
32112         LDKChannelAnnouncement this_ptr_conv;
32113         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32114         this_ptr_conv.is_owned = false;
32115         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32116         LDKSignature val_ref;
32117         CHECK(val->arr_len == 64);
32118         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
32119         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
32120 }
32121
32122 uint32_t  __attribute__((export_name("TS_ChannelAnnouncement_get_contents"))) TS_ChannelAnnouncement_get_contents(uint32_t this_ptr) {
32123         LDKChannelAnnouncement this_ptr_conv;
32124         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32125         this_ptr_conv.is_owned = false;
32126         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32127         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
32128         uint32_t ret_ref = 0;
32129         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32130         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32131         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32132         ret_ref = (uintptr_t)ret_var.inner;
32133         if (ret_var.is_owned) {
32134                 ret_ref |= 1;
32135         }
32136         return ret_ref;
32137 }
32138
32139 void  __attribute__((export_name("TS_ChannelAnnouncement_set_contents"))) TS_ChannelAnnouncement_set_contents(uint32_t this_ptr, uint32_t val) {
32140         LDKChannelAnnouncement this_ptr_conv;
32141         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32142         this_ptr_conv.is_owned = false;
32143         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32144         LDKUnsignedChannelAnnouncement val_conv;
32145         val_conv.inner = (void*)(val & (~1));
32146         val_conv.is_owned = (val & 1) || (val == 0);
32147         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32148         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
32149         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
32150 }
32151
32152 uint32_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, uint32_t contents_arg) {
32153         LDKSignature node_signature_1_arg_ref;
32154         CHECK(node_signature_1_arg->arr_len == 64);
32155         memcpy(node_signature_1_arg_ref.compact_form, node_signature_1_arg->elems, 64); FREE(node_signature_1_arg);
32156         LDKSignature node_signature_2_arg_ref;
32157         CHECK(node_signature_2_arg->arr_len == 64);
32158         memcpy(node_signature_2_arg_ref.compact_form, node_signature_2_arg->elems, 64); FREE(node_signature_2_arg);
32159         LDKSignature bitcoin_signature_1_arg_ref;
32160         CHECK(bitcoin_signature_1_arg->arr_len == 64);
32161         memcpy(bitcoin_signature_1_arg_ref.compact_form, bitcoin_signature_1_arg->elems, 64); FREE(bitcoin_signature_1_arg);
32162         LDKSignature bitcoin_signature_2_arg_ref;
32163         CHECK(bitcoin_signature_2_arg->arr_len == 64);
32164         memcpy(bitcoin_signature_2_arg_ref.compact_form, bitcoin_signature_2_arg->elems, 64); FREE(bitcoin_signature_2_arg);
32165         LDKUnsignedChannelAnnouncement contents_arg_conv;
32166         contents_arg_conv.inner = (void*)(contents_arg & (~1));
32167         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
32168         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
32169         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
32170         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);
32171         uint32_t ret_ref = 0;
32172         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32173         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32174         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32175         ret_ref = (uintptr_t)ret_var.inner;
32176         if (ret_var.is_owned) {
32177                 ret_ref |= 1;
32178         }
32179         return ret_ref;
32180 }
32181
32182 static inline uintptr_t ChannelAnnouncement_clone_ptr(LDKChannelAnnouncement *NONNULL_PTR arg) {
32183         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(arg);
32184 uint32_t ret_ref = 0;
32185 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32186 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32187 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32188 ret_ref = (uintptr_t)ret_var.inner;
32189 if (ret_var.is_owned) {
32190         ret_ref |= 1;
32191 }
32192         return ret_ref;
32193 }
32194 uint32_t  __attribute__((export_name("TS_ChannelAnnouncement_clone_ptr"))) TS_ChannelAnnouncement_clone_ptr(uint32_t arg) {
32195         LDKChannelAnnouncement arg_conv;
32196         arg_conv.inner = (void*)(arg & (~1));
32197         arg_conv.is_owned = false;
32198         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32199         uint32_t ret_conv = ChannelAnnouncement_clone_ptr(&arg_conv);
32200         return ret_conv;
32201 }
32202
32203 uint32_t  __attribute__((export_name("TS_ChannelAnnouncement_clone"))) TS_ChannelAnnouncement_clone(uint32_t orig) {
32204         LDKChannelAnnouncement orig_conv;
32205         orig_conv.inner = (void*)(orig & (~1));
32206         orig_conv.is_owned = false;
32207         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32208         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
32209         uint32_t ret_ref = 0;
32210         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32211         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32212         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32213         ret_ref = (uintptr_t)ret_var.inner;
32214         if (ret_var.is_owned) {
32215                 ret_ref |= 1;
32216         }
32217         return ret_ref;
32218 }
32219
32220 void  __attribute__((export_name("TS_UnsignedChannelUpdate_free"))) TS_UnsignedChannelUpdate_free(uint32_t this_obj) {
32221         LDKUnsignedChannelUpdate this_obj_conv;
32222         this_obj_conv.inner = (void*)(this_obj & (~1));
32223         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32224         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32225         UnsignedChannelUpdate_free(this_obj_conv);
32226 }
32227
32228 int8_tArray  __attribute__((export_name("TS_UnsignedChannelUpdate_get_chain_hash"))) TS_UnsignedChannelUpdate_get_chain_hash(uint32_t this_ptr) {
32229         LDKUnsignedChannelUpdate this_ptr_conv;
32230         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32231         this_ptr_conv.is_owned = false;
32232         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32233         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
32234         memcpy(ret_arr->elems, *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv), 32);
32235         return ret_arr;
32236 }
32237
32238 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_chain_hash"))) TS_UnsignedChannelUpdate_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
32239         LDKUnsignedChannelUpdate this_ptr_conv;
32240         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32241         this_ptr_conv.is_owned = false;
32242         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32243         LDKThirtyTwoBytes val_ref;
32244         CHECK(val->arr_len == 32);
32245         memcpy(val_ref.data, val->elems, 32); FREE(val);
32246         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
32247 }
32248
32249 int64_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_short_channel_id"))) TS_UnsignedChannelUpdate_get_short_channel_id(uint32_t this_ptr) {
32250         LDKUnsignedChannelUpdate this_ptr_conv;
32251         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32252         this_ptr_conv.is_owned = false;
32253         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32254         int64_t ret_conv = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
32255         return ret_conv;
32256 }
32257
32258 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_short_channel_id"))) TS_UnsignedChannelUpdate_set_short_channel_id(uint32_t this_ptr, int64_t val) {
32259         LDKUnsignedChannelUpdate this_ptr_conv;
32260         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32261         this_ptr_conv.is_owned = false;
32262         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32263         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
32264 }
32265
32266 int32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_timestamp"))) TS_UnsignedChannelUpdate_get_timestamp(uint32_t this_ptr) {
32267         LDKUnsignedChannelUpdate this_ptr_conv;
32268         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32269         this_ptr_conv.is_owned = false;
32270         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32271         int32_t ret_conv = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
32272         return ret_conv;
32273 }
32274
32275 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_timestamp"))) TS_UnsignedChannelUpdate_set_timestamp(uint32_t this_ptr, int32_t val) {
32276         LDKUnsignedChannelUpdate this_ptr_conv;
32277         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32278         this_ptr_conv.is_owned = false;
32279         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32280         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
32281 }
32282
32283 int8_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_flags"))) TS_UnsignedChannelUpdate_get_flags(uint32_t this_ptr) {
32284         LDKUnsignedChannelUpdate this_ptr_conv;
32285         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32286         this_ptr_conv.is_owned = false;
32287         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32288         int8_t ret_conv = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
32289         return ret_conv;
32290 }
32291
32292 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_flags"))) TS_UnsignedChannelUpdate_set_flags(uint32_t this_ptr, int8_t val) {
32293         LDKUnsignedChannelUpdate this_ptr_conv;
32294         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32295         this_ptr_conv.is_owned = false;
32296         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32297         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
32298 }
32299
32300 int16_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_cltv_expiry_delta"))) TS_UnsignedChannelUpdate_get_cltv_expiry_delta(uint32_t this_ptr) {
32301         LDKUnsignedChannelUpdate this_ptr_conv;
32302         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32303         this_ptr_conv.is_owned = false;
32304         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32305         int16_t ret_conv = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
32306         return ret_conv;
32307 }
32308
32309 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_cltv_expiry_delta"))) TS_UnsignedChannelUpdate_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
32310         LDKUnsignedChannelUpdate this_ptr_conv;
32311         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32312         this_ptr_conv.is_owned = false;
32313         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32314         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
32315 }
32316
32317 int64_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_htlc_minimum_msat"))) TS_UnsignedChannelUpdate_get_htlc_minimum_msat(uint32_t this_ptr) {
32318         LDKUnsignedChannelUpdate this_ptr_conv;
32319         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32320         this_ptr_conv.is_owned = false;
32321         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32322         int64_t ret_conv = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
32323         return ret_conv;
32324 }
32325
32326 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_htlc_minimum_msat"))) TS_UnsignedChannelUpdate_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
32327         LDKUnsignedChannelUpdate this_ptr_conv;
32328         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32329         this_ptr_conv.is_owned = false;
32330         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32331         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
32332 }
32333
32334 int64_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_htlc_maximum_msat"))) TS_UnsignedChannelUpdate_get_htlc_maximum_msat(uint32_t this_ptr) {
32335         LDKUnsignedChannelUpdate this_ptr_conv;
32336         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32337         this_ptr_conv.is_owned = false;
32338         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32339         int64_t ret_conv = UnsignedChannelUpdate_get_htlc_maximum_msat(&this_ptr_conv);
32340         return ret_conv;
32341 }
32342
32343 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_htlc_maximum_msat"))) TS_UnsignedChannelUpdate_set_htlc_maximum_msat(uint32_t this_ptr, int64_t val) {
32344         LDKUnsignedChannelUpdate this_ptr_conv;
32345         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32346         this_ptr_conv.is_owned = false;
32347         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32348         UnsignedChannelUpdate_set_htlc_maximum_msat(&this_ptr_conv, val);
32349 }
32350
32351 int32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_fee_base_msat"))) TS_UnsignedChannelUpdate_get_fee_base_msat(uint32_t this_ptr) {
32352         LDKUnsignedChannelUpdate this_ptr_conv;
32353         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32354         this_ptr_conv.is_owned = false;
32355         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32356         int32_t ret_conv = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
32357         return ret_conv;
32358 }
32359
32360 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_fee_base_msat"))) TS_UnsignedChannelUpdate_set_fee_base_msat(uint32_t this_ptr, int32_t val) {
32361         LDKUnsignedChannelUpdate this_ptr_conv;
32362         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32363         this_ptr_conv.is_owned = false;
32364         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32365         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
32366 }
32367
32368 int32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_fee_proportional_millionths"))) TS_UnsignedChannelUpdate_get_fee_proportional_millionths(uint32_t this_ptr) {
32369         LDKUnsignedChannelUpdate this_ptr_conv;
32370         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32371         this_ptr_conv.is_owned = false;
32372         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32373         int32_t ret_conv = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
32374         return ret_conv;
32375 }
32376
32377 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_fee_proportional_millionths"))) TS_UnsignedChannelUpdate_set_fee_proportional_millionths(uint32_t this_ptr, int32_t val) {
32378         LDKUnsignedChannelUpdate this_ptr_conv;
32379         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32380         this_ptr_conv.is_owned = false;
32381         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32382         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
32383 }
32384
32385 int8_tArray  __attribute__((export_name("TS_UnsignedChannelUpdate_get_excess_data"))) TS_UnsignedChannelUpdate_get_excess_data(uint32_t this_ptr) {
32386         LDKUnsignedChannelUpdate this_ptr_conv;
32387         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32388         this_ptr_conv.is_owned = false;
32389         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32390         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_get_excess_data(&this_ptr_conv);
32391         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32392         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32393         CVec_u8Z_free(ret_var);
32394         return ret_arr;
32395 }
32396
32397 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_excess_data"))) TS_UnsignedChannelUpdate_set_excess_data(uint32_t this_ptr, int8_tArray val) {
32398         LDKUnsignedChannelUpdate this_ptr_conv;
32399         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32400         this_ptr_conv.is_owned = false;
32401         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32402         LDKCVec_u8Z val_ref;
32403         val_ref.datalen = val->arr_len;
32404         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
32405         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
32406         UnsignedChannelUpdate_set_excess_data(&this_ptr_conv, val_ref);
32407 }
32408
32409 uint32_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) {
32410         LDKThirtyTwoBytes chain_hash_arg_ref;
32411         CHECK(chain_hash_arg->arr_len == 32);
32412         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
32413         LDKCVec_u8Z excess_data_arg_ref;
32414         excess_data_arg_ref.datalen = excess_data_arg->arr_len;
32415         excess_data_arg_ref.data = MALLOC(excess_data_arg_ref.datalen, "LDKCVec_u8Z Bytes");
32416         memcpy(excess_data_arg_ref.data, excess_data_arg->elems, excess_data_arg_ref.datalen); FREE(excess_data_arg);
32417         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);
32418         uint32_t ret_ref = 0;
32419         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32420         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32421         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32422         ret_ref = (uintptr_t)ret_var.inner;
32423         if (ret_var.is_owned) {
32424                 ret_ref |= 1;
32425         }
32426         return ret_ref;
32427 }
32428
32429 static inline uintptr_t UnsignedChannelUpdate_clone_ptr(LDKUnsignedChannelUpdate *NONNULL_PTR arg) {
32430         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(arg);
32431 uint32_t ret_ref = 0;
32432 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32433 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32434 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32435 ret_ref = (uintptr_t)ret_var.inner;
32436 if (ret_var.is_owned) {
32437         ret_ref |= 1;
32438 }
32439         return ret_ref;
32440 }
32441 uint32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_clone_ptr"))) TS_UnsignedChannelUpdate_clone_ptr(uint32_t arg) {
32442         LDKUnsignedChannelUpdate arg_conv;
32443         arg_conv.inner = (void*)(arg & (~1));
32444         arg_conv.is_owned = false;
32445         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32446         uint32_t ret_conv = UnsignedChannelUpdate_clone_ptr(&arg_conv);
32447         return ret_conv;
32448 }
32449
32450 uint32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_clone"))) TS_UnsignedChannelUpdate_clone(uint32_t orig) {
32451         LDKUnsignedChannelUpdate orig_conv;
32452         orig_conv.inner = (void*)(orig & (~1));
32453         orig_conv.is_owned = false;
32454         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32455         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
32456         uint32_t ret_ref = 0;
32457         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32458         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32459         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32460         ret_ref = (uintptr_t)ret_var.inner;
32461         if (ret_var.is_owned) {
32462                 ret_ref |= 1;
32463         }
32464         return ret_ref;
32465 }
32466
32467 void  __attribute__((export_name("TS_ChannelUpdate_free"))) TS_ChannelUpdate_free(uint32_t this_obj) {
32468         LDKChannelUpdate this_obj_conv;
32469         this_obj_conv.inner = (void*)(this_obj & (~1));
32470         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32471         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32472         ChannelUpdate_free(this_obj_conv);
32473 }
32474
32475 int8_tArray  __attribute__((export_name("TS_ChannelUpdate_get_signature"))) TS_ChannelUpdate_get_signature(uint32_t this_ptr) {
32476         LDKChannelUpdate this_ptr_conv;
32477         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32478         this_ptr_conv.is_owned = false;
32479         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32480         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
32481         memcpy(ret_arr->elems, ChannelUpdate_get_signature(&this_ptr_conv).compact_form, 64);
32482         return ret_arr;
32483 }
32484
32485 void  __attribute__((export_name("TS_ChannelUpdate_set_signature"))) TS_ChannelUpdate_set_signature(uint32_t this_ptr, int8_tArray val) {
32486         LDKChannelUpdate this_ptr_conv;
32487         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32488         this_ptr_conv.is_owned = false;
32489         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32490         LDKSignature val_ref;
32491         CHECK(val->arr_len == 64);
32492         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
32493         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
32494 }
32495
32496 uint32_t  __attribute__((export_name("TS_ChannelUpdate_get_contents"))) TS_ChannelUpdate_get_contents(uint32_t this_ptr) {
32497         LDKChannelUpdate this_ptr_conv;
32498         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32499         this_ptr_conv.is_owned = false;
32500         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32501         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
32502         uint32_t ret_ref = 0;
32503         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32504         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32505         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32506         ret_ref = (uintptr_t)ret_var.inner;
32507         if (ret_var.is_owned) {
32508                 ret_ref |= 1;
32509         }
32510         return ret_ref;
32511 }
32512
32513 void  __attribute__((export_name("TS_ChannelUpdate_set_contents"))) TS_ChannelUpdate_set_contents(uint32_t this_ptr, uint32_t val) {
32514         LDKChannelUpdate this_ptr_conv;
32515         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32516         this_ptr_conv.is_owned = false;
32517         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32518         LDKUnsignedChannelUpdate val_conv;
32519         val_conv.inner = (void*)(val & (~1));
32520         val_conv.is_owned = (val & 1) || (val == 0);
32521         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32522         val_conv = UnsignedChannelUpdate_clone(&val_conv);
32523         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
32524 }
32525
32526 uint32_t  __attribute__((export_name("TS_ChannelUpdate_new"))) TS_ChannelUpdate_new(int8_tArray signature_arg, uint32_t contents_arg) {
32527         LDKSignature signature_arg_ref;
32528         CHECK(signature_arg->arr_len == 64);
32529         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
32530         LDKUnsignedChannelUpdate contents_arg_conv;
32531         contents_arg_conv.inner = (void*)(contents_arg & (~1));
32532         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
32533         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
32534         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
32535         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
32536         uint32_t ret_ref = 0;
32537         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32538         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32539         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32540         ret_ref = (uintptr_t)ret_var.inner;
32541         if (ret_var.is_owned) {
32542                 ret_ref |= 1;
32543         }
32544         return ret_ref;
32545 }
32546
32547 static inline uintptr_t ChannelUpdate_clone_ptr(LDKChannelUpdate *NONNULL_PTR arg) {
32548         LDKChannelUpdate ret_var = ChannelUpdate_clone(arg);
32549 uint32_t ret_ref = 0;
32550 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32551 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32552 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32553 ret_ref = (uintptr_t)ret_var.inner;
32554 if (ret_var.is_owned) {
32555         ret_ref |= 1;
32556 }
32557         return ret_ref;
32558 }
32559 uint32_t  __attribute__((export_name("TS_ChannelUpdate_clone_ptr"))) TS_ChannelUpdate_clone_ptr(uint32_t arg) {
32560         LDKChannelUpdate arg_conv;
32561         arg_conv.inner = (void*)(arg & (~1));
32562         arg_conv.is_owned = false;
32563         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32564         uint32_t ret_conv = ChannelUpdate_clone_ptr(&arg_conv);
32565         return ret_conv;
32566 }
32567
32568 uint32_t  __attribute__((export_name("TS_ChannelUpdate_clone"))) TS_ChannelUpdate_clone(uint32_t orig) {
32569         LDKChannelUpdate orig_conv;
32570         orig_conv.inner = (void*)(orig & (~1));
32571         orig_conv.is_owned = false;
32572         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32573         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
32574         uint32_t ret_ref = 0;
32575         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32576         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32577         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32578         ret_ref = (uintptr_t)ret_var.inner;
32579         if (ret_var.is_owned) {
32580                 ret_ref |= 1;
32581         }
32582         return ret_ref;
32583 }
32584
32585 void  __attribute__((export_name("TS_QueryChannelRange_free"))) TS_QueryChannelRange_free(uint32_t this_obj) {
32586         LDKQueryChannelRange this_obj_conv;
32587         this_obj_conv.inner = (void*)(this_obj & (~1));
32588         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32589         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32590         QueryChannelRange_free(this_obj_conv);
32591 }
32592
32593 int8_tArray  __attribute__((export_name("TS_QueryChannelRange_get_chain_hash"))) TS_QueryChannelRange_get_chain_hash(uint32_t this_ptr) {
32594         LDKQueryChannelRange this_ptr_conv;
32595         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32596         this_ptr_conv.is_owned = false;
32597         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32598         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
32599         memcpy(ret_arr->elems, *QueryChannelRange_get_chain_hash(&this_ptr_conv), 32);
32600         return ret_arr;
32601 }
32602
32603 void  __attribute__((export_name("TS_QueryChannelRange_set_chain_hash"))) TS_QueryChannelRange_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
32604         LDKQueryChannelRange this_ptr_conv;
32605         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32606         this_ptr_conv.is_owned = false;
32607         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32608         LDKThirtyTwoBytes val_ref;
32609         CHECK(val->arr_len == 32);
32610         memcpy(val_ref.data, val->elems, 32); FREE(val);
32611         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
32612 }
32613
32614 int32_t  __attribute__((export_name("TS_QueryChannelRange_get_first_blocknum"))) TS_QueryChannelRange_get_first_blocknum(uint32_t this_ptr) {
32615         LDKQueryChannelRange this_ptr_conv;
32616         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32617         this_ptr_conv.is_owned = false;
32618         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32619         int32_t ret_conv = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
32620         return ret_conv;
32621 }
32622
32623 void  __attribute__((export_name("TS_QueryChannelRange_set_first_blocknum"))) TS_QueryChannelRange_set_first_blocknum(uint32_t this_ptr, int32_t val) {
32624         LDKQueryChannelRange this_ptr_conv;
32625         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32626         this_ptr_conv.is_owned = false;
32627         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32628         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
32629 }
32630
32631 int32_t  __attribute__((export_name("TS_QueryChannelRange_get_number_of_blocks"))) TS_QueryChannelRange_get_number_of_blocks(uint32_t this_ptr) {
32632         LDKQueryChannelRange this_ptr_conv;
32633         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32634         this_ptr_conv.is_owned = false;
32635         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32636         int32_t ret_conv = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
32637         return ret_conv;
32638 }
32639
32640 void  __attribute__((export_name("TS_QueryChannelRange_set_number_of_blocks"))) TS_QueryChannelRange_set_number_of_blocks(uint32_t this_ptr, int32_t val) {
32641         LDKQueryChannelRange this_ptr_conv;
32642         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32643         this_ptr_conv.is_owned = false;
32644         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32645         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
32646 }
32647
32648 uint32_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) {
32649         LDKThirtyTwoBytes chain_hash_arg_ref;
32650         CHECK(chain_hash_arg->arr_len == 32);
32651         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
32652         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
32653         uint32_t ret_ref = 0;
32654         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32655         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32656         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32657         ret_ref = (uintptr_t)ret_var.inner;
32658         if (ret_var.is_owned) {
32659                 ret_ref |= 1;
32660         }
32661         return ret_ref;
32662 }
32663
32664 static inline uintptr_t QueryChannelRange_clone_ptr(LDKQueryChannelRange *NONNULL_PTR arg) {
32665         LDKQueryChannelRange ret_var = QueryChannelRange_clone(arg);
32666 uint32_t ret_ref = 0;
32667 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32668 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32669 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32670 ret_ref = (uintptr_t)ret_var.inner;
32671 if (ret_var.is_owned) {
32672         ret_ref |= 1;
32673 }
32674         return ret_ref;
32675 }
32676 uint32_t  __attribute__((export_name("TS_QueryChannelRange_clone_ptr"))) TS_QueryChannelRange_clone_ptr(uint32_t arg) {
32677         LDKQueryChannelRange arg_conv;
32678         arg_conv.inner = (void*)(arg & (~1));
32679         arg_conv.is_owned = false;
32680         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32681         uint32_t ret_conv = QueryChannelRange_clone_ptr(&arg_conv);
32682         return ret_conv;
32683 }
32684
32685 uint32_t  __attribute__((export_name("TS_QueryChannelRange_clone"))) TS_QueryChannelRange_clone(uint32_t orig) {
32686         LDKQueryChannelRange orig_conv;
32687         orig_conv.inner = (void*)(orig & (~1));
32688         orig_conv.is_owned = false;
32689         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32690         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
32691         uint32_t ret_ref = 0;
32692         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32693         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32694         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32695         ret_ref = (uintptr_t)ret_var.inner;
32696         if (ret_var.is_owned) {
32697                 ret_ref |= 1;
32698         }
32699         return ret_ref;
32700 }
32701
32702 void  __attribute__((export_name("TS_ReplyChannelRange_free"))) TS_ReplyChannelRange_free(uint32_t this_obj) {
32703         LDKReplyChannelRange this_obj_conv;
32704         this_obj_conv.inner = (void*)(this_obj & (~1));
32705         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32706         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32707         ReplyChannelRange_free(this_obj_conv);
32708 }
32709
32710 int8_tArray  __attribute__((export_name("TS_ReplyChannelRange_get_chain_hash"))) TS_ReplyChannelRange_get_chain_hash(uint32_t this_ptr) {
32711         LDKReplyChannelRange this_ptr_conv;
32712         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32713         this_ptr_conv.is_owned = false;
32714         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32715         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
32716         memcpy(ret_arr->elems, *ReplyChannelRange_get_chain_hash(&this_ptr_conv), 32);
32717         return ret_arr;
32718 }
32719
32720 void  __attribute__((export_name("TS_ReplyChannelRange_set_chain_hash"))) TS_ReplyChannelRange_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
32721         LDKReplyChannelRange this_ptr_conv;
32722         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32723         this_ptr_conv.is_owned = false;
32724         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32725         LDKThirtyTwoBytes val_ref;
32726         CHECK(val->arr_len == 32);
32727         memcpy(val_ref.data, val->elems, 32); FREE(val);
32728         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
32729 }
32730
32731 int32_t  __attribute__((export_name("TS_ReplyChannelRange_get_first_blocknum"))) TS_ReplyChannelRange_get_first_blocknum(uint32_t this_ptr) {
32732         LDKReplyChannelRange this_ptr_conv;
32733         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32734         this_ptr_conv.is_owned = false;
32735         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32736         int32_t ret_conv = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
32737         return ret_conv;
32738 }
32739
32740 void  __attribute__((export_name("TS_ReplyChannelRange_set_first_blocknum"))) TS_ReplyChannelRange_set_first_blocknum(uint32_t this_ptr, int32_t val) {
32741         LDKReplyChannelRange this_ptr_conv;
32742         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32743         this_ptr_conv.is_owned = false;
32744         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32745         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
32746 }
32747
32748 int32_t  __attribute__((export_name("TS_ReplyChannelRange_get_number_of_blocks"))) TS_ReplyChannelRange_get_number_of_blocks(uint32_t this_ptr) {
32749         LDKReplyChannelRange this_ptr_conv;
32750         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32751         this_ptr_conv.is_owned = false;
32752         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32753         int32_t ret_conv = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
32754         return ret_conv;
32755 }
32756
32757 void  __attribute__((export_name("TS_ReplyChannelRange_set_number_of_blocks"))) TS_ReplyChannelRange_set_number_of_blocks(uint32_t this_ptr, int32_t val) {
32758         LDKReplyChannelRange this_ptr_conv;
32759         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32760         this_ptr_conv.is_owned = false;
32761         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32762         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
32763 }
32764
32765 jboolean  __attribute__((export_name("TS_ReplyChannelRange_get_sync_complete"))) TS_ReplyChannelRange_get_sync_complete(uint32_t this_ptr) {
32766         LDKReplyChannelRange this_ptr_conv;
32767         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32768         this_ptr_conv.is_owned = false;
32769         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32770         jboolean ret_conv = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
32771         return ret_conv;
32772 }
32773
32774 void  __attribute__((export_name("TS_ReplyChannelRange_set_sync_complete"))) TS_ReplyChannelRange_set_sync_complete(uint32_t this_ptr, jboolean val) {
32775         LDKReplyChannelRange this_ptr_conv;
32776         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32777         this_ptr_conv.is_owned = false;
32778         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32779         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
32780 }
32781
32782 int64_tArray  __attribute__((export_name("TS_ReplyChannelRange_get_short_channel_ids"))) TS_ReplyChannelRange_get_short_channel_ids(uint32_t this_ptr) {
32783         LDKReplyChannelRange this_ptr_conv;
32784         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32785         this_ptr_conv.is_owned = false;
32786         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32787         LDKCVec_u64Z ret_var = ReplyChannelRange_get_short_channel_ids(&this_ptr_conv);
32788         int64_tArray ret_arr = NULL;
32789         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
32790         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
32791         for (size_t i = 0; i < ret_var.datalen; i++) {
32792                 int64_t ret_conv_8_conv = ret_var.data[i];
32793                 ret_arr_ptr[i] = ret_conv_8_conv;
32794         }
32795         
32796         FREE(ret_var.data);
32797         return ret_arr;
32798 }
32799
32800 void  __attribute__((export_name("TS_ReplyChannelRange_set_short_channel_ids"))) TS_ReplyChannelRange_set_short_channel_ids(uint32_t this_ptr, int64_tArray val) {
32801         LDKReplyChannelRange this_ptr_conv;
32802         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32803         this_ptr_conv.is_owned = false;
32804         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32805         LDKCVec_u64Z val_constr;
32806         val_constr.datalen = val->arr_len;
32807         if (val_constr.datalen > 0)
32808                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
32809         else
32810                 val_constr.data = NULL;
32811         int64_t* val_vals = val->elems;
32812         for (size_t i = 0; i < val_constr.datalen; i++) {
32813                 int64_t val_conv_8 = val_vals[i];
32814                 val_constr.data[i] = val_conv_8;
32815         }
32816         FREE(val);
32817         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
32818 }
32819
32820 uint32_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) {
32821         LDKThirtyTwoBytes chain_hash_arg_ref;
32822         CHECK(chain_hash_arg->arr_len == 32);
32823         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
32824         LDKCVec_u64Z short_channel_ids_arg_constr;
32825         short_channel_ids_arg_constr.datalen = short_channel_ids_arg->arr_len;
32826         if (short_channel_ids_arg_constr.datalen > 0)
32827                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
32828         else
32829                 short_channel_ids_arg_constr.data = NULL;
32830         int64_t* short_channel_ids_arg_vals = short_channel_ids_arg->elems;
32831         for (size_t i = 0; i < short_channel_ids_arg_constr.datalen; i++) {
32832                 int64_t short_channel_ids_arg_conv_8 = short_channel_ids_arg_vals[i];
32833                 short_channel_ids_arg_constr.data[i] = short_channel_ids_arg_conv_8;
32834         }
32835         FREE(short_channel_ids_arg);
32836         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
32837         uint32_t ret_ref = 0;
32838         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32839         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32840         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32841         ret_ref = (uintptr_t)ret_var.inner;
32842         if (ret_var.is_owned) {
32843                 ret_ref |= 1;
32844         }
32845         return ret_ref;
32846 }
32847
32848 static inline uintptr_t ReplyChannelRange_clone_ptr(LDKReplyChannelRange *NONNULL_PTR arg) {
32849         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(arg);
32850 uint32_t ret_ref = 0;
32851 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32852 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32853 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32854 ret_ref = (uintptr_t)ret_var.inner;
32855 if (ret_var.is_owned) {
32856         ret_ref |= 1;
32857 }
32858         return ret_ref;
32859 }
32860 uint32_t  __attribute__((export_name("TS_ReplyChannelRange_clone_ptr"))) TS_ReplyChannelRange_clone_ptr(uint32_t arg) {
32861         LDKReplyChannelRange arg_conv;
32862         arg_conv.inner = (void*)(arg & (~1));
32863         arg_conv.is_owned = false;
32864         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32865         uint32_t ret_conv = ReplyChannelRange_clone_ptr(&arg_conv);
32866         return ret_conv;
32867 }
32868
32869 uint32_t  __attribute__((export_name("TS_ReplyChannelRange_clone"))) TS_ReplyChannelRange_clone(uint32_t orig) {
32870         LDKReplyChannelRange orig_conv;
32871         orig_conv.inner = (void*)(orig & (~1));
32872         orig_conv.is_owned = false;
32873         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32874         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
32875         uint32_t ret_ref = 0;
32876         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32877         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32878         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32879         ret_ref = (uintptr_t)ret_var.inner;
32880         if (ret_var.is_owned) {
32881                 ret_ref |= 1;
32882         }
32883         return ret_ref;
32884 }
32885
32886 void  __attribute__((export_name("TS_QueryShortChannelIds_free"))) TS_QueryShortChannelIds_free(uint32_t this_obj) {
32887         LDKQueryShortChannelIds this_obj_conv;
32888         this_obj_conv.inner = (void*)(this_obj & (~1));
32889         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32890         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32891         QueryShortChannelIds_free(this_obj_conv);
32892 }
32893
32894 int8_tArray  __attribute__((export_name("TS_QueryShortChannelIds_get_chain_hash"))) TS_QueryShortChannelIds_get_chain_hash(uint32_t this_ptr) {
32895         LDKQueryShortChannelIds this_ptr_conv;
32896         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32897         this_ptr_conv.is_owned = false;
32898         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32899         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
32900         memcpy(ret_arr->elems, *QueryShortChannelIds_get_chain_hash(&this_ptr_conv), 32);
32901         return ret_arr;
32902 }
32903
32904 void  __attribute__((export_name("TS_QueryShortChannelIds_set_chain_hash"))) TS_QueryShortChannelIds_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
32905         LDKQueryShortChannelIds this_ptr_conv;
32906         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32907         this_ptr_conv.is_owned = false;
32908         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32909         LDKThirtyTwoBytes val_ref;
32910         CHECK(val->arr_len == 32);
32911         memcpy(val_ref.data, val->elems, 32); FREE(val);
32912         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
32913 }
32914
32915 int64_tArray  __attribute__((export_name("TS_QueryShortChannelIds_get_short_channel_ids"))) TS_QueryShortChannelIds_get_short_channel_ids(uint32_t this_ptr) {
32916         LDKQueryShortChannelIds this_ptr_conv;
32917         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32918         this_ptr_conv.is_owned = false;
32919         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32920         LDKCVec_u64Z ret_var = QueryShortChannelIds_get_short_channel_ids(&this_ptr_conv);
32921         int64_tArray ret_arr = NULL;
32922         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
32923         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
32924         for (size_t i = 0; i < ret_var.datalen; i++) {
32925                 int64_t ret_conv_8_conv = ret_var.data[i];
32926                 ret_arr_ptr[i] = ret_conv_8_conv;
32927         }
32928         
32929         FREE(ret_var.data);
32930         return ret_arr;
32931 }
32932
32933 void  __attribute__((export_name("TS_QueryShortChannelIds_set_short_channel_ids"))) TS_QueryShortChannelIds_set_short_channel_ids(uint32_t this_ptr, int64_tArray val) {
32934         LDKQueryShortChannelIds this_ptr_conv;
32935         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32936         this_ptr_conv.is_owned = false;
32937         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32938         LDKCVec_u64Z val_constr;
32939         val_constr.datalen = val->arr_len;
32940         if (val_constr.datalen > 0)
32941                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
32942         else
32943                 val_constr.data = NULL;
32944         int64_t* val_vals = val->elems;
32945         for (size_t i = 0; i < val_constr.datalen; i++) {
32946                 int64_t val_conv_8 = val_vals[i];
32947                 val_constr.data[i] = val_conv_8;
32948         }
32949         FREE(val);
32950         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
32951 }
32952
32953 uint32_t  __attribute__((export_name("TS_QueryShortChannelIds_new"))) TS_QueryShortChannelIds_new(int8_tArray chain_hash_arg, int64_tArray short_channel_ids_arg) {
32954         LDKThirtyTwoBytes chain_hash_arg_ref;
32955         CHECK(chain_hash_arg->arr_len == 32);
32956         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
32957         LDKCVec_u64Z short_channel_ids_arg_constr;
32958         short_channel_ids_arg_constr.datalen = short_channel_ids_arg->arr_len;
32959         if (short_channel_ids_arg_constr.datalen > 0)
32960                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
32961         else
32962                 short_channel_ids_arg_constr.data = NULL;
32963         int64_t* short_channel_ids_arg_vals = short_channel_ids_arg->elems;
32964         for (size_t i = 0; i < short_channel_ids_arg_constr.datalen; i++) {
32965                 int64_t short_channel_ids_arg_conv_8 = short_channel_ids_arg_vals[i];
32966                 short_channel_ids_arg_constr.data[i] = short_channel_ids_arg_conv_8;
32967         }
32968         FREE(short_channel_ids_arg);
32969         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
32970         uint32_t ret_ref = 0;
32971         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32972         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32973         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32974         ret_ref = (uintptr_t)ret_var.inner;
32975         if (ret_var.is_owned) {
32976                 ret_ref |= 1;
32977         }
32978         return ret_ref;
32979 }
32980
32981 static inline uintptr_t QueryShortChannelIds_clone_ptr(LDKQueryShortChannelIds *NONNULL_PTR arg) {
32982         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(arg);
32983 uint32_t ret_ref = 0;
32984 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32985 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32986 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32987 ret_ref = (uintptr_t)ret_var.inner;
32988 if (ret_var.is_owned) {
32989         ret_ref |= 1;
32990 }
32991         return ret_ref;
32992 }
32993 uint32_t  __attribute__((export_name("TS_QueryShortChannelIds_clone_ptr"))) TS_QueryShortChannelIds_clone_ptr(uint32_t arg) {
32994         LDKQueryShortChannelIds arg_conv;
32995         arg_conv.inner = (void*)(arg & (~1));
32996         arg_conv.is_owned = false;
32997         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32998         uint32_t ret_conv = QueryShortChannelIds_clone_ptr(&arg_conv);
32999         return ret_conv;
33000 }
33001
33002 uint32_t  __attribute__((export_name("TS_QueryShortChannelIds_clone"))) TS_QueryShortChannelIds_clone(uint32_t orig) {
33003         LDKQueryShortChannelIds orig_conv;
33004         orig_conv.inner = (void*)(orig & (~1));
33005         orig_conv.is_owned = false;
33006         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33007         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
33008         uint32_t ret_ref = 0;
33009         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33010         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33011         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33012         ret_ref = (uintptr_t)ret_var.inner;
33013         if (ret_var.is_owned) {
33014                 ret_ref |= 1;
33015         }
33016         return ret_ref;
33017 }
33018
33019 void  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_free"))) TS_ReplyShortChannelIdsEnd_free(uint32_t this_obj) {
33020         LDKReplyShortChannelIdsEnd this_obj_conv;
33021         this_obj_conv.inner = (void*)(this_obj & (~1));
33022         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33023         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33024         ReplyShortChannelIdsEnd_free(this_obj_conv);
33025 }
33026
33027 int8_tArray  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_get_chain_hash"))) TS_ReplyShortChannelIdsEnd_get_chain_hash(uint32_t this_ptr) {
33028         LDKReplyShortChannelIdsEnd this_ptr_conv;
33029         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33030         this_ptr_conv.is_owned = false;
33031         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33032         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
33033         memcpy(ret_arr->elems, *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv), 32);
33034         return ret_arr;
33035 }
33036
33037 void  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_set_chain_hash"))) TS_ReplyShortChannelIdsEnd_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
33038         LDKReplyShortChannelIdsEnd this_ptr_conv;
33039         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33040         this_ptr_conv.is_owned = false;
33041         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33042         LDKThirtyTwoBytes val_ref;
33043         CHECK(val->arr_len == 32);
33044         memcpy(val_ref.data, val->elems, 32); FREE(val);
33045         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
33046 }
33047
33048 jboolean  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_get_full_information"))) TS_ReplyShortChannelIdsEnd_get_full_information(uint32_t this_ptr) {
33049         LDKReplyShortChannelIdsEnd this_ptr_conv;
33050         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33051         this_ptr_conv.is_owned = false;
33052         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33053         jboolean ret_conv = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
33054         return ret_conv;
33055 }
33056
33057 void  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_set_full_information"))) TS_ReplyShortChannelIdsEnd_set_full_information(uint32_t this_ptr, jboolean val) {
33058         LDKReplyShortChannelIdsEnd this_ptr_conv;
33059         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33060         this_ptr_conv.is_owned = false;
33061         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33062         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
33063 }
33064
33065 uint32_t  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_new"))) TS_ReplyShortChannelIdsEnd_new(int8_tArray chain_hash_arg, jboolean full_information_arg) {
33066         LDKThirtyTwoBytes chain_hash_arg_ref;
33067         CHECK(chain_hash_arg->arr_len == 32);
33068         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
33069         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
33070         uint32_t ret_ref = 0;
33071         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33072         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33073         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33074         ret_ref = (uintptr_t)ret_var.inner;
33075         if (ret_var.is_owned) {
33076                 ret_ref |= 1;
33077         }
33078         return ret_ref;
33079 }
33080
33081 static inline uintptr_t ReplyShortChannelIdsEnd_clone_ptr(LDKReplyShortChannelIdsEnd *NONNULL_PTR arg) {
33082         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(arg);
33083 uint32_t ret_ref = 0;
33084 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33085 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33086 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33087 ret_ref = (uintptr_t)ret_var.inner;
33088 if (ret_var.is_owned) {
33089         ret_ref |= 1;
33090 }
33091         return ret_ref;
33092 }
33093 uint32_t  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_clone_ptr"))) TS_ReplyShortChannelIdsEnd_clone_ptr(uint32_t arg) {
33094         LDKReplyShortChannelIdsEnd arg_conv;
33095         arg_conv.inner = (void*)(arg & (~1));
33096         arg_conv.is_owned = false;
33097         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33098         uint32_t ret_conv = ReplyShortChannelIdsEnd_clone_ptr(&arg_conv);
33099         return ret_conv;
33100 }
33101
33102 uint32_t  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_clone"))) TS_ReplyShortChannelIdsEnd_clone(uint32_t orig) {
33103         LDKReplyShortChannelIdsEnd orig_conv;
33104         orig_conv.inner = (void*)(orig & (~1));
33105         orig_conv.is_owned = false;
33106         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33107         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
33108         uint32_t ret_ref = 0;
33109         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33110         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33111         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33112         ret_ref = (uintptr_t)ret_var.inner;
33113         if (ret_var.is_owned) {
33114                 ret_ref |= 1;
33115         }
33116         return ret_ref;
33117 }
33118
33119 void  __attribute__((export_name("TS_GossipTimestampFilter_free"))) TS_GossipTimestampFilter_free(uint32_t this_obj) {
33120         LDKGossipTimestampFilter this_obj_conv;
33121         this_obj_conv.inner = (void*)(this_obj & (~1));
33122         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33123         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33124         GossipTimestampFilter_free(this_obj_conv);
33125 }
33126
33127 int8_tArray  __attribute__((export_name("TS_GossipTimestampFilter_get_chain_hash"))) TS_GossipTimestampFilter_get_chain_hash(uint32_t this_ptr) {
33128         LDKGossipTimestampFilter this_ptr_conv;
33129         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33130         this_ptr_conv.is_owned = false;
33131         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33132         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
33133         memcpy(ret_arr->elems, *GossipTimestampFilter_get_chain_hash(&this_ptr_conv), 32);
33134         return ret_arr;
33135 }
33136
33137 void  __attribute__((export_name("TS_GossipTimestampFilter_set_chain_hash"))) TS_GossipTimestampFilter_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
33138         LDKGossipTimestampFilter this_ptr_conv;
33139         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33140         this_ptr_conv.is_owned = false;
33141         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33142         LDKThirtyTwoBytes val_ref;
33143         CHECK(val->arr_len == 32);
33144         memcpy(val_ref.data, val->elems, 32); FREE(val);
33145         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
33146 }
33147
33148 int32_t  __attribute__((export_name("TS_GossipTimestampFilter_get_first_timestamp"))) TS_GossipTimestampFilter_get_first_timestamp(uint32_t this_ptr) {
33149         LDKGossipTimestampFilter this_ptr_conv;
33150         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33151         this_ptr_conv.is_owned = false;
33152         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33153         int32_t ret_conv = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
33154         return ret_conv;
33155 }
33156
33157 void  __attribute__((export_name("TS_GossipTimestampFilter_set_first_timestamp"))) TS_GossipTimestampFilter_set_first_timestamp(uint32_t this_ptr, int32_t val) {
33158         LDKGossipTimestampFilter this_ptr_conv;
33159         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33160         this_ptr_conv.is_owned = false;
33161         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33162         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
33163 }
33164
33165 int32_t  __attribute__((export_name("TS_GossipTimestampFilter_get_timestamp_range"))) TS_GossipTimestampFilter_get_timestamp_range(uint32_t this_ptr) {
33166         LDKGossipTimestampFilter this_ptr_conv;
33167         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33168         this_ptr_conv.is_owned = false;
33169         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33170         int32_t ret_conv = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
33171         return ret_conv;
33172 }
33173
33174 void  __attribute__((export_name("TS_GossipTimestampFilter_set_timestamp_range"))) TS_GossipTimestampFilter_set_timestamp_range(uint32_t this_ptr, int32_t val) {
33175         LDKGossipTimestampFilter this_ptr_conv;
33176         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33177         this_ptr_conv.is_owned = false;
33178         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33179         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
33180 }
33181
33182 uint32_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) {
33183         LDKThirtyTwoBytes chain_hash_arg_ref;
33184         CHECK(chain_hash_arg->arr_len == 32);
33185         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
33186         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
33187         uint32_t ret_ref = 0;
33188         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33189         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33190         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33191         ret_ref = (uintptr_t)ret_var.inner;
33192         if (ret_var.is_owned) {
33193                 ret_ref |= 1;
33194         }
33195         return ret_ref;
33196 }
33197
33198 static inline uintptr_t GossipTimestampFilter_clone_ptr(LDKGossipTimestampFilter *NONNULL_PTR arg) {
33199         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(arg);
33200 uint32_t ret_ref = 0;
33201 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33202 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33203 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33204 ret_ref = (uintptr_t)ret_var.inner;
33205 if (ret_var.is_owned) {
33206         ret_ref |= 1;
33207 }
33208         return ret_ref;
33209 }
33210 uint32_t  __attribute__((export_name("TS_GossipTimestampFilter_clone_ptr"))) TS_GossipTimestampFilter_clone_ptr(uint32_t arg) {
33211         LDKGossipTimestampFilter arg_conv;
33212         arg_conv.inner = (void*)(arg & (~1));
33213         arg_conv.is_owned = false;
33214         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33215         uint32_t ret_conv = GossipTimestampFilter_clone_ptr(&arg_conv);
33216         return ret_conv;
33217 }
33218
33219 uint32_t  __attribute__((export_name("TS_GossipTimestampFilter_clone"))) TS_GossipTimestampFilter_clone(uint32_t orig) {
33220         LDKGossipTimestampFilter orig_conv;
33221         orig_conv.inner = (void*)(orig & (~1));
33222         orig_conv.is_owned = false;
33223         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33224         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
33225         uint32_t ret_ref = 0;
33226         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33227         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33228         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33229         ret_ref = (uintptr_t)ret_var.inner;
33230         if (ret_var.is_owned) {
33231                 ret_ref |= 1;
33232         }
33233         return ret_ref;
33234 }
33235
33236 void  __attribute__((export_name("TS_ErrorAction_free"))) TS_ErrorAction_free(uint32_t this_ptr) {
33237         if ((this_ptr & 1) != 0) return;
33238         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
33239         CHECK_ACCESS(this_ptr_ptr);
33240         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(this_ptr_ptr);
33241         FREE((void*)this_ptr);
33242         ErrorAction_free(this_ptr_conv);
33243 }
33244
33245 static inline uintptr_t ErrorAction_clone_ptr(LDKErrorAction *NONNULL_PTR arg) {
33246         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
33247         *ret_copy = ErrorAction_clone(arg);
33248 uint32_t ret_ref = (uintptr_t)ret_copy;
33249         return ret_ref;
33250 }
33251 uint32_t  __attribute__((export_name("TS_ErrorAction_clone_ptr"))) TS_ErrorAction_clone_ptr(uint32_t arg) {
33252         LDKErrorAction* arg_conv = (LDKErrorAction*)arg;
33253         uint32_t ret_conv = ErrorAction_clone_ptr(arg_conv);
33254         return ret_conv;
33255 }
33256
33257 uint32_t  __attribute__((export_name("TS_ErrorAction_clone"))) TS_ErrorAction_clone(uint32_t orig) {
33258         LDKErrorAction* orig_conv = (LDKErrorAction*)orig;
33259         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
33260         *ret_copy = ErrorAction_clone(orig_conv);
33261         uint32_t ret_ref = (uintptr_t)ret_copy;
33262         return ret_ref;
33263 }
33264
33265 uint32_t  __attribute__((export_name("TS_ErrorAction_disconnect_peer"))) TS_ErrorAction_disconnect_peer(uint32_t msg) {
33266         LDKErrorMessage msg_conv;
33267         msg_conv.inner = (void*)(msg & (~1));
33268         msg_conv.is_owned = (msg & 1) || (msg == 0);
33269         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
33270         msg_conv = ErrorMessage_clone(&msg_conv);
33271         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
33272         *ret_copy = ErrorAction_disconnect_peer(msg_conv);
33273         uint32_t ret_ref = (uintptr_t)ret_copy;
33274         return ret_ref;
33275 }
33276
33277 uint32_t  __attribute__((export_name("TS_ErrorAction_ignore_error"))) TS_ErrorAction_ignore_error() {
33278         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
33279         *ret_copy = ErrorAction_ignore_error();
33280         uint32_t ret_ref = (uintptr_t)ret_copy;
33281         return ret_ref;
33282 }
33283
33284 uint32_t  __attribute__((export_name("TS_ErrorAction_ignore_and_log"))) TS_ErrorAction_ignore_and_log(uint32_t a) {
33285         LDKLevel a_conv = LDKLevel_from_js(a);
33286         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
33287         *ret_copy = ErrorAction_ignore_and_log(a_conv);
33288         uint32_t ret_ref = (uintptr_t)ret_copy;
33289         return ret_ref;
33290 }
33291
33292 uint32_t  __attribute__((export_name("TS_ErrorAction_ignore_duplicate_gossip"))) TS_ErrorAction_ignore_duplicate_gossip() {
33293         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
33294         *ret_copy = ErrorAction_ignore_duplicate_gossip();
33295         uint32_t ret_ref = (uintptr_t)ret_copy;
33296         return ret_ref;
33297 }
33298
33299 uint32_t  __attribute__((export_name("TS_ErrorAction_send_error_message"))) TS_ErrorAction_send_error_message(uint32_t msg) {
33300         LDKErrorMessage msg_conv;
33301         msg_conv.inner = (void*)(msg & (~1));
33302         msg_conv.is_owned = (msg & 1) || (msg == 0);
33303         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
33304         msg_conv = ErrorMessage_clone(&msg_conv);
33305         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
33306         *ret_copy = ErrorAction_send_error_message(msg_conv);
33307         uint32_t ret_ref = (uintptr_t)ret_copy;
33308         return ret_ref;
33309 }
33310
33311 uint32_t  __attribute__((export_name("TS_ErrorAction_send_warning_message"))) TS_ErrorAction_send_warning_message(uint32_t msg, uint32_t log_level) {
33312         LDKWarningMessage msg_conv;
33313         msg_conv.inner = (void*)(msg & (~1));
33314         msg_conv.is_owned = (msg & 1) || (msg == 0);
33315         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
33316         msg_conv = WarningMessage_clone(&msg_conv);
33317         LDKLevel log_level_conv = LDKLevel_from_js(log_level);
33318         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
33319         *ret_copy = ErrorAction_send_warning_message(msg_conv, log_level_conv);
33320         uint32_t ret_ref = (uintptr_t)ret_copy;
33321         return ret_ref;
33322 }
33323
33324 void  __attribute__((export_name("TS_LightningError_free"))) TS_LightningError_free(uint32_t this_obj) {
33325         LDKLightningError this_obj_conv;
33326         this_obj_conv.inner = (void*)(this_obj & (~1));
33327         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33328         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33329         LightningError_free(this_obj_conv);
33330 }
33331
33332 jstring  __attribute__((export_name("TS_LightningError_get_err"))) TS_LightningError_get_err(uint32_t this_ptr) {
33333         LDKLightningError this_ptr_conv;
33334         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33335         this_ptr_conv.is_owned = false;
33336         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33337         LDKStr ret_str = LightningError_get_err(&this_ptr_conv);
33338         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
33339         Str_free(ret_str);
33340         return ret_conv;
33341 }
33342
33343 void  __attribute__((export_name("TS_LightningError_set_err"))) TS_LightningError_set_err(uint32_t this_ptr, jstring val) {
33344         LDKLightningError this_ptr_conv;
33345         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33346         this_ptr_conv.is_owned = false;
33347         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33348         LDKStr val_conv = str_ref_to_owned_c(val);
33349         LightningError_set_err(&this_ptr_conv, val_conv);
33350 }
33351
33352 uint32_t  __attribute__((export_name("TS_LightningError_get_action"))) TS_LightningError_get_action(uint32_t this_ptr) {
33353         LDKLightningError this_ptr_conv;
33354         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33355         this_ptr_conv.is_owned = false;
33356         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33357         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
33358         *ret_copy = LightningError_get_action(&this_ptr_conv);
33359         uint32_t ret_ref = (uintptr_t)ret_copy;
33360         return ret_ref;
33361 }
33362
33363 void  __attribute__((export_name("TS_LightningError_set_action"))) TS_LightningError_set_action(uint32_t this_ptr, uint32_t val) {
33364         LDKLightningError this_ptr_conv;
33365         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33366         this_ptr_conv.is_owned = false;
33367         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33368         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
33369         CHECK_ACCESS(val_ptr);
33370         LDKErrorAction val_conv = *(LDKErrorAction*)(val_ptr);
33371         val_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)val) & ~1));
33372         LightningError_set_action(&this_ptr_conv, val_conv);
33373 }
33374
33375 uint32_t  __attribute__((export_name("TS_LightningError_new"))) TS_LightningError_new(jstring err_arg, uint32_t action_arg) {
33376         LDKStr err_arg_conv = str_ref_to_owned_c(err_arg);
33377         void* action_arg_ptr = (void*)(((uintptr_t)action_arg) & ~1);
33378         CHECK_ACCESS(action_arg_ptr);
33379         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(action_arg_ptr);
33380         action_arg_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)action_arg) & ~1));
33381         LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv);
33382         uint32_t ret_ref = 0;
33383         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33384         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33385         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33386         ret_ref = (uintptr_t)ret_var.inner;
33387         if (ret_var.is_owned) {
33388                 ret_ref |= 1;
33389         }
33390         return ret_ref;
33391 }
33392
33393 static inline uintptr_t LightningError_clone_ptr(LDKLightningError *NONNULL_PTR arg) {
33394         LDKLightningError ret_var = LightningError_clone(arg);
33395 uint32_t ret_ref = 0;
33396 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33397 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33398 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33399 ret_ref = (uintptr_t)ret_var.inner;
33400 if (ret_var.is_owned) {
33401         ret_ref |= 1;
33402 }
33403         return ret_ref;
33404 }
33405 uint32_t  __attribute__((export_name("TS_LightningError_clone_ptr"))) TS_LightningError_clone_ptr(uint32_t arg) {
33406         LDKLightningError arg_conv;
33407         arg_conv.inner = (void*)(arg & (~1));
33408         arg_conv.is_owned = false;
33409         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33410         uint32_t ret_conv = LightningError_clone_ptr(&arg_conv);
33411         return ret_conv;
33412 }
33413
33414 uint32_t  __attribute__((export_name("TS_LightningError_clone"))) TS_LightningError_clone(uint32_t orig) {
33415         LDKLightningError orig_conv;
33416         orig_conv.inner = (void*)(orig & (~1));
33417         orig_conv.is_owned = false;
33418         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33419         LDKLightningError ret_var = LightningError_clone(&orig_conv);
33420         uint32_t ret_ref = 0;
33421         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33422         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33423         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33424         ret_ref = (uintptr_t)ret_var.inner;
33425         if (ret_var.is_owned) {
33426                 ret_ref |= 1;
33427         }
33428         return ret_ref;
33429 }
33430
33431 void  __attribute__((export_name("TS_CommitmentUpdate_free"))) TS_CommitmentUpdate_free(uint32_t this_obj) {
33432         LDKCommitmentUpdate this_obj_conv;
33433         this_obj_conv.inner = (void*)(this_obj & (~1));
33434         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33435         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33436         CommitmentUpdate_free(this_obj_conv);
33437 }
33438
33439 uint32_tArray  __attribute__((export_name("TS_CommitmentUpdate_get_update_add_htlcs"))) TS_CommitmentUpdate_get_update_add_htlcs(uint32_t this_ptr) {
33440         LDKCommitmentUpdate this_ptr_conv;
33441         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33442         this_ptr_conv.is_owned = false;
33443         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33444         LDKCVec_UpdateAddHTLCZ ret_var = CommitmentUpdate_get_update_add_htlcs(&this_ptr_conv);
33445         uint32_tArray ret_arr = NULL;
33446         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
33447         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 8);
33448         for (size_t p = 0; p < ret_var.datalen; p++) {
33449                 LDKUpdateAddHTLC ret_conv_15_var = ret_var.data[p];
33450                 uint32_t ret_conv_15_ref = 0;
33451                 CHECK((((uintptr_t)ret_conv_15_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33452                 CHECK((((uintptr_t)&ret_conv_15_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33453                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_15_var);
33454                 ret_conv_15_ref = (uintptr_t)ret_conv_15_var.inner;
33455                 if (ret_conv_15_var.is_owned) {
33456                         ret_conv_15_ref |= 1;
33457                 }
33458                 ret_arr_ptr[p] = ret_conv_15_ref;
33459         }
33460         
33461         FREE(ret_var.data);
33462         return ret_arr;
33463 }
33464
33465 void  __attribute__((export_name("TS_CommitmentUpdate_set_update_add_htlcs"))) TS_CommitmentUpdate_set_update_add_htlcs(uint32_t this_ptr, uint32_tArray val) {
33466         LDKCommitmentUpdate this_ptr_conv;
33467         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33468         this_ptr_conv.is_owned = false;
33469         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33470         LDKCVec_UpdateAddHTLCZ val_constr;
33471         val_constr.datalen = val->arr_len;
33472         if (val_constr.datalen > 0)
33473                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
33474         else
33475                 val_constr.data = NULL;
33476         uint32_t* val_vals = val->elems;
33477         for (size_t p = 0; p < val_constr.datalen; p++) {
33478                 uint32_t val_conv_15 = val_vals[p];
33479                 LDKUpdateAddHTLC val_conv_15_conv;
33480                 val_conv_15_conv.inner = (void*)(val_conv_15 & (~1));
33481                 val_conv_15_conv.is_owned = (val_conv_15 & 1) || (val_conv_15 == 0);
33482                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_15_conv);
33483                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
33484                 val_constr.data[p] = val_conv_15_conv;
33485         }
33486         FREE(val);
33487         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
33488 }
33489
33490 uint32_tArray  __attribute__((export_name("TS_CommitmentUpdate_get_update_fulfill_htlcs"))) TS_CommitmentUpdate_get_update_fulfill_htlcs(uint32_t this_ptr) {
33491         LDKCommitmentUpdate this_ptr_conv;
33492         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33493         this_ptr_conv.is_owned = false;
33494         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33495         LDKCVec_UpdateFulfillHTLCZ ret_var = CommitmentUpdate_get_update_fulfill_htlcs(&this_ptr_conv);
33496         uint32_tArray ret_arr = NULL;
33497         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
33498         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 8);
33499         for (size_t t = 0; t < ret_var.datalen; t++) {
33500                 LDKUpdateFulfillHTLC ret_conv_19_var = ret_var.data[t];
33501                 uint32_t ret_conv_19_ref = 0;
33502                 CHECK((((uintptr_t)ret_conv_19_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33503                 CHECK((((uintptr_t)&ret_conv_19_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33504                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_19_var);
33505                 ret_conv_19_ref = (uintptr_t)ret_conv_19_var.inner;
33506                 if (ret_conv_19_var.is_owned) {
33507                         ret_conv_19_ref |= 1;
33508                 }
33509                 ret_arr_ptr[t] = ret_conv_19_ref;
33510         }
33511         
33512         FREE(ret_var.data);
33513         return ret_arr;
33514 }
33515
33516 void  __attribute__((export_name("TS_CommitmentUpdate_set_update_fulfill_htlcs"))) TS_CommitmentUpdate_set_update_fulfill_htlcs(uint32_t this_ptr, uint32_tArray val) {
33517         LDKCommitmentUpdate this_ptr_conv;
33518         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33519         this_ptr_conv.is_owned = false;
33520         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33521         LDKCVec_UpdateFulfillHTLCZ val_constr;
33522         val_constr.datalen = val->arr_len;
33523         if (val_constr.datalen > 0)
33524                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
33525         else
33526                 val_constr.data = NULL;
33527         uint32_t* val_vals = val->elems;
33528         for (size_t t = 0; t < val_constr.datalen; t++) {
33529                 uint32_t val_conv_19 = val_vals[t];
33530                 LDKUpdateFulfillHTLC val_conv_19_conv;
33531                 val_conv_19_conv.inner = (void*)(val_conv_19 & (~1));
33532                 val_conv_19_conv.is_owned = (val_conv_19 & 1) || (val_conv_19 == 0);
33533                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_19_conv);
33534                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
33535                 val_constr.data[t] = val_conv_19_conv;
33536         }
33537         FREE(val);
33538         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
33539 }
33540
33541 uint32_tArray  __attribute__((export_name("TS_CommitmentUpdate_get_update_fail_htlcs"))) TS_CommitmentUpdate_get_update_fail_htlcs(uint32_t this_ptr) {
33542         LDKCommitmentUpdate this_ptr_conv;
33543         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33544         this_ptr_conv.is_owned = false;
33545         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33546         LDKCVec_UpdateFailHTLCZ ret_var = CommitmentUpdate_get_update_fail_htlcs(&this_ptr_conv);
33547         uint32_tArray ret_arr = NULL;
33548         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
33549         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 8);
33550         for (size_t q = 0; q < ret_var.datalen; q++) {
33551                 LDKUpdateFailHTLC ret_conv_16_var = ret_var.data[q];
33552                 uint32_t ret_conv_16_ref = 0;
33553                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33554                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33555                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
33556                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
33557                 if (ret_conv_16_var.is_owned) {
33558                         ret_conv_16_ref |= 1;
33559                 }
33560                 ret_arr_ptr[q] = ret_conv_16_ref;
33561         }
33562         
33563         FREE(ret_var.data);
33564         return ret_arr;
33565 }
33566
33567 void  __attribute__((export_name("TS_CommitmentUpdate_set_update_fail_htlcs"))) TS_CommitmentUpdate_set_update_fail_htlcs(uint32_t this_ptr, uint32_tArray val) {
33568         LDKCommitmentUpdate this_ptr_conv;
33569         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33570         this_ptr_conv.is_owned = false;
33571         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33572         LDKCVec_UpdateFailHTLCZ val_constr;
33573         val_constr.datalen = val->arr_len;
33574         if (val_constr.datalen > 0)
33575                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
33576         else
33577                 val_constr.data = NULL;
33578         uint32_t* val_vals = val->elems;
33579         for (size_t q = 0; q < val_constr.datalen; q++) {
33580                 uint32_t val_conv_16 = val_vals[q];
33581                 LDKUpdateFailHTLC val_conv_16_conv;
33582                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
33583                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
33584                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
33585                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
33586                 val_constr.data[q] = val_conv_16_conv;
33587         }
33588         FREE(val);
33589         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
33590 }
33591
33592 uint32_tArray  __attribute__((export_name("TS_CommitmentUpdate_get_update_fail_malformed_htlcs"))) TS_CommitmentUpdate_get_update_fail_malformed_htlcs(uint32_t this_ptr) {
33593         LDKCommitmentUpdate this_ptr_conv;
33594         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33595         this_ptr_conv.is_owned = false;
33596         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33597         LDKCVec_UpdateFailMalformedHTLCZ ret_var = CommitmentUpdate_get_update_fail_malformed_htlcs(&this_ptr_conv);
33598         uint32_tArray ret_arr = NULL;
33599         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
33600         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 8);
33601         for (size_t z = 0; z < ret_var.datalen; z++) {
33602                 LDKUpdateFailMalformedHTLC ret_conv_25_var = ret_var.data[z];
33603                 uint32_t ret_conv_25_ref = 0;
33604                 CHECK((((uintptr_t)ret_conv_25_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33605                 CHECK((((uintptr_t)&ret_conv_25_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33606                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_25_var);
33607                 ret_conv_25_ref = (uintptr_t)ret_conv_25_var.inner;
33608                 if (ret_conv_25_var.is_owned) {
33609                         ret_conv_25_ref |= 1;
33610                 }
33611                 ret_arr_ptr[z] = ret_conv_25_ref;
33612         }
33613         
33614         FREE(ret_var.data);
33615         return ret_arr;
33616 }
33617
33618 void  __attribute__((export_name("TS_CommitmentUpdate_set_update_fail_malformed_htlcs"))) TS_CommitmentUpdate_set_update_fail_malformed_htlcs(uint32_t this_ptr, uint32_tArray val) {
33619         LDKCommitmentUpdate this_ptr_conv;
33620         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33621         this_ptr_conv.is_owned = false;
33622         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33623         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
33624         val_constr.datalen = val->arr_len;
33625         if (val_constr.datalen > 0)
33626                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
33627         else
33628                 val_constr.data = NULL;
33629         uint32_t* val_vals = val->elems;
33630         for (size_t z = 0; z < val_constr.datalen; z++) {
33631                 uint32_t val_conv_25 = val_vals[z];
33632                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
33633                 val_conv_25_conv.inner = (void*)(val_conv_25 & (~1));
33634                 val_conv_25_conv.is_owned = (val_conv_25 & 1) || (val_conv_25 == 0);
33635                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_25_conv);
33636                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
33637                 val_constr.data[z] = val_conv_25_conv;
33638         }
33639         FREE(val);
33640         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
33641 }
33642
33643 uint32_t  __attribute__((export_name("TS_CommitmentUpdate_get_update_fee"))) TS_CommitmentUpdate_get_update_fee(uint32_t this_ptr) {
33644         LDKCommitmentUpdate this_ptr_conv;
33645         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33646         this_ptr_conv.is_owned = false;
33647         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33648         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
33649         uint32_t ret_ref = 0;
33650         if ((uintptr_t)ret_var.inner > 4096) {
33651                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33652                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33653         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33654                 ret_ref = (uintptr_t)ret_var.inner;
33655                 if (ret_var.is_owned) {
33656                         ret_ref |= 1;
33657                 }
33658         }
33659         return ret_ref;
33660 }
33661
33662 void  __attribute__((export_name("TS_CommitmentUpdate_set_update_fee"))) TS_CommitmentUpdate_set_update_fee(uint32_t this_ptr, uint32_t val) {
33663         LDKCommitmentUpdate this_ptr_conv;
33664         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33665         this_ptr_conv.is_owned = false;
33666         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33667         LDKUpdateFee val_conv;
33668         val_conv.inner = (void*)(val & (~1));
33669         val_conv.is_owned = (val & 1) || (val == 0);
33670         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33671         val_conv = UpdateFee_clone(&val_conv);
33672         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
33673 }
33674
33675 uint32_t  __attribute__((export_name("TS_CommitmentUpdate_get_commitment_signed"))) TS_CommitmentUpdate_get_commitment_signed(uint32_t this_ptr) {
33676         LDKCommitmentUpdate this_ptr_conv;
33677         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33678         this_ptr_conv.is_owned = false;
33679         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33680         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
33681         uint32_t ret_ref = 0;
33682         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33683         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33684         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33685         ret_ref = (uintptr_t)ret_var.inner;
33686         if (ret_var.is_owned) {
33687                 ret_ref |= 1;
33688         }
33689         return ret_ref;
33690 }
33691
33692 void  __attribute__((export_name("TS_CommitmentUpdate_set_commitment_signed"))) TS_CommitmentUpdate_set_commitment_signed(uint32_t this_ptr, uint32_t val) {
33693         LDKCommitmentUpdate this_ptr_conv;
33694         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33695         this_ptr_conv.is_owned = false;
33696         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33697         LDKCommitmentSigned val_conv;
33698         val_conv.inner = (void*)(val & (~1));
33699         val_conv.is_owned = (val & 1) || (val == 0);
33700         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33701         val_conv = CommitmentSigned_clone(&val_conv);
33702         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
33703 }
33704
33705 uint32_t  __attribute__((export_name("TS_CommitmentUpdate_new"))) TS_CommitmentUpdate_new(uint32_tArray update_add_htlcs_arg, uint32_tArray update_fulfill_htlcs_arg, uint32_tArray update_fail_htlcs_arg, uint32_tArray update_fail_malformed_htlcs_arg, uint32_t update_fee_arg, uint32_t commitment_signed_arg) {
33706         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
33707         update_add_htlcs_arg_constr.datalen = update_add_htlcs_arg->arr_len;
33708         if (update_add_htlcs_arg_constr.datalen > 0)
33709                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
33710         else
33711                 update_add_htlcs_arg_constr.data = NULL;
33712         uint32_t* update_add_htlcs_arg_vals = update_add_htlcs_arg->elems;
33713         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
33714                 uint32_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
33715                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
33716                 update_add_htlcs_arg_conv_15_conv.inner = (void*)(update_add_htlcs_arg_conv_15 & (~1));
33717                 update_add_htlcs_arg_conv_15_conv.is_owned = (update_add_htlcs_arg_conv_15 & 1) || (update_add_htlcs_arg_conv_15 == 0);
33718                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_add_htlcs_arg_conv_15_conv);
33719                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
33720                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
33721         }
33722         FREE(update_add_htlcs_arg);
33723         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
33724         update_fulfill_htlcs_arg_constr.datalen = update_fulfill_htlcs_arg->arr_len;
33725         if (update_fulfill_htlcs_arg_constr.datalen > 0)
33726                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
33727         else
33728                 update_fulfill_htlcs_arg_constr.data = NULL;
33729         uint32_t* update_fulfill_htlcs_arg_vals = update_fulfill_htlcs_arg->elems;
33730         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
33731                 uint32_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
33732                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
33733                 update_fulfill_htlcs_arg_conv_19_conv.inner = (void*)(update_fulfill_htlcs_arg_conv_19 & (~1));
33734                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = (update_fulfill_htlcs_arg_conv_19 & 1) || (update_fulfill_htlcs_arg_conv_19 == 0);
33735                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fulfill_htlcs_arg_conv_19_conv);
33736                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
33737                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
33738         }
33739         FREE(update_fulfill_htlcs_arg);
33740         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
33741         update_fail_htlcs_arg_constr.datalen = update_fail_htlcs_arg->arr_len;
33742         if (update_fail_htlcs_arg_constr.datalen > 0)
33743                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
33744         else
33745                 update_fail_htlcs_arg_constr.data = NULL;
33746         uint32_t* update_fail_htlcs_arg_vals = update_fail_htlcs_arg->elems;
33747         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
33748                 uint32_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
33749                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
33750                 update_fail_htlcs_arg_conv_16_conv.inner = (void*)(update_fail_htlcs_arg_conv_16 & (~1));
33751                 update_fail_htlcs_arg_conv_16_conv.is_owned = (update_fail_htlcs_arg_conv_16 & 1) || (update_fail_htlcs_arg_conv_16 == 0);
33752                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_htlcs_arg_conv_16_conv);
33753                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
33754                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
33755         }
33756         FREE(update_fail_htlcs_arg);
33757         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
33758         update_fail_malformed_htlcs_arg_constr.datalen = update_fail_malformed_htlcs_arg->arr_len;
33759         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
33760                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
33761         else
33762                 update_fail_malformed_htlcs_arg_constr.data = NULL;
33763         uint32_t* update_fail_malformed_htlcs_arg_vals = update_fail_malformed_htlcs_arg->elems;
33764         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
33765                 uint32_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
33766                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
33767                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = (void*)(update_fail_malformed_htlcs_arg_conv_25 & (~1));
33768                 update_fail_malformed_htlcs_arg_conv_25_conv.is_owned = (update_fail_malformed_htlcs_arg_conv_25 & 1) || (update_fail_malformed_htlcs_arg_conv_25 == 0);
33769                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_malformed_htlcs_arg_conv_25_conv);
33770                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
33771                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
33772         }
33773         FREE(update_fail_malformed_htlcs_arg);
33774         LDKUpdateFee update_fee_arg_conv;
33775         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
33776         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
33777         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fee_arg_conv);
33778         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
33779         LDKCommitmentSigned commitment_signed_arg_conv;
33780         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
33781         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
33782         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_signed_arg_conv);
33783         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
33784         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);
33785         uint32_t ret_ref = 0;
33786         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33787         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33788         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33789         ret_ref = (uintptr_t)ret_var.inner;
33790         if (ret_var.is_owned) {
33791                 ret_ref |= 1;
33792         }
33793         return ret_ref;
33794 }
33795
33796 static inline uintptr_t CommitmentUpdate_clone_ptr(LDKCommitmentUpdate *NONNULL_PTR arg) {
33797         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(arg);
33798 uint32_t ret_ref = 0;
33799 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33800 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33801 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33802 ret_ref = (uintptr_t)ret_var.inner;
33803 if (ret_var.is_owned) {
33804         ret_ref |= 1;
33805 }
33806         return ret_ref;
33807 }
33808 uint32_t  __attribute__((export_name("TS_CommitmentUpdate_clone_ptr"))) TS_CommitmentUpdate_clone_ptr(uint32_t arg) {
33809         LDKCommitmentUpdate arg_conv;
33810         arg_conv.inner = (void*)(arg & (~1));
33811         arg_conv.is_owned = false;
33812         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33813         uint32_t ret_conv = CommitmentUpdate_clone_ptr(&arg_conv);
33814         return ret_conv;
33815 }
33816
33817 uint32_t  __attribute__((export_name("TS_CommitmentUpdate_clone"))) TS_CommitmentUpdate_clone(uint32_t orig) {
33818         LDKCommitmentUpdate orig_conv;
33819         orig_conv.inner = (void*)(orig & (~1));
33820         orig_conv.is_owned = false;
33821         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33822         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
33823         uint32_t ret_ref = 0;
33824         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33825         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33826         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33827         ret_ref = (uintptr_t)ret_var.inner;
33828         if (ret_var.is_owned) {
33829                 ret_ref |= 1;
33830         }
33831         return ret_ref;
33832 }
33833
33834 void  __attribute__((export_name("TS_ChannelMessageHandler_free"))) TS_ChannelMessageHandler_free(uint32_t this_ptr) {
33835         if ((this_ptr & 1) != 0) return;
33836         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
33837         CHECK_ACCESS(this_ptr_ptr);
33838         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(this_ptr_ptr);
33839         FREE((void*)this_ptr);
33840         ChannelMessageHandler_free(this_ptr_conv);
33841 }
33842
33843 void  __attribute__((export_name("TS_RoutingMessageHandler_free"))) TS_RoutingMessageHandler_free(uint32_t this_ptr) {
33844         if ((this_ptr & 1) != 0) return;
33845         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
33846         CHECK_ACCESS(this_ptr_ptr);
33847         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(this_ptr_ptr);
33848         FREE((void*)this_ptr);
33849         RoutingMessageHandler_free(this_ptr_conv);
33850 }
33851
33852 int8_tArray  __attribute__((export_name("TS_AcceptChannel_write"))) TS_AcceptChannel_write(uint32_t obj) {
33853         LDKAcceptChannel obj_conv;
33854         obj_conv.inner = (void*)(obj & (~1));
33855         obj_conv.is_owned = false;
33856         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33857         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
33858         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33859         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33860         CVec_u8Z_free(ret_var);
33861         return ret_arr;
33862 }
33863
33864 uint32_t  __attribute__((export_name("TS_AcceptChannel_read"))) TS_AcceptChannel_read(int8_tArray ser) {
33865         LDKu8slice ser_ref;
33866         ser_ref.datalen = ser->arr_len;
33867         ser_ref.data = ser->elems;
33868         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
33869         *ret_conv = AcceptChannel_read(ser_ref);
33870         FREE(ser);
33871         return (uint32_t)ret_conv;
33872 }
33873
33874 int8_tArray  __attribute__((export_name("TS_AnnouncementSignatures_write"))) TS_AnnouncementSignatures_write(uint32_t obj) {
33875         LDKAnnouncementSignatures obj_conv;
33876         obj_conv.inner = (void*)(obj & (~1));
33877         obj_conv.is_owned = false;
33878         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33879         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
33880         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33881         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33882         CVec_u8Z_free(ret_var);
33883         return ret_arr;
33884 }
33885
33886 uint32_t  __attribute__((export_name("TS_AnnouncementSignatures_read"))) TS_AnnouncementSignatures_read(int8_tArray ser) {
33887         LDKu8slice ser_ref;
33888         ser_ref.datalen = ser->arr_len;
33889         ser_ref.data = ser->elems;
33890         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
33891         *ret_conv = AnnouncementSignatures_read(ser_ref);
33892         FREE(ser);
33893         return (uint32_t)ret_conv;
33894 }
33895
33896 int8_tArray  __attribute__((export_name("TS_ChannelReestablish_write"))) TS_ChannelReestablish_write(uint32_t obj) {
33897         LDKChannelReestablish obj_conv;
33898         obj_conv.inner = (void*)(obj & (~1));
33899         obj_conv.is_owned = false;
33900         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33901         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
33902         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33903         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33904         CVec_u8Z_free(ret_var);
33905         return ret_arr;
33906 }
33907
33908 uint32_t  __attribute__((export_name("TS_ChannelReestablish_read"))) TS_ChannelReestablish_read(int8_tArray ser) {
33909         LDKu8slice ser_ref;
33910         ser_ref.datalen = ser->arr_len;
33911         ser_ref.data = ser->elems;
33912         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
33913         *ret_conv = ChannelReestablish_read(ser_ref);
33914         FREE(ser);
33915         return (uint32_t)ret_conv;
33916 }
33917
33918 int8_tArray  __attribute__((export_name("TS_ClosingSigned_write"))) TS_ClosingSigned_write(uint32_t obj) {
33919         LDKClosingSigned obj_conv;
33920         obj_conv.inner = (void*)(obj & (~1));
33921         obj_conv.is_owned = false;
33922         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33923         LDKCVec_u8Z ret_var = ClosingSigned_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 uint32_t  __attribute__((export_name("TS_ClosingSigned_read"))) TS_ClosingSigned_read(int8_tArray ser) {
33931         LDKu8slice ser_ref;
33932         ser_ref.datalen = ser->arr_len;
33933         ser_ref.data = ser->elems;
33934         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
33935         *ret_conv = ClosingSigned_read(ser_ref);
33936         FREE(ser);
33937         return (uint32_t)ret_conv;
33938 }
33939
33940 int8_tArray  __attribute__((export_name("TS_ClosingSignedFeeRange_write"))) TS_ClosingSignedFeeRange_write(uint32_t obj) {
33941         LDKClosingSignedFeeRange obj_conv;
33942         obj_conv.inner = (void*)(obj & (~1));
33943         obj_conv.is_owned = false;
33944         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33945         LDKCVec_u8Z ret_var = ClosingSignedFeeRange_write(&obj_conv);
33946         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33947         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33948         CVec_u8Z_free(ret_var);
33949         return ret_arr;
33950 }
33951
33952 uint32_t  __attribute__((export_name("TS_ClosingSignedFeeRange_read"))) TS_ClosingSignedFeeRange_read(int8_tArray ser) {
33953         LDKu8slice ser_ref;
33954         ser_ref.datalen = ser->arr_len;
33955         ser_ref.data = ser->elems;
33956         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
33957         *ret_conv = ClosingSignedFeeRange_read(ser_ref);
33958         FREE(ser);
33959         return (uint32_t)ret_conv;
33960 }
33961
33962 int8_tArray  __attribute__((export_name("TS_CommitmentSigned_write"))) TS_CommitmentSigned_write(uint32_t obj) {
33963         LDKCommitmentSigned obj_conv;
33964         obj_conv.inner = (void*)(obj & (~1));
33965         obj_conv.is_owned = false;
33966         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33967         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
33968         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33969         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33970         CVec_u8Z_free(ret_var);
33971         return ret_arr;
33972 }
33973
33974 uint32_t  __attribute__((export_name("TS_CommitmentSigned_read"))) TS_CommitmentSigned_read(int8_tArray ser) {
33975         LDKu8slice ser_ref;
33976         ser_ref.datalen = ser->arr_len;
33977         ser_ref.data = ser->elems;
33978         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
33979         *ret_conv = CommitmentSigned_read(ser_ref);
33980         FREE(ser);
33981         return (uint32_t)ret_conv;
33982 }
33983
33984 int8_tArray  __attribute__((export_name("TS_FundingCreated_write"))) TS_FundingCreated_write(uint32_t obj) {
33985         LDKFundingCreated obj_conv;
33986         obj_conv.inner = (void*)(obj & (~1));
33987         obj_conv.is_owned = false;
33988         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33989         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
33990         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33991         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33992         CVec_u8Z_free(ret_var);
33993         return ret_arr;
33994 }
33995
33996 uint32_t  __attribute__((export_name("TS_FundingCreated_read"))) TS_FundingCreated_read(int8_tArray ser) {
33997         LDKu8slice ser_ref;
33998         ser_ref.datalen = ser->arr_len;
33999         ser_ref.data = ser->elems;
34000         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
34001         *ret_conv = FundingCreated_read(ser_ref);
34002         FREE(ser);
34003         return (uint32_t)ret_conv;
34004 }
34005
34006 int8_tArray  __attribute__((export_name("TS_FundingSigned_write"))) TS_FundingSigned_write(uint32_t obj) {
34007         LDKFundingSigned obj_conv;
34008         obj_conv.inner = (void*)(obj & (~1));
34009         obj_conv.is_owned = false;
34010         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34011         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
34012         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34013         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34014         CVec_u8Z_free(ret_var);
34015         return ret_arr;
34016 }
34017
34018 uint32_t  __attribute__((export_name("TS_FundingSigned_read"))) TS_FundingSigned_read(int8_tArray ser) {
34019         LDKu8slice ser_ref;
34020         ser_ref.datalen = ser->arr_len;
34021         ser_ref.data = ser->elems;
34022         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
34023         *ret_conv = FundingSigned_read(ser_ref);
34024         FREE(ser);
34025         return (uint32_t)ret_conv;
34026 }
34027
34028 int8_tArray  __attribute__((export_name("TS_ChannelReady_write"))) TS_ChannelReady_write(uint32_t obj) {
34029         LDKChannelReady obj_conv;
34030         obj_conv.inner = (void*)(obj & (~1));
34031         obj_conv.is_owned = false;
34032         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34033         LDKCVec_u8Z ret_var = ChannelReady_write(&obj_conv);
34034         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34035         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34036         CVec_u8Z_free(ret_var);
34037         return ret_arr;
34038 }
34039
34040 uint32_t  __attribute__((export_name("TS_ChannelReady_read"))) TS_ChannelReady_read(int8_tArray ser) {
34041         LDKu8slice ser_ref;
34042         ser_ref.datalen = ser->arr_len;
34043         ser_ref.data = ser->elems;
34044         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
34045         *ret_conv = ChannelReady_read(ser_ref);
34046         FREE(ser);
34047         return (uint32_t)ret_conv;
34048 }
34049
34050 int8_tArray  __attribute__((export_name("TS_Init_write"))) TS_Init_write(uint32_t obj) {
34051         LDKInit obj_conv;
34052         obj_conv.inner = (void*)(obj & (~1));
34053         obj_conv.is_owned = false;
34054         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34055         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
34056         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34057         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34058         CVec_u8Z_free(ret_var);
34059         return ret_arr;
34060 }
34061
34062 uint32_t  __attribute__((export_name("TS_Init_read"))) TS_Init_read(int8_tArray ser) {
34063         LDKu8slice ser_ref;
34064         ser_ref.datalen = ser->arr_len;
34065         ser_ref.data = ser->elems;
34066         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
34067         *ret_conv = Init_read(ser_ref);
34068         FREE(ser);
34069         return (uint32_t)ret_conv;
34070 }
34071
34072 int8_tArray  __attribute__((export_name("TS_OpenChannel_write"))) TS_OpenChannel_write(uint32_t obj) {
34073         LDKOpenChannel obj_conv;
34074         obj_conv.inner = (void*)(obj & (~1));
34075         obj_conv.is_owned = false;
34076         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34077         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
34078         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34079         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34080         CVec_u8Z_free(ret_var);
34081         return ret_arr;
34082 }
34083
34084 uint32_t  __attribute__((export_name("TS_OpenChannel_read"))) TS_OpenChannel_read(int8_tArray ser) {
34085         LDKu8slice ser_ref;
34086         ser_ref.datalen = ser->arr_len;
34087         ser_ref.data = ser->elems;
34088         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
34089         *ret_conv = OpenChannel_read(ser_ref);
34090         FREE(ser);
34091         return (uint32_t)ret_conv;
34092 }
34093
34094 int8_tArray  __attribute__((export_name("TS_RevokeAndACK_write"))) TS_RevokeAndACK_write(uint32_t obj) {
34095         LDKRevokeAndACK obj_conv;
34096         obj_conv.inner = (void*)(obj & (~1));
34097         obj_conv.is_owned = false;
34098         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34099         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
34100         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34101         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34102         CVec_u8Z_free(ret_var);
34103         return ret_arr;
34104 }
34105
34106 uint32_t  __attribute__((export_name("TS_RevokeAndACK_read"))) TS_RevokeAndACK_read(int8_tArray ser) {
34107         LDKu8slice ser_ref;
34108         ser_ref.datalen = ser->arr_len;
34109         ser_ref.data = ser->elems;
34110         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
34111         *ret_conv = RevokeAndACK_read(ser_ref);
34112         FREE(ser);
34113         return (uint32_t)ret_conv;
34114 }
34115
34116 int8_tArray  __attribute__((export_name("TS_Shutdown_write"))) TS_Shutdown_write(uint32_t obj) {
34117         LDKShutdown obj_conv;
34118         obj_conv.inner = (void*)(obj & (~1));
34119         obj_conv.is_owned = false;
34120         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34121         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
34122         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34123         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34124         CVec_u8Z_free(ret_var);
34125         return ret_arr;
34126 }
34127
34128 uint32_t  __attribute__((export_name("TS_Shutdown_read"))) TS_Shutdown_read(int8_tArray ser) {
34129         LDKu8slice ser_ref;
34130         ser_ref.datalen = ser->arr_len;
34131         ser_ref.data = ser->elems;
34132         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
34133         *ret_conv = Shutdown_read(ser_ref);
34134         FREE(ser);
34135         return (uint32_t)ret_conv;
34136 }
34137
34138 int8_tArray  __attribute__((export_name("TS_UpdateFailHTLC_write"))) TS_UpdateFailHTLC_write(uint32_t obj) {
34139         LDKUpdateFailHTLC obj_conv;
34140         obj_conv.inner = (void*)(obj & (~1));
34141         obj_conv.is_owned = false;
34142         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34143         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
34144         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34145         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34146         CVec_u8Z_free(ret_var);
34147         return ret_arr;
34148 }
34149
34150 uint32_t  __attribute__((export_name("TS_UpdateFailHTLC_read"))) TS_UpdateFailHTLC_read(int8_tArray ser) {
34151         LDKu8slice ser_ref;
34152         ser_ref.datalen = ser->arr_len;
34153         ser_ref.data = ser->elems;
34154         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
34155         *ret_conv = UpdateFailHTLC_read(ser_ref);
34156         FREE(ser);
34157         return (uint32_t)ret_conv;
34158 }
34159
34160 int8_tArray  __attribute__((export_name("TS_UpdateFailMalformedHTLC_write"))) TS_UpdateFailMalformedHTLC_write(uint32_t obj) {
34161         LDKUpdateFailMalformedHTLC obj_conv;
34162         obj_conv.inner = (void*)(obj & (~1));
34163         obj_conv.is_owned = false;
34164         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34165         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
34166         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34167         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34168         CVec_u8Z_free(ret_var);
34169         return ret_arr;
34170 }
34171
34172 uint32_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_read"))) TS_UpdateFailMalformedHTLC_read(int8_tArray ser) {
34173         LDKu8slice ser_ref;
34174         ser_ref.datalen = ser->arr_len;
34175         ser_ref.data = ser->elems;
34176         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
34177         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
34178         FREE(ser);
34179         return (uint32_t)ret_conv;
34180 }
34181
34182 int8_tArray  __attribute__((export_name("TS_UpdateFee_write"))) TS_UpdateFee_write(uint32_t obj) {
34183         LDKUpdateFee obj_conv;
34184         obj_conv.inner = (void*)(obj & (~1));
34185         obj_conv.is_owned = false;
34186         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34187         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
34188         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34189         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34190         CVec_u8Z_free(ret_var);
34191         return ret_arr;
34192 }
34193
34194 uint32_t  __attribute__((export_name("TS_UpdateFee_read"))) TS_UpdateFee_read(int8_tArray ser) {
34195         LDKu8slice ser_ref;
34196         ser_ref.datalen = ser->arr_len;
34197         ser_ref.data = ser->elems;
34198         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
34199         *ret_conv = UpdateFee_read(ser_ref);
34200         FREE(ser);
34201         return (uint32_t)ret_conv;
34202 }
34203
34204 int8_tArray  __attribute__((export_name("TS_UpdateFulfillHTLC_write"))) TS_UpdateFulfillHTLC_write(uint32_t obj) {
34205         LDKUpdateFulfillHTLC obj_conv;
34206         obj_conv.inner = (void*)(obj & (~1));
34207         obj_conv.is_owned = false;
34208         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34209         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
34210         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34211         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34212         CVec_u8Z_free(ret_var);
34213         return ret_arr;
34214 }
34215
34216 uint32_t  __attribute__((export_name("TS_UpdateFulfillHTLC_read"))) TS_UpdateFulfillHTLC_read(int8_tArray ser) {
34217         LDKu8slice ser_ref;
34218         ser_ref.datalen = ser->arr_len;
34219         ser_ref.data = ser->elems;
34220         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
34221         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
34222         FREE(ser);
34223         return (uint32_t)ret_conv;
34224 }
34225
34226 int8_tArray  __attribute__((export_name("TS_UpdateAddHTLC_write"))) TS_UpdateAddHTLC_write(uint32_t obj) {
34227         LDKUpdateAddHTLC obj_conv;
34228         obj_conv.inner = (void*)(obj & (~1));
34229         obj_conv.is_owned = false;
34230         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34231         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
34232         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34233         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34234         CVec_u8Z_free(ret_var);
34235         return ret_arr;
34236 }
34237
34238 uint32_t  __attribute__((export_name("TS_UpdateAddHTLC_read"))) TS_UpdateAddHTLC_read(int8_tArray ser) {
34239         LDKu8slice ser_ref;
34240         ser_ref.datalen = ser->arr_len;
34241         ser_ref.data = ser->elems;
34242         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
34243         *ret_conv = UpdateAddHTLC_read(ser_ref);
34244         FREE(ser);
34245         return (uint32_t)ret_conv;
34246 }
34247
34248 int8_tArray  __attribute__((export_name("TS_Ping_write"))) TS_Ping_write(uint32_t obj) {
34249         LDKPing obj_conv;
34250         obj_conv.inner = (void*)(obj & (~1));
34251         obj_conv.is_owned = false;
34252         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34253         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
34254         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34255         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34256         CVec_u8Z_free(ret_var);
34257         return ret_arr;
34258 }
34259
34260 uint32_t  __attribute__((export_name("TS_Ping_read"))) TS_Ping_read(int8_tArray ser) {
34261         LDKu8slice ser_ref;
34262         ser_ref.datalen = ser->arr_len;
34263         ser_ref.data = ser->elems;
34264         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
34265         *ret_conv = Ping_read(ser_ref);
34266         FREE(ser);
34267         return (uint32_t)ret_conv;
34268 }
34269
34270 int8_tArray  __attribute__((export_name("TS_Pong_write"))) TS_Pong_write(uint32_t obj) {
34271         LDKPong obj_conv;
34272         obj_conv.inner = (void*)(obj & (~1));
34273         obj_conv.is_owned = false;
34274         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34275         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
34276         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34277         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34278         CVec_u8Z_free(ret_var);
34279         return ret_arr;
34280 }
34281
34282 uint32_t  __attribute__((export_name("TS_Pong_read"))) TS_Pong_read(int8_tArray ser) {
34283         LDKu8slice ser_ref;
34284         ser_ref.datalen = ser->arr_len;
34285         ser_ref.data = ser->elems;
34286         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
34287         *ret_conv = Pong_read(ser_ref);
34288         FREE(ser);
34289         return (uint32_t)ret_conv;
34290 }
34291
34292 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_write"))) TS_UnsignedChannelAnnouncement_write(uint32_t obj) {
34293         LDKUnsignedChannelAnnouncement obj_conv;
34294         obj_conv.inner = (void*)(obj & (~1));
34295         obj_conv.is_owned = false;
34296         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34297         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
34298         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34299         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34300         CVec_u8Z_free(ret_var);
34301         return ret_arr;
34302 }
34303
34304 uint32_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_read"))) TS_UnsignedChannelAnnouncement_read(int8_tArray ser) {
34305         LDKu8slice ser_ref;
34306         ser_ref.datalen = ser->arr_len;
34307         ser_ref.data = ser->elems;
34308         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
34309         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
34310         FREE(ser);
34311         return (uint32_t)ret_conv;
34312 }
34313
34314 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_write"))) TS_ChannelAnnouncement_write(uint32_t obj) {
34315         LDKChannelAnnouncement obj_conv;
34316         obj_conv.inner = (void*)(obj & (~1));
34317         obj_conv.is_owned = false;
34318         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34319         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
34320         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34321         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34322         CVec_u8Z_free(ret_var);
34323         return ret_arr;
34324 }
34325
34326 uint32_t  __attribute__((export_name("TS_ChannelAnnouncement_read"))) TS_ChannelAnnouncement_read(int8_tArray ser) {
34327         LDKu8slice ser_ref;
34328         ser_ref.datalen = ser->arr_len;
34329         ser_ref.data = ser->elems;
34330         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
34331         *ret_conv = ChannelAnnouncement_read(ser_ref);
34332         FREE(ser);
34333         return (uint32_t)ret_conv;
34334 }
34335
34336 int8_tArray  __attribute__((export_name("TS_UnsignedChannelUpdate_write"))) TS_UnsignedChannelUpdate_write(uint32_t obj) {
34337         LDKUnsignedChannelUpdate obj_conv;
34338         obj_conv.inner = (void*)(obj & (~1));
34339         obj_conv.is_owned = false;
34340         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34341         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
34342         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34343         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34344         CVec_u8Z_free(ret_var);
34345         return ret_arr;
34346 }
34347
34348 uint32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_read"))) TS_UnsignedChannelUpdate_read(int8_tArray ser) {
34349         LDKu8slice ser_ref;
34350         ser_ref.datalen = ser->arr_len;
34351         ser_ref.data = ser->elems;
34352         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
34353         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
34354         FREE(ser);
34355         return (uint32_t)ret_conv;
34356 }
34357
34358 int8_tArray  __attribute__((export_name("TS_ChannelUpdate_write"))) TS_ChannelUpdate_write(uint32_t obj) {
34359         LDKChannelUpdate obj_conv;
34360         obj_conv.inner = (void*)(obj & (~1));
34361         obj_conv.is_owned = false;
34362         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34363         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
34364         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34365         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34366         CVec_u8Z_free(ret_var);
34367         return ret_arr;
34368 }
34369
34370 uint32_t  __attribute__((export_name("TS_ChannelUpdate_read"))) TS_ChannelUpdate_read(int8_tArray ser) {
34371         LDKu8slice ser_ref;
34372         ser_ref.datalen = ser->arr_len;
34373         ser_ref.data = ser->elems;
34374         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
34375         *ret_conv = ChannelUpdate_read(ser_ref);
34376         FREE(ser);
34377         return (uint32_t)ret_conv;
34378 }
34379
34380 int8_tArray  __attribute__((export_name("TS_ErrorMessage_write"))) TS_ErrorMessage_write(uint32_t obj) {
34381         LDKErrorMessage obj_conv;
34382         obj_conv.inner = (void*)(obj & (~1));
34383         obj_conv.is_owned = false;
34384         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34385         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
34386         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34387         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34388         CVec_u8Z_free(ret_var);
34389         return ret_arr;
34390 }
34391
34392 uint32_t  __attribute__((export_name("TS_ErrorMessage_read"))) TS_ErrorMessage_read(int8_tArray ser) {
34393         LDKu8slice ser_ref;
34394         ser_ref.datalen = ser->arr_len;
34395         ser_ref.data = ser->elems;
34396         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
34397         *ret_conv = ErrorMessage_read(ser_ref);
34398         FREE(ser);
34399         return (uint32_t)ret_conv;
34400 }
34401
34402 int8_tArray  __attribute__((export_name("TS_WarningMessage_write"))) TS_WarningMessage_write(uint32_t obj) {
34403         LDKWarningMessage obj_conv;
34404         obj_conv.inner = (void*)(obj & (~1));
34405         obj_conv.is_owned = false;
34406         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34407         LDKCVec_u8Z ret_var = WarningMessage_write(&obj_conv);
34408         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34409         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34410         CVec_u8Z_free(ret_var);
34411         return ret_arr;
34412 }
34413
34414 uint32_t  __attribute__((export_name("TS_WarningMessage_read"))) TS_WarningMessage_read(int8_tArray ser) {
34415         LDKu8slice ser_ref;
34416         ser_ref.datalen = ser->arr_len;
34417         ser_ref.data = ser->elems;
34418         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
34419         *ret_conv = WarningMessage_read(ser_ref);
34420         FREE(ser);
34421         return (uint32_t)ret_conv;
34422 }
34423
34424 int8_tArray  __attribute__((export_name("TS_UnsignedNodeAnnouncement_write"))) TS_UnsignedNodeAnnouncement_write(uint32_t obj) {
34425         LDKUnsignedNodeAnnouncement obj_conv;
34426         obj_conv.inner = (void*)(obj & (~1));
34427         obj_conv.is_owned = false;
34428         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34429         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
34430         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34431         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34432         CVec_u8Z_free(ret_var);
34433         return ret_arr;
34434 }
34435
34436 uint32_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_read"))) TS_UnsignedNodeAnnouncement_read(int8_tArray ser) {
34437         LDKu8slice ser_ref;
34438         ser_ref.datalen = ser->arr_len;
34439         ser_ref.data = ser->elems;
34440         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
34441         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
34442         FREE(ser);
34443         return (uint32_t)ret_conv;
34444 }
34445
34446 int8_tArray  __attribute__((export_name("TS_NodeAnnouncement_write"))) TS_NodeAnnouncement_write(uint32_t obj) {
34447         LDKNodeAnnouncement obj_conv;
34448         obj_conv.inner = (void*)(obj & (~1));
34449         obj_conv.is_owned = false;
34450         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34451         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
34452         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34453         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34454         CVec_u8Z_free(ret_var);
34455         return ret_arr;
34456 }
34457
34458 uint32_t  __attribute__((export_name("TS_NodeAnnouncement_read"))) TS_NodeAnnouncement_read(int8_tArray ser) {
34459         LDKu8slice ser_ref;
34460         ser_ref.datalen = ser->arr_len;
34461         ser_ref.data = ser->elems;
34462         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
34463         *ret_conv = NodeAnnouncement_read(ser_ref);
34464         FREE(ser);
34465         return (uint32_t)ret_conv;
34466 }
34467
34468 uint32_t  __attribute__((export_name("TS_QueryShortChannelIds_read"))) TS_QueryShortChannelIds_read(int8_tArray ser) {
34469         LDKu8slice ser_ref;
34470         ser_ref.datalen = ser->arr_len;
34471         ser_ref.data = ser->elems;
34472         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
34473         *ret_conv = QueryShortChannelIds_read(ser_ref);
34474         FREE(ser);
34475         return (uint32_t)ret_conv;
34476 }
34477
34478 int8_tArray  __attribute__((export_name("TS_QueryShortChannelIds_write"))) TS_QueryShortChannelIds_write(uint32_t obj) {
34479         LDKQueryShortChannelIds obj_conv;
34480         obj_conv.inner = (void*)(obj & (~1));
34481         obj_conv.is_owned = false;
34482         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34483         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
34484         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34485         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34486         CVec_u8Z_free(ret_var);
34487         return ret_arr;
34488 }
34489
34490 int8_tArray  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_write"))) TS_ReplyShortChannelIdsEnd_write(uint32_t obj) {
34491         LDKReplyShortChannelIdsEnd obj_conv;
34492         obj_conv.inner = (void*)(obj & (~1));
34493         obj_conv.is_owned = false;
34494         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34495         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
34496         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34497         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34498         CVec_u8Z_free(ret_var);
34499         return ret_arr;
34500 }
34501
34502 uint32_t  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_read"))) TS_ReplyShortChannelIdsEnd_read(int8_tArray ser) {
34503         LDKu8slice ser_ref;
34504         ser_ref.datalen = ser->arr_len;
34505         ser_ref.data = ser->elems;
34506         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
34507         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
34508         FREE(ser);
34509         return (uint32_t)ret_conv;
34510 }
34511
34512 int32_t  __attribute__((export_name("TS_QueryChannelRange_end_blocknum"))) TS_QueryChannelRange_end_blocknum(uint32_t this_arg) {
34513         LDKQueryChannelRange this_arg_conv;
34514         this_arg_conv.inner = (void*)(this_arg & (~1));
34515         this_arg_conv.is_owned = false;
34516         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34517         int32_t ret_conv = QueryChannelRange_end_blocknum(&this_arg_conv);
34518         return ret_conv;
34519 }
34520
34521 int8_tArray  __attribute__((export_name("TS_QueryChannelRange_write"))) TS_QueryChannelRange_write(uint32_t obj) {
34522         LDKQueryChannelRange obj_conv;
34523         obj_conv.inner = (void*)(obj & (~1));
34524         obj_conv.is_owned = false;
34525         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34526         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
34527         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34528         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34529         CVec_u8Z_free(ret_var);
34530         return ret_arr;
34531 }
34532
34533 uint32_t  __attribute__((export_name("TS_QueryChannelRange_read"))) TS_QueryChannelRange_read(int8_tArray ser) {
34534         LDKu8slice ser_ref;
34535         ser_ref.datalen = ser->arr_len;
34536         ser_ref.data = ser->elems;
34537         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
34538         *ret_conv = QueryChannelRange_read(ser_ref);
34539         FREE(ser);
34540         return (uint32_t)ret_conv;
34541 }
34542
34543 uint32_t  __attribute__((export_name("TS_ReplyChannelRange_read"))) TS_ReplyChannelRange_read(int8_tArray ser) {
34544         LDKu8slice ser_ref;
34545         ser_ref.datalen = ser->arr_len;
34546         ser_ref.data = ser->elems;
34547         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
34548         *ret_conv = ReplyChannelRange_read(ser_ref);
34549         FREE(ser);
34550         return (uint32_t)ret_conv;
34551 }
34552
34553 int8_tArray  __attribute__((export_name("TS_ReplyChannelRange_write"))) TS_ReplyChannelRange_write(uint32_t obj) {
34554         LDKReplyChannelRange obj_conv;
34555         obj_conv.inner = (void*)(obj & (~1));
34556         obj_conv.is_owned = false;
34557         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34558         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
34559         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34560         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34561         CVec_u8Z_free(ret_var);
34562         return ret_arr;
34563 }
34564
34565 int8_tArray  __attribute__((export_name("TS_GossipTimestampFilter_write"))) TS_GossipTimestampFilter_write(uint32_t obj) {
34566         LDKGossipTimestampFilter obj_conv;
34567         obj_conv.inner = (void*)(obj & (~1));
34568         obj_conv.is_owned = false;
34569         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34570         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
34571         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34572         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34573         CVec_u8Z_free(ret_var);
34574         return ret_arr;
34575 }
34576
34577 uint32_t  __attribute__((export_name("TS_GossipTimestampFilter_read"))) TS_GossipTimestampFilter_read(int8_tArray ser) {
34578         LDKu8slice ser_ref;
34579         ser_ref.datalen = ser->arr_len;
34580         ser_ref.data = ser->elems;
34581         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
34582         *ret_conv = GossipTimestampFilter_read(ser_ref);
34583         FREE(ser);
34584         return (uint32_t)ret_conv;
34585 }
34586
34587 void  __attribute__((export_name("TS_CustomMessageHandler_free"))) TS_CustomMessageHandler_free(uint32_t this_ptr) {
34588         if ((this_ptr & 1) != 0) return;
34589         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
34590         CHECK_ACCESS(this_ptr_ptr);
34591         LDKCustomMessageHandler this_ptr_conv = *(LDKCustomMessageHandler*)(this_ptr_ptr);
34592         FREE((void*)this_ptr);
34593         CustomMessageHandler_free(this_ptr_conv);
34594 }
34595
34596 void  __attribute__((export_name("TS_IgnoringMessageHandler_free"))) TS_IgnoringMessageHandler_free(uint32_t this_obj) {
34597         LDKIgnoringMessageHandler this_obj_conv;
34598         this_obj_conv.inner = (void*)(this_obj & (~1));
34599         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34600         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34601         IgnoringMessageHandler_free(this_obj_conv);
34602 }
34603
34604 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_new"))) TS_IgnoringMessageHandler_new() {
34605         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
34606         uint32_t ret_ref = 0;
34607         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34608         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34609         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34610         ret_ref = (uintptr_t)ret_var.inner;
34611         if (ret_var.is_owned) {
34612                 ret_ref |= 1;
34613         }
34614         return ret_ref;
34615 }
34616
34617 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_as_MessageSendEventsProvider"))) TS_IgnoringMessageHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
34618         LDKIgnoringMessageHandler this_arg_conv;
34619         this_arg_conv.inner = (void*)(this_arg & (~1));
34620         this_arg_conv.is_owned = false;
34621         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34622         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
34623         *ret_ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
34624         return (uint32_t)ret_ret;
34625 }
34626
34627 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_as_RoutingMessageHandler"))) TS_IgnoringMessageHandler_as_RoutingMessageHandler(uint32_t this_arg) {
34628         LDKIgnoringMessageHandler this_arg_conv;
34629         this_arg_conv.inner = (void*)(this_arg & (~1));
34630         this_arg_conv.is_owned = false;
34631         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34632         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
34633         *ret_ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
34634         return (uint32_t)ret_ret;
34635 }
34636
34637 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_as_CustomMessageReader"))) TS_IgnoringMessageHandler_as_CustomMessageReader(uint32_t this_arg) {
34638         LDKIgnoringMessageHandler this_arg_conv;
34639         this_arg_conv.inner = (void*)(this_arg & (~1));
34640         this_arg_conv.is_owned = false;
34641         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34642         LDKCustomMessageReader* ret_ret = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
34643         *ret_ret = IgnoringMessageHandler_as_CustomMessageReader(&this_arg_conv);
34644         return (uint32_t)ret_ret;
34645 }
34646
34647 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_as_CustomMessageHandler"))) TS_IgnoringMessageHandler_as_CustomMessageHandler(uint32_t this_arg) {
34648         LDKIgnoringMessageHandler this_arg_conv;
34649         this_arg_conv.inner = (void*)(this_arg & (~1));
34650         this_arg_conv.is_owned = false;
34651         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34652         LDKCustomMessageHandler* ret_ret = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
34653         *ret_ret = IgnoringMessageHandler_as_CustomMessageHandler(&this_arg_conv);
34654         return (uint32_t)ret_ret;
34655 }
34656
34657 void  __attribute__((export_name("TS_ErroringMessageHandler_free"))) TS_ErroringMessageHandler_free(uint32_t this_obj) {
34658         LDKErroringMessageHandler this_obj_conv;
34659         this_obj_conv.inner = (void*)(this_obj & (~1));
34660         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34661         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34662         ErroringMessageHandler_free(this_obj_conv);
34663 }
34664
34665 uint32_t  __attribute__((export_name("TS_ErroringMessageHandler_new"))) TS_ErroringMessageHandler_new() {
34666         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
34667         uint32_t ret_ref = 0;
34668         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34669         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34670         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34671         ret_ref = (uintptr_t)ret_var.inner;
34672         if (ret_var.is_owned) {
34673                 ret_ref |= 1;
34674         }
34675         return ret_ref;
34676 }
34677
34678 uint32_t  __attribute__((export_name("TS_ErroringMessageHandler_as_MessageSendEventsProvider"))) TS_ErroringMessageHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
34679         LDKErroringMessageHandler this_arg_conv;
34680         this_arg_conv.inner = (void*)(this_arg & (~1));
34681         this_arg_conv.is_owned = false;
34682         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34683         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
34684         *ret_ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
34685         return (uint32_t)ret_ret;
34686 }
34687
34688 uint32_t  __attribute__((export_name("TS_ErroringMessageHandler_as_ChannelMessageHandler"))) TS_ErroringMessageHandler_as_ChannelMessageHandler(uint32_t this_arg) {
34689         LDKErroringMessageHandler this_arg_conv;
34690         this_arg_conv.inner = (void*)(this_arg & (~1));
34691         this_arg_conv.is_owned = false;
34692         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34693         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
34694         *ret_ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
34695         return (uint32_t)ret_ret;
34696 }
34697
34698 void  __attribute__((export_name("TS_MessageHandler_free"))) TS_MessageHandler_free(uint32_t this_obj) {
34699         LDKMessageHandler this_obj_conv;
34700         this_obj_conv.inner = (void*)(this_obj & (~1));
34701         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34702         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34703         MessageHandler_free(this_obj_conv);
34704 }
34705
34706 uint32_t  __attribute__((export_name("TS_MessageHandler_get_chan_handler"))) TS_MessageHandler_get_chan_handler(uint32_t this_ptr) {
34707         LDKMessageHandler this_ptr_conv;
34708         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34709         this_ptr_conv.is_owned = false;
34710         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34711         // WARNING: This object doesn't live past this scope, needs clone!
34712         uint32_t ret_ret = ((uintptr_t)MessageHandler_get_chan_handler(&this_ptr_conv)) | 1;
34713         return ret_ret;
34714 }
34715
34716 void  __attribute__((export_name("TS_MessageHandler_set_chan_handler"))) TS_MessageHandler_set_chan_handler(uint32_t this_ptr, uint32_t val) {
34717         LDKMessageHandler this_ptr_conv;
34718         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34719         this_ptr_conv.is_owned = false;
34720         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34721         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
34722         CHECK_ACCESS(val_ptr);
34723         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(val_ptr);
34724         if (val_conv.free == LDKChannelMessageHandler_JCalls_free) {
34725                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34726                 LDKChannelMessageHandler_JCalls_cloned(&val_conv);
34727         }
34728         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
34729 }
34730
34731 uint32_t  __attribute__((export_name("TS_MessageHandler_get_route_handler"))) TS_MessageHandler_get_route_handler(uint32_t this_ptr) {
34732         LDKMessageHandler this_ptr_conv;
34733         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34734         this_ptr_conv.is_owned = false;
34735         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34736         // WARNING: This object doesn't live past this scope, needs clone!
34737         uint32_t ret_ret = ((uintptr_t)MessageHandler_get_route_handler(&this_ptr_conv)) | 1;
34738         return ret_ret;
34739 }
34740
34741 void  __attribute__((export_name("TS_MessageHandler_set_route_handler"))) TS_MessageHandler_set_route_handler(uint32_t this_ptr, uint32_t val) {
34742         LDKMessageHandler this_ptr_conv;
34743         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34744         this_ptr_conv.is_owned = false;
34745         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34746         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
34747         CHECK_ACCESS(val_ptr);
34748         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(val_ptr);
34749         if (val_conv.free == LDKRoutingMessageHandler_JCalls_free) {
34750                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34751                 LDKRoutingMessageHandler_JCalls_cloned(&val_conv);
34752         }
34753         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
34754 }
34755
34756 uint32_t  __attribute__((export_name("TS_MessageHandler_new"))) TS_MessageHandler_new(uint32_t chan_handler_arg, uint32_t route_handler_arg) {
34757         void* chan_handler_arg_ptr = (void*)(((uintptr_t)chan_handler_arg) & ~1);
34758         CHECK_ACCESS(chan_handler_arg_ptr);
34759         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(chan_handler_arg_ptr);
34760         if (chan_handler_arg_conv.free == LDKChannelMessageHandler_JCalls_free) {
34761                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34762                 LDKChannelMessageHandler_JCalls_cloned(&chan_handler_arg_conv);
34763         }
34764         void* route_handler_arg_ptr = (void*)(((uintptr_t)route_handler_arg) & ~1);
34765         CHECK_ACCESS(route_handler_arg_ptr);
34766         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(route_handler_arg_ptr);
34767         if (route_handler_arg_conv.free == LDKRoutingMessageHandler_JCalls_free) {
34768                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34769                 LDKRoutingMessageHandler_JCalls_cloned(&route_handler_arg_conv);
34770         }
34771         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
34772         uint32_t ret_ref = 0;
34773         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34774         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34775         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34776         ret_ref = (uintptr_t)ret_var.inner;
34777         if (ret_var.is_owned) {
34778                 ret_ref |= 1;
34779         }
34780         return ret_ref;
34781 }
34782
34783 static inline uintptr_t SocketDescriptor_clone_ptr(LDKSocketDescriptor *NONNULL_PTR arg) {
34784         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
34785         *ret_ret = SocketDescriptor_clone(arg);
34786         return (uint32_t)ret_ret;
34787 }
34788 uint32_t  __attribute__((export_name("TS_SocketDescriptor_clone_ptr"))) TS_SocketDescriptor_clone_ptr(uint32_t arg) {
34789         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
34790         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
34791         LDKSocketDescriptor* arg_conv = (LDKSocketDescriptor*)arg_ptr;
34792         uint32_t ret_conv = SocketDescriptor_clone_ptr(arg_conv);
34793         return ret_conv;
34794 }
34795
34796 uint32_t  __attribute__((export_name("TS_SocketDescriptor_clone"))) TS_SocketDescriptor_clone(uint32_t orig) {
34797         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
34798         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
34799         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)orig_ptr;
34800         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
34801         *ret_ret = SocketDescriptor_clone(orig_conv);
34802         return (uint32_t)ret_ret;
34803 }
34804
34805 void  __attribute__((export_name("TS_SocketDescriptor_free"))) TS_SocketDescriptor_free(uint32_t this_ptr) {
34806         if ((this_ptr & 1) != 0) return;
34807         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
34808         CHECK_ACCESS(this_ptr_ptr);
34809         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(this_ptr_ptr);
34810         FREE((void*)this_ptr);
34811         SocketDescriptor_free(this_ptr_conv);
34812 }
34813
34814 void  __attribute__((export_name("TS_PeerHandleError_free"))) TS_PeerHandleError_free(uint32_t this_obj) {
34815         LDKPeerHandleError this_obj_conv;
34816         this_obj_conv.inner = (void*)(this_obj & (~1));
34817         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34818         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34819         PeerHandleError_free(this_obj_conv);
34820 }
34821
34822 jboolean  __attribute__((export_name("TS_PeerHandleError_get_no_connection_possible"))) TS_PeerHandleError_get_no_connection_possible(uint32_t this_ptr) {
34823         LDKPeerHandleError this_ptr_conv;
34824         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34825         this_ptr_conv.is_owned = false;
34826         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34827         jboolean ret_conv = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
34828         return ret_conv;
34829 }
34830
34831 void  __attribute__((export_name("TS_PeerHandleError_set_no_connection_possible"))) TS_PeerHandleError_set_no_connection_possible(uint32_t this_ptr, jboolean val) {
34832         LDKPeerHandleError this_ptr_conv;
34833         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34834         this_ptr_conv.is_owned = false;
34835         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34836         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
34837 }
34838
34839 uint32_t  __attribute__((export_name("TS_PeerHandleError_new"))) TS_PeerHandleError_new(jboolean no_connection_possible_arg) {
34840         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
34841         uint32_t ret_ref = 0;
34842         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34843         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34844         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34845         ret_ref = (uintptr_t)ret_var.inner;
34846         if (ret_var.is_owned) {
34847                 ret_ref |= 1;
34848         }
34849         return ret_ref;
34850 }
34851
34852 static inline uintptr_t PeerHandleError_clone_ptr(LDKPeerHandleError *NONNULL_PTR arg) {
34853         LDKPeerHandleError ret_var = PeerHandleError_clone(arg);
34854 uint32_t ret_ref = 0;
34855 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34856 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34857 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34858 ret_ref = (uintptr_t)ret_var.inner;
34859 if (ret_var.is_owned) {
34860         ret_ref |= 1;
34861 }
34862         return ret_ref;
34863 }
34864 uint32_t  __attribute__((export_name("TS_PeerHandleError_clone_ptr"))) TS_PeerHandleError_clone_ptr(uint32_t arg) {
34865         LDKPeerHandleError arg_conv;
34866         arg_conv.inner = (void*)(arg & (~1));
34867         arg_conv.is_owned = false;
34868         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34869         uint32_t ret_conv = PeerHandleError_clone_ptr(&arg_conv);
34870         return ret_conv;
34871 }
34872
34873 uint32_t  __attribute__((export_name("TS_PeerHandleError_clone"))) TS_PeerHandleError_clone(uint32_t orig) {
34874         LDKPeerHandleError orig_conv;
34875         orig_conv.inner = (void*)(orig & (~1));
34876         orig_conv.is_owned = false;
34877         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34878         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
34879         uint32_t ret_ref = 0;
34880         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34881         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34882         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34883         ret_ref = (uintptr_t)ret_var.inner;
34884         if (ret_var.is_owned) {
34885                 ret_ref |= 1;
34886         }
34887         return ret_ref;
34888 }
34889
34890 void  __attribute__((export_name("TS_PeerManager_free"))) TS_PeerManager_free(uint32_t this_obj) {
34891         LDKPeerManager this_obj_conv;
34892         this_obj_conv.inner = (void*)(this_obj & (~1));
34893         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34894         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34895         PeerManager_free(this_obj_conv);
34896 }
34897
34898 uint32_t  __attribute__((export_name("TS_PeerManager_new"))) TS_PeerManager_new(uint32_t message_handler, int8_tArray our_node_secret, int8_tArray ephemeral_random_data, uint32_t logger, uint32_t custom_message_handler) {
34899         LDKMessageHandler message_handler_conv;
34900         message_handler_conv.inner = (void*)(message_handler & (~1));
34901         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
34902         CHECK_INNER_FIELD_ACCESS_OR_NULL(message_handler_conv);
34903         // WARNING: we need a move here but no clone is available for LDKMessageHandler
34904         LDKSecretKey our_node_secret_ref;
34905         CHECK(our_node_secret->arr_len == 32);
34906         memcpy(our_node_secret_ref.bytes, our_node_secret->elems, 32); FREE(our_node_secret);
34907         unsigned char ephemeral_random_data_arr[32];
34908         CHECK(ephemeral_random_data->arr_len == 32);
34909         memcpy(ephemeral_random_data_arr, ephemeral_random_data->elems, 32); FREE(ephemeral_random_data);
34910         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
34911         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
34912         CHECK_ACCESS(logger_ptr);
34913         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
34914         if (logger_conv.free == LDKLogger_JCalls_free) {
34915                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34916                 LDKLogger_JCalls_cloned(&logger_conv);
34917         }
34918         void* custom_message_handler_ptr = (void*)(((uintptr_t)custom_message_handler) & ~1);
34919         CHECK_ACCESS(custom_message_handler_ptr);
34920         LDKCustomMessageHandler custom_message_handler_conv = *(LDKCustomMessageHandler*)(custom_message_handler_ptr);
34921         if (custom_message_handler_conv.free == LDKCustomMessageHandler_JCalls_free) {
34922                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34923                 LDKCustomMessageHandler_JCalls_cloned(&custom_message_handler_conv);
34924         }
34925         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv, custom_message_handler_conv);
34926         uint32_t ret_ref = 0;
34927         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34928         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34929         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34930         ret_ref = (uintptr_t)ret_var.inner;
34931         if (ret_var.is_owned) {
34932                 ret_ref |= 1;
34933         }
34934         return ret_ref;
34935 }
34936
34937 ptrArray  __attribute__((export_name("TS_PeerManager_get_peer_node_ids"))) TS_PeerManager_get_peer_node_ids(uint32_t this_arg) {
34938         LDKPeerManager this_arg_conv;
34939         this_arg_conv.inner = (void*)(this_arg & (~1));
34940         this_arg_conv.is_owned = false;
34941         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34942         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
34943         ptrArray ret_arr = NULL;
34944         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
34945         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 8);
34946         for (size_t m = 0; m < ret_var.datalen; m++) {
34947                 int8_tArray ret_conv_12_arr = init_int8_tArray(33, __LINE__);
34948                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].compressed_form, 33);
34949                 ret_arr_ptr[m] = ret_conv_12_arr;
34950         }
34951         
34952         FREE(ret_var.data);
34953         return ret_arr;
34954 }
34955
34956 uint32_t  __attribute__((export_name("TS_PeerManager_new_outbound_connection"))) TS_PeerManager_new_outbound_connection(uint32_t this_arg, int8_tArray their_node_id, uint32_t descriptor, uint32_t remote_network_address) {
34957         LDKPeerManager this_arg_conv;
34958         this_arg_conv.inner = (void*)(this_arg & (~1));
34959         this_arg_conv.is_owned = false;
34960         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34961         LDKPublicKey their_node_id_ref;
34962         CHECK(their_node_id->arr_len == 33);
34963         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
34964         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
34965         CHECK_ACCESS(descriptor_ptr);
34966         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
34967         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
34968                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34969                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
34970         }
34971         void* remote_network_address_ptr = (void*)(((uintptr_t)remote_network_address) & ~1);
34972         CHECK_ACCESS(remote_network_address_ptr);
34973         LDKCOption_NetAddressZ remote_network_address_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_ptr);
34974         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
34975         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv, remote_network_address_conv);
34976         return (uint32_t)ret_conv;
34977 }
34978
34979 uint32_t  __attribute__((export_name("TS_PeerManager_new_inbound_connection"))) TS_PeerManager_new_inbound_connection(uint32_t this_arg, uint32_t descriptor, uint32_t remote_network_address) {
34980         LDKPeerManager this_arg_conv;
34981         this_arg_conv.inner = (void*)(this_arg & (~1));
34982         this_arg_conv.is_owned = false;
34983         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34984         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
34985         CHECK_ACCESS(descriptor_ptr);
34986         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
34987         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
34988                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34989                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
34990         }
34991         void* remote_network_address_ptr = (void*)(((uintptr_t)remote_network_address) & ~1);
34992         CHECK_ACCESS(remote_network_address_ptr);
34993         LDKCOption_NetAddressZ remote_network_address_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_ptr);
34994         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
34995         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv, remote_network_address_conv);
34996         return (uint32_t)ret_conv;
34997 }
34998
34999 uint32_t  __attribute__((export_name("TS_PeerManager_write_buffer_space_avail"))) TS_PeerManager_write_buffer_space_avail(uint32_t this_arg, uint32_t descriptor) {
35000         LDKPeerManager this_arg_conv;
35001         this_arg_conv.inner = (void*)(this_arg & (~1));
35002         this_arg_conv.is_owned = false;
35003         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35004         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
35005         if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
35006         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
35007         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
35008         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
35009         return (uint32_t)ret_conv;
35010 }
35011
35012 uint32_t  __attribute__((export_name("TS_PeerManager_read_event"))) TS_PeerManager_read_event(uint32_t this_arg, uint32_t peer_descriptor, int8_tArray data) {
35013         LDKPeerManager this_arg_conv;
35014         this_arg_conv.inner = (void*)(this_arg & (~1));
35015         this_arg_conv.is_owned = false;
35016         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35017         void* peer_descriptor_ptr = (void*)(((uintptr_t)peer_descriptor) & ~1);
35018         if (!(peer_descriptor & 1)) { CHECK_ACCESS(peer_descriptor_ptr); }
35019         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)peer_descriptor_ptr;
35020         LDKu8slice data_ref;
35021         data_ref.datalen = data->arr_len;
35022         data_ref.data = data->elems;
35023         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
35024         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
35025         FREE(data);
35026         return (uint32_t)ret_conv;
35027 }
35028
35029 void  __attribute__((export_name("TS_PeerManager_process_events"))) TS_PeerManager_process_events(uint32_t this_arg) {
35030         LDKPeerManager this_arg_conv;
35031         this_arg_conv.inner = (void*)(this_arg & (~1));
35032         this_arg_conv.is_owned = false;
35033         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35034         PeerManager_process_events(&this_arg_conv);
35035 }
35036
35037 void  __attribute__((export_name("TS_PeerManager_socket_disconnected"))) TS_PeerManager_socket_disconnected(uint32_t this_arg, uint32_t descriptor) {
35038         LDKPeerManager this_arg_conv;
35039         this_arg_conv.inner = (void*)(this_arg & (~1));
35040         this_arg_conv.is_owned = false;
35041         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35042         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
35043         if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
35044         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
35045         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
35046 }
35047
35048 void  __attribute__((export_name("TS_PeerManager_disconnect_by_node_id"))) TS_PeerManager_disconnect_by_node_id(uint32_t this_arg, int8_tArray node_id, jboolean no_connection_possible) {
35049         LDKPeerManager this_arg_conv;
35050         this_arg_conv.inner = (void*)(this_arg & (~1));
35051         this_arg_conv.is_owned = false;
35052         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35053         LDKPublicKey node_id_ref;
35054         CHECK(node_id->arr_len == 33);
35055         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
35056         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
35057 }
35058
35059 void  __attribute__((export_name("TS_PeerManager_disconnect_all_peers"))) TS_PeerManager_disconnect_all_peers(uint32_t this_arg) {
35060         LDKPeerManager this_arg_conv;
35061         this_arg_conv.inner = (void*)(this_arg & (~1));
35062         this_arg_conv.is_owned = false;
35063         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35064         PeerManager_disconnect_all_peers(&this_arg_conv);
35065 }
35066
35067 void  __attribute__((export_name("TS_PeerManager_timer_tick_occurred"))) TS_PeerManager_timer_tick_occurred(uint32_t this_arg) {
35068         LDKPeerManager this_arg_conv;
35069         this_arg_conv.inner = (void*)(this_arg & (~1));
35070         this_arg_conv.is_owned = false;
35071         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35072         PeerManager_timer_tick_occurred(&this_arg_conv);
35073 }
35074
35075 int64_t  __attribute__((export_name("TS_htlc_success_tx_weight"))) TS_htlc_success_tx_weight(jboolean opt_anchors) {
35076         int64_t ret_conv = htlc_success_tx_weight(opt_anchors);
35077         return ret_conv;
35078 }
35079
35080 int64_t  __attribute__((export_name("TS_htlc_timeout_tx_weight"))) TS_htlc_timeout_tx_weight(jboolean opt_anchors) {
35081         int64_t ret_conv = htlc_timeout_tx_weight(opt_anchors);
35082         return ret_conv;
35083 }
35084
35085 int8_tArray  __attribute__((export_name("TS_build_commitment_secret"))) TS_build_commitment_secret(int8_tArray commitment_seed, int64_t idx) {
35086         unsigned char commitment_seed_arr[32];
35087         CHECK(commitment_seed->arr_len == 32);
35088         memcpy(commitment_seed_arr, commitment_seed->elems, 32); FREE(commitment_seed);
35089         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
35090         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
35091         memcpy(ret_arr->elems, build_commitment_secret(commitment_seed_ref, idx).data, 32);
35092         return ret_arr;
35093 }
35094
35095 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, uint32_t funding_outpoint) {
35096         LDKCVec_u8Z to_holder_script_ref;
35097         to_holder_script_ref.datalen = to_holder_script->arr_len;
35098         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
35099         memcpy(to_holder_script_ref.data, to_holder_script->elems, to_holder_script_ref.datalen); FREE(to_holder_script);
35100         LDKCVec_u8Z to_counterparty_script_ref;
35101         to_counterparty_script_ref.datalen = to_counterparty_script->arr_len;
35102         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
35103         memcpy(to_counterparty_script_ref.data, to_counterparty_script->elems, to_counterparty_script_ref.datalen); FREE(to_counterparty_script);
35104         LDKOutPoint funding_outpoint_conv;
35105         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
35106         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
35107         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
35108         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
35109         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);
35110         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35111         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35112         Transaction_free(ret_var);
35113         return ret_arr;
35114 }
35115
35116 void  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_free"))) TS_CounterpartyCommitmentSecrets_free(uint32_t this_obj) {
35117         LDKCounterpartyCommitmentSecrets this_obj_conv;
35118         this_obj_conv.inner = (void*)(this_obj & (~1));
35119         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35120         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35121         CounterpartyCommitmentSecrets_free(this_obj_conv);
35122 }
35123
35124 static inline uintptr_t CounterpartyCommitmentSecrets_clone_ptr(LDKCounterpartyCommitmentSecrets *NONNULL_PTR arg) {
35125         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(arg);
35126 uint32_t ret_ref = 0;
35127 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35128 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35129 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35130 ret_ref = (uintptr_t)ret_var.inner;
35131 if (ret_var.is_owned) {
35132         ret_ref |= 1;
35133 }
35134         return ret_ref;
35135 }
35136 uint32_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_clone_ptr"))) TS_CounterpartyCommitmentSecrets_clone_ptr(uint32_t arg) {
35137         LDKCounterpartyCommitmentSecrets arg_conv;
35138         arg_conv.inner = (void*)(arg & (~1));
35139         arg_conv.is_owned = false;
35140         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35141         uint32_t ret_conv = CounterpartyCommitmentSecrets_clone_ptr(&arg_conv);
35142         return ret_conv;
35143 }
35144
35145 uint32_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_clone"))) TS_CounterpartyCommitmentSecrets_clone(uint32_t orig) {
35146         LDKCounterpartyCommitmentSecrets orig_conv;
35147         orig_conv.inner = (void*)(orig & (~1));
35148         orig_conv.is_owned = false;
35149         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35150         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(&orig_conv);
35151         uint32_t ret_ref = 0;
35152         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35153         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35154         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35155         ret_ref = (uintptr_t)ret_var.inner;
35156         if (ret_var.is_owned) {
35157                 ret_ref |= 1;
35158         }
35159         return ret_ref;
35160 }
35161
35162 uint32_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_new"))) TS_CounterpartyCommitmentSecrets_new() {
35163         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_new();
35164         uint32_t ret_ref = 0;
35165         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35166         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35167         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35168         ret_ref = (uintptr_t)ret_var.inner;
35169         if (ret_var.is_owned) {
35170                 ret_ref |= 1;
35171         }
35172         return ret_ref;
35173 }
35174
35175 int64_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_get_min_seen_secret"))) TS_CounterpartyCommitmentSecrets_get_min_seen_secret(uint32_t this_arg) {
35176         LDKCounterpartyCommitmentSecrets this_arg_conv;
35177         this_arg_conv.inner = (void*)(this_arg & (~1));
35178         this_arg_conv.is_owned = false;
35179         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35180         int64_t ret_conv = CounterpartyCommitmentSecrets_get_min_seen_secret(&this_arg_conv);
35181         return ret_conv;
35182 }
35183
35184 uint32_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_provide_secret"))) TS_CounterpartyCommitmentSecrets_provide_secret(uint32_t this_arg, int64_t idx, int8_tArray secret) {
35185         LDKCounterpartyCommitmentSecrets this_arg_conv;
35186         this_arg_conv.inner = (void*)(this_arg & (~1));
35187         this_arg_conv.is_owned = false;
35188         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35189         LDKThirtyTwoBytes secret_ref;
35190         CHECK(secret->arr_len == 32);
35191         memcpy(secret_ref.data, secret->elems, 32); FREE(secret);
35192         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
35193         *ret_conv = CounterpartyCommitmentSecrets_provide_secret(&this_arg_conv, idx, secret_ref);
35194         return (uint32_t)ret_conv;
35195 }
35196
35197 int8_tArray  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_get_secret"))) TS_CounterpartyCommitmentSecrets_get_secret(uint32_t this_arg, int64_t idx) {
35198         LDKCounterpartyCommitmentSecrets this_arg_conv;
35199         this_arg_conv.inner = (void*)(this_arg & (~1));
35200         this_arg_conv.is_owned = false;
35201         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35202         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
35203         memcpy(ret_arr->elems, CounterpartyCommitmentSecrets_get_secret(&this_arg_conv, idx).data, 32);
35204         return ret_arr;
35205 }
35206
35207 int8_tArray  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_write"))) TS_CounterpartyCommitmentSecrets_write(uint32_t obj) {
35208         LDKCounterpartyCommitmentSecrets obj_conv;
35209         obj_conv.inner = (void*)(obj & (~1));
35210         obj_conv.is_owned = false;
35211         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35212         LDKCVec_u8Z ret_var = CounterpartyCommitmentSecrets_write(&obj_conv);
35213         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35214         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35215         CVec_u8Z_free(ret_var);
35216         return ret_arr;
35217 }
35218
35219 uint32_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_read"))) TS_CounterpartyCommitmentSecrets_read(int8_tArray ser) {
35220         LDKu8slice ser_ref;
35221         ser_ref.datalen = ser->arr_len;
35222         ser_ref.data = ser->elems;
35223         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
35224         *ret_conv = CounterpartyCommitmentSecrets_read(ser_ref);
35225         FREE(ser);
35226         return (uint32_t)ret_conv;
35227 }
35228
35229 uint32_t  __attribute__((export_name("TS_derive_private_key"))) TS_derive_private_key(int8_tArray per_commitment_point, int8_tArray base_secret) {
35230         LDKPublicKey per_commitment_point_ref;
35231         CHECK(per_commitment_point->arr_len == 33);
35232         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
35233         unsigned char base_secret_arr[32];
35234         CHECK(base_secret->arr_len == 32);
35235         memcpy(base_secret_arr, base_secret->elems, 32); FREE(base_secret);
35236         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
35237         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
35238         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
35239         return (uint32_t)ret_conv;
35240 }
35241
35242 uint32_t  __attribute__((export_name("TS_derive_public_key"))) TS_derive_public_key(int8_tArray per_commitment_point, int8_tArray base_point) {
35243         LDKPublicKey per_commitment_point_ref;
35244         CHECK(per_commitment_point->arr_len == 33);
35245         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
35246         LDKPublicKey base_point_ref;
35247         CHECK(base_point->arr_len == 33);
35248         memcpy(base_point_ref.compressed_form, base_point->elems, 33); FREE(base_point);
35249         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
35250         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
35251         return (uint32_t)ret_conv;
35252 }
35253
35254 uint32_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) {
35255         unsigned char per_commitment_secret_arr[32];
35256         CHECK(per_commitment_secret->arr_len == 32);
35257         memcpy(per_commitment_secret_arr, per_commitment_secret->elems, 32); FREE(per_commitment_secret);
35258         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
35259         unsigned char countersignatory_revocation_base_secret_arr[32];
35260         CHECK(countersignatory_revocation_base_secret->arr_len == 32);
35261         memcpy(countersignatory_revocation_base_secret_arr, countersignatory_revocation_base_secret->elems, 32); FREE(countersignatory_revocation_base_secret);
35262         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
35263         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
35264         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
35265         return (uint32_t)ret_conv;
35266 }
35267
35268 uint32_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) {
35269         LDKPublicKey per_commitment_point_ref;
35270         CHECK(per_commitment_point->arr_len == 33);
35271         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
35272         LDKPublicKey countersignatory_revocation_base_point_ref;
35273         CHECK(countersignatory_revocation_base_point->arr_len == 33);
35274         memcpy(countersignatory_revocation_base_point_ref.compressed_form, countersignatory_revocation_base_point->elems, 33); FREE(countersignatory_revocation_base_point);
35275         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
35276         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
35277         return (uint32_t)ret_conv;
35278 }
35279
35280 void  __attribute__((export_name("TS_TxCreationKeys_free"))) TS_TxCreationKeys_free(uint32_t this_obj) {
35281         LDKTxCreationKeys this_obj_conv;
35282         this_obj_conv.inner = (void*)(this_obj & (~1));
35283         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35284         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35285         TxCreationKeys_free(this_obj_conv);
35286 }
35287
35288 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_per_commitment_point"))) TS_TxCreationKeys_get_per_commitment_point(uint32_t this_ptr) {
35289         LDKTxCreationKeys this_ptr_conv;
35290         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35291         this_ptr_conv.is_owned = false;
35292         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35293         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
35294         memcpy(ret_arr->elems, TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form, 33);
35295         return ret_arr;
35296 }
35297
35298 void  __attribute__((export_name("TS_TxCreationKeys_set_per_commitment_point"))) TS_TxCreationKeys_set_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
35299         LDKTxCreationKeys this_ptr_conv;
35300         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35301         this_ptr_conv.is_owned = false;
35302         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35303         LDKPublicKey val_ref;
35304         CHECK(val->arr_len == 33);
35305         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
35306         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
35307 }
35308
35309 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_revocation_key"))) TS_TxCreationKeys_get_revocation_key(uint32_t this_ptr) {
35310         LDKTxCreationKeys this_ptr_conv;
35311         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35312         this_ptr_conv.is_owned = false;
35313         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35314         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
35315         memcpy(ret_arr->elems, TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form, 33);
35316         return ret_arr;
35317 }
35318
35319 void  __attribute__((export_name("TS_TxCreationKeys_set_revocation_key"))) TS_TxCreationKeys_set_revocation_key(uint32_t this_ptr, int8_tArray val) {
35320         LDKTxCreationKeys this_ptr_conv;
35321         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35322         this_ptr_conv.is_owned = false;
35323         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35324         LDKPublicKey val_ref;
35325         CHECK(val->arr_len == 33);
35326         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
35327         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
35328 }
35329
35330 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_broadcaster_htlc_key"))) TS_TxCreationKeys_get_broadcaster_htlc_key(uint32_t this_ptr) {
35331         LDKTxCreationKeys this_ptr_conv;
35332         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35333         this_ptr_conv.is_owned = false;
35334         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35335         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
35336         memcpy(ret_arr->elems, TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form, 33);
35337         return ret_arr;
35338 }
35339
35340 void  __attribute__((export_name("TS_TxCreationKeys_set_broadcaster_htlc_key"))) TS_TxCreationKeys_set_broadcaster_htlc_key(uint32_t this_ptr, int8_tArray val) {
35341         LDKTxCreationKeys this_ptr_conv;
35342         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35343         this_ptr_conv.is_owned = false;
35344         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35345         LDKPublicKey val_ref;
35346         CHECK(val->arr_len == 33);
35347         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
35348         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
35349 }
35350
35351 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_countersignatory_htlc_key"))) TS_TxCreationKeys_get_countersignatory_htlc_key(uint32_t this_ptr) {
35352         LDKTxCreationKeys this_ptr_conv;
35353         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35354         this_ptr_conv.is_owned = false;
35355         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35356         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
35357         memcpy(ret_arr->elems, TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form, 33);
35358         return ret_arr;
35359 }
35360
35361 void  __attribute__((export_name("TS_TxCreationKeys_set_countersignatory_htlc_key"))) TS_TxCreationKeys_set_countersignatory_htlc_key(uint32_t this_ptr, int8_tArray val) {
35362         LDKTxCreationKeys this_ptr_conv;
35363         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35364         this_ptr_conv.is_owned = false;
35365         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35366         LDKPublicKey val_ref;
35367         CHECK(val->arr_len == 33);
35368         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
35369         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
35370 }
35371
35372 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_broadcaster_delayed_payment_key"))) TS_TxCreationKeys_get_broadcaster_delayed_payment_key(uint32_t this_ptr) {
35373         LDKTxCreationKeys this_ptr_conv;
35374         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35375         this_ptr_conv.is_owned = false;
35376         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35377         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
35378         memcpy(ret_arr->elems, TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form, 33);
35379         return ret_arr;
35380 }
35381
35382 void  __attribute__((export_name("TS_TxCreationKeys_set_broadcaster_delayed_payment_key"))) TS_TxCreationKeys_set_broadcaster_delayed_payment_key(uint32_t this_ptr, int8_tArray val) {
35383         LDKTxCreationKeys this_ptr_conv;
35384         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35385         this_ptr_conv.is_owned = false;
35386         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35387         LDKPublicKey val_ref;
35388         CHECK(val->arr_len == 33);
35389         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
35390         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
35391 }
35392
35393 uint32_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) {
35394         LDKPublicKey per_commitment_point_arg_ref;
35395         CHECK(per_commitment_point_arg->arr_len == 33);
35396         memcpy(per_commitment_point_arg_ref.compressed_form, per_commitment_point_arg->elems, 33); FREE(per_commitment_point_arg);
35397         LDKPublicKey revocation_key_arg_ref;
35398         CHECK(revocation_key_arg->arr_len == 33);
35399         memcpy(revocation_key_arg_ref.compressed_form, revocation_key_arg->elems, 33); FREE(revocation_key_arg);
35400         LDKPublicKey broadcaster_htlc_key_arg_ref;
35401         CHECK(broadcaster_htlc_key_arg->arr_len == 33);
35402         memcpy(broadcaster_htlc_key_arg_ref.compressed_form, broadcaster_htlc_key_arg->elems, 33); FREE(broadcaster_htlc_key_arg);
35403         LDKPublicKey countersignatory_htlc_key_arg_ref;
35404         CHECK(countersignatory_htlc_key_arg->arr_len == 33);
35405         memcpy(countersignatory_htlc_key_arg_ref.compressed_form, countersignatory_htlc_key_arg->elems, 33); FREE(countersignatory_htlc_key_arg);
35406         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
35407         CHECK(broadcaster_delayed_payment_key_arg->arr_len == 33);
35408         memcpy(broadcaster_delayed_payment_key_arg_ref.compressed_form, broadcaster_delayed_payment_key_arg->elems, 33); FREE(broadcaster_delayed_payment_key_arg);
35409         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);
35410         uint32_t ret_ref = 0;
35411         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35412         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35413         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35414         ret_ref = (uintptr_t)ret_var.inner;
35415         if (ret_var.is_owned) {
35416                 ret_ref |= 1;
35417         }
35418         return ret_ref;
35419 }
35420
35421 static inline uintptr_t TxCreationKeys_clone_ptr(LDKTxCreationKeys *NONNULL_PTR arg) {
35422         LDKTxCreationKeys ret_var = TxCreationKeys_clone(arg);
35423 uint32_t ret_ref = 0;
35424 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35425 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35426 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35427 ret_ref = (uintptr_t)ret_var.inner;
35428 if (ret_var.is_owned) {
35429         ret_ref |= 1;
35430 }
35431         return ret_ref;
35432 }
35433 uint32_t  __attribute__((export_name("TS_TxCreationKeys_clone_ptr"))) TS_TxCreationKeys_clone_ptr(uint32_t arg) {
35434         LDKTxCreationKeys arg_conv;
35435         arg_conv.inner = (void*)(arg & (~1));
35436         arg_conv.is_owned = false;
35437         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35438         uint32_t ret_conv = TxCreationKeys_clone_ptr(&arg_conv);
35439         return ret_conv;
35440 }
35441
35442 uint32_t  __attribute__((export_name("TS_TxCreationKeys_clone"))) TS_TxCreationKeys_clone(uint32_t orig) {
35443         LDKTxCreationKeys orig_conv;
35444         orig_conv.inner = (void*)(orig & (~1));
35445         orig_conv.is_owned = false;
35446         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35447         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
35448         uint32_t ret_ref = 0;
35449         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35450         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35451         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35452         ret_ref = (uintptr_t)ret_var.inner;
35453         if (ret_var.is_owned) {
35454                 ret_ref |= 1;
35455         }
35456         return ret_ref;
35457 }
35458
35459 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_write"))) TS_TxCreationKeys_write(uint32_t obj) {
35460         LDKTxCreationKeys obj_conv;
35461         obj_conv.inner = (void*)(obj & (~1));
35462         obj_conv.is_owned = false;
35463         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35464         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
35465         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35466         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35467         CVec_u8Z_free(ret_var);
35468         return ret_arr;
35469 }
35470
35471 uint32_t  __attribute__((export_name("TS_TxCreationKeys_read"))) TS_TxCreationKeys_read(int8_tArray ser) {
35472         LDKu8slice ser_ref;
35473         ser_ref.datalen = ser->arr_len;
35474         ser_ref.data = ser->elems;
35475         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
35476         *ret_conv = TxCreationKeys_read(ser_ref);
35477         FREE(ser);
35478         return (uint32_t)ret_conv;
35479 }
35480
35481 void  __attribute__((export_name("TS_ChannelPublicKeys_free"))) TS_ChannelPublicKeys_free(uint32_t this_obj) {
35482         LDKChannelPublicKeys this_obj_conv;
35483         this_obj_conv.inner = (void*)(this_obj & (~1));
35484         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35485         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35486         ChannelPublicKeys_free(this_obj_conv);
35487 }
35488
35489 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_funding_pubkey"))) TS_ChannelPublicKeys_get_funding_pubkey(uint32_t this_ptr) {
35490         LDKChannelPublicKeys this_ptr_conv;
35491         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35492         this_ptr_conv.is_owned = false;
35493         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35494         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
35495         memcpy(ret_arr->elems, ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
35496         return ret_arr;
35497 }
35498
35499 void  __attribute__((export_name("TS_ChannelPublicKeys_set_funding_pubkey"))) TS_ChannelPublicKeys_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
35500         LDKChannelPublicKeys this_ptr_conv;
35501         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35502         this_ptr_conv.is_owned = false;
35503         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35504         LDKPublicKey val_ref;
35505         CHECK(val->arr_len == 33);
35506         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
35507         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
35508 }
35509
35510 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_revocation_basepoint"))) TS_ChannelPublicKeys_get_revocation_basepoint(uint32_t this_ptr) {
35511         LDKChannelPublicKeys this_ptr_conv;
35512         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35513         this_ptr_conv.is_owned = false;
35514         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35515         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
35516         memcpy(ret_arr->elems, ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
35517         return ret_arr;
35518 }
35519
35520 void  __attribute__((export_name("TS_ChannelPublicKeys_set_revocation_basepoint"))) TS_ChannelPublicKeys_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
35521         LDKChannelPublicKeys this_ptr_conv;
35522         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35523         this_ptr_conv.is_owned = false;
35524         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35525         LDKPublicKey val_ref;
35526         CHECK(val->arr_len == 33);
35527         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
35528         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
35529 }
35530
35531 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_payment_point"))) TS_ChannelPublicKeys_get_payment_point(uint32_t this_ptr) {
35532         LDKChannelPublicKeys this_ptr_conv;
35533         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35534         this_ptr_conv.is_owned = false;
35535         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35536         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
35537         memcpy(ret_arr->elems, ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form, 33);
35538         return ret_arr;
35539 }
35540
35541 void  __attribute__((export_name("TS_ChannelPublicKeys_set_payment_point"))) TS_ChannelPublicKeys_set_payment_point(uint32_t this_ptr, int8_tArray val) {
35542         LDKChannelPublicKeys this_ptr_conv;
35543         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35544         this_ptr_conv.is_owned = false;
35545         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35546         LDKPublicKey val_ref;
35547         CHECK(val->arr_len == 33);
35548         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
35549         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
35550 }
35551
35552 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_delayed_payment_basepoint"))) TS_ChannelPublicKeys_get_delayed_payment_basepoint(uint32_t this_ptr) {
35553         LDKChannelPublicKeys this_ptr_conv;
35554         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35555         this_ptr_conv.is_owned = false;
35556         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35557         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
35558         memcpy(ret_arr->elems, ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
35559         return ret_arr;
35560 }
35561
35562 void  __attribute__((export_name("TS_ChannelPublicKeys_set_delayed_payment_basepoint"))) TS_ChannelPublicKeys_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
35563         LDKChannelPublicKeys this_ptr_conv;
35564         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35565         this_ptr_conv.is_owned = false;
35566         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35567         LDKPublicKey val_ref;
35568         CHECK(val->arr_len == 33);
35569         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
35570         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
35571 }
35572
35573 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_htlc_basepoint"))) TS_ChannelPublicKeys_get_htlc_basepoint(uint32_t this_ptr) {
35574         LDKChannelPublicKeys this_ptr_conv;
35575         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35576         this_ptr_conv.is_owned = false;
35577         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35578         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
35579         memcpy(ret_arr->elems, ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
35580         return ret_arr;
35581 }
35582
35583 void  __attribute__((export_name("TS_ChannelPublicKeys_set_htlc_basepoint"))) TS_ChannelPublicKeys_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
35584         LDKChannelPublicKeys this_ptr_conv;
35585         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35586         this_ptr_conv.is_owned = false;
35587         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35588         LDKPublicKey val_ref;
35589         CHECK(val->arr_len == 33);
35590         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
35591         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
35592 }
35593
35594 uint32_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) {
35595         LDKPublicKey funding_pubkey_arg_ref;
35596         CHECK(funding_pubkey_arg->arr_len == 33);
35597         memcpy(funding_pubkey_arg_ref.compressed_form, funding_pubkey_arg->elems, 33); FREE(funding_pubkey_arg);
35598         LDKPublicKey revocation_basepoint_arg_ref;
35599         CHECK(revocation_basepoint_arg->arr_len == 33);
35600         memcpy(revocation_basepoint_arg_ref.compressed_form, revocation_basepoint_arg->elems, 33); FREE(revocation_basepoint_arg);
35601         LDKPublicKey payment_point_arg_ref;
35602         CHECK(payment_point_arg->arr_len == 33);
35603         memcpy(payment_point_arg_ref.compressed_form, payment_point_arg->elems, 33); FREE(payment_point_arg);
35604         LDKPublicKey delayed_payment_basepoint_arg_ref;
35605         CHECK(delayed_payment_basepoint_arg->arr_len == 33);
35606         memcpy(delayed_payment_basepoint_arg_ref.compressed_form, delayed_payment_basepoint_arg->elems, 33); FREE(delayed_payment_basepoint_arg);
35607         LDKPublicKey htlc_basepoint_arg_ref;
35608         CHECK(htlc_basepoint_arg->arr_len == 33);
35609         memcpy(htlc_basepoint_arg_ref.compressed_form, htlc_basepoint_arg->elems, 33); FREE(htlc_basepoint_arg);
35610         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);
35611         uint32_t ret_ref = 0;
35612         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35613         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35614         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35615         ret_ref = (uintptr_t)ret_var.inner;
35616         if (ret_var.is_owned) {
35617                 ret_ref |= 1;
35618         }
35619         return ret_ref;
35620 }
35621
35622 static inline uintptr_t ChannelPublicKeys_clone_ptr(LDKChannelPublicKeys *NONNULL_PTR arg) {
35623         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(arg);
35624 uint32_t ret_ref = 0;
35625 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35626 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35627 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35628 ret_ref = (uintptr_t)ret_var.inner;
35629 if (ret_var.is_owned) {
35630         ret_ref |= 1;
35631 }
35632         return ret_ref;
35633 }
35634 uint32_t  __attribute__((export_name("TS_ChannelPublicKeys_clone_ptr"))) TS_ChannelPublicKeys_clone_ptr(uint32_t arg) {
35635         LDKChannelPublicKeys arg_conv;
35636         arg_conv.inner = (void*)(arg & (~1));
35637         arg_conv.is_owned = false;
35638         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35639         uint32_t ret_conv = ChannelPublicKeys_clone_ptr(&arg_conv);
35640         return ret_conv;
35641 }
35642
35643 uint32_t  __attribute__((export_name("TS_ChannelPublicKeys_clone"))) TS_ChannelPublicKeys_clone(uint32_t orig) {
35644         LDKChannelPublicKeys orig_conv;
35645         orig_conv.inner = (void*)(orig & (~1));
35646         orig_conv.is_owned = false;
35647         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35648         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
35649         uint32_t ret_ref = 0;
35650         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35651         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35652         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35653         ret_ref = (uintptr_t)ret_var.inner;
35654         if (ret_var.is_owned) {
35655                 ret_ref |= 1;
35656         }
35657         return ret_ref;
35658 }
35659
35660 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_write"))) TS_ChannelPublicKeys_write(uint32_t obj) {
35661         LDKChannelPublicKeys obj_conv;
35662         obj_conv.inner = (void*)(obj & (~1));
35663         obj_conv.is_owned = false;
35664         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35665         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
35666         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35667         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35668         CVec_u8Z_free(ret_var);
35669         return ret_arr;
35670 }
35671
35672 uint32_t  __attribute__((export_name("TS_ChannelPublicKeys_read"))) TS_ChannelPublicKeys_read(int8_tArray ser) {
35673         LDKu8slice ser_ref;
35674         ser_ref.datalen = ser->arr_len;
35675         ser_ref.data = ser->elems;
35676         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
35677         *ret_conv = ChannelPublicKeys_read(ser_ref);
35678         FREE(ser);
35679         return (uint32_t)ret_conv;
35680 }
35681
35682 uint32_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) {
35683         LDKPublicKey per_commitment_point_ref;
35684         CHECK(per_commitment_point->arr_len == 33);
35685         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
35686         LDKPublicKey broadcaster_delayed_payment_base_ref;
35687         CHECK(broadcaster_delayed_payment_base->arr_len == 33);
35688         memcpy(broadcaster_delayed_payment_base_ref.compressed_form, broadcaster_delayed_payment_base->elems, 33); FREE(broadcaster_delayed_payment_base);
35689         LDKPublicKey broadcaster_htlc_base_ref;
35690         CHECK(broadcaster_htlc_base->arr_len == 33);
35691         memcpy(broadcaster_htlc_base_ref.compressed_form, broadcaster_htlc_base->elems, 33); FREE(broadcaster_htlc_base);
35692         LDKPublicKey countersignatory_revocation_base_ref;
35693         CHECK(countersignatory_revocation_base->arr_len == 33);
35694         memcpy(countersignatory_revocation_base_ref.compressed_form, countersignatory_revocation_base->elems, 33); FREE(countersignatory_revocation_base);
35695         LDKPublicKey countersignatory_htlc_base_ref;
35696         CHECK(countersignatory_htlc_base->arr_len == 33);
35697         memcpy(countersignatory_htlc_base_ref.compressed_form, countersignatory_htlc_base->elems, 33); FREE(countersignatory_htlc_base);
35698         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
35699         *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);
35700         return (uint32_t)ret_conv;
35701 }
35702
35703 uint32_t  __attribute__((export_name("TS_TxCreationKeys_from_channel_static_keys"))) TS_TxCreationKeys_from_channel_static_keys(int8_tArray per_commitment_point, uint32_t broadcaster_keys, uint32_t countersignatory_keys) {
35704         LDKPublicKey per_commitment_point_ref;
35705         CHECK(per_commitment_point->arr_len == 33);
35706         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
35707         LDKChannelPublicKeys broadcaster_keys_conv;
35708         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
35709         broadcaster_keys_conv.is_owned = false;
35710         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
35711         LDKChannelPublicKeys countersignatory_keys_conv;
35712         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
35713         countersignatory_keys_conv.is_owned = false;
35714         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
35715         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
35716         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
35717         return (uint32_t)ret_conv;
35718 }
35719
35720 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) {
35721         LDKPublicKey revocation_key_ref;
35722         CHECK(revocation_key->arr_len == 33);
35723         memcpy(revocation_key_ref.compressed_form, revocation_key->elems, 33); FREE(revocation_key);
35724         LDKPublicKey broadcaster_delayed_payment_key_ref;
35725         CHECK(broadcaster_delayed_payment_key->arr_len == 33);
35726         memcpy(broadcaster_delayed_payment_key_ref.compressed_form, broadcaster_delayed_payment_key->elems, 33); FREE(broadcaster_delayed_payment_key);
35727         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
35728         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35729         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35730         CVec_u8Z_free(ret_var);
35731         return ret_arr;
35732 }
35733
35734 void  __attribute__((export_name("TS_HTLCOutputInCommitment_free"))) TS_HTLCOutputInCommitment_free(uint32_t this_obj) {
35735         LDKHTLCOutputInCommitment this_obj_conv;
35736         this_obj_conv.inner = (void*)(this_obj & (~1));
35737         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35738         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35739         HTLCOutputInCommitment_free(this_obj_conv);
35740 }
35741
35742 jboolean  __attribute__((export_name("TS_HTLCOutputInCommitment_get_offered"))) TS_HTLCOutputInCommitment_get_offered(uint32_t this_ptr) {
35743         LDKHTLCOutputInCommitment this_ptr_conv;
35744         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35745         this_ptr_conv.is_owned = false;
35746         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35747         jboolean ret_conv = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
35748         return ret_conv;
35749 }
35750
35751 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_offered"))) TS_HTLCOutputInCommitment_set_offered(uint32_t this_ptr, jboolean val) {
35752         LDKHTLCOutputInCommitment this_ptr_conv;
35753         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35754         this_ptr_conv.is_owned = false;
35755         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35756         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
35757 }
35758
35759 int64_t  __attribute__((export_name("TS_HTLCOutputInCommitment_get_amount_msat"))) TS_HTLCOutputInCommitment_get_amount_msat(uint32_t this_ptr) {
35760         LDKHTLCOutputInCommitment this_ptr_conv;
35761         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35762         this_ptr_conv.is_owned = false;
35763         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35764         int64_t ret_conv = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
35765         return ret_conv;
35766 }
35767
35768 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_amount_msat"))) TS_HTLCOutputInCommitment_set_amount_msat(uint32_t this_ptr, int64_t val) {
35769         LDKHTLCOutputInCommitment this_ptr_conv;
35770         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35771         this_ptr_conv.is_owned = false;
35772         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35773         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
35774 }
35775
35776 int32_t  __attribute__((export_name("TS_HTLCOutputInCommitment_get_cltv_expiry"))) TS_HTLCOutputInCommitment_get_cltv_expiry(uint32_t this_ptr) {
35777         LDKHTLCOutputInCommitment this_ptr_conv;
35778         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35779         this_ptr_conv.is_owned = false;
35780         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35781         int32_t ret_conv = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
35782         return ret_conv;
35783 }
35784
35785 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_cltv_expiry"))) TS_HTLCOutputInCommitment_set_cltv_expiry(uint32_t this_ptr, int32_t val) {
35786         LDKHTLCOutputInCommitment this_ptr_conv;
35787         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35788         this_ptr_conv.is_owned = false;
35789         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35790         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
35791 }
35792
35793 int8_tArray  __attribute__((export_name("TS_HTLCOutputInCommitment_get_payment_hash"))) TS_HTLCOutputInCommitment_get_payment_hash(uint32_t this_ptr) {
35794         LDKHTLCOutputInCommitment this_ptr_conv;
35795         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35796         this_ptr_conv.is_owned = false;
35797         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35798         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
35799         memcpy(ret_arr->elems, *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv), 32);
35800         return ret_arr;
35801 }
35802
35803 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_payment_hash"))) TS_HTLCOutputInCommitment_set_payment_hash(uint32_t this_ptr, int8_tArray val) {
35804         LDKHTLCOutputInCommitment this_ptr_conv;
35805         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35806         this_ptr_conv.is_owned = false;
35807         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35808         LDKThirtyTwoBytes val_ref;
35809         CHECK(val->arr_len == 32);
35810         memcpy(val_ref.data, val->elems, 32); FREE(val);
35811         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
35812 }
35813
35814 uint32_t  __attribute__((export_name("TS_HTLCOutputInCommitment_get_transaction_output_index"))) TS_HTLCOutputInCommitment_get_transaction_output_index(uint32_t this_ptr) {
35815         LDKHTLCOutputInCommitment this_ptr_conv;
35816         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35817         this_ptr_conv.is_owned = false;
35818         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35819         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
35820         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
35821         uint32_t ret_ref = (uintptr_t)ret_copy;
35822         return ret_ref;
35823 }
35824
35825 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_transaction_output_index"))) TS_HTLCOutputInCommitment_set_transaction_output_index(uint32_t this_ptr, uint32_t val) {
35826         LDKHTLCOutputInCommitment this_ptr_conv;
35827         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35828         this_ptr_conv.is_owned = false;
35829         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35830         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
35831         CHECK_ACCESS(val_ptr);
35832         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
35833         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)val) & ~1));
35834         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
35835 }
35836
35837 uint32_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, uint32_t transaction_output_index_arg) {
35838         LDKThirtyTwoBytes payment_hash_arg_ref;
35839         CHECK(payment_hash_arg->arr_len == 32);
35840         memcpy(payment_hash_arg_ref.data, payment_hash_arg->elems, 32); FREE(payment_hash_arg);
35841         void* transaction_output_index_arg_ptr = (void*)(((uintptr_t)transaction_output_index_arg) & ~1);
35842         CHECK_ACCESS(transaction_output_index_arg_ptr);
35843         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(transaction_output_index_arg_ptr);
35844         transaction_output_index_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)transaction_output_index_arg) & ~1));
35845         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
35846         uint32_t ret_ref = 0;
35847         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35848         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35849         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35850         ret_ref = (uintptr_t)ret_var.inner;
35851         if (ret_var.is_owned) {
35852                 ret_ref |= 1;
35853         }
35854         return ret_ref;
35855 }
35856
35857 static inline uintptr_t HTLCOutputInCommitment_clone_ptr(LDKHTLCOutputInCommitment *NONNULL_PTR arg) {
35858         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(arg);
35859 uint32_t ret_ref = 0;
35860 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35861 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35862 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35863 ret_ref = (uintptr_t)ret_var.inner;
35864 if (ret_var.is_owned) {
35865         ret_ref |= 1;
35866 }
35867         return ret_ref;
35868 }
35869 uint32_t  __attribute__((export_name("TS_HTLCOutputInCommitment_clone_ptr"))) TS_HTLCOutputInCommitment_clone_ptr(uint32_t arg) {
35870         LDKHTLCOutputInCommitment arg_conv;
35871         arg_conv.inner = (void*)(arg & (~1));
35872         arg_conv.is_owned = false;
35873         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35874         uint32_t ret_conv = HTLCOutputInCommitment_clone_ptr(&arg_conv);
35875         return ret_conv;
35876 }
35877
35878 uint32_t  __attribute__((export_name("TS_HTLCOutputInCommitment_clone"))) TS_HTLCOutputInCommitment_clone(uint32_t orig) {
35879         LDKHTLCOutputInCommitment orig_conv;
35880         orig_conv.inner = (void*)(orig & (~1));
35881         orig_conv.is_owned = false;
35882         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35883         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
35884         uint32_t ret_ref = 0;
35885         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35886         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35887         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35888         ret_ref = (uintptr_t)ret_var.inner;
35889         if (ret_var.is_owned) {
35890                 ret_ref |= 1;
35891         }
35892         return ret_ref;
35893 }
35894
35895 int8_tArray  __attribute__((export_name("TS_HTLCOutputInCommitment_write"))) TS_HTLCOutputInCommitment_write(uint32_t obj) {
35896         LDKHTLCOutputInCommitment obj_conv;
35897         obj_conv.inner = (void*)(obj & (~1));
35898         obj_conv.is_owned = false;
35899         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35900         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
35901         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35902         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35903         CVec_u8Z_free(ret_var);
35904         return ret_arr;
35905 }
35906
35907 uint32_t  __attribute__((export_name("TS_HTLCOutputInCommitment_read"))) TS_HTLCOutputInCommitment_read(int8_tArray ser) {
35908         LDKu8slice ser_ref;
35909         ser_ref.datalen = ser->arr_len;
35910         ser_ref.data = ser->elems;
35911         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
35912         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
35913         FREE(ser);
35914         return (uint32_t)ret_conv;
35915 }
35916
35917 int8_tArray  __attribute__((export_name("TS_get_htlc_redeemscript"))) TS_get_htlc_redeemscript(uint32_t htlc, jboolean opt_anchors, uint32_t keys) {
35918         LDKHTLCOutputInCommitment htlc_conv;
35919         htlc_conv.inner = (void*)(htlc & (~1));
35920         htlc_conv.is_owned = false;
35921         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
35922         LDKTxCreationKeys keys_conv;
35923         keys_conv.inner = (void*)(keys & (~1));
35924         keys_conv.is_owned = false;
35925         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
35926         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, opt_anchors, &keys_conv);
35927         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35928         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35929         CVec_u8Z_free(ret_var);
35930         return ret_arr;
35931 }
35932
35933 int8_tArray  __attribute__((export_name("TS_make_funding_redeemscript"))) TS_make_funding_redeemscript(int8_tArray broadcaster, int8_tArray countersignatory) {
35934         LDKPublicKey broadcaster_ref;
35935         CHECK(broadcaster->arr_len == 33);
35936         memcpy(broadcaster_ref.compressed_form, broadcaster->elems, 33); FREE(broadcaster);
35937         LDKPublicKey countersignatory_ref;
35938         CHECK(countersignatory->arr_len == 33);
35939         memcpy(countersignatory_ref.compressed_form, countersignatory->elems, 33); FREE(countersignatory);
35940         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
35941         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35942         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35943         CVec_u8Z_free(ret_var);
35944         return ret_arr;
35945 }
35946
35947 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, uint32_t htlc, jboolean opt_anchors, int8_tArray broadcaster_delayed_payment_key, int8_tArray revocation_key) {
35948         unsigned char commitment_txid_arr[32];
35949         CHECK(commitment_txid->arr_len == 32);
35950         memcpy(commitment_txid_arr, commitment_txid->elems, 32); FREE(commitment_txid);
35951         unsigned char (*commitment_txid_ref)[32] = &commitment_txid_arr;
35952         LDKHTLCOutputInCommitment htlc_conv;
35953         htlc_conv.inner = (void*)(htlc & (~1));
35954         htlc_conv.is_owned = false;
35955         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
35956         LDKPublicKey broadcaster_delayed_payment_key_ref;
35957         CHECK(broadcaster_delayed_payment_key->arr_len == 33);
35958         memcpy(broadcaster_delayed_payment_key_ref.compressed_form, broadcaster_delayed_payment_key->elems, 33); FREE(broadcaster_delayed_payment_key);
35959         LDKPublicKey revocation_key_ref;
35960         CHECK(revocation_key->arr_len == 33);
35961         memcpy(revocation_key_ref.compressed_form, revocation_key->elems, 33); FREE(revocation_key);
35962         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);
35963         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35964         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35965         Transaction_free(ret_var);
35966         return ret_arr;
35967 }
35968
35969 int8_tArray  __attribute__((export_name("TS_get_anchor_redeemscript"))) TS_get_anchor_redeemscript(int8_tArray funding_pubkey) {
35970         LDKPublicKey funding_pubkey_ref;
35971         CHECK(funding_pubkey->arr_len == 33);
35972         memcpy(funding_pubkey_ref.compressed_form, funding_pubkey->elems, 33); FREE(funding_pubkey);
35973         LDKCVec_u8Z ret_var = get_anchor_redeemscript(funding_pubkey_ref);
35974         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35975         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35976         CVec_u8Z_free(ret_var);
35977         return ret_arr;
35978 }
35979
35980 void  __attribute__((export_name("TS_ChannelTransactionParameters_free"))) TS_ChannelTransactionParameters_free(uint32_t this_obj) {
35981         LDKChannelTransactionParameters this_obj_conv;
35982         this_obj_conv.inner = (void*)(this_obj & (~1));
35983         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35984         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35985         ChannelTransactionParameters_free(this_obj_conv);
35986 }
35987
35988 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_holder_pubkeys"))) TS_ChannelTransactionParameters_get_holder_pubkeys(uint32_t this_ptr) {
35989         LDKChannelTransactionParameters this_ptr_conv;
35990         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35991         this_ptr_conv.is_owned = false;
35992         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35993         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
35994         uint32_t ret_ref = 0;
35995         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35996         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35997         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35998         ret_ref = (uintptr_t)ret_var.inner;
35999         if (ret_var.is_owned) {
36000                 ret_ref |= 1;
36001         }
36002         return ret_ref;
36003 }
36004
36005 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_holder_pubkeys"))) TS_ChannelTransactionParameters_set_holder_pubkeys(uint32_t this_ptr, uint32_t val) {
36006         LDKChannelTransactionParameters this_ptr_conv;
36007         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36008         this_ptr_conv.is_owned = false;
36009         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36010         LDKChannelPublicKeys val_conv;
36011         val_conv.inner = (void*)(val & (~1));
36012         val_conv.is_owned = (val & 1) || (val == 0);
36013         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36014         val_conv = ChannelPublicKeys_clone(&val_conv);
36015         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
36016 }
36017
36018 int16_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_holder_selected_contest_delay"))) TS_ChannelTransactionParameters_get_holder_selected_contest_delay(uint32_t this_ptr) {
36019         LDKChannelTransactionParameters this_ptr_conv;
36020         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36021         this_ptr_conv.is_owned = false;
36022         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36023         int16_t ret_conv = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
36024         return ret_conv;
36025 }
36026
36027 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_holder_selected_contest_delay"))) TS_ChannelTransactionParameters_set_holder_selected_contest_delay(uint32_t this_ptr, int16_t val) {
36028         LDKChannelTransactionParameters this_ptr_conv;
36029         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36030         this_ptr_conv.is_owned = false;
36031         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36032         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
36033 }
36034
36035 jboolean  __attribute__((export_name("TS_ChannelTransactionParameters_get_is_outbound_from_holder"))) TS_ChannelTransactionParameters_get_is_outbound_from_holder(uint32_t this_ptr) {
36036         LDKChannelTransactionParameters this_ptr_conv;
36037         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36038         this_ptr_conv.is_owned = false;
36039         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36040         jboolean ret_conv = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
36041         return ret_conv;
36042 }
36043
36044 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_is_outbound_from_holder"))) TS_ChannelTransactionParameters_set_is_outbound_from_holder(uint32_t this_ptr, jboolean val) {
36045         LDKChannelTransactionParameters this_ptr_conv;
36046         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36047         this_ptr_conv.is_owned = false;
36048         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36049         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
36050 }
36051
36052 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_counterparty_parameters"))) TS_ChannelTransactionParameters_get_counterparty_parameters(uint32_t this_ptr) {
36053         LDKChannelTransactionParameters this_ptr_conv;
36054         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36055         this_ptr_conv.is_owned = false;
36056         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36057         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
36058         uint32_t ret_ref = 0;
36059         if ((uintptr_t)ret_var.inner > 4096) {
36060                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36061                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36062         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36063                 ret_ref = (uintptr_t)ret_var.inner;
36064                 if (ret_var.is_owned) {
36065                         ret_ref |= 1;
36066                 }
36067         }
36068         return ret_ref;
36069 }
36070
36071 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_counterparty_parameters"))) TS_ChannelTransactionParameters_set_counterparty_parameters(uint32_t this_ptr, uint32_t val) {
36072         LDKChannelTransactionParameters this_ptr_conv;
36073         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36074         this_ptr_conv.is_owned = false;
36075         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36076         LDKCounterpartyChannelTransactionParameters val_conv;
36077         val_conv.inner = (void*)(val & (~1));
36078         val_conv.is_owned = (val & 1) || (val == 0);
36079         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36080         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
36081         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
36082 }
36083
36084 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_funding_outpoint"))) TS_ChannelTransactionParameters_get_funding_outpoint(uint32_t this_ptr) {
36085         LDKChannelTransactionParameters this_ptr_conv;
36086         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36087         this_ptr_conv.is_owned = false;
36088         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36089         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
36090         uint32_t ret_ref = 0;
36091         if ((uintptr_t)ret_var.inner > 4096) {
36092                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36093                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36094         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36095                 ret_ref = (uintptr_t)ret_var.inner;
36096                 if (ret_var.is_owned) {
36097                         ret_ref |= 1;
36098                 }
36099         }
36100         return ret_ref;
36101 }
36102
36103 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_funding_outpoint"))) TS_ChannelTransactionParameters_set_funding_outpoint(uint32_t this_ptr, uint32_t val) {
36104         LDKChannelTransactionParameters this_ptr_conv;
36105         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36106         this_ptr_conv.is_owned = false;
36107         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36108         LDKOutPoint val_conv;
36109         val_conv.inner = (void*)(val & (~1));
36110         val_conv.is_owned = (val & 1) || (val == 0);
36111         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36112         val_conv = OutPoint_clone(&val_conv);
36113         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
36114 }
36115
36116 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_opt_anchors"))) TS_ChannelTransactionParameters_get_opt_anchors(uint32_t this_ptr) {
36117         LDKChannelTransactionParameters this_ptr_conv;
36118         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36119         this_ptr_conv.is_owned = false;
36120         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36121         uint32_t ret_conv = LDKCOption_NoneZ_to_js(ChannelTransactionParameters_get_opt_anchors(&this_ptr_conv));
36122         return ret_conv;
36123 }
36124
36125 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_opt_anchors"))) TS_ChannelTransactionParameters_set_opt_anchors(uint32_t this_ptr, uint32_t val) {
36126         LDKChannelTransactionParameters this_ptr_conv;
36127         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36128         this_ptr_conv.is_owned = false;
36129         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36130         LDKCOption_NoneZ val_conv = LDKCOption_NoneZ_from_js(val);
36131         ChannelTransactionParameters_set_opt_anchors(&this_ptr_conv, val_conv);
36132 }
36133
36134 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_new"))) TS_ChannelTransactionParameters_new(uint32_t holder_pubkeys_arg, int16_t holder_selected_contest_delay_arg, jboolean is_outbound_from_holder_arg, uint32_t counterparty_parameters_arg, uint32_t funding_outpoint_arg, uint32_t opt_anchors_arg) {
36135         LDKChannelPublicKeys holder_pubkeys_arg_conv;
36136         holder_pubkeys_arg_conv.inner = (void*)(holder_pubkeys_arg & (~1));
36137         holder_pubkeys_arg_conv.is_owned = (holder_pubkeys_arg & 1) || (holder_pubkeys_arg == 0);
36138         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_pubkeys_arg_conv);
36139         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
36140         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
36141         counterparty_parameters_arg_conv.inner = (void*)(counterparty_parameters_arg & (~1));
36142         counterparty_parameters_arg_conv.is_owned = (counterparty_parameters_arg & 1) || (counterparty_parameters_arg == 0);
36143         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_parameters_arg_conv);
36144         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
36145         LDKOutPoint funding_outpoint_arg_conv;
36146         funding_outpoint_arg_conv.inner = (void*)(funding_outpoint_arg & (~1));
36147         funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
36148         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_arg_conv);
36149         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
36150         LDKCOption_NoneZ opt_anchors_arg_conv = LDKCOption_NoneZ_from_js(opt_anchors_arg);
36151         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);
36152         uint32_t ret_ref = 0;
36153         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36154         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36155         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36156         ret_ref = (uintptr_t)ret_var.inner;
36157         if (ret_var.is_owned) {
36158                 ret_ref |= 1;
36159         }
36160         return ret_ref;
36161 }
36162
36163 static inline uintptr_t ChannelTransactionParameters_clone_ptr(LDKChannelTransactionParameters *NONNULL_PTR arg) {
36164         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(arg);
36165 uint32_t ret_ref = 0;
36166 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36167 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36168 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36169 ret_ref = (uintptr_t)ret_var.inner;
36170 if (ret_var.is_owned) {
36171         ret_ref |= 1;
36172 }
36173         return ret_ref;
36174 }
36175 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_clone_ptr"))) TS_ChannelTransactionParameters_clone_ptr(uint32_t arg) {
36176         LDKChannelTransactionParameters arg_conv;
36177         arg_conv.inner = (void*)(arg & (~1));
36178         arg_conv.is_owned = false;
36179         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36180         uint32_t ret_conv = ChannelTransactionParameters_clone_ptr(&arg_conv);
36181         return ret_conv;
36182 }
36183
36184 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_clone"))) TS_ChannelTransactionParameters_clone(uint32_t orig) {
36185         LDKChannelTransactionParameters orig_conv;
36186         orig_conv.inner = (void*)(orig & (~1));
36187         orig_conv.is_owned = false;
36188         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36189         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
36190         uint32_t ret_ref = 0;
36191         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36192         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36193         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36194         ret_ref = (uintptr_t)ret_var.inner;
36195         if (ret_var.is_owned) {
36196                 ret_ref |= 1;
36197         }
36198         return ret_ref;
36199 }
36200
36201 void  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_free"))) TS_CounterpartyChannelTransactionParameters_free(uint32_t this_obj) {
36202         LDKCounterpartyChannelTransactionParameters this_obj_conv;
36203         this_obj_conv.inner = (void*)(this_obj & (~1));
36204         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36205         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36206         CounterpartyChannelTransactionParameters_free(this_obj_conv);
36207 }
36208
36209 uint32_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_get_pubkeys"))) TS_CounterpartyChannelTransactionParameters_get_pubkeys(uint32_t this_ptr) {
36210         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
36211         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36212         this_ptr_conv.is_owned = false;
36213         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36214         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
36215         uint32_t ret_ref = 0;
36216         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36217         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36218         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36219         ret_ref = (uintptr_t)ret_var.inner;
36220         if (ret_var.is_owned) {
36221                 ret_ref |= 1;
36222         }
36223         return ret_ref;
36224 }
36225
36226 void  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_set_pubkeys"))) TS_CounterpartyChannelTransactionParameters_set_pubkeys(uint32_t this_ptr, uint32_t val) {
36227         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
36228         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36229         this_ptr_conv.is_owned = false;
36230         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36231         LDKChannelPublicKeys val_conv;
36232         val_conv.inner = (void*)(val & (~1));
36233         val_conv.is_owned = (val & 1) || (val == 0);
36234         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36235         val_conv = ChannelPublicKeys_clone(&val_conv);
36236         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
36237 }
36238
36239 int16_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_get_selected_contest_delay"))) TS_CounterpartyChannelTransactionParameters_get_selected_contest_delay(uint32_t this_ptr) {
36240         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
36241         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36242         this_ptr_conv.is_owned = false;
36243         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36244         int16_t ret_conv = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
36245         return ret_conv;
36246 }
36247
36248 void  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_set_selected_contest_delay"))) TS_CounterpartyChannelTransactionParameters_set_selected_contest_delay(uint32_t this_ptr, int16_t val) {
36249         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
36250         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36251         this_ptr_conv.is_owned = false;
36252         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36253         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
36254 }
36255
36256 uint32_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_new"))) TS_CounterpartyChannelTransactionParameters_new(uint32_t pubkeys_arg, int16_t selected_contest_delay_arg) {
36257         LDKChannelPublicKeys pubkeys_arg_conv;
36258         pubkeys_arg_conv.inner = (void*)(pubkeys_arg & (~1));
36259         pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
36260         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_arg_conv);
36261         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
36262         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
36263         uint32_t ret_ref = 0;
36264         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36265         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36266         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36267         ret_ref = (uintptr_t)ret_var.inner;
36268         if (ret_var.is_owned) {
36269                 ret_ref |= 1;
36270         }
36271         return ret_ref;
36272 }
36273
36274 static inline uintptr_t CounterpartyChannelTransactionParameters_clone_ptr(LDKCounterpartyChannelTransactionParameters *NONNULL_PTR arg) {
36275         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(arg);
36276 uint32_t ret_ref = 0;
36277 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36278 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36279 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36280 ret_ref = (uintptr_t)ret_var.inner;
36281 if (ret_var.is_owned) {
36282         ret_ref |= 1;
36283 }
36284         return ret_ref;
36285 }
36286 uint32_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_clone_ptr"))) TS_CounterpartyChannelTransactionParameters_clone_ptr(uint32_t arg) {
36287         LDKCounterpartyChannelTransactionParameters arg_conv;
36288         arg_conv.inner = (void*)(arg & (~1));
36289         arg_conv.is_owned = false;
36290         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36291         uint32_t ret_conv = CounterpartyChannelTransactionParameters_clone_ptr(&arg_conv);
36292         return ret_conv;
36293 }
36294
36295 uint32_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_clone"))) TS_CounterpartyChannelTransactionParameters_clone(uint32_t orig) {
36296         LDKCounterpartyChannelTransactionParameters orig_conv;
36297         orig_conv.inner = (void*)(orig & (~1));
36298         orig_conv.is_owned = false;
36299         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36300         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
36301         uint32_t ret_ref = 0;
36302         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36303         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36304         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36305         ret_ref = (uintptr_t)ret_var.inner;
36306         if (ret_var.is_owned) {
36307                 ret_ref |= 1;
36308         }
36309         return ret_ref;
36310 }
36311
36312 jboolean  __attribute__((export_name("TS_ChannelTransactionParameters_is_populated"))) TS_ChannelTransactionParameters_is_populated(uint32_t this_arg) {
36313         LDKChannelTransactionParameters this_arg_conv;
36314         this_arg_conv.inner = (void*)(this_arg & (~1));
36315         this_arg_conv.is_owned = false;
36316         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36317         jboolean ret_conv = ChannelTransactionParameters_is_populated(&this_arg_conv);
36318         return ret_conv;
36319 }
36320
36321 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_as_holder_broadcastable"))) TS_ChannelTransactionParameters_as_holder_broadcastable(uint32_t this_arg) {
36322         LDKChannelTransactionParameters this_arg_conv;
36323         this_arg_conv.inner = (void*)(this_arg & (~1));
36324         this_arg_conv.is_owned = false;
36325         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36326         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
36327         uint32_t ret_ref = 0;
36328         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36329         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36330         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36331         ret_ref = (uintptr_t)ret_var.inner;
36332         if (ret_var.is_owned) {
36333                 ret_ref |= 1;
36334         }
36335         return ret_ref;
36336 }
36337
36338 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_as_counterparty_broadcastable"))) TS_ChannelTransactionParameters_as_counterparty_broadcastable(uint32_t this_arg) {
36339         LDKChannelTransactionParameters this_arg_conv;
36340         this_arg_conv.inner = (void*)(this_arg & (~1));
36341         this_arg_conv.is_owned = false;
36342         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36343         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
36344         uint32_t ret_ref = 0;
36345         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36346         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36347         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36348         ret_ref = (uintptr_t)ret_var.inner;
36349         if (ret_var.is_owned) {
36350                 ret_ref |= 1;
36351         }
36352         return ret_ref;
36353 }
36354
36355 int8_tArray  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_write"))) TS_CounterpartyChannelTransactionParameters_write(uint32_t obj) {
36356         LDKCounterpartyChannelTransactionParameters obj_conv;
36357         obj_conv.inner = (void*)(obj & (~1));
36358         obj_conv.is_owned = false;
36359         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36360         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
36361         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36362         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36363         CVec_u8Z_free(ret_var);
36364         return ret_arr;
36365 }
36366
36367 uint32_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_read"))) TS_CounterpartyChannelTransactionParameters_read(int8_tArray ser) {
36368         LDKu8slice ser_ref;
36369         ser_ref.datalen = ser->arr_len;
36370         ser_ref.data = ser->elems;
36371         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
36372         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
36373         FREE(ser);
36374         return (uint32_t)ret_conv;
36375 }
36376
36377 int8_tArray  __attribute__((export_name("TS_ChannelTransactionParameters_write"))) TS_ChannelTransactionParameters_write(uint32_t obj) {
36378         LDKChannelTransactionParameters obj_conv;
36379         obj_conv.inner = (void*)(obj & (~1));
36380         obj_conv.is_owned = false;
36381         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36382         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
36383         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36384         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36385         CVec_u8Z_free(ret_var);
36386         return ret_arr;
36387 }
36388
36389 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_read"))) TS_ChannelTransactionParameters_read(int8_tArray ser) {
36390         LDKu8slice ser_ref;
36391         ser_ref.datalen = ser->arr_len;
36392         ser_ref.data = ser->elems;
36393         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
36394         *ret_conv = ChannelTransactionParameters_read(ser_ref);
36395         FREE(ser);
36396         return (uint32_t)ret_conv;
36397 }
36398
36399 void  __attribute__((export_name("TS_DirectedChannelTransactionParameters_free"))) TS_DirectedChannelTransactionParameters_free(uint32_t this_obj) {
36400         LDKDirectedChannelTransactionParameters this_obj_conv;
36401         this_obj_conv.inner = (void*)(this_obj & (~1));
36402         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36403         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36404         DirectedChannelTransactionParameters_free(this_obj_conv);
36405 }
36406
36407 uint32_t  __attribute__((export_name("TS_DirectedChannelTransactionParameters_broadcaster_pubkeys"))) TS_DirectedChannelTransactionParameters_broadcaster_pubkeys(uint32_t this_arg) {
36408         LDKDirectedChannelTransactionParameters this_arg_conv;
36409         this_arg_conv.inner = (void*)(this_arg & (~1));
36410         this_arg_conv.is_owned = false;
36411         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36412         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
36413         uint32_t ret_ref = 0;
36414         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36415         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36416         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36417         ret_ref = (uintptr_t)ret_var.inner;
36418         if (ret_var.is_owned) {
36419                 ret_ref |= 1;
36420         }
36421         return ret_ref;
36422 }
36423
36424 uint32_t  __attribute__((export_name("TS_DirectedChannelTransactionParameters_countersignatory_pubkeys"))) TS_DirectedChannelTransactionParameters_countersignatory_pubkeys(uint32_t this_arg) {
36425         LDKDirectedChannelTransactionParameters this_arg_conv;
36426         this_arg_conv.inner = (void*)(this_arg & (~1));
36427         this_arg_conv.is_owned = false;
36428         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36429         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
36430         uint32_t ret_ref = 0;
36431         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36432         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36433         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36434         ret_ref = (uintptr_t)ret_var.inner;
36435         if (ret_var.is_owned) {
36436                 ret_ref |= 1;
36437         }
36438         return ret_ref;
36439 }
36440
36441 int16_t  __attribute__((export_name("TS_DirectedChannelTransactionParameters_contest_delay"))) TS_DirectedChannelTransactionParameters_contest_delay(uint32_t this_arg) {
36442         LDKDirectedChannelTransactionParameters this_arg_conv;
36443         this_arg_conv.inner = (void*)(this_arg & (~1));
36444         this_arg_conv.is_owned = false;
36445         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36446         int16_t ret_conv = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
36447         return ret_conv;
36448 }
36449
36450 jboolean  __attribute__((export_name("TS_DirectedChannelTransactionParameters_is_outbound"))) TS_DirectedChannelTransactionParameters_is_outbound(uint32_t this_arg) {
36451         LDKDirectedChannelTransactionParameters this_arg_conv;
36452         this_arg_conv.inner = (void*)(this_arg & (~1));
36453         this_arg_conv.is_owned = false;
36454         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36455         jboolean ret_conv = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
36456         return ret_conv;
36457 }
36458
36459 uint32_t  __attribute__((export_name("TS_DirectedChannelTransactionParameters_funding_outpoint"))) TS_DirectedChannelTransactionParameters_funding_outpoint(uint32_t this_arg) {
36460         LDKDirectedChannelTransactionParameters this_arg_conv;
36461         this_arg_conv.inner = (void*)(this_arg & (~1));
36462         this_arg_conv.is_owned = false;
36463         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36464         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
36465         uint32_t ret_ref = 0;
36466         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36467         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36468         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36469         ret_ref = (uintptr_t)ret_var.inner;
36470         if (ret_var.is_owned) {
36471                 ret_ref |= 1;
36472         }
36473         return ret_ref;
36474 }
36475
36476 jboolean  __attribute__((export_name("TS_DirectedChannelTransactionParameters_opt_anchors"))) TS_DirectedChannelTransactionParameters_opt_anchors(uint32_t this_arg) {
36477         LDKDirectedChannelTransactionParameters this_arg_conv;
36478         this_arg_conv.inner = (void*)(this_arg & (~1));
36479         this_arg_conv.is_owned = false;
36480         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36481         jboolean ret_conv = DirectedChannelTransactionParameters_opt_anchors(&this_arg_conv);
36482         return ret_conv;
36483 }
36484
36485 void  __attribute__((export_name("TS_HolderCommitmentTransaction_free"))) TS_HolderCommitmentTransaction_free(uint32_t this_obj) {
36486         LDKHolderCommitmentTransaction this_obj_conv;
36487         this_obj_conv.inner = (void*)(this_obj & (~1));
36488         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36489         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36490         HolderCommitmentTransaction_free(this_obj_conv);
36491 }
36492
36493 int8_tArray  __attribute__((export_name("TS_HolderCommitmentTransaction_get_counterparty_sig"))) TS_HolderCommitmentTransaction_get_counterparty_sig(uint32_t this_ptr) {
36494         LDKHolderCommitmentTransaction this_ptr_conv;
36495         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36496         this_ptr_conv.is_owned = false;
36497         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36498         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
36499         memcpy(ret_arr->elems, HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form, 64);
36500         return ret_arr;
36501 }
36502
36503 void  __attribute__((export_name("TS_HolderCommitmentTransaction_set_counterparty_sig"))) TS_HolderCommitmentTransaction_set_counterparty_sig(uint32_t this_ptr, int8_tArray val) {
36504         LDKHolderCommitmentTransaction this_ptr_conv;
36505         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36506         this_ptr_conv.is_owned = false;
36507         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36508         LDKSignature val_ref;
36509         CHECK(val->arr_len == 64);
36510         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
36511         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
36512 }
36513
36514 ptrArray  __attribute__((export_name("TS_HolderCommitmentTransaction_get_counterparty_htlc_sigs"))) TS_HolderCommitmentTransaction_get_counterparty_htlc_sigs(uint32_t this_ptr) {
36515         LDKHolderCommitmentTransaction this_ptr_conv;
36516         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36517         this_ptr_conv.is_owned = false;
36518         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36519         LDKCVec_SignatureZ ret_var = HolderCommitmentTransaction_get_counterparty_htlc_sigs(&this_ptr_conv);
36520         ptrArray ret_arr = NULL;
36521         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
36522         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 8);
36523         for (size_t m = 0; m < ret_var.datalen; m++) {
36524                 int8_tArray ret_conv_12_arr = init_int8_tArray(64, __LINE__);
36525                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].compact_form, 64);
36526                 ret_arr_ptr[m] = ret_conv_12_arr;
36527         }
36528         
36529         FREE(ret_var.data);
36530         return ret_arr;
36531 }
36532
36533 void  __attribute__((export_name("TS_HolderCommitmentTransaction_set_counterparty_htlc_sigs"))) TS_HolderCommitmentTransaction_set_counterparty_htlc_sigs(uint32_t this_ptr, ptrArray val) {
36534         LDKHolderCommitmentTransaction this_ptr_conv;
36535         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36536         this_ptr_conv.is_owned = false;
36537         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36538         LDKCVec_SignatureZ val_constr;
36539         val_constr.datalen = val->arr_len;
36540         if (val_constr.datalen > 0)
36541                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
36542         else
36543                 val_constr.data = NULL;
36544         int8_tArray* val_vals = (void*) val->elems;
36545         for (size_t m = 0; m < val_constr.datalen; m++) {
36546                 int8_tArray val_conv_12 = val_vals[m];
36547                 LDKSignature val_conv_12_ref;
36548                 CHECK(val_conv_12->arr_len == 64);
36549                 memcpy(val_conv_12_ref.compact_form, val_conv_12->elems, 64); FREE(val_conv_12);
36550                 val_constr.data[m] = val_conv_12_ref;
36551         }
36552         FREE(val);
36553         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
36554 }
36555
36556 static inline uintptr_t HolderCommitmentTransaction_clone_ptr(LDKHolderCommitmentTransaction *NONNULL_PTR arg) {
36557         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(arg);
36558 uint32_t ret_ref = 0;
36559 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36560 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36561 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36562 ret_ref = (uintptr_t)ret_var.inner;
36563 if (ret_var.is_owned) {
36564         ret_ref |= 1;
36565 }
36566         return ret_ref;
36567 }
36568 uint32_t  __attribute__((export_name("TS_HolderCommitmentTransaction_clone_ptr"))) TS_HolderCommitmentTransaction_clone_ptr(uint32_t arg) {
36569         LDKHolderCommitmentTransaction arg_conv;
36570         arg_conv.inner = (void*)(arg & (~1));
36571         arg_conv.is_owned = false;
36572         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36573         uint32_t ret_conv = HolderCommitmentTransaction_clone_ptr(&arg_conv);
36574         return ret_conv;
36575 }
36576
36577 uint32_t  __attribute__((export_name("TS_HolderCommitmentTransaction_clone"))) TS_HolderCommitmentTransaction_clone(uint32_t orig) {
36578         LDKHolderCommitmentTransaction orig_conv;
36579         orig_conv.inner = (void*)(orig & (~1));
36580         orig_conv.is_owned = false;
36581         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36582         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
36583         uint32_t ret_ref = 0;
36584         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36585         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36586         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36587         ret_ref = (uintptr_t)ret_var.inner;
36588         if (ret_var.is_owned) {
36589                 ret_ref |= 1;
36590         }
36591         return ret_ref;
36592 }
36593
36594 int8_tArray  __attribute__((export_name("TS_HolderCommitmentTransaction_write"))) TS_HolderCommitmentTransaction_write(uint32_t obj) {
36595         LDKHolderCommitmentTransaction obj_conv;
36596         obj_conv.inner = (void*)(obj & (~1));
36597         obj_conv.is_owned = false;
36598         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36599         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
36600         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36601         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36602         CVec_u8Z_free(ret_var);
36603         return ret_arr;
36604 }
36605
36606 uint32_t  __attribute__((export_name("TS_HolderCommitmentTransaction_read"))) TS_HolderCommitmentTransaction_read(int8_tArray ser) {
36607         LDKu8slice ser_ref;
36608         ser_ref.datalen = ser->arr_len;
36609         ser_ref.data = ser->elems;
36610         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
36611         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
36612         FREE(ser);
36613         return (uint32_t)ret_conv;
36614 }
36615
36616 uint32_t  __attribute__((export_name("TS_HolderCommitmentTransaction_new"))) TS_HolderCommitmentTransaction_new(uint32_t commitment_tx, int8_tArray counterparty_sig, ptrArray counterparty_htlc_sigs, int8_tArray holder_funding_key, int8_tArray counterparty_funding_key) {
36617         LDKCommitmentTransaction commitment_tx_conv;
36618         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
36619         commitment_tx_conv.is_owned = (commitment_tx & 1) || (commitment_tx == 0);
36620         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
36621         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
36622         LDKSignature counterparty_sig_ref;
36623         CHECK(counterparty_sig->arr_len == 64);
36624         memcpy(counterparty_sig_ref.compact_form, counterparty_sig->elems, 64); FREE(counterparty_sig);
36625         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
36626         counterparty_htlc_sigs_constr.datalen = counterparty_htlc_sigs->arr_len;
36627         if (counterparty_htlc_sigs_constr.datalen > 0)
36628                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
36629         else
36630                 counterparty_htlc_sigs_constr.data = NULL;
36631         int8_tArray* counterparty_htlc_sigs_vals = (void*) counterparty_htlc_sigs->elems;
36632         for (size_t m = 0; m < counterparty_htlc_sigs_constr.datalen; m++) {
36633                 int8_tArray counterparty_htlc_sigs_conv_12 = counterparty_htlc_sigs_vals[m];
36634                 LDKSignature counterparty_htlc_sigs_conv_12_ref;
36635                 CHECK(counterparty_htlc_sigs_conv_12->arr_len == 64);
36636                 memcpy(counterparty_htlc_sigs_conv_12_ref.compact_form, counterparty_htlc_sigs_conv_12->elems, 64); FREE(counterparty_htlc_sigs_conv_12);
36637                 counterparty_htlc_sigs_constr.data[m] = counterparty_htlc_sigs_conv_12_ref;
36638         }
36639         FREE(counterparty_htlc_sigs);
36640         LDKPublicKey holder_funding_key_ref;
36641         CHECK(holder_funding_key->arr_len == 33);
36642         memcpy(holder_funding_key_ref.compressed_form, holder_funding_key->elems, 33); FREE(holder_funding_key);
36643         LDKPublicKey counterparty_funding_key_ref;
36644         CHECK(counterparty_funding_key->arr_len == 33);
36645         memcpy(counterparty_funding_key_ref.compressed_form, counterparty_funding_key->elems, 33); FREE(counterparty_funding_key);
36646         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
36647         uint32_t ret_ref = 0;
36648         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36649         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36650         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36651         ret_ref = (uintptr_t)ret_var.inner;
36652         if (ret_var.is_owned) {
36653                 ret_ref |= 1;
36654         }
36655         return ret_ref;
36656 }
36657
36658 void  __attribute__((export_name("TS_BuiltCommitmentTransaction_free"))) TS_BuiltCommitmentTransaction_free(uint32_t this_obj) {
36659         LDKBuiltCommitmentTransaction this_obj_conv;
36660         this_obj_conv.inner = (void*)(this_obj & (~1));
36661         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36662         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36663         BuiltCommitmentTransaction_free(this_obj_conv);
36664 }
36665
36666 int8_tArray  __attribute__((export_name("TS_BuiltCommitmentTransaction_get_transaction"))) TS_BuiltCommitmentTransaction_get_transaction(uint32_t this_ptr) {
36667         LDKBuiltCommitmentTransaction this_ptr_conv;
36668         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36669         this_ptr_conv.is_owned = false;
36670         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36671         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
36672         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36673         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36674         Transaction_free(ret_var);
36675         return ret_arr;
36676 }
36677
36678 void  __attribute__((export_name("TS_BuiltCommitmentTransaction_set_transaction"))) TS_BuiltCommitmentTransaction_set_transaction(uint32_t this_ptr, int8_tArray val) {
36679         LDKBuiltCommitmentTransaction this_ptr_conv;
36680         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36681         this_ptr_conv.is_owned = false;
36682         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36683         LDKTransaction val_ref;
36684         val_ref.datalen = val->arr_len;
36685         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
36686         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
36687         val_ref.data_is_owned = true;
36688         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
36689 }
36690
36691 int8_tArray  __attribute__((export_name("TS_BuiltCommitmentTransaction_get_txid"))) TS_BuiltCommitmentTransaction_get_txid(uint32_t this_ptr) {
36692         LDKBuiltCommitmentTransaction this_ptr_conv;
36693         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36694         this_ptr_conv.is_owned = false;
36695         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36696         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
36697         memcpy(ret_arr->elems, *BuiltCommitmentTransaction_get_txid(&this_ptr_conv), 32);
36698         return ret_arr;
36699 }
36700
36701 void  __attribute__((export_name("TS_BuiltCommitmentTransaction_set_txid"))) TS_BuiltCommitmentTransaction_set_txid(uint32_t this_ptr, int8_tArray val) {
36702         LDKBuiltCommitmentTransaction this_ptr_conv;
36703         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36704         this_ptr_conv.is_owned = false;
36705         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36706         LDKThirtyTwoBytes val_ref;
36707         CHECK(val->arr_len == 32);
36708         memcpy(val_ref.data, val->elems, 32); FREE(val);
36709         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
36710 }
36711
36712 uint32_t  __attribute__((export_name("TS_BuiltCommitmentTransaction_new"))) TS_BuiltCommitmentTransaction_new(int8_tArray transaction_arg, int8_tArray txid_arg) {
36713         LDKTransaction transaction_arg_ref;
36714         transaction_arg_ref.datalen = transaction_arg->arr_len;
36715         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
36716         memcpy(transaction_arg_ref.data, transaction_arg->elems, transaction_arg_ref.datalen); FREE(transaction_arg);
36717         transaction_arg_ref.data_is_owned = true;
36718         LDKThirtyTwoBytes txid_arg_ref;
36719         CHECK(txid_arg->arr_len == 32);
36720         memcpy(txid_arg_ref.data, txid_arg->elems, 32); FREE(txid_arg);
36721         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
36722         uint32_t ret_ref = 0;
36723         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36724         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36725         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36726         ret_ref = (uintptr_t)ret_var.inner;
36727         if (ret_var.is_owned) {
36728                 ret_ref |= 1;
36729         }
36730         return ret_ref;
36731 }
36732
36733 static inline uintptr_t BuiltCommitmentTransaction_clone_ptr(LDKBuiltCommitmentTransaction *NONNULL_PTR arg) {
36734         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(arg);
36735 uint32_t ret_ref = 0;
36736 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36737 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36738 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36739 ret_ref = (uintptr_t)ret_var.inner;
36740 if (ret_var.is_owned) {
36741         ret_ref |= 1;
36742 }
36743         return ret_ref;
36744 }
36745 uint32_t  __attribute__((export_name("TS_BuiltCommitmentTransaction_clone_ptr"))) TS_BuiltCommitmentTransaction_clone_ptr(uint32_t arg) {
36746         LDKBuiltCommitmentTransaction arg_conv;
36747         arg_conv.inner = (void*)(arg & (~1));
36748         arg_conv.is_owned = false;
36749         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36750         uint32_t ret_conv = BuiltCommitmentTransaction_clone_ptr(&arg_conv);
36751         return ret_conv;
36752 }
36753
36754 uint32_t  __attribute__((export_name("TS_BuiltCommitmentTransaction_clone"))) TS_BuiltCommitmentTransaction_clone(uint32_t orig) {
36755         LDKBuiltCommitmentTransaction orig_conv;
36756         orig_conv.inner = (void*)(orig & (~1));
36757         orig_conv.is_owned = false;
36758         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36759         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
36760         uint32_t ret_ref = 0;
36761         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36762         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36763         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36764         ret_ref = (uintptr_t)ret_var.inner;
36765         if (ret_var.is_owned) {
36766                 ret_ref |= 1;
36767         }
36768         return ret_ref;
36769 }
36770
36771 int8_tArray  __attribute__((export_name("TS_BuiltCommitmentTransaction_write"))) TS_BuiltCommitmentTransaction_write(uint32_t obj) {
36772         LDKBuiltCommitmentTransaction obj_conv;
36773         obj_conv.inner = (void*)(obj & (~1));
36774         obj_conv.is_owned = false;
36775         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36776         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
36777         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36778         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36779         CVec_u8Z_free(ret_var);
36780         return ret_arr;
36781 }
36782
36783 uint32_t  __attribute__((export_name("TS_BuiltCommitmentTransaction_read"))) TS_BuiltCommitmentTransaction_read(int8_tArray ser) {
36784         LDKu8slice ser_ref;
36785         ser_ref.datalen = ser->arr_len;
36786         ser_ref.data = ser->elems;
36787         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
36788         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
36789         FREE(ser);
36790         return (uint32_t)ret_conv;
36791 }
36792
36793 int8_tArray  __attribute__((export_name("TS_BuiltCommitmentTransaction_get_sighash_all"))) TS_BuiltCommitmentTransaction_get_sighash_all(uint32_t this_arg, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) {
36794         LDKBuiltCommitmentTransaction this_arg_conv;
36795         this_arg_conv.inner = (void*)(this_arg & (~1));
36796         this_arg_conv.is_owned = false;
36797         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36798         LDKu8slice funding_redeemscript_ref;
36799         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
36800         funding_redeemscript_ref.data = funding_redeemscript->elems;
36801         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
36802         memcpy(ret_arr->elems, BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data, 32);
36803         FREE(funding_redeemscript);
36804         return ret_arr;
36805 }
36806
36807 int8_tArray  __attribute__((export_name("TS_BuiltCommitmentTransaction_sign"))) TS_BuiltCommitmentTransaction_sign(uint32_t this_arg, int8_tArray funding_key, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) {
36808         LDKBuiltCommitmentTransaction this_arg_conv;
36809         this_arg_conv.inner = (void*)(this_arg & (~1));
36810         this_arg_conv.is_owned = false;
36811         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36812         unsigned char funding_key_arr[32];
36813         CHECK(funding_key->arr_len == 32);
36814         memcpy(funding_key_arr, funding_key->elems, 32); FREE(funding_key);
36815         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
36816         LDKu8slice funding_redeemscript_ref;
36817         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
36818         funding_redeemscript_ref.data = funding_redeemscript->elems;
36819         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
36820         memcpy(ret_arr->elems, BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form, 64);
36821         FREE(funding_redeemscript);
36822         return ret_arr;
36823 }
36824
36825 void  __attribute__((export_name("TS_ClosingTransaction_free"))) TS_ClosingTransaction_free(uint32_t this_obj) {
36826         LDKClosingTransaction this_obj_conv;
36827         this_obj_conv.inner = (void*)(this_obj & (~1));
36828         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36829         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36830         ClosingTransaction_free(this_obj_conv);
36831 }
36832
36833 static inline uintptr_t ClosingTransaction_clone_ptr(LDKClosingTransaction *NONNULL_PTR arg) {
36834         LDKClosingTransaction ret_var = ClosingTransaction_clone(arg);
36835 uint32_t ret_ref = 0;
36836 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36837 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36838 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36839 ret_ref = (uintptr_t)ret_var.inner;
36840 if (ret_var.is_owned) {
36841         ret_ref |= 1;
36842 }
36843         return ret_ref;
36844 }
36845 uint32_t  __attribute__((export_name("TS_ClosingTransaction_clone_ptr"))) TS_ClosingTransaction_clone_ptr(uint32_t arg) {
36846         LDKClosingTransaction arg_conv;
36847         arg_conv.inner = (void*)(arg & (~1));
36848         arg_conv.is_owned = false;
36849         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36850         uint32_t ret_conv = ClosingTransaction_clone_ptr(&arg_conv);
36851         return ret_conv;
36852 }
36853
36854 uint32_t  __attribute__((export_name("TS_ClosingTransaction_clone"))) TS_ClosingTransaction_clone(uint32_t orig) {
36855         LDKClosingTransaction orig_conv;
36856         orig_conv.inner = (void*)(orig & (~1));
36857         orig_conv.is_owned = false;
36858         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36859         LDKClosingTransaction ret_var = ClosingTransaction_clone(&orig_conv);
36860         uint32_t ret_ref = 0;
36861         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36862         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36863         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36864         ret_ref = (uintptr_t)ret_var.inner;
36865         if (ret_var.is_owned) {
36866                 ret_ref |= 1;
36867         }
36868         return ret_ref;
36869 }
36870
36871 int64_t  __attribute__((export_name("TS_ClosingTransaction_hash"))) TS_ClosingTransaction_hash(uint32_t o) {
36872         LDKClosingTransaction o_conv;
36873         o_conv.inner = (void*)(o & (~1));
36874         o_conv.is_owned = false;
36875         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
36876         int64_t ret_conv = ClosingTransaction_hash(&o_conv);
36877         return ret_conv;
36878 }
36879
36880 uint32_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, uint32_t funding_outpoint) {
36881         LDKCVec_u8Z to_holder_script_ref;
36882         to_holder_script_ref.datalen = to_holder_script->arr_len;
36883         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
36884         memcpy(to_holder_script_ref.data, to_holder_script->elems, to_holder_script_ref.datalen); FREE(to_holder_script);
36885         LDKCVec_u8Z to_counterparty_script_ref;
36886         to_counterparty_script_ref.datalen = to_counterparty_script->arr_len;
36887         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
36888         memcpy(to_counterparty_script_ref.data, to_counterparty_script->elems, to_counterparty_script_ref.datalen); FREE(to_counterparty_script);
36889         LDKOutPoint funding_outpoint_conv;
36890         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
36891         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
36892         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
36893         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
36894         LDKClosingTransaction ret_var = ClosingTransaction_new(to_holder_value_sat, to_counterparty_value_sat, to_holder_script_ref, to_counterparty_script_ref, funding_outpoint_conv);
36895         uint32_t ret_ref = 0;
36896         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36897         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36898         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36899         ret_ref = (uintptr_t)ret_var.inner;
36900         if (ret_var.is_owned) {
36901                 ret_ref |= 1;
36902         }
36903         return ret_ref;
36904 }
36905
36906 uint32_t  __attribute__((export_name("TS_ClosingTransaction_trust"))) TS_ClosingTransaction_trust(uint32_t this_arg) {
36907         LDKClosingTransaction this_arg_conv;
36908         this_arg_conv.inner = (void*)(this_arg & (~1));
36909         this_arg_conv.is_owned = false;
36910         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36911         LDKTrustedClosingTransaction ret_var = ClosingTransaction_trust(&this_arg_conv);
36912         uint32_t ret_ref = 0;
36913         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36914         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36915         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36916         ret_ref = (uintptr_t)ret_var.inner;
36917         if (ret_var.is_owned) {
36918                 ret_ref |= 1;
36919         }
36920         return ret_ref;
36921 }
36922
36923 uint32_t  __attribute__((export_name("TS_ClosingTransaction_verify"))) TS_ClosingTransaction_verify(uint32_t this_arg, uint32_t funding_outpoint) {
36924         LDKClosingTransaction this_arg_conv;
36925         this_arg_conv.inner = (void*)(this_arg & (~1));
36926         this_arg_conv.is_owned = false;
36927         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36928         LDKOutPoint funding_outpoint_conv;
36929         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
36930         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
36931         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
36932         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
36933         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
36934         *ret_conv = ClosingTransaction_verify(&this_arg_conv, funding_outpoint_conv);
36935         return (uint32_t)ret_conv;
36936 }
36937
36938 int64_t  __attribute__((export_name("TS_ClosingTransaction_to_holder_value_sat"))) TS_ClosingTransaction_to_holder_value_sat(uint32_t this_arg) {
36939         LDKClosingTransaction this_arg_conv;
36940         this_arg_conv.inner = (void*)(this_arg & (~1));
36941         this_arg_conv.is_owned = false;
36942         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36943         int64_t ret_conv = ClosingTransaction_to_holder_value_sat(&this_arg_conv);
36944         return ret_conv;
36945 }
36946
36947 int64_t  __attribute__((export_name("TS_ClosingTransaction_to_counterparty_value_sat"))) TS_ClosingTransaction_to_counterparty_value_sat(uint32_t this_arg) {
36948         LDKClosingTransaction this_arg_conv;
36949         this_arg_conv.inner = (void*)(this_arg & (~1));
36950         this_arg_conv.is_owned = false;
36951         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36952         int64_t ret_conv = ClosingTransaction_to_counterparty_value_sat(&this_arg_conv);
36953         return ret_conv;
36954 }
36955
36956 int8_tArray  __attribute__((export_name("TS_ClosingTransaction_to_holder_script"))) TS_ClosingTransaction_to_holder_script(uint32_t this_arg) {
36957         LDKClosingTransaction this_arg_conv;
36958         this_arg_conv.inner = (void*)(this_arg & (~1));
36959         this_arg_conv.is_owned = false;
36960         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36961         LDKu8slice ret_var = ClosingTransaction_to_holder_script(&this_arg_conv);
36962         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36963         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36964         return ret_arr;
36965 }
36966
36967 int8_tArray  __attribute__((export_name("TS_ClosingTransaction_to_counterparty_script"))) TS_ClosingTransaction_to_counterparty_script(uint32_t this_arg) {
36968         LDKClosingTransaction this_arg_conv;
36969         this_arg_conv.inner = (void*)(this_arg & (~1));
36970         this_arg_conv.is_owned = false;
36971         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36972         LDKu8slice ret_var = ClosingTransaction_to_counterparty_script(&this_arg_conv);
36973         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36974         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36975         return ret_arr;
36976 }
36977
36978 void  __attribute__((export_name("TS_TrustedClosingTransaction_free"))) TS_TrustedClosingTransaction_free(uint32_t this_obj) {
36979         LDKTrustedClosingTransaction this_obj_conv;
36980         this_obj_conv.inner = (void*)(this_obj & (~1));
36981         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36982         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36983         TrustedClosingTransaction_free(this_obj_conv);
36984 }
36985
36986 int8_tArray  __attribute__((export_name("TS_TrustedClosingTransaction_built_transaction"))) TS_TrustedClosingTransaction_built_transaction(uint32_t this_arg) {
36987         LDKTrustedClosingTransaction this_arg_conv;
36988         this_arg_conv.inner = (void*)(this_arg & (~1));
36989         this_arg_conv.is_owned = false;
36990         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36991         LDKTransaction ret_var = TrustedClosingTransaction_built_transaction(&this_arg_conv);
36992         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36993         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36994         Transaction_free(ret_var);
36995         return ret_arr;
36996 }
36997
36998 int8_tArray  __attribute__((export_name("TS_TrustedClosingTransaction_get_sighash_all"))) TS_TrustedClosingTransaction_get_sighash_all(uint32_t this_arg, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) {
36999         LDKTrustedClosingTransaction this_arg_conv;
37000         this_arg_conv.inner = (void*)(this_arg & (~1));
37001         this_arg_conv.is_owned = false;
37002         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37003         LDKu8slice funding_redeemscript_ref;
37004         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
37005         funding_redeemscript_ref.data = funding_redeemscript->elems;
37006         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
37007         memcpy(ret_arr->elems, TrustedClosingTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data, 32);
37008         FREE(funding_redeemscript);
37009         return ret_arr;
37010 }
37011
37012 int8_tArray  __attribute__((export_name("TS_TrustedClosingTransaction_sign"))) TS_TrustedClosingTransaction_sign(uint32_t this_arg, int8_tArray funding_key, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) {
37013         LDKTrustedClosingTransaction this_arg_conv;
37014         this_arg_conv.inner = (void*)(this_arg & (~1));
37015         this_arg_conv.is_owned = false;
37016         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37017         unsigned char funding_key_arr[32];
37018         CHECK(funding_key->arr_len == 32);
37019         memcpy(funding_key_arr, funding_key->elems, 32); FREE(funding_key);
37020         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
37021         LDKu8slice funding_redeemscript_ref;
37022         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
37023         funding_redeemscript_ref.data = funding_redeemscript->elems;
37024         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
37025         memcpy(ret_arr->elems, TrustedClosingTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form, 64);
37026         FREE(funding_redeemscript);
37027         return ret_arr;
37028 }
37029
37030 void  __attribute__((export_name("TS_CommitmentTransaction_free"))) TS_CommitmentTransaction_free(uint32_t this_obj) {
37031         LDKCommitmentTransaction this_obj_conv;
37032         this_obj_conv.inner = (void*)(this_obj & (~1));
37033         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37034         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37035         CommitmentTransaction_free(this_obj_conv);
37036 }
37037
37038 static inline uintptr_t CommitmentTransaction_clone_ptr(LDKCommitmentTransaction *NONNULL_PTR arg) {
37039         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(arg);
37040 uint32_t ret_ref = 0;
37041 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37042 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37043 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37044 ret_ref = (uintptr_t)ret_var.inner;
37045 if (ret_var.is_owned) {
37046         ret_ref |= 1;
37047 }
37048         return ret_ref;
37049 }
37050 uint32_t  __attribute__((export_name("TS_CommitmentTransaction_clone_ptr"))) TS_CommitmentTransaction_clone_ptr(uint32_t arg) {
37051         LDKCommitmentTransaction arg_conv;
37052         arg_conv.inner = (void*)(arg & (~1));
37053         arg_conv.is_owned = false;
37054         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37055         uint32_t ret_conv = CommitmentTransaction_clone_ptr(&arg_conv);
37056         return ret_conv;
37057 }
37058
37059 uint32_t  __attribute__((export_name("TS_CommitmentTransaction_clone"))) TS_CommitmentTransaction_clone(uint32_t orig) {
37060         LDKCommitmentTransaction orig_conv;
37061         orig_conv.inner = (void*)(orig & (~1));
37062         orig_conv.is_owned = false;
37063         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37064         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
37065         uint32_t ret_ref = 0;
37066         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37067         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37068         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37069         ret_ref = (uintptr_t)ret_var.inner;
37070         if (ret_var.is_owned) {
37071                 ret_ref |= 1;
37072         }
37073         return ret_ref;
37074 }
37075
37076 int8_tArray  __attribute__((export_name("TS_CommitmentTransaction_write"))) TS_CommitmentTransaction_write(uint32_t obj) {
37077         LDKCommitmentTransaction obj_conv;
37078         obj_conv.inner = (void*)(obj & (~1));
37079         obj_conv.is_owned = false;
37080         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37081         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
37082         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
37083         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
37084         CVec_u8Z_free(ret_var);
37085         return ret_arr;
37086 }
37087
37088 uint32_t  __attribute__((export_name("TS_CommitmentTransaction_read"))) TS_CommitmentTransaction_read(int8_tArray ser) {
37089         LDKu8slice ser_ref;
37090         ser_ref.datalen = ser->arr_len;
37091         ser_ref.data = ser->elems;
37092         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
37093         *ret_conv = CommitmentTransaction_read(ser_ref);
37094         FREE(ser);
37095         return (uint32_t)ret_conv;
37096 }
37097
37098 int64_t  __attribute__((export_name("TS_CommitmentTransaction_commitment_number"))) TS_CommitmentTransaction_commitment_number(uint32_t this_arg) {
37099         LDKCommitmentTransaction this_arg_conv;
37100         this_arg_conv.inner = (void*)(this_arg & (~1));
37101         this_arg_conv.is_owned = false;
37102         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37103         int64_t ret_conv = CommitmentTransaction_commitment_number(&this_arg_conv);
37104         return ret_conv;
37105 }
37106
37107 int64_t  __attribute__((export_name("TS_CommitmentTransaction_to_broadcaster_value_sat"))) TS_CommitmentTransaction_to_broadcaster_value_sat(uint32_t this_arg) {
37108         LDKCommitmentTransaction this_arg_conv;
37109         this_arg_conv.inner = (void*)(this_arg & (~1));
37110         this_arg_conv.is_owned = false;
37111         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37112         int64_t ret_conv = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
37113         return ret_conv;
37114 }
37115
37116 int64_t  __attribute__((export_name("TS_CommitmentTransaction_to_countersignatory_value_sat"))) TS_CommitmentTransaction_to_countersignatory_value_sat(uint32_t this_arg) {
37117         LDKCommitmentTransaction this_arg_conv;
37118         this_arg_conv.inner = (void*)(this_arg & (~1));
37119         this_arg_conv.is_owned = false;
37120         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37121         int64_t ret_conv = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
37122         return ret_conv;
37123 }
37124
37125 int32_t  __attribute__((export_name("TS_CommitmentTransaction_feerate_per_kw"))) TS_CommitmentTransaction_feerate_per_kw(uint32_t this_arg) {
37126         LDKCommitmentTransaction this_arg_conv;
37127         this_arg_conv.inner = (void*)(this_arg & (~1));
37128         this_arg_conv.is_owned = false;
37129         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37130         int32_t ret_conv = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
37131         return ret_conv;
37132 }
37133
37134 uint32_t  __attribute__((export_name("TS_CommitmentTransaction_trust"))) TS_CommitmentTransaction_trust(uint32_t this_arg) {
37135         LDKCommitmentTransaction this_arg_conv;
37136         this_arg_conv.inner = (void*)(this_arg & (~1));
37137         this_arg_conv.is_owned = false;
37138         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37139         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
37140         uint32_t ret_ref = 0;
37141         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37142         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37143         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37144         ret_ref = (uintptr_t)ret_var.inner;
37145         if (ret_var.is_owned) {
37146                 ret_ref |= 1;
37147         }
37148         return ret_ref;
37149 }
37150
37151 uint32_t  __attribute__((export_name("TS_CommitmentTransaction_verify"))) TS_CommitmentTransaction_verify(uint32_t this_arg, uint32_t channel_parameters, uint32_t broadcaster_keys, uint32_t countersignatory_keys) {
37152         LDKCommitmentTransaction this_arg_conv;
37153         this_arg_conv.inner = (void*)(this_arg & (~1));
37154         this_arg_conv.is_owned = false;
37155         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37156         LDKDirectedChannelTransactionParameters channel_parameters_conv;
37157         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
37158         channel_parameters_conv.is_owned = false;
37159         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
37160         LDKChannelPublicKeys broadcaster_keys_conv;
37161         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
37162         broadcaster_keys_conv.is_owned = false;
37163         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
37164         LDKChannelPublicKeys countersignatory_keys_conv;
37165         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
37166         countersignatory_keys_conv.is_owned = false;
37167         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
37168         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
37169         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
37170         return (uint32_t)ret_conv;
37171 }
37172
37173 void  __attribute__((export_name("TS_TrustedCommitmentTransaction_free"))) TS_TrustedCommitmentTransaction_free(uint32_t this_obj) {
37174         LDKTrustedCommitmentTransaction this_obj_conv;
37175         this_obj_conv.inner = (void*)(this_obj & (~1));
37176         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37177         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37178         TrustedCommitmentTransaction_free(this_obj_conv);
37179 }
37180
37181 int8_tArray  __attribute__((export_name("TS_TrustedCommitmentTransaction_txid"))) TS_TrustedCommitmentTransaction_txid(uint32_t this_arg) {
37182         LDKTrustedCommitmentTransaction this_arg_conv;
37183         this_arg_conv.inner = (void*)(this_arg & (~1));
37184         this_arg_conv.is_owned = false;
37185         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37186         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
37187         memcpy(ret_arr->elems, TrustedCommitmentTransaction_txid(&this_arg_conv).data, 32);
37188         return ret_arr;
37189 }
37190
37191 uint32_t  __attribute__((export_name("TS_TrustedCommitmentTransaction_built_transaction"))) TS_TrustedCommitmentTransaction_built_transaction(uint32_t this_arg) {
37192         LDKTrustedCommitmentTransaction this_arg_conv;
37193         this_arg_conv.inner = (void*)(this_arg & (~1));
37194         this_arg_conv.is_owned = false;
37195         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37196         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
37197         uint32_t ret_ref = 0;
37198         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37199         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37200         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37201         ret_ref = (uintptr_t)ret_var.inner;
37202         if (ret_var.is_owned) {
37203                 ret_ref |= 1;
37204         }
37205         return ret_ref;
37206 }
37207
37208 uint32_t  __attribute__((export_name("TS_TrustedCommitmentTransaction_keys"))) TS_TrustedCommitmentTransaction_keys(uint32_t this_arg) {
37209         LDKTrustedCommitmentTransaction this_arg_conv;
37210         this_arg_conv.inner = (void*)(this_arg & (~1));
37211         this_arg_conv.is_owned = false;
37212         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37213         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
37214         uint32_t ret_ref = 0;
37215         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37216         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37217         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37218         ret_ref = (uintptr_t)ret_var.inner;
37219         if (ret_var.is_owned) {
37220                 ret_ref |= 1;
37221         }
37222         return ret_ref;
37223 }
37224
37225 jboolean  __attribute__((export_name("TS_TrustedCommitmentTransaction_opt_anchors"))) TS_TrustedCommitmentTransaction_opt_anchors(uint32_t this_arg) {
37226         LDKTrustedCommitmentTransaction this_arg_conv;
37227         this_arg_conv.inner = (void*)(this_arg & (~1));
37228         this_arg_conv.is_owned = false;
37229         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37230         jboolean ret_conv = TrustedCommitmentTransaction_opt_anchors(&this_arg_conv);
37231         return ret_conv;
37232 }
37233
37234 uint32_t  __attribute__((export_name("TS_TrustedCommitmentTransaction_get_htlc_sigs"))) TS_TrustedCommitmentTransaction_get_htlc_sigs(uint32_t this_arg, int8_tArray htlc_base_key, uint32_t channel_parameters) {
37235         LDKTrustedCommitmentTransaction this_arg_conv;
37236         this_arg_conv.inner = (void*)(this_arg & (~1));
37237         this_arg_conv.is_owned = false;
37238         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37239         unsigned char htlc_base_key_arr[32];
37240         CHECK(htlc_base_key->arr_len == 32);
37241         memcpy(htlc_base_key_arr, htlc_base_key->elems, 32); FREE(htlc_base_key);
37242         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
37243         LDKDirectedChannelTransactionParameters channel_parameters_conv;
37244         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
37245         channel_parameters_conv.is_owned = false;
37246         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
37247         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
37248         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
37249         return (uint32_t)ret_conv;
37250 }
37251
37252 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) {
37253         LDKPublicKey broadcaster_payment_basepoint_ref;
37254         CHECK(broadcaster_payment_basepoint->arr_len == 33);
37255         memcpy(broadcaster_payment_basepoint_ref.compressed_form, broadcaster_payment_basepoint->elems, 33); FREE(broadcaster_payment_basepoint);
37256         LDKPublicKey countersignatory_payment_basepoint_ref;
37257         CHECK(countersignatory_payment_basepoint->arr_len == 33);
37258         memcpy(countersignatory_payment_basepoint_ref.compressed_form, countersignatory_payment_basepoint->elems, 33); FREE(countersignatory_payment_basepoint);
37259         int64_t ret_conv = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
37260         return ret_conv;
37261 }
37262
37263 jboolean  __attribute__((export_name("TS_InitFeatures_eq"))) TS_InitFeatures_eq(uint32_t a, uint32_t b) {
37264         LDKInitFeatures a_conv;
37265         a_conv.inner = (void*)(a & (~1));
37266         a_conv.is_owned = false;
37267         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37268         LDKInitFeatures b_conv;
37269         b_conv.inner = (void*)(b & (~1));
37270         b_conv.is_owned = false;
37271         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37272         jboolean ret_conv = InitFeatures_eq(&a_conv, &b_conv);
37273         return ret_conv;
37274 }
37275
37276 jboolean  __attribute__((export_name("TS_NodeFeatures_eq"))) TS_NodeFeatures_eq(uint32_t a, uint32_t b) {
37277         LDKNodeFeatures a_conv;
37278         a_conv.inner = (void*)(a & (~1));
37279         a_conv.is_owned = false;
37280         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37281         LDKNodeFeatures b_conv;
37282         b_conv.inner = (void*)(b & (~1));
37283         b_conv.is_owned = false;
37284         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37285         jboolean ret_conv = NodeFeatures_eq(&a_conv, &b_conv);
37286         return ret_conv;
37287 }
37288
37289 jboolean  __attribute__((export_name("TS_ChannelFeatures_eq"))) TS_ChannelFeatures_eq(uint32_t a, uint32_t b) {
37290         LDKChannelFeatures a_conv;
37291         a_conv.inner = (void*)(a & (~1));
37292         a_conv.is_owned = false;
37293         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37294         LDKChannelFeatures b_conv;
37295         b_conv.inner = (void*)(b & (~1));
37296         b_conv.is_owned = false;
37297         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37298         jboolean ret_conv = ChannelFeatures_eq(&a_conv, &b_conv);
37299         return ret_conv;
37300 }
37301
37302 jboolean  __attribute__((export_name("TS_InvoiceFeatures_eq"))) TS_InvoiceFeatures_eq(uint32_t a, uint32_t b) {
37303         LDKInvoiceFeatures a_conv;
37304         a_conv.inner = (void*)(a & (~1));
37305         a_conv.is_owned = false;
37306         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37307         LDKInvoiceFeatures b_conv;
37308         b_conv.inner = (void*)(b & (~1));
37309         b_conv.is_owned = false;
37310         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37311         jboolean ret_conv = InvoiceFeatures_eq(&a_conv, &b_conv);
37312         return ret_conv;
37313 }
37314
37315 jboolean  __attribute__((export_name("TS_ChannelTypeFeatures_eq"))) TS_ChannelTypeFeatures_eq(uint32_t a, uint32_t b) {
37316         LDKChannelTypeFeatures a_conv;
37317         a_conv.inner = (void*)(a & (~1));
37318         a_conv.is_owned = false;
37319         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37320         LDKChannelTypeFeatures b_conv;
37321         b_conv.inner = (void*)(b & (~1));
37322         b_conv.is_owned = false;
37323         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37324         jboolean ret_conv = ChannelTypeFeatures_eq(&a_conv, &b_conv);
37325         return ret_conv;
37326 }
37327
37328 static inline uintptr_t InitFeatures_clone_ptr(LDKInitFeatures *NONNULL_PTR arg) {
37329         LDKInitFeatures ret_var = InitFeatures_clone(arg);
37330 uint32_t ret_ref = 0;
37331 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37332 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37333 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37334 ret_ref = (uintptr_t)ret_var.inner;
37335 if (ret_var.is_owned) {
37336         ret_ref |= 1;
37337 }
37338         return ret_ref;
37339 }
37340 uint32_t  __attribute__((export_name("TS_InitFeatures_clone_ptr"))) TS_InitFeatures_clone_ptr(uint32_t arg) {
37341         LDKInitFeatures arg_conv;
37342         arg_conv.inner = (void*)(arg & (~1));
37343         arg_conv.is_owned = false;
37344         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37345         uint32_t ret_conv = InitFeatures_clone_ptr(&arg_conv);
37346         return ret_conv;
37347 }
37348
37349 uint32_t  __attribute__((export_name("TS_InitFeatures_clone"))) TS_InitFeatures_clone(uint32_t orig) {
37350         LDKInitFeatures orig_conv;
37351         orig_conv.inner = (void*)(orig & (~1));
37352         orig_conv.is_owned = false;
37353         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37354         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
37355         uint32_t ret_ref = 0;
37356         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37357         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37358         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37359         ret_ref = (uintptr_t)ret_var.inner;
37360         if (ret_var.is_owned) {
37361                 ret_ref |= 1;
37362         }
37363         return ret_ref;
37364 }
37365
37366 static inline uintptr_t NodeFeatures_clone_ptr(LDKNodeFeatures *NONNULL_PTR arg) {
37367         LDKNodeFeatures ret_var = NodeFeatures_clone(arg);
37368 uint32_t ret_ref = 0;
37369 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37370 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37371 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37372 ret_ref = (uintptr_t)ret_var.inner;
37373 if (ret_var.is_owned) {
37374         ret_ref |= 1;
37375 }
37376         return ret_ref;
37377 }
37378 uint32_t  __attribute__((export_name("TS_NodeFeatures_clone_ptr"))) TS_NodeFeatures_clone_ptr(uint32_t arg) {
37379         LDKNodeFeatures arg_conv;
37380         arg_conv.inner = (void*)(arg & (~1));
37381         arg_conv.is_owned = false;
37382         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37383         uint32_t ret_conv = NodeFeatures_clone_ptr(&arg_conv);
37384         return ret_conv;
37385 }
37386
37387 uint32_t  __attribute__((export_name("TS_NodeFeatures_clone"))) TS_NodeFeatures_clone(uint32_t orig) {
37388         LDKNodeFeatures orig_conv;
37389         orig_conv.inner = (void*)(orig & (~1));
37390         orig_conv.is_owned = false;
37391         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37392         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
37393         uint32_t ret_ref = 0;
37394         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37395         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37396         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37397         ret_ref = (uintptr_t)ret_var.inner;
37398         if (ret_var.is_owned) {
37399                 ret_ref |= 1;
37400         }
37401         return ret_ref;
37402 }
37403
37404 static inline uintptr_t ChannelFeatures_clone_ptr(LDKChannelFeatures *NONNULL_PTR arg) {
37405         LDKChannelFeatures ret_var = ChannelFeatures_clone(arg);
37406 uint32_t ret_ref = 0;
37407 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37408 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37409 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37410 ret_ref = (uintptr_t)ret_var.inner;
37411 if (ret_var.is_owned) {
37412         ret_ref |= 1;
37413 }
37414         return ret_ref;
37415 }
37416 uint32_t  __attribute__((export_name("TS_ChannelFeatures_clone_ptr"))) TS_ChannelFeatures_clone_ptr(uint32_t arg) {
37417         LDKChannelFeatures arg_conv;
37418         arg_conv.inner = (void*)(arg & (~1));
37419         arg_conv.is_owned = false;
37420         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37421         uint32_t ret_conv = ChannelFeatures_clone_ptr(&arg_conv);
37422         return ret_conv;
37423 }
37424
37425 uint32_t  __attribute__((export_name("TS_ChannelFeatures_clone"))) TS_ChannelFeatures_clone(uint32_t orig) {
37426         LDKChannelFeatures orig_conv;
37427         orig_conv.inner = (void*)(orig & (~1));
37428         orig_conv.is_owned = false;
37429         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37430         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
37431         uint32_t ret_ref = 0;
37432         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37433         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37434         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37435         ret_ref = (uintptr_t)ret_var.inner;
37436         if (ret_var.is_owned) {
37437                 ret_ref |= 1;
37438         }
37439         return ret_ref;
37440 }
37441
37442 static inline uintptr_t InvoiceFeatures_clone_ptr(LDKInvoiceFeatures *NONNULL_PTR arg) {
37443         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(arg);
37444 uint32_t ret_ref = 0;
37445 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37446 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37447 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37448 ret_ref = (uintptr_t)ret_var.inner;
37449 if (ret_var.is_owned) {
37450         ret_ref |= 1;
37451 }
37452         return ret_ref;
37453 }
37454 uint32_t  __attribute__((export_name("TS_InvoiceFeatures_clone_ptr"))) TS_InvoiceFeatures_clone_ptr(uint32_t arg) {
37455         LDKInvoiceFeatures arg_conv;
37456         arg_conv.inner = (void*)(arg & (~1));
37457         arg_conv.is_owned = false;
37458         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37459         uint32_t ret_conv = InvoiceFeatures_clone_ptr(&arg_conv);
37460         return ret_conv;
37461 }
37462
37463 uint32_t  __attribute__((export_name("TS_InvoiceFeatures_clone"))) TS_InvoiceFeatures_clone(uint32_t orig) {
37464         LDKInvoiceFeatures orig_conv;
37465         orig_conv.inner = (void*)(orig & (~1));
37466         orig_conv.is_owned = false;
37467         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37468         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
37469         uint32_t ret_ref = 0;
37470         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37471         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37472         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37473         ret_ref = (uintptr_t)ret_var.inner;
37474         if (ret_var.is_owned) {
37475                 ret_ref |= 1;
37476         }
37477         return ret_ref;
37478 }
37479
37480 static inline uintptr_t ChannelTypeFeatures_clone_ptr(LDKChannelTypeFeatures *NONNULL_PTR arg) {
37481         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(arg);
37482 uint32_t ret_ref = 0;
37483 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37484 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37485 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37486 ret_ref = (uintptr_t)ret_var.inner;
37487 if (ret_var.is_owned) {
37488         ret_ref |= 1;
37489 }
37490         return ret_ref;
37491 }
37492 uint32_t  __attribute__((export_name("TS_ChannelTypeFeatures_clone_ptr"))) TS_ChannelTypeFeatures_clone_ptr(uint32_t arg) {
37493         LDKChannelTypeFeatures arg_conv;
37494         arg_conv.inner = (void*)(arg & (~1));
37495         arg_conv.is_owned = false;
37496         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37497         uint32_t ret_conv = ChannelTypeFeatures_clone_ptr(&arg_conv);
37498         return ret_conv;
37499 }
37500
37501 uint32_t  __attribute__((export_name("TS_ChannelTypeFeatures_clone"))) TS_ChannelTypeFeatures_clone(uint32_t orig) {
37502         LDKChannelTypeFeatures orig_conv;
37503         orig_conv.inner = (void*)(orig & (~1));
37504         orig_conv.is_owned = false;
37505         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37506         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(&orig_conv);
37507         uint32_t ret_ref = 0;
37508         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37509         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37510         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37511         ret_ref = (uintptr_t)ret_var.inner;
37512         if (ret_var.is_owned) {
37513                 ret_ref |= 1;
37514         }
37515         return ret_ref;
37516 }
37517
37518 void  __attribute__((export_name("TS_InitFeatures_free"))) TS_InitFeatures_free(uint32_t this_obj) {
37519         LDKInitFeatures this_obj_conv;
37520         this_obj_conv.inner = (void*)(this_obj & (~1));
37521         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37522         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37523         InitFeatures_free(this_obj_conv);
37524 }
37525
37526 void  __attribute__((export_name("TS_NodeFeatures_free"))) TS_NodeFeatures_free(uint32_t this_obj) {
37527         LDKNodeFeatures this_obj_conv;
37528         this_obj_conv.inner = (void*)(this_obj & (~1));
37529         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37530         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37531         NodeFeatures_free(this_obj_conv);
37532 }
37533
37534 void  __attribute__((export_name("TS_ChannelFeatures_free"))) TS_ChannelFeatures_free(uint32_t this_obj) {
37535         LDKChannelFeatures this_obj_conv;
37536         this_obj_conv.inner = (void*)(this_obj & (~1));
37537         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37538         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37539         ChannelFeatures_free(this_obj_conv);
37540 }
37541
37542 void  __attribute__((export_name("TS_InvoiceFeatures_free"))) TS_InvoiceFeatures_free(uint32_t this_obj) {
37543         LDKInvoiceFeatures this_obj_conv;
37544         this_obj_conv.inner = (void*)(this_obj & (~1));
37545         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37546         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37547         InvoiceFeatures_free(this_obj_conv);
37548 }
37549
37550 void  __attribute__((export_name("TS_ChannelTypeFeatures_free"))) TS_ChannelTypeFeatures_free(uint32_t this_obj) {
37551         LDKChannelTypeFeatures this_obj_conv;
37552         this_obj_conv.inner = (void*)(this_obj & (~1));
37553         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37554         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37555         ChannelTypeFeatures_free(this_obj_conv);
37556 }
37557
37558 uint32_t  __attribute__((export_name("TS_InitFeatures_empty"))) TS_InitFeatures_empty() {
37559         LDKInitFeatures ret_var = InitFeatures_empty();
37560         uint32_t ret_ref = 0;
37561         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37562         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37563         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37564         ret_ref = (uintptr_t)ret_var.inner;
37565         if (ret_var.is_owned) {
37566                 ret_ref |= 1;
37567         }
37568         return ret_ref;
37569 }
37570
37571 uint32_t  __attribute__((export_name("TS_InitFeatures_known"))) TS_InitFeatures_known() {
37572         LDKInitFeatures ret_var = InitFeatures_known();
37573         uint32_t ret_ref = 0;
37574         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37575         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37576         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37577         ret_ref = (uintptr_t)ret_var.inner;
37578         if (ret_var.is_owned) {
37579                 ret_ref |= 1;
37580         }
37581         return ret_ref;
37582 }
37583
37584 jboolean  __attribute__((export_name("TS_InitFeatures_requires_unknown_bits"))) TS_InitFeatures_requires_unknown_bits(uint32_t this_arg) {
37585         LDKInitFeatures this_arg_conv;
37586         this_arg_conv.inner = (void*)(this_arg & (~1));
37587         this_arg_conv.is_owned = false;
37588         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37589         jboolean ret_conv = InitFeatures_requires_unknown_bits(&this_arg_conv);
37590         return ret_conv;
37591 }
37592
37593 uint32_t  __attribute__((export_name("TS_NodeFeatures_empty"))) TS_NodeFeatures_empty() {
37594         LDKNodeFeatures ret_var = NodeFeatures_empty();
37595         uint32_t ret_ref = 0;
37596         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37597         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37598         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37599         ret_ref = (uintptr_t)ret_var.inner;
37600         if (ret_var.is_owned) {
37601                 ret_ref |= 1;
37602         }
37603         return ret_ref;
37604 }
37605
37606 uint32_t  __attribute__((export_name("TS_NodeFeatures_known"))) TS_NodeFeatures_known() {
37607         LDKNodeFeatures ret_var = NodeFeatures_known();
37608         uint32_t ret_ref = 0;
37609         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37610         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37611         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37612         ret_ref = (uintptr_t)ret_var.inner;
37613         if (ret_var.is_owned) {
37614                 ret_ref |= 1;
37615         }
37616         return ret_ref;
37617 }
37618
37619 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_unknown_bits"))) TS_NodeFeatures_requires_unknown_bits(uint32_t this_arg) {
37620         LDKNodeFeatures this_arg_conv;
37621         this_arg_conv.inner = (void*)(this_arg & (~1));
37622         this_arg_conv.is_owned = false;
37623         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37624         jboolean ret_conv = NodeFeatures_requires_unknown_bits(&this_arg_conv);
37625         return ret_conv;
37626 }
37627
37628 uint32_t  __attribute__((export_name("TS_ChannelFeatures_empty"))) TS_ChannelFeatures_empty() {
37629         LDKChannelFeatures ret_var = ChannelFeatures_empty();
37630         uint32_t ret_ref = 0;
37631         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37632         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37633         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37634         ret_ref = (uintptr_t)ret_var.inner;
37635         if (ret_var.is_owned) {
37636                 ret_ref |= 1;
37637         }
37638         return ret_ref;
37639 }
37640
37641 uint32_t  __attribute__((export_name("TS_ChannelFeatures_known"))) TS_ChannelFeatures_known() {
37642         LDKChannelFeatures ret_var = ChannelFeatures_known();
37643         uint32_t ret_ref = 0;
37644         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37645         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37646         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37647         ret_ref = (uintptr_t)ret_var.inner;
37648         if (ret_var.is_owned) {
37649                 ret_ref |= 1;
37650         }
37651         return ret_ref;
37652 }
37653
37654 jboolean  __attribute__((export_name("TS_ChannelFeatures_requires_unknown_bits"))) TS_ChannelFeatures_requires_unknown_bits(uint32_t this_arg) {
37655         LDKChannelFeatures this_arg_conv;
37656         this_arg_conv.inner = (void*)(this_arg & (~1));
37657         this_arg_conv.is_owned = false;
37658         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37659         jboolean ret_conv = ChannelFeatures_requires_unknown_bits(&this_arg_conv);
37660         return ret_conv;
37661 }
37662
37663 uint32_t  __attribute__((export_name("TS_InvoiceFeatures_empty"))) TS_InvoiceFeatures_empty() {
37664         LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
37665         uint32_t ret_ref = 0;
37666         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37667         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37668         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37669         ret_ref = (uintptr_t)ret_var.inner;
37670         if (ret_var.is_owned) {
37671                 ret_ref |= 1;
37672         }
37673         return ret_ref;
37674 }
37675
37676 uint32_t  __attribute__((export_name("TS_InvoiceFeatures_known"))) TS_InvoiceFeatures_known() {
37677         LDKInvoiceFeatures ret_var = InvoiceFeatures_known();
37678         uint32_t ret_ref = 0;
37679         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37680         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37681         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37682         ret_ref = (uintptr_t)ret_var.inner;
37683         if (ret_var.is_owned) {
37684                 ret_ref |= 1;
37685         }
37686         return ret_ref;
37687 }
37688
37689 jboolean  __attribute__((export_name("TS_InvoiceFeatures_requires_unknown_bits"))) TS_InvoiceFeatures_requires_unknown_bits(uint32_t this_arg) {
37690         LDKInvoiceFeatures this_arg_conv;
37691         this_arg_conv.inner = (void*)(this_arg & (~1));
37692         this_arg_conv.is_owned = false;
37693         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37694         jboolean ret_conv = InvoiceFeatures_requires_unknown_bits(&this_arg_conv);
37695         return ret_conv;
37696 }
37697
37698 uint32_t  __attribute__((export_name("TS_ChannelTypeFeatures_empty"))) TS_ChannelTypeFeatures_empty() {
37699         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_empty();
37700         uint32_t ret_ref = 0;
37701         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37702         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37703         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37704         ret_ref = (uintptr_t)ret_var.inner;
37705         if (ret_var.is_owned) {
37706                 ret_ref |= 1;
37707         }
37708         return ret_ref;
37709 }
37710
37711 uint32_t  __attribute__((export_name("TS_ChannelTypeFeatures_known"))) TS_ChannelTypeFeatures_known() {
37712         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_known();
37713         uint32_t ret_ref = 0;
37714         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37715         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37716         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37717         ret_ref = (uintptr_t)ret_var.inner;
37718         if (ret_var.is_owned) {
37719                 ret_ref |= 1;
37720         }
37721         return ret_ref;
37722 }
37723
37724 jboolean  __attribute__((export_name("TS_ChannelTypeFeatures_requires_unknown_bits"))) TS_ChannelTypeFeatures_requires_unknown_bits(uint32_t this_arg) {
37725         LDKChannelTypeFeatures this_arg_conv;
37726         this_arg_conv.inner = (void*)(this_arg & (~1));
37727         this_arg_conv.is_owned = false;
37728         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37729         jboolean ret_conv = ChannelTypeFeatures_requires_unknown_bits(&this_arg_conv);
37730         return ret_conv;
37731 }
37732
37733 int8_tArray  __attribute__((export_name("TS_InitFeatures_write"))) TS_InitFeatures_write(uint32_t obj) {
37734         LDKInitFeatures obj_conv;
37735         obj_conv.inner = (void*)(obj & (~1));
37736         obj_conv.is_owned = false;
37737         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37738         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
37739         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
37740         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
37741         CVec_u8Z_free(ret_var);
37742         return ret_arr;
37743 }
37744
37745 uint32_t  __attribute__((export_name("TS_InitFeatures_read"))) TS_InitFeatures_read(int8_tArray ser) {
37746         LDKu8slice ser_ref;
37747         ser_ref.datalen = ser->arr_len;
37748         ser_ref.data = ser->elems;
37749         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
37750         *ret_conv = InitFeatures_read(ser_ref);
37751         FREE(ser);
37752         return (uint32_t)ret_conv;
37753 }
37754
37755 int8_tArray  __attribute__((export_name("TS_ChannelFeatures_write"))) TS_ChannelFeatures_write(uint32_t obj) {
37756         LDKChannelFeatures obj_conv;
37757         obj_conv.inner = (void*)(obj & (~1));
37758         obj_conv.is_owned = false;
37759         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37760         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
37761         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
37762         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
37763         CVec_u8Z_free(ret_var);
37764         return ret_arr;
37765 }
37766
37767 uint32_t  __attribute__((export_name("TS_ChannelFeatures_read"))) TS_ChannelFeatures_read(int8_tArray ser) {
37768         LDKu8slice ser_ref;
37769         ser_ref.datalen = ser->arr_len;
37770         ser_ref.data = ser->elems;
37771         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
37772         *ret_conv = ChannelFeatures_read(ser_ref);
37773         FREE(ser);
37774         return (uint32_t)ret_conv;
37775 }
37776
37777 int8_tArray  __attribute__((export_name("TS_NodeFeatures_write"))) TS_NodeFeatures_write(uint32_t obj) {
37778         LDKNodeFeatures obj_conv;
37779         obj_conv.inner = (void*)(obj & (~1));
37780         obj_conv.is_owned = false;
37781         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37782         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
37783         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
37784         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
37785         CVec_u8Z_free(ret_var);
37786         return ret_arr;
37787 }
37788
37789 uint32_t  __attribute__((export_name("TS_NodeFeatures_read"))) TS_NodeFeatures_read(int8_tArray ser) {
37790         LDKu8slice ser_ref;
37791         ser_ref.datalen = ser->arr_len;
37792         ser_ref.data = ser->elems;
37793         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
37794         *ret_conv = NodeFeatures_read(ser_ref);
37795         FREE(ser);
37796         return (uint32_t)ret_conv;
37797 }
37798
37799 int8_tArray  __attribute__((export_name("TS_InvoiceFeatures_write"))) TS_InvoiceFeatures_write(uint32_t obj) {
37800         LDKInvoiceFeatures obj_conv;
37801         obj_conv.inner = (void*)(obj & (~1));
37802         obj_conv.is_owned = false;
37803         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37804         LDKCVec_u8Z ret_var = InvoiceFeatures_write(&obj_conv);
37805         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
37806         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
37807         CVec_u8Z_free(ret_var);
37808         return ret_arr;
37809 }
37810
37811 uint32_t  __attribute__((export_name("TS_InvoiceFeatures_read"))) TS_InvoiceFeatures_read(int8_tArray ser) {
37812         LDKu8slice ser_ref;
37813         ser_ref.datalen = ser->arr_len;
37814         ser_ref.data = ser->elems;
37815         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
37816         *ret_conv = InvoiceFeatures_read(ser_ref);
37817         FREE(ser);
37818         return (uint32_t)ret_conv;
37819 }
37820
37821 int8_tArray  __attribute__((export_name("TS_ChannelTypeFeatures_write"))) TS_ChannelTypeFeatures_write(uint32_t obj) {
37822         LDKChannelTypeFeatures obj_conv;
37823         obj_conv.inner = (void*)(obj & (~1));
37824         obj_conv.is_owned = false;
37825         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37826         LDKCVec_u8Z ret_var = ChannelTypeFeatures_write(&obj_conv);
37827         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
37828         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
37829         CVec_u8Z_free(ret_var);
37830         return ret_arr;
37831 }
37832
37833 uint32_t  __attribute__((export_name("TS_ChannelTypeFeatures_read"))) TS_ChannelTypeFeatures_read(int8_tArray ser) {
37834         LDKu8slice ser_ref;
37835         ser_ref.datalen = ser->arr_len;
37836         ser_ref.data = ser->elems;
37837         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
37838         *ret_conv = ChannelTypeFeatures_read(ser_ref);
37839         FREE(ser);
37840         return (uint32_t)ret_conv;
37841 }
37842
37843 void  __attribute__((export_name("TS_InitFeatures_set_data_loss_protect_optional"))) TS_InitFeatures_set_data_loss_protect_optional(uint32_t this_arg) {
37844         LDKInitFeatures this_arg_conv;
37845         this_arg_conv.inner = (void*)(this_arg & (~1));
37846         this_arg_conv.is_owned = false;
37847         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37848         InitFeatures_set_data_loss_protect_optional(&this_arg_conv);
37849 }
37850
37851 void  __attribute__((export_name("TS_InitFeatures_set_data_loss_protect_required"))) TS_InitFeatures_set_data_loss_protect_required(uint32_t this_arg) {
37852         LDKInitFeatures this_arg_conv;
37853         this_arg_conv.inner = (void*)(this_arg & (~1));
37854         this_arg_conv.is_owned = false;
37855         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37856         InitFeatures_set_data_loss_protect_required(&this_arg_conv);
37857 }
37858
37859 jboolean  __attribute__((export_name("TS_InitFeatures_supports_data_loss_protect"))) TS_InitFeatures_supports_data_loss_protect(uint32_t this_arg) {
37860         LDKInitFeatures this_arg_conv;
37861         this_arg_conv.inner = (void*)(this_arg & (~1));
37862         this_arg_conv.is_owned = false;
37863         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37864         jboolean ret_conv = InitFeatures_supports_data_loss_protect(&this_arg_conv);
37865         return ret_conv;
37866 }
37867
37868 void  __attribute__((export_name("TS_NodeFeatures_set_data_loss_protect_optional"))) TS_NodeFeatures_set_data_loss_protect_optional(uint32_t this_arg) {
37869         LDKNodeFeatures this_arg_conv;
37870         this_arg_conv.inner = (void*)(this_arg & (~1));
37871         this_arg_conv.is_owned = false;
37872         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37873         NodeFeatures_set_data_loss_protect_optional(&this_arg_conv);
37874 }
37875
37876 void  __attribute__((export_name("TS_NodeFeatures_set_data_loss_protect_required"))) TS_NodeFeatures_set_data_loss_protect_required(uint32_t this_arg) {
37877         LDKNodeFeatures this_arg_conv;
37878         this_arg_conv.inner = (void*)(this_arg & (~1));
37879         this_arg_conv.is_owned = false;
37880         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37881         NodeFeatures_set_data_loss_protect_required(&this_arg_conv);
37882 }
37883
37884 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_data_loss_protect"))) TS_NodeFeatures_supports_data_loss_protect(uint32_t this_arg) {
37885         LDKNodeFeatures this_arg_conv;
37886         this_arg_conv.inner = (void*)(this_arg & (~1));
37887         this_arg_conv.is_owned = false;
37888         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37889         jboolean ret_conv = NodeFeatures_supports_data_loss_protect(&this_arg_conv);
37890         return ret_conv;
37891 }
37892
37893 jboolean  __attribute__((export_name("TS_InitFeatures_requires_data_loss_protect"))) TS_InitFeatures_requires_data_loss_protect(uint32_t this_arg) {
37894         LDKInitFeatures this_arg_conv;
37895         this_arg_conv.inner = (void*)(this_arg & (~1));
37896         this_arg_conv.is_owned = false;
37897         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37898         jboolean ret_conv = InitFeatures_requires_data_loss_protect(&this_arg_conv);
37899         return ret_conv;
37900 }
37901
37902 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_data_loss_protect"))) TS_NodeFeatures_requires_data_loss_protect(uint32_t this_arg) {
37903         LDKNodeFeatures this_arg_conv;
37904         this_arg_conv.inner = (void*)(this_arg & (~1));
37905         this_arg_conv.is_owned = false;
37906         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37907         jboolean ret_conv = NodeFeatures_requires_data_loss_protect(&this_arg_conv);
37908         return ret_conv;
37909 }
37910
37911 void  __attribute__((export_name("TS_InitFeatures_set_initial_routing_sync_optional"))) TS_InitFeatures_set_initial_routing_sync_optional(uint32_t this_arg) {
37912         LDKInitFeatures this_arg_conv;
37913         this_arg_conv.inner = (void*)(this_arg & (~1));
37914         this_arg_conv.is_owned = false;
37915         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37916         InitFeatures_set_initial_routing_sync_optional(&this_arg_conv);
37917 }
37918
37919 void  __attribute__((export_name("TS_InitFeatures_set_initial_routing_sync_required"))) TS_InitFeatures_set_initial_routing_sync_required(uint32_t this_arg) {
37920         LDKInitFeatures this_arg_conv;
37921         this_arg_conv.inner = (void*)(this_arg & (~1));
37922         this_arg_conv.is_owned = false;
37923         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37924         InitFeatures_set_initial_routing_sync_required(&this_arg_conv);
37925 }
37926
37927 jboolean  __attribute__((export_name("TS_InitFeatures_initial_routing_sync"))) TS_InitFeatures_initial_routing_sync(uint32_t this_arg) {
37928         LDKInitFeatures this_arg_conv;
37929         this_arg_conv.inner = (void*)(this_arg & (~1));
37930         this_arg_conv.is_owned = false;
37931         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37932         jboolean ret_conv = InitFeatures_initial_routing_sync(&this_arg_conv);
37933         return ret_conv;
37934 }
37935
37936 void  __attribute__((export_name("TS_InitFeatures_set_upfront_shutdown_script_optional"))) TS_InitFeatures_set_upfront_shutdown_script_optional(uint32_t this_arg) {
37937         LDKInitFeatures this_arg_conv;
37938         this_arg_conv.inner = (void*)(this_arg & (~1));
37939         this_arg_conv.is_owned = false;
37940         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37941         InitFeatures_set_upfront_shutdown_script_optional(&this_arg_conv);
37942 }
37943
37944 void  __attribute__((export_name("TS_InitFeatures_set_upfront_shutdown_script_required"))) TS_InitFeatures_set_upfront_shutdown_script_required(uint32_t this_arg) {
37945         LDKInitFeatures this_arg_conv;
37946         this_arg_conv.inner = (void*)(this_arg & (~1));
37947         this_arg_conv.is_owned = false;
37948         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37949         InitFeatures_set_upfront_shutdown_script_required(&this_arg_conv);
37950 }
37951
37952 jboolean  __attribute__((export_name("TS_InitFeatures_supports_upfront_shutdown_script"))) TS_InitFeatures_supports_upfront_shutdown_script(uint32_t this_arg) {
37953         LDKInitFeatures this_arg_conv;
37954         this_arg_conv.inner = (void*)(this_arg & (~1));
37955         this_arg_conv.is_owned = false;
37956         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37957         jboolean ret_conv = InitFeatures_supports_upfront_shutdown_script(&this_arg_conv);
37958         return ret_conv;
37959 }
37960
37961 void  __attribute__((export_name("TS_NodeFeatures_set_upfront_shutdown_script_optional"))) TS_NodeFeatures_set_upfront_shutdown_script_optional(uint32_t this_arg) {
37962         LDKNodeFeatures this_arg_conv;
37963         this_arg_conv.inner = (void*)(this_arg & (~1));
37964         this_arg_conv.is_owned = false;
37965         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37966         NodeFeatures_set_upfront_shutdown_script_optional(&this_arg_conv);
37967 }
37968
37969 void  __attribute__((export_name("TS_NodeFeatures_set_upfront_shutdown_script_required"))) TS_NodeFeatures_set_upfront_shutdown_script_required(uint32_t this_arg) {
37970         LDKNodeFeatures this_arg_conv;
37971         this_arg_conv.inner = (void*)(this_arg & (~1));
37972         this_arg_conv.is_owned = false;
37973         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37974         NodeFeatures_set_upfront_shutdown_script_required(&this_arg_conv);
37975 }
37976
37977 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_upfront_shutdown_script"))) TS_NodeFeatures_supports_upfront_shutdown_script(uint32_t this_arg) {
37978         LDKNodeFeatures this_arg_conv;
37979         this_arg_conv.inner = (void*)(this_arg & (~1));
37980         this_arg_conv.is_owned = false;
37981         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37982         jboolean ret_conv = NodeFeatures_supports_upfront_shutdown_script(&this_arg_conv);
37983         return ret_conv;
37984 }
37985
37986 jboolean  __attribute__((export_name("TS_InitFeatures_requires_upfront_shutdown_script"))) TS_InitFeatures_requires_upfront_shutdown_script(uint32_t this_arg) {
37987         LDKInitFeatures this_arg_conv;
37988         this_arg_conv.inner = (void*)(this_arg & (~1));
37989         this_arg_conv.is_owned = false;
37990         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37991         jboolean ret_conv = InitFeatures_requires_upfront_shutdown_script(&this_arg_conv);
37992         return ret_conv;
37993 }
37994
37995 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_upfront_shutdown_script"))) TS_NodeFeatures_requires_upfront_shutdown_script(uint32_t this_arg) {
37996         LDKNodeFeatures this_arg_conv;
37997         this_arg_conv.inner = (void*)(this_arg & (~1));
37998         this_arg_conv.is_owned = false;
37999         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38000         jboolean ret_conv = NodeFeatures_requires_upfront_shutdown_script(&this_arg_conv);
38001         return ret_conv;
38002 }
38003
38004 void  __attribute__((export_name("TS_InitFeatures_set_gossip_queries_optional"))) TS_InitFeatures_set_gossip_queries_optional(uint32_t this_arg) {
38005         LDKInitFeatures this_arg_conv;
38006         this_arg_conv.inner = (void*)(this_arg & (~1));
38007         this_arg_conv.is_owned = false;
38008         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38009         InitFeatures_set_gossip_queries_optional(&this_arg_conv);
38010 }
38011
38012 void  __attribute__((export_name("TS_InitFeatures_set_gossip_queries_required"))) TS_InitFeatures_set_gossip_queries_required(uint32_t this_arg) {
38013         LDKInitFeatures this_arg_conv;
38014         this_arg_conv.inner = (void*)(this_arg & (~1));
38015         this_arg_conv.is_owned = false;
38016         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38017         InitFeatures_set_gossip_queries_required(&this_arg_conv);
38018 }
38019
38020 jboolean  __attribute__((export_name("TS_InitFeatures_supports_gossip_queries"))) TS_InitFeatures_supports_gossip_queries(uint32_t this_arg) {
38021         LDKInitFeatures this_arg_conv;
38022         this_arg_conv.inner = (void*)(this_arg & (~1));
38023         this_arg_conv.is_owned = false;
38024         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38025         jboolean ret_conv = InitFeatures_supports_gossip_queries(&this_arg_conv);
38026         return ret_conv;
38027 }
38028
38029 void  __attribute__((export_name("TS_NodeFeatures_set_gossip_queries_optional"))) TS_NodeFeatures_set_gossip_queries_optional(uint32_t this_arg) {
38030         LDKNodeFeatures this_arg_conv;
38031         this_arg_conv.inner = (void*)(this_arg & (~1));
38032         this_arg_conv.is_owned = false;
38033         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38034         NodeFeatures_set_gossip_queries_optional(&this_arg_conv);
38035 }
38036
38037 void  __attribute__((export_name("TS_NodeFeatures_set_gossip_queries_required"))) TS_NodeFeatures_set_gossip_queries_required(uint32_t this_arg) {
38038         LDKNodeFeatures this_arg_conv;
38039         this_arg_conv.inner = (void*)(this_arg & (~1));
38040         this_arg_conv.is_owned = false;
38041         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38042         NodeFeatures_set_gossip_queries_required(&this_arg_conv);
38043 }
38044
38045 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_gossip_queries"))) TS_NodeFeatures_supports_gossip_queries(uint32_t this_arg) {
38046         LDKNodeFeatures this_arg_conv;
38047         this_arg_conv.inner = (void*)(this_arg & (~1));
38048         this_arg_conv.is_owned = false;
38049         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38050         jboolean ret_conv = NodeFeatures_supports_gossip_queries(&this_arg_conv);
38051         return ret_conv;
38052 }
38053
38054 jboolean  __attribute__((export_name("TS_InitFeatures_requires_gossip_queries"))) TS_InitFeatures_requires_gossip_queries(uint32_t this_arg) {
38055         LDKInitFeatures this_arg_conv;
38056         this_arg_conv.inner = (void*)(this_arg & (~1));
38057         this_arg_conv.is_owned = false;
38058         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38059         jboolean ret_conv = InitFeatures_requires_gossip_queries(&this_arg_conv);
38060         return ret_conv;
38061 }
38062
38063 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_gossip_queries"))) TS_NodeFeatures_requires_gossip_queries(uint32_t this_arg) {
38064         LDKNodeFeatures this_arg_conv;
38065         this_arg_conv.inner = (void*)(this_arg & (~1));
38066         this_arg_conv.is_owned = false;
38067         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38068         jboolean ret_conv = NodeFeatures_requires_gossip_queries(&this_arg_conv);
38069         return ret_conv;
38070 }
38071
38072 void  __attribute__((export_name("TS_InitFeatures_set_variable_length_onion_optional"))) TS_InitFeatures_set_variable_length_onion_optional(uint32_t this_arg) {
38073         LDKInitFeatures this_arg_conv;
38074         this_arg_conv.inner = (void*)(this_arg & (~1));
38075         this_arg_conv.is_owned = false;
38076         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38077         InitFeatures_set_variable_length_onion_optional(&this_arg_conv);
38078 }
38079
38080 void  __attribute__((export_name("TS_InitFeatures_set_variable_length_onion_required"))) TS_InitFeatures_set_variable_length_onion_required(uint32_t this_arg) {
38081         LDKInitFeatures this_arg_conv;
38082         this_arg_conv.inner = (void*)(this_arg & (~1));
38083         this_arg_conv.is_owned = false;
38084         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38085         InitFeatures_set_variable_length_onion_required(&this_arg_conv);
38086 }
38087
38088 jboolean  __attribute__((export_name("TS_InitFeatures_supports_variable_length_onion"))) TS_InitFeatures_supports_variable_length_onion(uint32_t this_arg) {
38089         LDKInitFeatures this_arg_conv;
38090         this_arg_conv.inner = (void*)(this_arg & (~1));
38091         this_arg_conv.is_owned = false;
38092         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38093         jboolean ret_conv = InitFeatures_supports_variable_length_onion(&this_arg_conv);
38094         return ret_conv;
38095 }
38096
38097 void  __attribute__((export_name("TS_NodeFeatures_set_variable_length_onion_optional"))) TS_NodeFeatures_set_variable_length_onion_optional(uint32_t this_arg) {
38098         LDKNodeFeatures this_arg_conv;
38099         this_arg_conv.inner = (void*)(this_arg & (~1));
38100         this_arg_conv.is_owned = false;
38101         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38102         NodeFeatures_set_variable_length_onion_optional(&this_arg_conv);
38103 }
38104
38105 void  __attribute__((export_name("TS_NodeFeatures_set_variable_length_onion_required"))) TS_NodeFeatures_set_variable_length_onion_required(uint32_t this_arg) {
38106         LDKNodeFeatures this_arg_conv;
38107         this_arg_conv.inner = (void*)(this_arg & (~1));
38108         this_arg_conv.is_owned = false;
38109         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38110         NodeFeatures_set_variable_length_onion_required(&this_arg_conv);
38111 }
38112
38113 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_variable_length_onion"))) TS_NodeFeatures_supports_variable_length_onion(uint32_t this_arg) {
38114         LDKNodeFeatures this_arg_conv;
38115         this_arg_conv.inner = (void*)(this_arg & (~1));
38116         this_arg_conv.is_owned = false;
38117         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38118         jboolean ret_conv = NodeFeatures_supports_variable_length_onion(&this_arg_conv);
38119         return ret_conv;
38120 }
38121
38122 void  __attribute__((export_name("TS_InvoiceFeatures_set_variable_length_onion_optional"))) TS_InvoiceFeatures_set_variable_length_onion_optional(uint32_t this_arg) {
38123         LDKInvoiceFeatures this_arg_conv;
38124         this_arg_conv.inner = (void*)(this_arg & (~1));
38125         this_arg_conv.is_owned = false;
38126         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38127         InvoiceFeatures_set_variable_length_onion_optional(&this_arg_conv);
38128 }
38129
38130 void  __attribute__((export_name("TS_InvoiceFeatures_set_variable_length_onion_required"))) TS_InvoiceFeatures_set_variable_length_onion_required(uint32_t this_arg) {
38131         LDKInvoiceFeatures this_arg_conv;
38132         this_arg_conv.inner = (void*)(this_arg & (~1));
38133         this_arg_conv.is_owned = false;
38134         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38135         InvoiceFeatures_set_variable_length_onion_required(&this_arg_conv);
38136 }
38137
38138 jboolean  __attribute__((export_name("TS_InvoiceFeatures_supports_variable_length_onion"))) TS_InvoiceFeatures_supports_variable_length_onion(uint32_t this_arg) {
38139         LDKInvoiceFeatures this_arg_conv;
38140         this_arg_conv.inner = (void*)(this_arg & (~1));
38141         this_arg_conv.is_owned = false;
38142         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38143         jboolean ret_conv = InvoiceFeatures_supports_variable_length_onion(&this_arg_conv);
38144         return ret_conv;
38145 }
38146
38147 jboolean  __attribute__((export_name("TS_InitFeatures_requires_variable_length_onion"))) TS_InitFeatures_requires_variable_length_onion(uint32_t this_arg) {
38148         LDKInitFeatures this_arg_conv;
38149         this_arg_conv.inner = (void*)(this_arg & (~1));
38150         this_arg_conv.is_owned = false;
38151         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38152         jboolean ret_conv = InitFeatures_requires_variable_length_onion(&this_arg_conv);
38153         return ret_conv;
38154 }
38155
38156 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_variable_length_onion"))) TS_NodeFeatures_requires_variable_length_onion(uint32_t this_arg) {
38157         LDKNodeFeatures this_arg_conv;
38158         this_arg_conv.inner = (void*)(this_arg & (~1));
38159         this_arg_conv.is_owned = false;
38160         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38161         jboolean ret_conv = NodeFeatures_requires_variable_length_onion(&this_arg_conv);
38162         return ret_conv;
38163 }
38164
38165 jboolean  __attribute__((export_name("TS_InvoiceFeatures_requires_variable_length_onion"))) TS_InvoiceFeatures_requires_variable_length_onion(uint32_t this_arg) {
38166         LDKInvoiceFeatures this_arg_conv;
38167         this_arg_conv.inner = (void*)(this_arg & (~1));
38168         this_arg_conv.is_owned = false;
38169         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38170         jboolean ret_conv = InvoiceFeatures_requires_variable_length_onion(&this_arg_conv);
38171         return ret_conv;
38172 }
38173
38174 void  __attribute__((export_name("TS_InitFeatures_set_static_remote_key_optional"))) TS_InitFeatures_set_static_remote_key_optional(uint32_t this_arg) {
38175         LDKInitFeatures this_arg_conv;
38176         this_arg_conv.inner = (void*)(this_arg & (~1));
38177         this_arg_conv.is_owned = false;
38178         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38179         InitFeatures_set_static_remote_key_optional(&this_arg_conv);
38180 }
38181
38182 void  __attribute__((export_name("TS_InitFeatures_set_static_remote_key_required"))) TS_InitFeatures_set_static_remote_key_required(uint32_t this_arg) {
38183         LDKInitFeatures this_arg_conv;
38184         this_arg_conv.inner = (void*)(this_arg & (~1));
38185         this_arg_conv.is_owned = false;
38186         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38187         InitFeatures_set_static_remote_key_required(&this_arg_conv);
38188 }
38189
38190 jboolean  __attribute__((export_name("TS_InitFeatures_supports_static_remote_key"))) TS_InitFeatures_supports_static_remote_key(uint32_t this_arg) {
38191         LDKInitFeatures this_arg_conv;
38192         this_arg_conv.inner = (void*)(this_arg & (~1));
38193         this_arg_conv.is_owned = false;
38194         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38195         jboolean ret_conv = InitFeatures_supports_static_remote_key(&this_arg_conv);
38196         return ret_conv;
38197 }
38198
38199 void  __attribute__((export_name("TS_NodeFeatures_set_static_remote_key_optional"))) TS_NodeFeatures_set_static_remote_key_optional(uint32_t this_arg) {
38200         LDKNodeFeatures this_arg_conv;
38201         this_arg_conv.inner = (void*)(this_arg & (~1));
38202         this_arg_conv.is_owned = false;
38203         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38204         NodeFeatures_set_static_remote_key_optional(&this_arg_conv);
38205 }
38206
38207 void  __attribute__((export_name("TS_NodeFeatures_set_static_remote_key_required"))) TS_NodeFeatures_set_static_remote_key_required(uint32_t this_arg) {
38208         LDKNodeFeatures this_arg_conv;
38209         this_arg_conv.inner = (void*)(this_arg & (~1));
38210         this_arg_conv.is_owned = false;
38211         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38212         NodeFeatures_set_static_remote_key_required(&this_arg_conv);
38213 }
38214
38215 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_static_remote_key"))) TS_NodeFeatures_supports_static_remote_key(uint32_t this_arg) {
38216         LDKNodeFeatures this_arg_conv;
38217         this_arg_conv.inner = (void*)(this_arg & (~1));
38218         this_arg_conv.is_owned = false;
38219         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38220         jboolean ret_conv = NodeFeatures_supports_static_remote_key(&this_arg_conv);
38221         return ret_conv;
38222 }
38223
38224 void  __attribute__((export_name("TS_ChannelTypeFeatures_set_static_remote_key_optional"))) TS_ChannelTypeFeatures_set_static_remote_key_optional(uint32_t this_arg) {
38225         LDKChannelTypeFeatures this_arg_conv;
38226         this_arg_conv.inner = (void*)(this_arg & (~1));
38227         this_arg_conv.is_owned = false;
38228         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38229         ChannelTypeFeatures_set_static_remote_key_optional(&this_arg_conv);
38230 }
38231
38232 void  __attribute__((export_name("TS_ChannelTypeFeatures_set_static_remote_key_required"))) TS_ChannelTypeFeatures_set_static_remote_key_required(uint32_t this_arg) {
38233         LDKChannelTypeFeatures this_arg_conv;
38234         this_arg_conv.inner = (void*)(this_arg & (~1));
38235         this_arg_conv.is_owned = false;
38236         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38237         ChannelTypeFeatures_set_static_remote_key_required(&this_arg_conv);
38238 }
38239
38240 jboolean  __attribute__((export_name("TS_ChannelTypeFeatures_supports_static_remote_key"))) TS_ChannelTypeFeatures_supports_static_remote_key(uint32_t this_arg) {
38241         LDKChannelTypeFeatures this_arg_conv;
38242         this_arg_conv.inner = (void*)(this_arg & (~1));
38243         this_arg_conv.is_owned = false;
38244         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38245         jboolean ret_conv = ChannelTypeFeatures_supports_static_remote_key(&this_arg_conv);
38246         return ret_conv;
38247 }
38248
38249 jboolean  __attribute__((export_name("TS_InitFeatures_requires_static_remote_key"))) TS_InitFeatures_requires_static_remote_key(uint32_t this_arg) {
38250         LDKInitFeatures this_arg_conv;
38251         this_arg_conv.inner = (void*)(this_arg & (~1));
38252         this_arg_conv.is_owned = false;
38253         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38254         jboolean ret_conv = InitFeatures_requires_static_remote_key(&this_arg_conv);
38255         return ret_conv;
38256 }
38257
38258 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_static_remote_key"))) TS_NodeFeatures_requires_static_remote_key(uint32_t this_arg) {
38259         LDKNodeFeatures this_arg_conv;
38260         this_arg_conv.inner = (void*)(this_arg & (~1));
38261         this_arg_conv.is_owned = false;
38262         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38263         jboolean ret_conv = NodeFeatures_requires_static_remote_key(&this_arg_conv);
38264         return ret_conv;
38265 }
38266
38267 jboolean  __attribute__((export_name("TS_ChannelTypeFeatures_requires_static_remote_key"))) TS_ChannelTypeFeatures_requires_static_remote_key(uint32_t this_arg) {
38268         LDKChannelTypeFeatures this_arg_conv;
38269         this_arg_conv.inner = (void*)(this_arg & (~1));
38270         this_arg_conv.is_owned = false;
38271         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38272         jboolean ret_conv = ChannelTypeFeatures_requires_static_remote_key(&this_arg_conv);
38273         return ret_conv;
38274 }
38275
38276 void  __attribute__((export_name("TS_InitFeatures_set_payment_secret_optional"))) TS_InitFeatures_set_payment_secret_optional(uint32_t this_arg) {
38277         LDKInitFeatures this_arg_conv;
38278         this_arg_conv.inner = (void*)(this_arg & (~1));
38279         this_arg_conv.is_owned = false;
38280         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38281         InitFeatures_set_payment_secret_optional(&this_arg_conv);
38282 }
38283
38284 void  __attribute__((export_name("TS_InitFeatures_set_payment_secret_required"))) TS_InitFeatures_set_payment_secret_required(uint32_t this_arg) {
38285         LDKInitFeatures this_arg_conv;
38286         this_arg_conv.inner = (void*)(this_arg & (~1));
38287         this_arg_conv.is_owned = false;
38288         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38289         InitFeatures_set_payment_secret_required(&this_arg_conv);
38290 }
38291
38292 jboolean  __attribute__((export_name("TS_InitFeatures_supports_payment_secret"))) TS_InitFeatures_supports_payment_secret(uint32_t this_arg) {
38293         LDKInitFeatures this_arg_conv;
38294         this_arg_conv.inner = (void*)(this_arg & (~1));
38295         this_arg_conv.is_owned = false;
38296         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38297         jboolean ret_conv = InitFeatures_supports_payment_secret(&this_arg_conv);
38298         return ret_conv;
38299 }
38300
38301 void  __attribute__((export_name("TS_NodeFeatures_set_payment_secret_optional"))) TS_NodeFeatures_set_payment_secret_optional(uint32_t this_arg) {
38302         LDKNodeFeatures this_arg_conv;
38303         this_arg_conv.inner = (void*)(this_arg & (~1));
38304         this_arg_conv.is_owned = false;
38305         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38306         NodeFeatures_set_payment_secret_optional(&this_arg_conv);
38307 }
38308
38309 void  __attribute__((export_name("TS_NodeFeatures_set_payment_secret_required"))) TS_NodeFeatures_set_payment_secret_required(uint32_t this_arg) {
38310         LDKNodeFeatures this_arg_conv;
38311         this_arg_conv.inner = (void*)(this_arg & (~1));
38312         this_arg_conv.is_owned = false;
38313         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38314         NodeFeatures_set_payment_secret_required(&this_arg_conv);
38315 }
38316
38317 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_payment_secret"))) TS_NodeFeatures_supports_payment_secret(uint32_t this_arg) {
38318         LDKNodeFeatures this_arg_conv;
38319         this_arg_conv.inner = (void*)(this_arg & (~1));
38320         this_arg_conv.is_owned = false;
38321         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38322         jboolean ret_conv = NodeFeatures_supports_payment_secret(&this_arg_conv);
38323         return ret_conv;
38324 }
38325
38326 void  __attribute__((export_name("TS_InvoiceFeatures_set_payment_secret_optional"))) TS_InvoiceFeatures_set_payment_secret_optional(uint32_t this_arg) {
38327         LDKInvoiceFeatures this_arg_conv;
38328         this_arg_conv.inner = (void*)(this_arg & (~1));
38329         this_arg_conv.is_owned = false;
38330         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38331         InvoiceFeatures_set_payment_secret_optional(&this_arg_conv);
38332 }
38333
38334 void  __attribute__((export_name("TS_InvoiceFeatures_set_payment_secret_required"))) TS_InvoiceFeatures_set_payment_secret_required(uint32_t this_arg) {
38335         LDKInvoiceFeatures this_arg_conv;
38336         this_arg_conv.inner = (void*)(this_arg & (~1));
38337         this_arg_conv.is_owned = false;
38338         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38339         InvoiceFeatures_set_payment_secret_required(&this_arg_conv);
38340 }
38341
38342 jboolean  __attribute__((export_name("TS_InvoiceFeatures_supports_payment_secret"))) TS_InvoiceFeatures_supports_payment_secret(uint32_t this_arg) {
38343         LDKInvoiceFeatures this_arg_conv;
38344         this_arg_conv.inner = (void*)(this_arg & (~1));
38345         this_arg_conv.is_owned = false;
38346         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38347         jboolean ret_conv = InvoiceFeatures_supports_payment_secret(&this_arg_conv);
38348         return ret_conv;
38349 }
38350
38351 jboolean  __attribute__((export_name("TS_InitFeatures_requires_payment_secret"))) TS_InitFeatures_requires_payment_secret(uint32_t this_arg) {
38352         LDKInitFeatures this_arg_conv;
38353         this_arg_conv.inner = (void*)(this_arg & (~1));
38354         this_arg_conv.is_owned = false;
38355         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38356         jboolean ret_conv = InitFeatures_requires_payment_secret(&this_arg_conv);
38357         return ret_conv;
38358 }
38359
38360 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_payment_secret"))) TS_NodeFeatures_requires_payment_secret(uint32_t this_arg) {
38361         LDKNodeFeatures this_arg_conv;
38362         this_arg_conv.inner = (void*)(this_arg & (~1));
38363         this_arg_conv.is_owned = false;
38364         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38365         jboolean ret_conv = NodeFeatures_requires_payment_secret(&this_arg_conv);
38366         return ret_conv;
38367 }
38368
38369 jboolean  __attribute__((export_name("TS_InvoiceFeatures_requires_payment_secret"))) TS_InvoiceFeatures_requires_payment_secret(uint32_t this_arg) {
38370         LDKInvoiceFeatures this_arg_conv;
38371         this_arg_conv.inner = (void*)(this_arg & (~1));
38372         this_arg_conv.is_owned = false;
38373         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38374         jboolean ret_conv = InvoiceFeatures_requires_payment_secret(&this_arg_conv);
38375         return ret_conv;
38376 }
38377
38378 void  __attribute__((export_name("TS_InitFeatures_set_basic_mpp_optional"))) TS_InitFeatures_set_basic_mpp_optional(uint32_t this_arg) {
38379         LDKInitFeatures this_arg_conv;
38380         this_arg_conv.inner = (void*)(this_arg & (~1));
38381         this_arg_conv.is_owned = false;
38382         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38383         InitFeatures_set_basic_mpp_optional(&this_arg_conv);
38384 }
38385
38386 void  __attribute__((export_name("TS_InitFeatures_set_basic_mpp_required"))) TS_InitFeatures_set_basic_mpp_required(uint32_t this_arg) {
38387         LDKInitFeatures this_arg_conv;
38388         this_arg_conv.inner = (void*)(this_arg & (~1));
38389         this_arg_conv.is_owned = false;
38390         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38391         InitFeatures_set_basic_mpp_required(&this_arg_conv);
38392 }
38393
38394 jboolean  __attribute__((export_name("TS_InitFeatures_supports_basic_mpp"))) TS_InitFeatures_supports_basic_mpp(uint32_t this_arg) {
38395         LDKInitFeatures this_arg_conv;
38396         this_arg_conv.inner = (void*)(this_arg & (~1));
38397         this_arg_conv.is_owned = false;
38398         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38399         jboolean ret_conv = InitFeatures_supports_basic_mpp(&this_arg_conv);
38400         return ret_conv;
38401 }
38402
38403 void  __attribute__((export_name("TS_NodeFeatures_set_basic_mpp_optional"))) TS_NodeFeatures_set_basic_mpp_optional(uint32_t this_arg) {
38404         LDKNodeFeatures this_arg_conv;
38405         this_arg_conv.inner = (void*)(this_arg & (~1));
38406         this_arg_conv.is_owned = false;
38407         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38408         NodeFeatures_set_basic_mpp_optional(&this_arg_conv);
38409 }
38410
38411 void  __attribute__((export_name("TS_NodeFeatures_set_basic_mpp_required"))) TS_NodeFeatures_set_basic_mpp_required(uint32_t this_arg) {
38412         LDKNodeFeatures this_arg_conv;
38413         this_arg_conv.inner = (void*)(this_arg & (~1));
38414         this_arg_conv.is_owned = false;
38415         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38416         NodeFeatures_set_basic_mpp_required(&this_arg_conv);
38417 }
38418
38419 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_basic_mpp"))) TS_NodeFeatures_supports_basic_mpp(uint32_t this_arg) {
38420         LDKNodeFeatures this_arg_conv;
38421         this_arg_conv.inner = (void*)(this_arg & (~1));
38422         this_arg_conv.is_owned = false;
38423         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38424         jboolean ret_conv = NodeFeatures_supports_basic_mpp(&this_arg_conv);
38425         return ret_conv;
38426 }
38427
38428 void  __attribute__((export_name("TS_InvoiceFeatures_set_basic_mpp_optional"))) TS_InvoiceFeatures_set_basic_mpp_optional(uint32_t this_arg) {
38429         LDKInvoiceFeatures this_arg_conv;
38430         this_arg_conv.inner = (void*)(this_arg & (~1));
38431         this_arg_conv.is_owned = false;
38432         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38433         InvoiceFeatures_set_basic_mpp_optional(&this_arg_conv);
38434 }
38435
38436 void  __attribute__((export_name("TS_InvoiceFeatures_set_basic_mpp_required"))) TS_InvoiceFeatures_set_basic_mpp_required(uint32_t this_arg) {
38437         LDKInvoiceFeatures this_arg_conv;
38438         this_arg_conv.inner = (void*)(this_arg & (~1));
38439         this_arg_conv.is_owned = false;
38440         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38441         InvoiceFeatures_set_basic_mpp_required(&this_arg_conv);
38442 }
38443
38444 jboolean  __attribute__((export_name("TS_InvoiceFeatures_supports_basic_mpp"))) TS_InvoiceFeatures_supports_basic_mpp(uint32_t this_arg) {
38445         LDKInvoiceFeatures this_arg_conv;
38446         this_arg_conv.inner = (void*)(this_arg & (~1));
38447         this_arg_conv.is_owned = false;
38448         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38449         jboolean ret_conv = InvoiceFeatures_supports_basic_mpp(&this_arg_conv);
38450         return ret_conv;
38451 }
38452
38453 jboolean  __attribute__((export_name("TS_InitFeatures_requires_basic_mpp"))) TS_InitFeatures_requires_basic_mpp(uint32_t this_arg) {
38454         LDKInitFeatures this_arg_conv;
38455         this_arg_conv.inner = (void*)(this_arg & (~1));
38456         this_arg_conv.is_owned = false;
38457         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38458         jboolean ret_conv = InitFeatures_requires_basic_mpp(&this_arg_conv);
38459         return ret_conv;
38460 }
38461
38462 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_basic_mpp"))) TS_NodeFeatures_requires_basic_mpp(uint32_t this_arg) {
38463         LDKNodeFeatures this_arg_conv;
38464         this_arg_conv.inner = (void*)(this_arg & (~1));
38465         this_arg_conv.is_owned = false;
38466         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38467         jboolean ret_conv = NodeFeatures_requires_basic_mpp(&this_arg_conv);
38468         return ret_conv;
38469 }
38470
38471 jboolean  __attribute__((export_name("TS_InvoiceFeatures_requires_basic_mpp"))) TS_InvoiceFeatures_requires_basic_mpp(uint32_t this_arg) {
38472         LDKInvoiceFeatures this_arg_conv;
38473         this_arg_conv.inner = (void*)(this_arg & (~1));
38474         this_arg_conv.is_owned = false;
38475         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38476         jboolean ret_conv = InvoiceFeatures_requires_basic_mpp(&this_arg_conv);
38477         return ret_conv;
38478 }
38479
38480 void  __attribute__((export_name("TS_InitFeatures_set_wumbo_optional"))) TS_InitFeatures_set_wumbo_optional(uint32_t this_arg) {
38481         LDKInitFeatures this_arg_conv;
38482         this_arg_conv.inner = (void*)(this_arg & (~1));
38483         this_arg_conv.is_owned = false;
38484         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38485         InitFeatures_set_wumbo_optional(&this_arg_conv);
38486 }
38487
38488 void  __attribute__((export_name("TS_InitFeatures_set_wumbo_required"))) TS_InitFeatures_set_wumbo_required(uint32_t this_arg) {
38489         LDKInitFeatures this_arg_conv;
38490         this_arg_conv.inner = (void*)(this_arg & (~1));
38491         this_arg_conv.is_owned = false;
38492         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38493         InitFeatures_set_wumbo_required(&this_arg_conv);
38494 }
38495
38496 jboolean  __attribute__((export_name("TS_InitFeatures_supports_wumbo"))) TS_InitFeatures_supports_wumbo(uint32_t this_arg) {
38497         LDKInitFeatures this_arg_conv;
38498         this_arg_conv.inner = (void*)(this_arg & (~1));
38499         this_arg_conv.is_owned = false;
38500         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38501         jboolean ret_conv = InitFeatures_supports_wumbo(&this_arg_conv);
38502         return ret_conv;
38503 }
38504
38505 void  __attribute__((export_name("TS_NodeFeatures_set_wumbo_optional"))) TS_NodeFeatures_set_wumbo_optional(uint32_t this_arg) {
38506         LDKNodeFeatures this_arg_conv;
38507         this_arg_conv.inner = (void*)(this_arg & (~1));
38508         this_arg_conv.is_owned = false;
38509         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38510         NodeFeatures_set_wumbo_optional(&this_arg_conv);
38511 }
38512
38513 void  __attribute__((export_name("TS_NodeFeatures_set_wumbo_required"))) TS_NodeFeatures_set_wumbo_required(uint32_t this_arg) {
38514         LDKNodeFeatures this_arg_conv;
38515         this_arg_conv.inner = (void*)(this_arg & (~1));
38516         this_arg_conv.is_owned = false;
38517         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38518         NodeFeatures_set_wumbo_required(&this_arg_conv);
38519 }
38520
38521 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_wumbo"))) TS_NodeFeatures_supports_wumbo(uint32_t this_arg) {
38522         LDKNodeFeatures this_arg_conv;
38523         this_arg_conv.inner = (void*)(this_arg & (~1));
38524         this_arg_conv.is_owned = false;
38525         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38526         jboolean ret_conv = NodeFeatures_supports_wumbo(&this_arg_conv);
38527         return ret_conv;
38528 }
38529
38530 jboolean  __attribute__((export_name("TS_InitFeatures_requires_wumbo"))) TS_InitFeatures_requires_wumbo(uint32_t this_arg) {
38531         LDKInitFeatures this_arg_conv;
38532         this_arg_conv.inner = (void*)(this_arg & (~1));
38533         this_arg_conv.is_owned = false;
38534         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38535         jboolean ret_conv = InitFeatures_requires_wumbo(&this_arg_conv);
38536         return ret_conv;
38537 }
38538
38539 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_wumbo"))) TS_NodeFeatures_requires_wumbo(uint32_t this_arg) {
38540         LDKNodeFeatures this_arg_conv;
38541         this_arg_conv.inner = (void*)(this_arg & (~1));
38542         this_arg_conv.is_owned = false;
38543         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38544         jboolean ret_conv = NodeFeatures_requires_wumbo(&this_arg_conv);
38545         return ret_conv;
38546 }
38547
38548 void  __attribute__((export_name("TS_InitFeatures_set_shutdown_any_segwit_optional"))) TS_InitFeatures_set_shutdown_any_segwit_optional(uint32_t this_arg) {
38549         LDKInitFeatures this_arg_conv;
38550         this_arg_conv.inner = (void*)(this_arg & (~1));
38551         this_arg_conv.is_owned = false;
38552         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38553         InitFeatures_set_shutdown_any_segwit_optional(&this_arg_conv);
38554 }
38555
38556 void  __attribute__((export_name("TS_InitFeatures_set_shutdown_any_segwit_required"))) TS_InitFeatures_set_shutdown_any_segwit_required(uint32_t this_arg) {
38557         LDKInitFeatures this_arg_conv;
38558         this_arg_conv.inner = (void*)(this_arg & (~1));
38559         this_arg_conv.is_owned = false;
38560         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38561         InitFeatures_set_shutdown_any_segwit_required(&this_arg_conv);
38562 }
38563
38564 jboolean  __attribute__((export_name("TS_InitFeatures_supports_shutdown_anysegwit"))) TS_InitFeatures_supports_shutdown_anysegwit(uint32_t this_arg) {
38565         LDKInitFeatures this_arg_conv;
38566         this_arg_conv.inner = (void*)(this_arg & (~1));
38567         this_arg_conv.is_owned = false;
38568         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38569         jboolean ret_conv = InitFeatures_supports_shutdown_anysegwit(&this_arg_conv);
38570         return ret_conv;
38571 }
38572
38573 void  __attribute__((export_name("TS_NodeFeatures_set_shutdown_any_segwit_optional"))) TS_NodeFeatures_set_shutdown_any_segwit_optional(uint32_t this_arg) {
38574         LDKNodeFeatures this_arg_conv;
38575         this_arg_conv.inner = (void*)(this_arg & (~1));
38576         this_arg_conv.is_owned = false;
38577         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38578         NodeFeatures_set_shutdown_any_segwit_optional(&this_arg_conv);
38579 }
38580
38581 void  __attribute__((export_name("TS_NodeFeatures_set_shutdown_any_segwit_required"))) TS_NodeFeatures_set_shutdown_any_segwit_required(uint32_t this_arg) {
38582         LDKNodeFeatures this_arg_conv;
38583         this_arg_conv.inner = (void*)(this_arg & (~1));
38584         this_arg_conv.is_owned = false;
38585         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38586         NodeFeatures_set_shutdown_any_segwit_required(&this_arg_conv);
38587 }
38588
38589 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_shutdown_anysegwit"))) TS_NodeFeatures_supports_shutdown_anysegwit(uint32_t this_arg) {
38590         LDKNodeFeatures this_arg_conv;
38591         this_arg_conv.inner = (void*)(this_arg & (~1));
38592         this_arg_conv.is_owned = false;
38593         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38594         jboolean ret_conv = NodeFeatures_supports_shutdown_anysegwit(&this_arg_conv);
38595         return ret_conv;
38596 }
38597
38598 jboolean  __attribute__((export_name("TS_InitFeatures_requires_shutdown_anysegwit"))) TS_InitFeatures_requires_shutdown_anysegwit(uint32_t this_arg) {
38599         LDKInitFeatures this_arg_conv;
38600         this_arg_conv.inner = (void*)(this_arg & (~1));
38601         this_arg_conv.is_owned = false;
38602         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38603         jboolean ret_conv = InitFeatures_requires_shutdown_anysegwit(&this_arg_conv);
38604         return ret_conv;
38605 }
38606
38607 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_shutdown_anysegwit"))) TS_NodeFeatures_requires_shutdown_anysegwit(uint32_t this_arg) {
38608         LDKNodeFeatures this_arg_conv;
38609         this_arg_conv.inner = (void*)(this_arg & (~1));
38610         this_arg_conv.is_owned = false;
38611         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38612         jboolean ret_conv = NodeFeatures_requires_shutdown_anysegwit(&this_arg_conv);
38613         return ret_conv;
38614 }
38615
38616 void  __attribute__((export_name("TS_InitFeatures_set_channel_type_optional"))) TS_InitFeatures_set_channel_type_optional(uint32_t this_arg) {
38617         LDKInitFeatures this_arg_conv;
38618         this_arg_conv.inner = (void*)(this_arg & (~1));
38619         this_arg_conv.is_owned = false;
38620         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38621         InitFeatures_set_channel_type_optional(&this_arg_conv);
38622 }
38623
38624 void  __attribute__((export_name("TS_InitFeatures_set_channel_type_required"))) TS_InitFeatures_set_channel_type_required(uint32_t this_arg) {
38625         LDKInitFeatures this_arg_conv;
38626         this_arg_conv.inner = (void*)(this_arg & (~1));
38627         this_arg_conv.is_owned = false;
38628         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38629         InitFeatures_set_channel_type_required(&this_arg_conv);
38630 }
38631
38632 jboolean  __attribute__((export_name("TS_InitFeatures_supports_channel_type"))) TS_InitFeatures_supports_channel_type(uint32_t this_arg) {
38633         LDKInitFeatures this_arg_conv;
38634         this_arg_conv.inner = (void*)(this_arg & (~1));
38635         this_arg_conv.is_owned = false;
38636         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38637         jboolean ret_conv = InitFeatures_supports_channel_type(&this_arg_conv);
38638         return ret_conv;
38639 }
38640
38641 void  __attribute__((export_name("TS_NodeFeatures_set_channel_type_optional"))) TS_NodeFeatures_set_channel_type_optional(uint32_t this_arg) {
38642         LDKNodeFeatures this_arg_conv;
38643         this_arg_conv.inner = (void*)(this_arg & (~1));
38644         this_arg_conv.is_owned = false;
38645         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38646         NodeFeatures_set_channel_type_optional(&this_arg_conv);
38647 }
38648
38649 void  __attribute__((export_name("TS_NodeFeatures_set_channel_type_required"))) TS_NodeFeatures_set_channel_type_required(uint32_t this_arg) {
38650         LDKNodeFeatures this_arg_conv;
38651         this_arg_conv.inner = (void*)(this_arg & (~1));
38652         this_arg_conv.is_owned = false;
38653         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38654         NodeFeatures_set_channel_type_required(&this_arg_conv);
38655 }
38656
38657 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_channel_type"))) TS_NodeFeatures_supports_channel_type(uint32_t this_arg) {
38658         LDKNodeFeatures this_arg_conv;
38659         this_arg_conv.inner = (void*)(this_arg & (~1));
38660         this_arg_conv.is_owned = false;
38661         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38662         jboolean ret_conv = NodeFeatures_supports_channel_type(&this_arg_conv);
38663         return ret_conv;
38664 }
38665
38666 jboolean  __attribute__((export_name("TS_InitFeatures_requires_channel_type"))) TS_InitFeatures_requires_channel_type(uint32_t this_arg) {
38667         LDKInitFeatures this_arg_conv;
38668         this_arg_conv.inner = (void*)(this_arg & (~1));
38669         this_arg_conv.is_owned = false;
38670         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38671         jboolean ret_conv = InitFeatures_requires_channel_type(&this_arg_conv);
38672         return ret_conv;
38673 }
38674
38675 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_channel_type"))) TS_NodeFeatures_requires_channel_type(uint32_t this_arg) {
38676         LDKNodeFeatures this_arg_conv;
38677         this_arg_conv.inner = (void*)(this_arg & (~1));
38678         this_arg_conv.is_owned = false;
38679         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38680         jboolean ret_conv = NodeFeatures_requires_channel_type(&this_arg_conv);
38681         return ret_conv;
38682 }
38683
38684 void  __attribute__((export_name("TS_InitFeatures_set_scid_privacy_optional"))) TS_InitFeatures_set_scid_privacy_optional(uint32_t this_arg) {
38685         LDKInitFeatures this_arg_conv;
38686         this_arg_conv.inner = (void*)(this_arg & (~1));
38687         this_arg_conv.is_owned = false;
38688         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38689         InitFeatures_set_scid_privacy_optional(&this_arg_conv);
38690 }
38691
38692 void  __attribute__((export_name("TS_InitFeatures_set_scid_privacy_required"))) TS_InitFeatures_set_scid_privacy_required(uint32_t this_arg) {
38693         LDKInitFeatures this_arg_conv;
38694         this_arg_conv.inner = (void*)(this_arg & (~1));
38695         this_arg_conv.is_owned = false;
38696         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38697         InitFeatures_set_scid_privacy_required(&this_arg_conv);
38698 }
38699
38700 jboolean  __attribute__((export_name("TS_InitFeatures_supports_scid_privacy"))) TS_InitFeatures_supports_scid_privacy(uint32_t this_arg) {
38701         LDKInitFeatures this_arg_conv;
38702         this_arg_conv.inner = (void*)(this_arg & (~1));
38703         this_arg_conv.is_owned = false;
38704         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38705         jboolean ret_conv = InitFeatures_supports_scid_privacy(&this_arg_conv);
38706         return ret_conv;
38707 }
38708
38709 void  __attribute__((export_name("TS_NodeFeatures_set_scid_privacy_optional"))) TS_NodeFeatures_set_scid_privacy_optional(uint32_t this_arg) {
38710         LDKNodeFeatures this_arg_conv;
38711         this_arg_conv.inner = (void*)(this_arg & (~1));
38712         this_arg_conv.is_owned = false;
38713         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38714         NodeFeatures_set_scid_privacy_optional(&this_arg_conv);
38715 }
38716
38717 void  __attribute__((export_name("TS_NodeFeatures_set_scid_privacy_required"))) TS_NodeFeatures_set_scid_privacy_required(uint32_t this_arg) {
38718         LDKNodeFeatures this_arg_conv;
38719         this_arg_conv.inner = (void*)(this_arg & (~1));
38720         this_arg_conv.is_owned = false;
38721         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38722         NodeFeatures_set_scid_privacy_required(&this_arg_conv);
38723 }
38724
38725 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_scid_privacy"))) TS_NodeFeatures_supports_scid_privacy(uint32_t this_arg) {
38726         LDKNodeFeatures this_arg_conv;
38727         this_arg_conv.inner = (void*)(this_arg & (~1));
38728         this_arg_conv.is_owned = false;
38729         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38730         jboolean ret_conv = NodeFeatures_supports_scid_privacy(&this_arg_conv);
38731         return ret_conv;
38732 }
38733
38734 void  __attribute__((export_name("TS_ChannelTypeFeatures_set_scid_privacy_optional"))) TS_ChannelTypeFeatures_set_scid_privacy_optional(uint32_t this_arg) {
38735         LDKChannelTypeFeatures this_arg_conv;
38736         this_arg_conv.inner = (void*)(this_arg & (~1));
38737         this_arg_conv.is_owned = false;
38738         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38739         ChannelTypeFeatures_set_scid_privacy_optional(&this_arg_conv);
38740 }
38741
38742 void  __attribute__((export_name("TS_ChannelTypeFeatures_set_scid_privacy_required"))) TS_ChannelTypeFeatures_set_scid_privacy_required(uint32_t this_arg) {
38743         LDKChannelTypeFeatures this_arg_conv;
38744         this_arg_conv.inner = (void*)(this_arg & (~1));
38745         this_arg_conv.is_owned = false;
38746         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38747         ChannelTypeFeatures_set_scid_privacy_required(&this_arg_conv);
38748 }
38749
38750 jboolean  __attribute__((export_name("TS_ChannelTypeFeatures_supports_scid_privacy"))) TS_ChannelTypeFeatures_supports_scid_privacy(uint32_t this_arg) {
38751         LDKChannelTypeFeatures this_arg_conv;
38752         this_arg_conv.inner = (void*)(this_arg & (~1));
38753         this_arg_conv.is_owned = false;
38754         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38755         jboolean ret_conv = ChannelTypeFeatures_supports_scid_privacy(&this_arg_conv);
38756         return ret_conv;
38757 }
38758
38759 jboolean  __attribute__((export_name("TS_InitFeatures_requires_scid_privacy"))) TS_InitFeatures_requires_scid_privacy(uint32_t this_arg) {
38760         LDKInitFeatures this_arg_conv;
38761         this_arg_conv.inner = (void*)(this_arg & (~1));
38762         this_arg_conv.is_owned = false;
38763         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38764         jboolean ret_conv = InitFeatures_requires_scid_privacy(&this_arg_conv);
38765         return ret_conv;
38766 }
38767
38768 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_scid_privacy"))) TS_NodeFeatures_requires_scid_privacy(uint32_t this_arg) {
38769         LDKNodeFeatures this_arg_conv;
38770         this_arg_conv.inner = (void*)(this_arg & (~1));
38771         this_arg_conv.is_owned = false;
38772         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38773         jboolean ret_conv = NodeFeatures_requires_scid_privacy(&this_arg_conv);
38774         return ret_conv;
38775 }
38776
38777 jboolean  __attribute__((export_name("TS_ChannelTypeFeatures_requires_scid_privacy"))) TS_ChannelTypeFeatures_requires_scid_privacy(uint32_t this_arg) {
38778         LDKChannelTypeFeatures this_arg_conv;
38779         this_arg_conv.inner = (void*)(this_arg & (~1));
38780         this_arg_conv.is_owned = false;
38781         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38782         jboolean ret_conv = ChannelTypeFeatures_requires_scid_privacy(&this_arg_conv);
38783         return ret_conv;
38784 }
38785
38786 void  __attribute__((export_name("TS_InitFeatures_set_zero_conf_optional"))) TS_InitFeatures_set_zero_conf_optional(uint32_t this_arg) {
38787         LDKInitFeatures this_arg_conv;
38788         this_arg_conv.inner = (void*)(this_arg & (~1));
38789         this_arg_conv.is_owned = false;
38790         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38791         InitFeatures_set_zero_conf_optional(&this_arg_conv);
38792 }
38793
38794 void  __attribute__((export_name("TS_InitFeatures_set_zero_conf_required"))) TS_InitFeatures_set_zero_conf_required(uint32_t this_arg) {
38795         LDKInitFeatures this_arg_conv;
38796         this_arg_conv.inner = (void*)(this_arg & (~1));
38797         this_arg_conv.is_owned = false;
38798         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38799         InitFeatures_set_zero_conf_required(&this_arg_conv);
38800 }
38801
38802 jboolean  __attribute__((export_name("TS_InitFeatures_supports_zero_conf"))) TS_InitFeatures_supports_zero_conf(uint32_t this_arg) {
38803         LDKInitFeatures this_arg_conv;
38804         this_arg_conv.inner = (void*)(this_arg & (~1));
38805         this_arg_conv.is_owned = false;
38806         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38807         jboolean ret_conv = InitFeatures_supports_zero_conf(&this_arg_conv);
38808         return ret_conv;
38809 }
38810
38811 void  __attribute__((export_name("TS_NodeFeatures_set_zero_conf_optional"))) TS_NodeFeatures_set_zero_conf_optional(uint32_t this_arg) {
38812         LDKNodeFeatures this_arg_conv;
38813         this_arg_conv.inner = (void*)(this_arg & (~1));
38814         this_arg_conv.is_owned = false;
38815         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38816         NodeFeatures_set_zero_conf_optional(&this_arg_conv);
38817 }
38818
38819 void  __attribute__((export_name("TS_NodeFeatures_set_zero_conf_required"))) TS_NodeFeatures_set_zero_conf_required(uint32_t this_arg) {
38820         LDKNodeFeatures this_arg_conv;
38821         this_arg_conv.inner = (void*)(this_arg & (~1));
38822         this_arg_conv.is_owned = false;
38823         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38824         NodeFeatures_set_zero_conf_required(&this_arg_conv);
38825 }
38826
38827 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_zero_conf"))) TS_NodeFeatures_supports_zero_conf(uint32_t this_arg) {
38828         LDKNodeFeatures this_arg_conv;
38829         this_arg_conv.inner = (void*)(this_arg & (~1));
38830         this_arg_conv.is_owned = false;
38831         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38832         jboolean ret_conv = NodeFeatures_supports_zero_conf(&this_arg_conv);
38833         return ret_conv;
38834 }
38835
38836 void  __attribute__((export_name("TS_ChannelTypeFeatures_set_zero_conf_optional"))) TS_ChannelTypeFeatures_set_zero_conf_optional(uint32_t this_arg) {
38837         LDKChannelTypeFeatures this_arg_conv;
38838         this_arg_conv.inner = (void*)(this_arg & (~1));
38839         this_arg_conv.is_owned = false;
38840         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38841         ChannelTypeFeatures_set_zero_conf_optional(&this_arg_conv);
38842 }
38843
38844 void  __attribute__((export_name("TS_ChannelTypeFeatures_set_zero_conf_required"))) TS_ChannelTypeFeatures_set_zero_conf_required(uint32_t this_arg) {
38845         LDKChannelTypeFeatures this_arg_conv;
38846         this_arg_conv.inner = (void*)(this_arg & (~1));
38847         this_arg_conv.is_owned = false;
38848         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38849         ChannelTypeFeatures_set_zero_conf_required(&this_arg_conv);
38850 }
38851
38852 jboolean  __attribute__((export_name("TS_ChannelTypeFeatures_supports_zero_conf"))) TS_ChannelTypeFeatures_supports_zero_conf(uint32_t this_arg) {
38853         LDKChannelTypeFeatures this_arg_conv;
38854         this_arg_conv.inner = (void*)(this_arg & (~1));
38855         this_arg_conv.is_owned = false;
38856         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
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(uint32_t this_arg) {
38862         LDKInitFeatures this_arg_conv;
38863         this_arg_conv.inner = (void*)(this_arg & (~1));
38864         this_arg_conv.is_owned = false;
38865         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38866         jboolean ret_conv = InitFeatures_requires_zero_conf(&this_arg_conv);
38867         return ret_conv;
38868 }
38869
38870 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_zero_conf"))) TS_NodeFeatures_requires_zero_conf(uint32_t this_arg) {
38871         LDKNodeFeatures this_arg_conv;
38872         this_arg_conv.inner = (void*)(this_arg & (~1));
38873         this_arg_conv.is_owned = false;
38874         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38875         jboolean ret_conv = NodeFeatures_requires_zero_conf(&this_arg_conv);
38876         return ret_conv;
38877 }
38878
38879 jboolean  __attribute__((export_name("TS_ChannelTypeFeatures_requires_zero_conf"))) TS_ChannelTypeFeatures_requires_zero_conf(uint32_t this_arg) {
38880         LDKChannelTypeFeatures this_arg_conv;
38881         this_arg_conv.inner = (void*)(this_arg & (~1));
38882         this_arg_conv.is_owned = false;
38883         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38884         jboolean ret_conv = ChannelTypeFeatures_requires_zero_conf(&this_arg_conv);
38885         return ret_conv;
38886 }
38887
38888 void  __attribute__((export_name("TS_NodeFeatures_set_keysend_optional"))) TS_NodeFeatures_set_keysend_optional(uint32_t this_arg) {
38889         LDKNodeFeatures this_arg_conv;
38890         this_arg_conv.inner = (void*)(this_arg & (~1));
38891         this_arg_conv.is_owned = false;
38892         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38893         NodeFeatures_set_keysend_optional(&this_arg_conv);
38894 }
38895
38896 void  __attribute__((export_name("TS_NodeFeatures_set_keysend_required"))) TS_NodeFeatures_set_keysend_required(uint32_t this_arg) {
38897         LDKNodeFeatures this_arg_conv;
38898         this_arg_conv.inner = (void*)(this_arg & (~1));
38899         this_arg_conv.is_owned = false;
38900         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38901         NodeFeatures_set_keysend_required(&this_arg_conv);
38902 }
38903
38904 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_keysend"))) TS_NodeFeatures_supports_keysend(uint32_t this_arg) {
38905         LDKNodeFeatures this_arg_conv;
38906         this_arg_conv.inner = (void*)(this_arg & (~1));
38907         this_arg_conv.is_owned = false;
38908         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38909         jboolean ret_conv = NodeFeatures_supports_keysend(&this_arg_conv);
38910         return ret_conv;
38911 }
38912
38913 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_keysend"))) TS_NodeFeatures_requires_keysend(uint32_t this_arg) {
38914         LDKNodeFeatures this_arg_conv;
38915         this_arg_conv.inner = (void*)(this_arg & (~1));
38916         this_arg_conv.is_owned = false;
38917         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38918         jboolean ret_conv = NodeFeatures_requires_keysend(&this_arg_conv);
38919         return ret_conv;
38920 }
38921
38922 void  __attribute__((export_name("TS_ShutdownScript_free"))) TS_ShutdownScript_free(uint32_t this_obj) {
38923         LDKShutdownScript this_obj_conv;
38924         this_obj_conv.inner = (void*)(this_obj & (~1));
38925         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38926         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38927         ShutdownScript_free(this_obj_conv);
38928 }
38929
38930 static inline uintptr_t ShutdownScript_clone_ptr(LDKShutdownScript *NONNULL_PTR arg) {
38931         LDKShutdownScript ret_var = ShutdownScript_clone(arg);
38932 uint32_t ret_ref = 0;
38933 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38934 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38935 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38936 ret_ref = (uintptr_t)ret_var.inner;
38937 if (ret_var.is_owned) {
38938         ret_ref |= 1;
38939 }
38940         return ret_ref;
38941 }
38942 uint32_t  __attribute__((export_name("TS_ShutdownScript_clone_ptr"))) TS_ShutdownScript_clone_ptr(uint32_t arg) {
38943         LDKShutdownScript arg_conv;
38944         arg_conv.inner = (void*)(arg & (~1));
38945         arg_conv.is_owned = false;
38946         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38947         uint32_t ret_conv = ShutdownScript_clone_ptr(&arg_conv);
38948         return ret_conv;
38949 }
38950
38951 uint32_t  __attribute__((export_name("TS_ShutdownScript_clone"))) TS_ShutdownScript_clone(uint32_t orig) {
38952         LDKShutdownScript orig_conv;
38953         orig_conv.inner = (void*)(orig & (~1));
38954         orig_conv.is_owned = false;
38955         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38956         LDKShutdownScript ret_var = ShutdownScript_clone(&orig_conv);
38957         uint32_t ret_ref = 0;
38958         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38959         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38960         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38961         ret_ref = (uintptr_t)ret_var.inner;
38962         if (ret_var.is_owned) {
38963                 ret_ref |= 1;
38964         }
38965         return ret_ref;
38966 }
38967
38968 void  __attribute__((export_name("TS_InvalidShutdownScript_free"))) TS_InvalidShutdownScript_free(uint32_t this_obj) {
38969         LDKInvalidShutdownScript this_obj_conv;
38970         this_obj_conv.inner = (void*)(this_obj & (~1));
38971         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38972         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38973         InvalidShutdownScript_free(this_obj_conv);
38974 }
38975
38976 int8_tArray  __attribute__((export_name("TS_InvalidShutdownScript_get_script"))) TS_InvalidShutdownScript_get_script(uint32_t this_ptr) {
38977         LDKInvalidShutdownScript this_ptr_conv;
38978         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38979         this_ptr_conv.is_owned = false;
38980         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
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(uint32_t this_ptr, int8_tArray val) {
38988         LDKInvalidShutdownScript this_ptr_conv;
38989         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38990         this_ptr_conv.is_owned = false;
38991         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38992         LDKCVec_u8Z val_ref;
38993         val_ref.datalen = val->arr_len;
38994         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
38995         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
38996         InvalidShutdownScript_set_script(&this_ptr_conv, val_ref);
38997 }
38998
38999 uint32_t  __attribute__((export_name("TS_InvalidShutdownScript_new"))) TS_InvalidShutdownScript_new(int8_tArray script_arg) {
39000         LDKCVec_u8Z script_arg_ref;
39001         script_arg_ref.datalen = script_arg->arr_len;
39002         script_arg_ref.data = MALLOC(script_arg_ref.datalen, "LDKCVec_u8Z Bytes");
39003         memcpy(script_arg_ref.data, script_arg->elems, script_arg_ref.datalen); FREE(script_arg);
39004         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_new(script_arg_ref);
39005         uint32_t ret_ref = 0;
39006         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39007         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39008         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39009         ret_ref = (uintptr_t)ret_var.inner;
39010         if (ret_var.is_owned) {
39011                 ret_ref |= 1;
39012         }
39013         return ret_ref;
39014 }
39015
39016 static inline uintptr_t InvalidShutdownScript_clone_ptr(LDKInvalidShutdownScript *NONNULL_PTR arg) {
39017         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(arg);
39018 uint32_t ret_ref = 0;
39019 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39020 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39021 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39022 ret_ref = (uintptr_t)ret_var.inner;
39023 if (ret_var.is_owned) {
39024         ret_ref |= 1;
39025 }
39026         return ret_ref;
39027 }
39028 uint32_t  __attribute__((export_name("TS_InvalidShutdownScript_clone_ptr"))) TS_InvalidShutdownScript_clone_ptr(uint32_t arg) {
39029         LDKInvalidShutdownScript arg_conv;
39030         arg_conv.inner = (void*)(arg & (~1));
39031         arg_conv.is_owned = false;
39032         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39033         uint32_t ret_conv = InvalidShutdownScript_clone_ptr(&arg_conv);
39034         return ret_conv;
39035 }
39036
39037 uint32_t  __attribute__((export_name("TS_InvalidShutdownScript_clone"))) TS_InvalidShutdownScript_clone(uint32_t orig) {
39038         LDKInvalidShutdownScript orig_conv;
39039         orig_conv.inner = (void*)(orig & (~1));
39040         orig_conv.is_owned = false;
39041         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39042         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(&orig_conv);
39043         uint32_t ret_ref = 0;
39044         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39045         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39046         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39047         ret_ref = (uintptr_t)ret_var.inner;
39048         if (ret_var.is_owned) {
39049                 ret_ref |= 1;
39050         }
39051         return ret_ref;
39052 }
39053
39054 int8_tArray  __attribute__((export_name("TS_ShutdownScript_write"))) TS_ShutdownScript_write(uint32_t obj) {
39055         LDKShutdownScript obj_conv;
39056         obj_conv.inner = (void*)(obj & (~1));
39057         obj_conv.is_owned = false;
39058         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39059         LDKCVec_u8Z ret_var = ShutdownScript_write(&obj_conv);
39060         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
39061         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
39062         CVec_u8Z_free(ret_var);
39063         return ret_arr;
39064 }
39065
39066 uint32_t  __attribute__((export_name("TS_ShutdownScript_read"))) TS_ShutdownScript_read(int8_tArray ser) {
39067         LDKu8slice ser_ref;
39068         ser_ref.datalen = ser->arr_len;
39069         ser_ref.data = ser->elems;
39070         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
39071         *ret_conv = ShutdownScript_read(ser_ref);
39072         FREE(ser);
39073         return (uint32_t)ret_conv;
39074 }
39075
39076 uint32_t  __attribute__((export_name("TS_ShutdownScript_new_p2wpkh"))) TS_ShutdownScript_new_p2wpkh(int8_tArray pubkey_hash) {
39077         unsigned char pubkey_hash_arr[20];
39078         CHECK(pubkey_hash->arr_len == 20);
39079         memcpy(pubkey_hash_arr, pubkey_hash->elems, 20); FREE(pubkey_hash);
39080         unsigned char (*pubkey_hash_ref)[20] = &pubkey_hash_arr;
39081         LDKShutdownScript ret_var = ShutdownScript_new_p2wpkh(pubkey_hash_ref);
39082         uint32_t ret_ref = 0;
39083         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39084         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39085         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39086         ret_ref = (uintptr_t)ret_var.inner;
39087         if (ret_var.is_owned) {
39088                 ret_ref |= 1;
39089         }
39090         return ret_ref;
39091 }
39092
39093 uint32_t  __attribute__((export_name("TS_ShutdownScript_new_p2wsh"))) TS_ShutdownScript_new_p2wsh(int8_tArray script_hash) {
39094         unsigned char script_hash_arr[32];
39095         CHECK(script_hash->arr_len == 32);
39096         memcpy(script_hash_arr, script_hash->elems, 32); FREE(script_hash);
39097         unsigned char (*script_hash_ref)[32] = &script_hash_arr;
39098         LDKShutdownScript ret_var = ShutdownScript_new_p2wsh(script_hash_ref);
39099         uint32_t ret_ref = 0;
39100         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39101         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39102         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39103         ret_ref = (uintptr_t)ret_var.inner;
39104         if (ret_var.is_owned) {
39105                 ret_ref |= 1;
39106         }
39107         return ret_ref;
39108 }
39109
39110 uint32_t  __attribute__((export_name("TS_ShutdownScript_new_witness_program"))) TS_ShutdownScript_new_witness_program(int8_t version, int8_tArray program) {
39111         
39112         LDKu8slice program_ref;
39113         program_ref.datalen = program->arr_len;
39114         program_ref.data = program->elems;
39115         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
39116         *ret_conv = ShutdownScript_new_witness_program((LDKWitnessVersion){ ._0 = version }, program_ref);
39117         FREE(program);
39118         return (uint32_t)ret_conv;
39119 }
39120
39121 int8_tArray  __attribute__((export_name("TS_ShutdownScript_into_inner"))) TS_ShutdownScript_into_inner(uint32_t this_arg) {
39122         LDKShutdownScript this_arg_conv;
39123         this_arg_conv.inner = (void*)(this_arg & (~1));
39124         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
39125         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39126         this_arg_conv = ShutdownScript_clone(&this_arg_conv);
39127         LDKCVec_u8Z ret_var = ShutdownScript_into_inner(this_arg_conv);
39128         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
39129         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
39130         CVec_u8Z_free(ret_var);
39131         return ret_arr;
39132 }
39133
39134 int8_tArray  __attribute__((export_name("TS_ShutdownScript_as_legacy_pubkey"))) TS_ShutdownScript_as_legacy_pubkey(uint32_t this_arg) {
39135         LDKShutdownScript this_arg_conv;
39136         this_arg_conv.inner = (void*)(this_arg & (~1));
39137         this_arg_conv.is_owned = false;
39138         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39139         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
39140         memcpy(ret_arr->elems, ShutdownScript_as_legacy_pubkey(&this_arg_conv).compressed_form, 33);
39141         return ret_arr;
39142 }
39143
39144 jboolean  __attribute__((export_name("TS_ShutdownScript_is_compatible"))) TS_ShutdownScript_is_compatible(uint32_t this_arg, uint32_t features) {
39145         LDKShutdownScript this_arg_conv;
39146         this_arg_conv.inner = (void*)(this_arg & (~1));
39147         this_arg_conv.is_owned = false;
39148         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39149         LDKInitFeatures features_conv;
39150         features_conv.inner = (void*)(features & (~1));
39151         features_conv.is_owned = false;
39152         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
39153         jboolean ret_conv = ShutdownScript_is_compatible(&this_arg_conv, &features_conv);
39154         return ret_conv;
39155 }
39156
39157 void  __attribute__((export_name("TS_CustomMessageReader_free"))) TS_CustomMessageReader_free(uint32_t this_ptr) {
39158         if ((this_ptr & 1) != 0) return;
39159         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
39160         CHECK_ACCESS(this_ptr_ptr);
39161         LDKCustomMessageReader this_ptr_conv = *(LDKCustomMessageReader*)(this_ptr_ptr);
39162         FREE((void*)this_ptr);
39163         CustomMessageReader_free(this_ptr_conv);
39164 }
39165
39166 static inline uintptr_t Type_clone_ptr(LDKType *NONNULL_PTR arg) {
39167         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
39168         *ret_ret = Type_clone(arg);
39169         return (uint32_t)ret_ret;
39170 }
39171 uint32_t  __attribute__((export_name("TS_Type_clone_ptr"))) TS_Type_clone_ptr(uint32_t arg) {
39172         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
39173         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
39174         LDKType* arg_conv = (LDKType*)arg_ptr;
39175         uint32_t ret_conv = Type_clone_ptr(arg_conv);
39176         return ret_conv;
39177 }
39178
39179 uint32_t  __attribute__((export_name("TS_Type_clone"))) TS_Type_clone(uint32_t orig) {
39180         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
39181         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
39182         LDKType* orig_conv = (LDKType*)orig_ptr;
39183         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
39184         *ret_ret = Type_clone(orig_conv);
39185         return (uint32_t)ret_ret;
39186 }
39187
39188 void  __attribute__((export_name("TS_Type_free"))) TS_Type_free(uint32_t this_ptr) {
39189         if ((this_ptr & 1) != 0) return;
39190         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
39191         CHECK_ACCESS(this_ptr_ptr);
39192         LDKType this_ptr_conv = *(LDKType*)(this_ptr_ptr);
39193         FREE((void*)this_ptr);
39194         Type_free(this_ptr_conv);
39195 }
39196
39197 void  __attribute__((export_name("TS_NodeId_free"))) TS_NodeId_free(uint32_t this_obj) {
39198         LDKNodeId this_obj_conv;
39199         this_obj_conv.inner = (void*)(this_obj & (~1));
39200         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39201         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39202         NodeId_free(this_obj_conv);
39203 }
39204
39205 static inline uintptr_t NodeId_clone_ptr(LDKNodeId *NONNULL_PTR arg) {
39206         LDKNodeId ret_var = NodeId_clone(arg);
39207 uint32_t ret_ref = 0;
39208 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39209 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39210 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39211 ret_ref = (uintptr_t)ret_var.inner;
39212 if (ret_var.is_owned) {
39213         ret_ref |= 1;
39214 }
39215         return ret_ref;
39216 }
39217 uint32_t  __attribute__((export_name("TS_NodeId_clone_ptr"))) TS_NodeId_clone_ptr(uint32_t arg) {
39218         LDKNodeId arg_conv;
39219         arg_conv.inner = (void*)(arg & (~1));
39220         arg_conv.is_owned = false;
39221         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39222         uint32_t ret_conv = NodeId_clone_ptr(&arg_conv);
39223         return ret_conv;
39224 }
39225
39226 uint32_t  __attribute__((export_name("TS_NodeId_clone"))) TS_NodeId_clone(uint32_t orig) {
39227         LDKNodeId orig_conv;
39228         orig_conv.inner = (void*)(orig & (~1));
39229         orig_conv.is_owned = false;
39230         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39231         LDKNodeId ret_var = NodeId_clone(&orig_conv);
39232         uint32_t ret_ref = 0;
39233         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39234         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39235         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39236         ret_ref = (uintptr_t)ret_var.inner;
39237         if (ret_var.is_owned) {
39238                 ret_ref |= 1;
39239         }
39240         return ret_ref;
39241 }
39242
39243 uint32_t  __attribute__((export_name("TS_NodeId_from_pubkey"))) TS_NodeId_from_pubkey(int8_tArray pubkey) {
39244         LDKPublicKey pubkey_ref;
39245         CHECK(pubkey->arr_len == 33);
39246         memcpy(pubkey_ref.compressed_form, pubkey->elems, 33); FREE(pubkey);
39247         LDKNodeId ret_var = NodeId_from_pubkey(pubkey_ref);
39248         uint32_t ret_ref = 0;
39249         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39250         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39251         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39252         ret_ref = (uintptr_t)ret_var.inner;
39253         if (ret_var.is_owned) {
39254                 ret_ref |= 1;
39255         }
39256         return ret_ref;
39257 }
39258
39259 int8_tArray  __attribute__((export_name("TS_NodeId_as_slice"))) TS_NodeId_as_slice(uint32_t this_arg) {
39260         LDKNodeId this_arg_conv;
39261         this_arg_conv.inner = (void*)(this_arg & (~1));
39262         this_arg_conv.is_owned = false;
39263         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39264         LDKu8slice ret_var = NodeId_as_slice(&this_arg_conv);
39265         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
39266         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
39267         return ret_arr;
39268 }
39269
39270 int64_t  __attribute__((export_name("TS_NodeId_hash"))) TS_NodeId_hash(uint32_t o) {
39271         LDKNodeId o_conv;
39272         o_conv.inner = (void*)(o & (~1));
39273         o_conv.is_owned = false;
39274         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
39275         int64_t ret_conv = NodeId_hash(&o_conv);
39276         return ret_conv;
39277 }
39278
39279 int8_tArray  __attribute__((export_name("TS_NodeId_write"))) TS_NodeId_write(uint32_t obj) {
39280         LDKNodeId obj_conv;
39281         obj_conv.inner = (void*)(obj & (~1));
39282         obj_conv.is_owned = false;
39283         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39284         LDKCVec_u8Z ret_var = NodeId_write(&obj_conv);
39285         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
39286         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
39287         CVec_u8Z_free(ret_var);
39288         return ret_arr;
39289 }
39290
39291 uint32_t  __attribute__((export_name("TS_NodeId_read"))) TS_NodeId_read(int8_tArray ser) {
39292         LDKu8slice ser_ref;
39293         ser_ref.datalen = ser->arr_len;
39294         ser_ref.data = ser->elems;
39295         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
39296         *ret_conv = NodeId_read(ser_ref);
39297         FREE(ser);
39298         return (uint32_t)ret_conv;
39299 }
39300
39301 void  __attribute__((export_name("TS_NetworkGraph_free"))) TS_NetworkGraph_free(uint32_t this_obj) {
39302         LDKNetworkGraph this_obj_conv;
39303         this_obj_conv.inner = (void*)(this_obj & (~1));
39304         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39305         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39306         NetworkGraph_free(this_obj_conv);
39307 }
39308
39309 void  __attribute__((export_name("TS_ReadOnlyNetworkGraph_free"))) TS_ReadOnlyNetworkGraph_free(uint32_t this_obj) {
39310         LDKReadOnlyNetworkGraph this_obj_conv;
39311         this_obj_conv.inner = (void*)(this_obj & (~1));
39312         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39313         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39314         ReadOnlyNetworkGraph_free(this_obj_conv);
39315 }
39316
39317 void  __attribute__((export_name("TS_NetworkUpdate_free"))) TS_NetworkUpdate_free(uint32_t this_ptr) {
39318         if ((this_ptr & 1) != 0) return;
39319         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
39320         CHECK_ACCESS(this_ptr_ptr);
39321         LDKNetworkUpdate this_ptr_conv = *(LDKNetworkUpdate*)(this_ptr_ptr);
39322         FREE((void*)this_ptr);
39323         NetworkUpdate_free(this_ptr_conv);
39324 }
39325
39326 static inline uintptr_t NetworkUpdate_clone_ptr(LDKNetworkUpdate *NONNULL_PTR arg) {
39327         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
39328         *ret_copy = NetworkUpdate_clone(arg);
39329 uint32_t ret_ref = (uintptr_t)ret_copy;
39330         return ret_ref;
39331 }
39332 uint32_t  __attribute__((export_name("TS_NetworkUpdate_clone_ptr"))) TS_NetworkUpdate_clone_ptr(uint32_t arg) {
39333         LDKNetworkUpdate* arg_conv = (LDKNetworkUpdate*)arg;
39334         uint32_t ret_conv = NetworkUpdate_clone_ptr(arg_conv);
39335         return ret_conv;
39336 }
39337
39338 uint32_t  __attribute__((export_name("TS_NetworkUpdate_clone"))) TS_NetworkUpdate_clone(uint32_t orig) {
39339         LDKNetworkUpdate* orig_conv = (LDKNetworkUpdate*)orig;
39340         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
39341         *ret_copy = NetworkUpdate_clone(orig_conv);
39342         uint32_t ret_ref = (uintptr_t)ret_copy;
39343         return ret_ref;
39344 }
39345
39346 uint32_t  __attribute__((export_name("TS_NetworkUpdate_channel_update_message"))) TS_NetworkUpdate_channel_update_message(uint32_t msg) {
39347         LDKChannelUpdate msg_conv;
39348         msg_conv.inner = (void*)(msg & (~1));
39349         msg_conv.is_owned = (msg & 1) || (msg == 0);
39350         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
39351         msg_conv = ChannelUpdate_clone(&msg_conv);
39352         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
39353         *ret_copy = NetworkUpdate_channel_update_message(msg_conv);
39354         uint32_t ret_ref = (uintptr_t)ret_copy;
39355         return ret_ref;
39356 }
39357
39358 uint32_t  __attribute__((export_name("TS_NetworkUpdate_channel_failure"))) TS_NetworkUpdate_channel_failure(int64_t short_channel_id, jboolean is_permanent) {
39359         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
39360         *ret_copy = NetworkUpdate_channel_failure(short_channel_id, is_permanent);
39361         uint32_t ret_ref = (uintptr_t)ret_copy;
39362         return ret_ref;
39363 }
39364
39365 uint32_t  __attribute__((export_name("TS_NetworkUpdate_node_failure"))) TS_NetworkUpdate_node_failure(int8_tArray node_id, jboolean is_permanent) {
39366         LDKPublicKey node_id_ref;
39367         CHECK(node_id->arr_len == 33);
39368         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
39369         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
39370         *ret_copy = NetworkUpdate_node_failure(node_id_ref, is_permanent);
39371         uint32_t ret_ref = (uintptr_t)ret_copy;
39372         return ret_ref;
39373 }
39374
39375 int8_tArray  __attribute__((export_name("TS_NetworkUpdate_write"))) TS_NetworkUpdate_write(uint32_t obj) {
39376         LDKNetworkUpdate* obj_conv = (LDKNetworkUpdate*)obj;
39377         LDKCVec_u8Z ret_var = NetworkUpdate_write(obj_conv);
39378         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
39379         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
39380         CVec_u8Z_free(ret_var);
39381         return ret_arr;
39382 }
39383
39384 uint32_t  __attribute__((export_name("TS_NetworkUpdate_read"))) TS_NetworkUpdate_read(int8_tArray ser) {
39385         LDKu8slice ser_ref;
39386         ser_ref.datalen = ser->arr_len;
39387         ser_ref.data = ser->elems;
39388         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
39389         *ret_conv = NetworkUpdate_read(ser_ref);
39390         FREE(ser);
39391         return (uint32_t)ret_conv;
39392 }
39393
39394 void  __attribute__((export_name("TS_P2PGossipSync_free"))) TS_P2PGossipSync_free(uint32_t this_obj) {
39395         LDKP2PGossipSync this_obj_conv;
39396         this_obj_conv.inner = (void*)(this_obj & (~1));
39397         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39398         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39399         P2PGossipSync_free(this_obj_conv);
39400 }
39401
39402 uint32_t  __attribute__((export_name("TS_P2PGossipSync_new"))) TS_P2PGossipSync_new(uint32_t network_graph, uint32_t chain_access, uint32_t logger) {
39403         LDKNetworkGraph network_graph_conv;
39404         network_graph_conv.inner = (void*)(network_graph & (~1));
39405         network_graph_conv.is_owned = false;
39406         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
39407         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
39408         CHECK_ACCESS(chain_access_ptr);
39409         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
39410         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
39411         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
39412                 // Manually implement clone for Java trait instances
39413                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
39414                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
39415                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
39416                 }
39417         }
39418         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
39419         CHECK_ACCESS(logger_ptr);
39420         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
39421         if (logger_conv.free == LDKLogger_JCalls_free) {
39422                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
39423                 LDKLogger_JCalls_cloned(&logger_conv);
39424         }
39425         LDKP2PGossipSync ret_var = P2PGossipSync_new(&network_graph_conv, chain_access_conv, logger_conv);
39426         uint32_t ret_ref = 0;
39427         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39428         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39429         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39430         ret_ref = (uintptr_t)ret_var.inner;
39431         if (ret_var.is_owned) {
39432                 ret_ref |= 1;
39433         }
39434         return ret_ref;
39435 }
39436
39437 void  __attribute__((export_name("TS_P2PGossipSync_add_chain_access"))) TS_P2PGossipSync_add_chain_access(uint32_t this_arg, uint32_t chain_access) {
39438         LDKP2PGossipSync this_arg_conv;
39439         this_arg_conv.inner = (void*)(this_arg & (~1));
39440         this_arg_conv.is_owned = false;
39441         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39442         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
39443         CHECK_ACCESS(chain_access_ptr);
39444         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
39445         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
39446         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
39447                 // Manually implement clone for Java trait instances
39448                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
39449                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
39450                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
39451                 }
39452         }
39453         P2PGossipSync_add_chain_access(&this_arg_conv, chain_access_conv);
39454 }
39455
39456 uint32_t  __attribute__((export_name("TS_NetworkGraph_as_EventHandler"))) TS_NetworkGraph_as_EventHandler(uint32_t this_arg) {
39457         LDKNetworkGraph this_arg_conv;
39458         this_arg_conv.inner = (void*)(this_arg & (~1));
39459         this_arg_conv.is_owned = false;
39460         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39461         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
39462         *ret_ret = NetworkGraph_as_EventHandler(&this_arg_conv);
39463         return (uint32_t)ret_ret;
39464 }
39465
39466 uint32_t  __attribute__((export_name("TS_P2PGossipSync_as_RoutingMessageHandler"))) TS_P2PGossipSync_as_RoutingMessageHandler(uint32_t this_arg) {
39467         LDKP2PGossipSync this_arg_conv;
39468         this_arg_conv.inner = (void*)(this_arg & (~1));
39469         this_arg_conv.is_owned = false;
39470         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39471         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
39472         *ret_ret = P2PGossipSync_as_RoutingMessageHandler(&this_arg_conv);
39473         return (uint32_t)ret_ret;
39474 }
39475
39476 uint32_t  __attribute__((export_name("TS_P2PGossipSync_as_MessageSendEventsProvider"))) TS_P2PGossipSync_as_MessageSendEventsProvider(uint32_t this_arg) {
39477         LDKP2PGossipSync this_arg_conv;
39478         this_arg_conv.inner = (void*)(this_arg & (~1));
39479         this_arg_conv.is_owned = false;
39480         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39481         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
39482         *ret_ret = P2PGossipSync_as_MessageSendEventsProvider(&this_arg_conv);
39483         return (uint32_t)ret_ret;
39484 }
39485
39486 void  __attribute__((export_name("TS_ChannelUpdateInfo_free"))) TS_ChannelUpdateInfo_free(uint32_t this_obj) {
39487         LDKChannelUpdateInfo this_obj_conv;
39488         this_obj_conv.inner = (void*)(this_obj & (~1));
39489         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39490         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39491         ChannelUpdateInfo_free(this_obj_conv);
39492 }
39493
39494 int32_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_last_update"))) TS_ChannelUpdateInfo_get_last_update(uint32_t this_ptr) {
39495         LDKChannelUpdateInfo this_ptr_conv;
39496         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39497         this_ptr_conv.is_owned = false;
39498         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39499         int32_t ret_conv = ChannelUpdateInfo_get_last_update(&this_ptr_conv);
39500         return ret_conv;
39501 }
39502
39503 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_last_update"))) TS_ChannelUpdateInfo_set_last_update(uint32_t this_ptr, int32_t val) {
39504         LDKChannelUpdateInfo this_ptr_conv;
39505         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39506         this_ptr_conv.is_owned = false;
39507         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39508         ChannelUpdateInfo_set_last_update(&this_ptr_conv, val);
39509 }
39510
39511 jboolean  __attribute__((export_name("TS_ChannelUpdateInfo_get_enabled"))) TS_ChannelUpdateInfo_get_enabled(uint32_t this_ptr) {
39512         LDKChannelUpdateInfo this_ptr_conv;
39513         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39514         this_ptr_conv.is_owned = false;
39515         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39516         jboolean ret_conv = ChannelUpdateInfo_get_enabled(&this_ptr_conv);
39517         return ret_conv;
39518 }
39519
39520 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_enabled"))) TS_ChannelUpdateInfo_set_enabled(uint32_t this_ptr, jboolean val) {
39521         LDKChannelUpdateInfo this_ptr_conv;
39522         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39523         this_ptr_conv.is_owned = false;
39524         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39525         ChannelUpdateInfo_set_enabled(&this_ptr_conv, val);
39526 }
39527
39528 int16_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_cltv_expiry_delta"))) TS_ChannelUpdateInfo_get_cltv_expiry_delta(uint32_t this_ptr) {
39529         LDKChannelUpdateInfo this_ptr_conv;
39530         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39531         this_ptr_conv.is_owned = false;
39532         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39533         int16_t ret_conv = ChannelUpdateInfo_get_cltv_expiry_delta(&this_ptr_conv);
39534         return ret_conv;
39535 }
39536
39537 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_cltv_expiry_delta"))) TS_ChannelUpdateInfo_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
39538         LDKChannelUpdateInfo this_ptr_conv;
39539         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39540         this_ptr_conv.is_owned = false;
39541         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39542         ChannelUpdateInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
39543 }
39544
39545 int64_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_htlc_minimum_msat"))) TS_ChannelUpdateInfo_get_htlc_minimum_msat(uint32_t this_ptr) {
39546         LDKChannelUpdateInfo this_ptr_conv;
39547         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39548         this_ptr_conv.is_owned = false;
39549         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39550         int64_t ret_conv = ChannelUpdateInfo_get_htlc_minimum_msat(&this_ptr_conv);
39551         return ret_conv;
39552 }
39553
39554 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_htlc_minimum_msat"))) TS_ChannelUpdateInfo_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
39555         LDKChannelUpdateInfo this_ptr_conv;
39556         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39557         this_ptr_conv.is_owned = false;
39558         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39559         ChannelUpdateInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
39560 }
39561
39562 int64_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_htlc_maximum_msat"))) TS_ChannelUpdateInfo_get_htlc_maximum_msat(uint32_t this_ptr) {
39563         LDKChannelUpdateInfo this_ptr_conv;
39564         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39565         this_ptr_conv.is_owned = false;
39566         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39567         int64_t ret_conv = ChannelUpdateInfo_get_htlc_maximum_msat(&this_ptr_conv);
39568         return ret_conv;
39569 }
39570
39571 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_htlc_maximum_msat"))) TS_ChannelUpdateInfo_set_htlc_maximum_msat(uint32_t this_ptr, int64_t val) {
39572         LDKChannelUpdateInfo this_ptr_conv;
39573         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39574         this_ptr_conv.is_owned = false;
39575         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39576         ChannelUpdateInfo_set_htlc_maximum_msat(&this_ptr_conv, val);
39577 }
39578
39579 uint32_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_fees"))) TS_ChannelUpdateInfo_get_fees(uint32_t this_ptr) {
39580         LDKChannelUpdateInfo this_ptr_conv;
39581         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39582         this_ptr_conv.is_owned = false;
39583         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39584         LDKRoutingFees ret_var = ChannelUpdateInfo_get_fees(&this_ptr_conv);
39585         uint32_t ret_ref = 0;
39586         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39587         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39588         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39589         ret_ref = (uintptr_t)ret_var.inner;
39590         if (ret_var.is_owned) {
39591                 ret_ref |= 1;
39592         }
39593         return ret_ref;
39594 }
39595
39596 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_fees"))) TS_ChannelUpdateInfo_set_fees(uint32_t this_ptr, uint32_t val) {
39597         LDKChannelUpdateInfo this_ptr_conv;
39598         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39599         this_ptr_conv.is_owned = false;
39600         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39601         LDKRoutingFees val_conv;
39602         val_conv.inner = (void*)(val & (~1));
39603         val_conv.is_owned = (val & 1) || (val == 0);
39604         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39605         val_conv = RoutingFees_clone(&val_conv);
39606         ChannelUpdateInfo_set_fees(&this_ptr_conv, val_conv);
39607 }
39608
39609 uint32_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_last_update_message"))) TS_ChannelUpdateInfo_get_last_update_message(uint32_t this_ptr) {
39610         LDKChannelUpdateInfo this_ptr_conv;
39611         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39612         this_ptr_conv.is_owned = false;
39613         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39614         LDKChannelUpdate ret_var = ChannelUpdateInfo_get_last_update_message(&this_ptr_conv);
39615         uint32_t ret_ref = 0;
39616         if ((uintptr_t)ret_var.inner > 4096) {
39617                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39618                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39619         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39620                 ret_ref = (uintptr_t)ret_var.inner;
39621                 if (ret_var.is_owned) {
39622                         ret_ref |= 1;
39623                 }
39624         }
39625         return ret_ref;
39626 }
39627
39628 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_last_update_message"))) TS_ChannelUpdateInfo_set_last_update_message(uint32_t this_ptr, uint32_t val) {
39629         LDKChannelUpdateInfo this_ptr_conv;
39630         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39631         this_ptr_conv.is_owned = false;
39632         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39633         LDKChannelUpdate val_conv;
39634         val_conv.inner = (void*)(val & (~1));
39635         val_conv.is_owned = (val & 1) || (val == 0);
39636         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39637         val_conv = ChannelUpdate_clone(&val_conv);
39638         ChannelUpdateInfo_set_last_update_message(&this_ptr_conv, val_conv);
39639 }
39640
39641 uint32_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, uint32_t fees_arg, uint32_t last_update_message_arg) {
39642         LDKRoutingFees fees_arg_conv;
39643         fees_arg_conv.inner = (void*)(fees_arg & (~1));
39644         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
39645         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
39646         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
39647         LDKChannelUpdate last_update_message_arg_conv;
39648         last_update_message_arg_conv.inner = (void*)(last_update_message_arg & (~1));
39649         last_update_message_arg_conv.is_owned = (last_update_message_arg & 1) || (last_update_message_arg == 0);
39650         CHECK_INNER_FIELD_ACCESS_OR_NULL(last_update_message_arg_conv);
39651         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
39652         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);
39653         uint32_t ret_ref = 0;
39654         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39655         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39656         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39657         ret_ref = (uintptr_t)ret_var.inner;
39658         if (ret_var.is_owned) {
39659                 ret_ref |= 1;
39660         }
39661         return ret_ref;
39662 }
39663
39664 static inline uintptr_t ChannelUpdateInfo_clone_ptr(LDKChannelUpdateInfo *NONNULL_PTR arg) {
39665         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(arg);
39666 uint32_t ret_ref = 0;
39667 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39668 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39669 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39670 ret_ref = (uintptr_t)ret_var.inner;
39671 if (ret_var.is_owned) {
39672         ret_ref |= 1;
39673 }
39674         return ret_ref;
39675 }
39676 uint32_t  __attribute__((export_name("TS_ChannelUpdateInfo_clone_ptr"))) TS_ChannelUpdateInfo_clone_ptr(uint32_t arg) {
39677         LDKChannelUpdateInfo arg_conv;
39678         arg_conv.inner = (void*)(arg & (~1));
39679         arg_conv.is_owned = false;
39680         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39681         uint32_t ret_conv = ChannelUpdateInfo_clone_ptr(&arg_conv);
39682         return ret_conv;
39683 }
39684
39685 uint32_t  __attribute__((export_name("TS_ChannelUpdateInfo_clone"))) TS_ChannelUpdateInfo_clone(uint32_t orig) {
39686         LDKChannelUpdateInfo orig_conv;
39687         orig_conv.inner = (void*)(orig & (~1));
39688         orig_conv.is_owned = false;
39689         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39690         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(&orig_conv);
39691         uint32_t ret_ref = 0;
39692         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39693         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39694         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39695         ret_ref = (uintptr_t)ret_var.inner;
39696         if (ret_var.is_owned) {
39697                 ret_ref |= 1;
39698         }
39699         return ret_ref;
39700 }
39701
39702 int8_tArray  __attribute__((export_name("TS_ChannelUpdateInfo_write"))) TS_ChannelUpdateInfo_write(uint32_t obj) {
39703         LDKChannelUpdateInfo obj_conv;
39704         obj_conv.inner = (void*)(obj & (~1));
39705         obj_conv.is_owned = false;
39706         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39707         LDKCVec_u8Z ret_var = ChannelUpdateInfo_write(&obj_conv);
39708         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
39709         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
39710         CVec_u8Z_free(ret_var);
39711         return ret_arr;
39712 }
39713
39714 uint32_t  __attribute__((export_name("TS_ChannelUpdateInfo_read"))) TS_ChannelUpdateInfo_read(int8_tArray ser) {
39715         LDKu8slice ser_ref;
39716         ser_ref.datalen = ser->arr_len;
39717         ser_ref.data = ser->elems;
39718         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
39719         *ret_conv = ChannelUpdateInfo_read(ser_ref);
39720         FREE(ser);
39721         return (uint32_t)ret_conv;
39722 }
39723
39724 void  __attribute__((export_name("TS_ChannelInfo_free"))) TS_ChannelInfo_free(uint32_t this_obj) {
39725         LDKChannelInfo this_obj_conv;
39726         this_obj_conv.inner = (void*)(this_obj & (~1));
39727         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39728         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39729         ChannelInfo_free(this_obj_conv);
39730 }
39731
39732 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_features"))) TS_ChannelInfo_get_features(uint32_t this_ptr) {
39733         LDKChannelInfo this_ptr_conv;
39734         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39735         this_ptr_conv.is_owned = false;
39736         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39737         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
39738         uint32_t ret_ref = 0;
39739         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39740         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39741         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39742         ret_ref = (uintptr_t)ret_var.inner;
39743         if (ret_var.is_owned) {
39744                 ret_ref |= 1;
39745         }
39746         return ret_ref;
39747 }
39748
39749 void  __attribute__((export_name("TS_ChannelInfo_set_features"))) TS_ChannelInfo_set_features(uint32_t this_ptr, uint32_t val) {
39750         LDKChannelInfo this_ptr_conv;
39751         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39752         this_ptr_conv.is_owned = false;
39753         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39754         LDKChannelFeatures val_conv;
39755         val_conv.inner = (void*)(val & (~1));
39756         val_conv.is_owned = (val & 1) || (val == 0);
39757         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39758         val_conv = ChannelFeatures_clone(&val_conv);
39759         ChannelInfo_set_features(&this_ptr_conv, val_conv);
39760 }
39761
39762 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_node_one"))) TS_ChannelInfo_get_node_one(uint32_t this_ptr) {
39763         LDKChannelInfo this_ptr_conv;
39764         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39765         this_ptr_conv.is_owned = false;
39766         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39767         LDKNodeId ret_var = ChannelInfo_get_node_one(&this_ptr_conv);
39768         uint32_t ret_ref = 0;
39769         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39770         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39771         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39772         ret_ref = (uintptr_t)ret_var.inner;
39773         if (ret_var.is_owned) {
39774                 ret_ref |= 1;
39775         }
39776         return ret_ref;
39777 }
39778
39779 void  __attribute__((export_name("TS_ChannelInfo_set_node_one"))) TS_ChannelInfo_set_node_one(uint32_t this_ptr, uint32_t val) {
39780         LDKChannelInfo this_ptr_conv;
39781         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39782         this_ptr_conv.is_owned = false;
39783         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39784         LDKNodeId val_conv;
39785         val_conv.inner = (void*)(val & (~1));
39786         val_conv.is_owned = (val & 1) || (val == 0);
39787         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39788         val_conv = NodeId_clone(&val_conv);
39789         ChannelInfo_set_node_one(&this_ptr_conv, val_conv);
39790 }
39791
39792 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_one_to_two"))) TS_ChannelInfo_get_one_to_two(uint32_t this_ptr) {
39793         LDKChannelInfo this_ptr_conv;
39794         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39795         this_ptr_conv.is_owned = false;
39796         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39797         LDKChannelUpdateInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
39798         uint32_t ret_ref = 0;
39799         if ((uintptr_t)ret_var.inner > 4096) {
39800                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39801                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39802         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39803                 ret_ref = (uintptr_t)ret_var.inner;
39804                 if (ret_var.is_owned) {
39805                         ret_ref |= 1;
39806                 }
39807         }
39808         return ret_ref;
39809 }
39810
39811 void  __attribute__((export_name("TS_ChannelInfo_set_one_to_two"))) TS_ChannelInfo_set_one_to_two(uint32_t this_ptr, uint32_t val) {
39812         LDKChannelInfo this_ptr_conv;
39813         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39814         this_ptr_conv.is_owned = false;
39815         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39816         LDKChannelUpdateInfo val_conv;
39817         val_conv.inner = (void*)(val & (~1));
39818         val_conv.is_owned = (val & 1) || (val == 0);
39819         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39820         val_conv = ChannelUpdateInfo_clone(&val_conv);
39821         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
39822 }
39823
39824 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_node_two"))) TS_ChannelInfo_get_node_two(uint32_t this_ptr) {
39825         LDKChannelInfo this_ptr_conv;
39826         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39827         this_ptr_conv.is_owned = false;
39828         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39829         LDKNodeId ret_var = ChannelInfo_get_node_two(&this_ptr_conv);
39830         uint32_t ret_ref = 0;
39831         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39832         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39833         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39834         ret_ref = (uintptr_t)ret_var.inner;
39835         if (ret_var.is_owned) {
39836                 ret_ref |= 1;
39837         }
39838         return ret_ref;
39839 }
39840
39841 void  __attribute__((export_name("TS_ChannelInfo_set_node_two"))) TS_ChannelInfo_set_node_two(uint32_t this_ptr, uint32_t val) {
39842         LDKChannelInfo this_ptr_conv;
39843         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39844         this_ptr_conv.is_owned = false;
39845         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39846         LDKNodeId val_conv;
39847         val_conv.inner = (void*)(val & (~1));
39848         val_conv.is_owned = (val & 1) || (val == 0);
39849         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39850         val_conv = NodeId_clone(&val_conv);
39851         ChannelInfo_set_node_two(&this_ptr_conv, val_conv);
39852 }
39853
39854 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_two_to_one"))) TS_ChannelInfo_get_two_to_one(uint32_t this_ptr) {
39855         LDKChannelInfo this_ptr_conv;
39856         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39857         this_ptr_conv.is_owned = false;
39858         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39859         LDKChannelUpdateInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
39860         uint32_t ret_ref = 0;
39861         if ((uintptr_t)ret_var.inner > 4096) {
39862                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39863                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39864         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39865                 ret_ref = (uintptr_t)ret_var.inner;
39866                 if (ret_var.is_owned) {
39867                         ret_ref |= 1;
39868                 }
39869         }
39870         return ret_ref;
39871 }
39872
39873 void  __attribute__((export_name("TS_ChannelInfo_set_two_to_one"))) TS_ChannelInfo_set_two_to_one(uint32_t this_ptr, uint32_t val) {
39874         LDKChannelInfo this_ptr_conv;
39875         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39876         this_ptr_conv.is_owned = false;
39877         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39878         LDKChannelUpdateInfo val_conv;
39879         val_conv.inner = (void*)(val & (~1));
39880         val_conv.is_owned = (val & 1) || (val == 0);
39881         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39882         val_conv = ChannelUpdateInfo_clone(&val_conv);
39883         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
39884 }
39885
39886 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_capacity_sats"))) TS_ChannelInfo_get_capacity_sats(uint32_t this_ptr) {
39887         LDKChannelInfo this_ptr_conv;
39888         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39889         this_ptr_conv.is_owned = false;
39890         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39891         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
39892         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
39893         uint32_t ret_ref = (uintptr_t)ret_copy;
39894         return ret_ref;
39895 }
39896
39897 void  __attribute__((export_name("TS_ChannelInfo_set_capacity_sats"))) TS_ChannelInfo_set_capacity_sats(uint32_t this_ptr, uint32_t val) {
39898         LDKChannelInfo this_ptr_conv;
39899         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39900         this_ptr_conv.is_owned = false;
39901         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39902         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
39903         CHECK_ACCESS(val_ptr);
39904         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
39905         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
39906         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
39907 }
39908
39909 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_announcement_message"))) TS_ChannelInfo_get_announcement_message(uint32_t this_ptr) {
39910         LDKChannelInfo this_ptr_conv;
39911         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39912         this_ptr_conv.is_owned = false;
39913         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39914         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
39915         uint32_t ret_ref = 0;
39916         if ((uintptr_t)ret_var.inner > 4096) {
39917                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39918                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39919         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39920                 ret_ref = (uintptr_t)ret_var.inner;
39921                 if (ret_var.is_owned) {
39922                         ret_ref |= 1;
39923                 }
39924         }
39925         return ret_ref;
39926 }
39927
39928 void  __attribute__((export_name("TS_ChannelInfo_set_announcement_message"))) TS_ChannelInfo_set_announcement_message(uint32_t this_ptr, uint32_t val) {
39929         LDKChannelInfo this_ptr_conv;
39930         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39931         this_ptr_conv.is_owned = false;
39932         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39933         LDKChannelAnnouncement val_conv;
39934         val_conv.inner = (void*)(val & (~1));
39935         val_conv.is_owned = (val & 1) || (val == 0);
39936         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39937         val_conv = ChannelAnnouncement_clone(&val_conv);
39938         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
39939 }
39940
39941 static inline uintptr_t ChannelInfo_clone_ptr(LDKChannelInfo *NONNULL_PTR arg) {
39942         LDKChannelInfo ret_var = ChannelInfo_clone(arg);
39943 uint32_t ret_ref = 0;
39944 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39945 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39946 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39947 ret_ref = (uintptr_t)ret_var.inner;
39948 if (ret_var.is_owned) {
39949         ret_ref |= 1;
39950 }
39951         return ret_ref;
39952 }
39953 uint32_t  __attribute__((export_name("TS_ChannelInfo_clone_ptr"))) TS_ChannelInfo_clone_ptr(uint32_t arg) {
39954         LDKChannelInfo arg_conv;
39955         arg_conv.inner = (void*)(arg & (~1));
39956         arg_conv.is_owned = false;
39957         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39958         uint32_t ret_conv = ChannelInfo_clone_ptr(&arg_conv);
39959         return ret_conv;
39960 }
39961
39962 uint32_t  __attribute__((export_name("TS_ChannelInfo_clone"))) TS_ChannelInfo_clone(uint32_t orig) {
39963         LDKChannelInfo orig_conv;
39964         orig_conv.inner = (void*)(orig & (~1));
39965         orig_conv.is_owned = false;
39966         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39967         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
39968         uint32_t ret_ref = 0;
39969         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39970         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39971         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39972         ret_ref = (uintptr_t)ret_var.inner;
39973         if (ret_var.is_owned) {
39974                 ret_ref |= 1;
39975         }
39976         return ret_ref;
39977 }
39978
39979 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_directional_info"))) TS_ChannelInfo_get_directional_info(uint32_t this_arg, int8_t channel_flags) {
39980         LDKChannelInfo this_arg_conv;
39981         this_arg_conv.inner = (void*)(this_arg & (~1));
39982         this_arg_conv.is_owned = false;
39983         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39984         LDKChannelUpdateInfo ret_var = ChannelInfo_get_directional_info(&this_arg_conv, channel_flags);
39985         uint32_t ret_ref = 0;
39986         if ((uintptr_t)ret_var.inner > 4096) {
39987                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39988                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39989         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39990                 ret_ref = (uintptr_t)ret_var.inner;
39991                 if (ret_var.is_owned) {
39992                         ret_ref |= 1;
39993                 }
39994         }
39995         return ret_ref;
39996 }
39997
39998 int8_tArray  __attribute__((export_name("TS_ChannelInfo_write"))) TS_ChannelInfo_write(uint32_t obj) {
39999         LDKChannelInfo obj_conv;
40000         obj_conv.inner = (void*)(obj & (~1));
40001         obj_conv.is_owned = false;
40002         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40003         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
40004         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
40005         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
40006         CVec_u8Z_free(ret_var);
40007         return ret_arr;
40008 }
40009
40010 uint32_t  __attribute__((export_name("TS_ChannelInfo_read"))) TS_ChannelInfo_read(int8_tArray ser) {
40011         LDKu8slice ser_ref;
40012         ser_ref.datalen = ser->arr_len;
40013         ser_ref.data = ser->elems;
40014         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
40015         *ret_conv = ChannelInfo_read(ser_ref);
40016         FREE(ser);
40017         return (uint32_t)ret_conv;
40018 }
40019
40020 void  __attribute__((export_name("TS_DirectedChannelInfo_free"))) TS_DirectedChannelInfo_free(uint32_t this_obj) {
40021         LDKDirectedChannelInfo this_obj_conv;
40022         this_obj_conv.inner = (void*)(this_obj & (~1));
40023         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40024         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40025         DirectedChannelInfo_free(this_obj_conv);
40026 }
40027
40028 static inline uintptr_t DirectedChannelInfo_clone_ptr(LDKDirectedChannelInfo *NONNULL_PTR arg) {
40029         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(arg);
40030 uint32_t ret_ref = 0;
40031 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40032 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40033 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40034 ret_ref = (uintptr_t)ret_var.inner;
40035 if (ret_var.is_owned) {
40036         ret_ref |= 1;
40037 }
40038         return ret_ref;
40039 }
40040 uint32_t  __attribute__((export_name("TS_DirectedChannelInfo_clone_ptr"))) TS_DirectedChannelInfo_clone_ptr(uint32_t arg) {
40041         LDKDirectedChannelInfo arg_conv;
40042         arg_conv.inner = (void*)(arg & (~1));
40043         arg_conv.is_owned = false;
40044         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40045         uint32_t ret_conv = DirectedChannelInfo_clone_ptr(&arg_conv);
40046         return ret_conv;
40047 }
40048
40049 uint32_t  __attribute__((export_name("TS_DirectedChannelInfo_clone"))) TS_DirectedChannelInfo_clone(uint32_t orig) {
40050         LDKDirectedChannelInfo orig_conv;
40051         orig_conv.inner = (void*)(orig & (~1));
40052         orig_conv.is_owned = false;
40053         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40054         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(&orig_conv);
40055         uint32_t ret_ref = 0;
40056         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40057         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40058         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40059         ret_ref = (uintptr_t)ret_var.inner;
40060         if (ret_var.is_owned) {
40061                 ret_ref |= 1;
40062         }
40063         return ret_ref;
40064 }
40065
40066 uint32_t  __attribute__((export_name("TS_DirectedChannelInfo_channel"))) TS_DirectedChannelInfo_channel(uint32_t this_arg) {
40067         LDKDirectedChannelInfo this_arg_conv;
40068         this_arg_conv.inner = (void*)(this_arg & (~1));
40069         this_arg_conv.is_owned = false;
40070         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40071         LDKChannelInfo ret_var = DirectedChannelInfo_channel(&this_arg_conv);
40072         uint32_t ret_ref = 0;
40073         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40074         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40075         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40076         ret_ref = (uintptr_t)ret_var.inner;
40077         if (ret_var.is_owned) {
40078                 ret_ref |= 1;
40079         }
40080         return ret_ref;
40081 }
40082
40083 uint32_t  __attribute__((export_name("TS_DirectedChannelInfo_direction"))) TS_DirectedChannelInfo_direction(uint32_t this_arg) {
40084         LDKDirectedChannelInfo this_arg_conv;
40085         this_arg_conv.inner = (void*)(this_arg & (~1));
40086         this_arg_conv.is_owned = false;
40087         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40088         LDKChannelUpdateInfo ret_var = DirectedChannelInfo_direction(&this_arg_conv);
40089         uint32_t ret_ref = 0;
40090         if ((uintptr_t)ret_var.inner > 4096) {
40091                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40092                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40093         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40094                 ret_ref = (uintptr_t)ret_var.inner;
40095                 if (ret_var.is_owned) {
40096                         ret_ref |= 1;
40097                 }
40098         }
40099         return ret_ref;
40100 }
40101
40102 int64_t  __attribute__((export_name("TS_DirectedChannelInfo_htlc_maximum_msat"))) TS_DirectedChannelInfo_htlc_maximum_msat(uint32_t this_arg) {
40103         LDKDirectedChannelInfo this_arg_conv;
40104         this_arg_conv.inner = (void*)(this_arg & (~1));
40105         this_arg_conv.is_owned = false;
40106         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40107         int64_t ret_conv = DirectedChannelInfo_htlc_maximum_msat(&this_arg_conv);
40108         return ret_conv;
40109 }
40110
40111 uint32_t  __attribute__((export_name("TS_DirectedChannelInfo_effective_capacity"))) TS_DirectedChannelInfo_effective_capacity(uint32_t this_arg) {
40112         LDKDirectedChannelInfo this_arg_conv;
40113         this_arg_conv.inner = (void*)(this_arg & (~1));
40114         this_arg_conv.is_owned = false;
40115         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40116         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
40117         *ret_copy = DirectedChannelInfo_effective_capacity(&this_arg_conv);
40118         uint32_t ret_ref = (uintptr_t)ret_copy;
40119         return ret_ref;
40120 }
40121
40122 void  __attribute__((export_name("TS_EffectiveCapacity_free"))) TS_EffectiveCapacity_free(uint32_t this_ptr) {
40123         if ((this_ptr & 1) != 0) return;
40124         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
40125         CHECK_ACCESS(this_ptr_ptr);
40126         LDKEffectiveCapacity this_ptr_conv = *(LDKEffectiveCapacity*)(this_ptr_ptr);
40127         FREE((void*)this_ptr);
40128         EffectiveCapacity_free(this_ptr_conv);
40129 }
40130
40131 static inline uintptr_t EffectiveCapacity_clone_ptr(LDKEffectiveCapacity *NONNULL_PTR arg) {
40132         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
40133         *ret_copy = EffectiveCapacity_clone(arg);
40134 uint32_t ret_ref = (uintptr_t)ret_copy;
40135         return ret_ref;
40136 }
40137 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_clone_ptr"))) TS_EffectiveCapacity_clone_ptr(uint32_t arg) {
40138         LDKEffectiveCapacity* arg_conv = (LDKEffectiveCapacity*)arg;
40139         uint32_t ret_conv = EffectiveCapacity_clone_ptr(arg_conv);
40140         return ret_conv;
40141 }
40142
40143 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_clone"))) TS_EffectiveCapacity_clone(uint32_t orig) {
40144         LDKEffectiveCapacity* orig_conv = (LDKEffectiveCapacity*)orig;
40145         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
40146         *ret_copy = EffectiveCapacity_clone(orig_conv);
40147         uint32_t ret_ref = (uintptr_t)ret_copy;
40148         return ret_ref;
40149 }
40150
40151 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_exact_liquidity"))) TS_EffectiveCapacity_exact_liquidity(int64_t liquidity_msat) {
40152         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
40153         *ret_copy = EffectiveCapacity_exact_liquidity(liquidity_msat);
40154         uint32_t ret_ref = (uintptr_t)ret_copy;
40155         return ret_ref;
40156 }
40157
40158 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_maximum_htlc"))) TS_EffectiveCapacity_maximum_htlc(int64_t amount_msat) {
40159         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
40160         *ret_copy = EffectiveCapacity_maximum_htlc(amount_msat);
40161         uint32_t ret_ref = (uintptr_t)ret_copy;
40162         return ret_ref;
40163 }
40164
40165 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_total"))) TS_EffectiveCapacity_total(int64_t capacity_msat, uint32_t htlc_maximum_msat) {
40166         void* htlc_maximum_msat_ptr = (void*)(((uintptr_t)htlc_maximum_msat) & ~1);
40167         CHECK_ACCESS(htlc_maximum_msat_ptr);
40168         LDKCOption_u64Z htlc_maximum_msat_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_ptr);
40169         htlc_maximum_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_maximum_msat) & ~1));
40170         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
40171         *ret_copy = EffectiveCapacity_total(capacity_msat, htlc_maximum_msat_conv);
40172         uint32_t ret_ref = (uintptr_t)ret_copy;
40173         return ret_ref;
40174 }
40175
40176 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_infinite"))) TS_EffectiveCapacity_infinite() {
40177         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
40178         *ret_copy = EffectiveCapacity_infinite();
40179         uint32_t ret_ref = (uintptr_t)ret_copy;
40180         return ret_ref;
40181 }
40182
40183 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_unknown"))) TS_EffectiveCapacity_unknown() {
40184         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
40185         *ret_copy = EffectiveCapacity_unknown();
40186         uint32_t ret_ref = (uintptr_t)ret_copy;
40187         return ret_ref;
40188 }
40189
40190 int64_t  __attribute__((export_name("TS_EffectiveCapacity_as_msat"))) TS_EffectiveCapacity_as_msat(uint32_t this_arg) {
40191         LDKEffectiveCapacity* this_arg_conv = (LDKEffectiveCapacity*)this_arg;
40192         int64_t ret_conv = EffectiveCapacity_as_msat(this_arg_conv);
40193         return ret_conv;
40194 }
40195
40196 void  __attribute__((export_name("TS_RoutingFees_free"))) TS_RoutingFees_free(uint32_t this_obj) {
40197         LDKRoutingFees this_obj_conv;
40198         this_obj_conv.inner = (void*)(this_obj & (~1));
40199         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40200         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40201         RoutingFees_free(this_obj_conv);
40202 }
40203
40204 int32_t  __attribute__((export_name("TS_RoutingFees_get_base_msat"))) TS_RoutingFees_get_base_msat(uint32_t this_ptr) {
40205         LDKRoutingFees this_ptr_conv;
40206         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40207         this_ptr_conv.is_owned = false;
40208         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40209         int32_t ret_conv = RoutingFees_get_base_msat(&this_ptr_conv);
40210         return ret_conv;
40211 }
40212
40213 void  __attribute__((export_name("TS_RoutingFees_set_base_msat"))) TS_RoutingFees_set_base_msat(uint32_t this_ptr, int32_t val) {
40214         LDKRoutingFees this_ptr_conv;
40215         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40216         this_ptr_conv.is_owned = false;
40217         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40218         RoutingFees_set_base_msat(&this_ptr_conv, val);
40219 }
40220
40221 int32_t  __attribute__((export_name("TS_RoutingFees_get_proportional_millionths"))) TS_RoutingFees_get_proportional_millionths(uint32_t this_ptr) {
40222         LDKRoutingFees this_ptr_conv;
40223         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40224         this_ptr_conv.is_owned = false;
40225         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40226         int32_t ret_conv = RoutingFees_get_proportional_millionths(&this_ptr_conv);
40227         return ret_conv;
40228 }
40229
40230 void  __attribute__((export_name("TS_RoutingFees_set_proportional_millionths"))) TS_RoutingFees_set_proportional_millionths(uint32_t this_ptr, int32_t val) {
40231         LDKRoutingFees this_ptr_conv;
40232         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40233         this_ptr_conv.is_owned = false;
40234         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40235         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
40236 }
40237
40238 uint32_t  __attribute__((export_name("TS_RoutingFees_new"))) TS_RoutingFees_new(int32_t base_msat_arg, int32_t proportional_millionths_arg) {
40239         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
40240         uint32_t ret_ref = 0;
40241         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40242         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40243         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40244         ret_ref = (uintptr_t)ret_var.inner;
40245         if (ret_var.is_owned) {
40246                 ret_ref |= 1;
40247         }
40248         return ret_ref;
40249 }
40250
40251 jboolean  __attribute__((export_name("TS_RoutingFees_eq"))) TS_RoutingFees_eq(uint32_t a, uint32_t b) {
40252         LDKRoutingFees a_conv;
40253         a_conv.inner = (void*)(a & (~1));
40254         a_conv.is_owned = false;
40255         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40256         LDKRoutingFees b_conv;
40257         b_conv.inner = (void*)(b & (~1));
40258         b_conv.is_owned = false;
40259         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40260         jboolean ret_conv = RoutingFees_eq(&a_conv, &b_conv);
40261         return ret_conv;
40262 }
40263
40264 static inline uintptr_t RoutingFees_clone_ptr(LDKRoutingFees *NONNULL_PTR arg) {
40265         LDKRoutingFees ret_var = RoutingFees_clone(arg);
40266 uint32_t ret_ref = 0;
40267 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40268 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40269 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40270 ret_ref = (uintptr_t)ret_var.inner;
40271 if (ret_var.is_owned) {
40272         ret_ref |= 1;
40273 }
40274         return ret_ref;
40275 }
40276 uint32_t  __attribute__((export_name("TS_RoutingFees_clone_ptr"))) TS_RoutingFees_clone_ptr(uint32_t arg) {
40277         LDKRoutingFees arg_conv;
40278         arg_conv.inner = (void*)(arg & (~1));
40279         arg_conv.is_owned = false;
40280         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40281         uint32_t ret_conv = RoutingFees_clone_ptr(&arg_conv);
40282         return ret_conv;
40283 }
40284
40285 uint32_t  __attribute__((export_name("TS_RoutingFees_clone"))) TS_RoutingFees_clone(uint32_t orig) {
40286         LDKRoutingFees orig_conv;
40287         orig_conv.inner = (void*)(orig & (~1));
40288         orig_conv.is_owned = false;
40289         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40290         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
40291         uint32_t ret_ref = 0;
40292         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40293         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40294         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40295         ret_ref = (uintptr_t)ret_var.inner;
40296         if (ret_var.is_owned) {
40297                 ret_ref |= 1;
40298         }
40299         return ret_ref;
40300 }
40301
40302 int64_t  __attribute__((export_name("TS_RoutingFees_hash"))) TS_RoutingFees_hash(uint32_t o) {
40303         LDKRoutingFees o_conv;
40304         o_conv.inner = (void*)(o & (~1));
40305         o_conv.is_owned = false;
40306         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
40307         int64_t ret_conv = RoutingFees_hash(&o_conv);
40308         return ret_conv;
40309 }
40310
40311 int8_tArray  __attribute__((export_name("TS_RoutingFees_write"))) TS_RoutingFees_write(uint32_t obj) {
40312         LDKRoutingFees obj_conv;
40313         obj_conv.inner = (void*)(obj & (~1));
40314         obj_conv.is_owned = false;
40315         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40316         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
40317         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
40318         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
40319         CVec_u8Z_free(ret_var);
40320         return ret_arr;
40321 }
40322
40323 uint32_t  __attribute__((export_name("TS_RoutingFees_read"))) TS_RoutingFees_read(int8_tArray ser) {
40324         LDKu8slice ser_ref;
40325         ser_ref.datalen = ser->arr_len;
40326         ser_ref.data = ser->elems;
40327         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
40328         *ret_conv = RoutingFees_read(ser_ref);
40329         FREE(ser);
40330         return (uint32_t)ret_conv;
40331 }
40332
40333 void  __attribute__((export_name("TS_NodeAnnouncementInfo_free"))) TS_NodeAnnouncementInfo_free(uint32_t this_obj) {
40334         LDKNodeAnnouncementInfo this_obj_conv;
40335         this_obj_conv.inner = (void*)(this_obj & (~1));
40336         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40337         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40338         NodeAnnouncementInfo_free(this_obj_conv);
40339 }
40340
40341 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_get_features"))) TS_NodeAnnouncementInfo_get_features(uint32_t this_ptr) {
40342         LDKNodeAnnouncementInfo this_ptr_conv;
40343         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40344         this_ptr_conv.is_owned = false;
40345         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40346         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
40347         uint32_t ret_ref = 0;
40348         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40349         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40350         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40351         ret_ref = (uintptr_t)ret_var.inner;
40352         if (ret_var.is_owned) {
40353                 ret_ref |= 1;
40354         }
40355         return ret_ref;
40356 }
40357
40358 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_features"))) TS_NodeAnnouncementInfo_set_features(uint32_t this_ptr, uint32_t val) {
40359         LDKNodeAnnouncementInfo this_ptr_conv;
40360         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40361         this_ptr_conv.is_owned = false;
40362         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40363         LDKNodeFeatures val_conv;
40364         val_conv.inner = (void*)(val & (~1));
40365         val_conv.is_owned = (val & 1) || (val == 0);
40366         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40367         val_conv = NodeFeatures_clone(&val_conv);
40368         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
40369 }
40370
40371 int32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_get_last_update"))) TS_NodeAnnouncementInfo_get_last_update(uint32_t this_ptr) {
40372         LDKNodeAnnouncementInfo this_ptr_conv;
40373         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40374         this_ptr_conv.is_owned = false;
40375         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40376         int32_t ret_conv = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
40377         return ret_conv;
40378 }
40379
40380 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_last_update"))) TS_NodeAnnouncementInfo_set_last_update(uint32_t this_ptr, int32_t val) {
40381         LDKNodeAnnouncementInfo this_ptr_conv;
40382         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40383         this_ptr_conv.is_owned = false;
40384         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40385         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
40386 }
40387
40388 int8_tArray  __attribute__((export_name("TS_NodeAnnouncementInfo_get_rgb"))) TS_NodeAnnouncementInfo_get_rgb(uint32_t this_ptr) {
40389         LDKNodeAnnouncementInfo this_ptr_conv;
40390         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40391         this_ptr_conv.is_owned = false;
40392         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40393         int8_tArray ret_arr = init_int8_tArray(3, __LINE__);
40394         memcpy(ret_arr->elems, *NodeAnnouncementInfo_get_rgb(&this_ptr_conv), 3);
40395         return ret_arr;
40396 }
40397
40398 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_rgb"))) TS_NodeAnnouncementInfo_set_rgb(uint32_t this_ptr, int8_tArray val) {
40399         LDKNodeAnnouncementInfo this_ptr_conv;
40400         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40401         this_ptr_conv.is_owned = false;
40402         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40403         LDKThreeBytes val_ref;
40404         CHECK(val->arr_len == 3);
40405         memcpy(val_ref.data, val->elems, 3); FREE(val);
40406         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
40407 }
40408
40409 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_get_alias"))) TS_NodeAnnouncementInfo_get_alias(uint32_t this_ptr) {
40410         LDKNodeAnnouncementInfo this_ptr_conv;
40411         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40412         this_ptr_conv.is_owned = false;
40413         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40414         LDKNodeAlias ret_var = NodeAnnouncementInfo_get_alias(&this_ptr_conv);
40415         uint32_t ret_ref = 0;
40416         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40417         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40418         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40419         ret_ref = (uintptr_t)ret_var.inner;
40420         if (ret_var.is_owned) {
40421                 ret_ref |= 1;
40422         }
40423         return ret_ref;
40424 }
40425
40426 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_alias"))) TS_NodeAnnouncementInfo_set_alias(uint32_t this_ptr, uint32_t val) {
40427         LDKNodeAnnouncementInfo this_ptr_conv;
40428         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40429         this_ptr_conv.is_owned = false;
40430         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40431         LDKNodeAlias val_conv;
40432         val_conv.inner = (void*)(val & (~1));
40433         val_conv.is_owned = (val & 1) || (val == 0);
40434         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40435         val_conv = NodeAlias_clone(&val_conv);
40436         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_conv);
40437 }
40438
40439 uint32_tArray  __attribute__((export_name("TS_NodeAnnouncementInfo_get_addresses"))) TS_NodeAnnouncementInfo_get_addresses(uint32_t this_ptr) {
40440         LDKNodeAnnouncementInfo this_ptr_conv;
40441         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40442         this_ptr_conv.is_owned = false;
40443         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40444         LDKCVec_NetAddressZ ret_var = NodeAnnouncementInfo_get_addresses(&this_ptr_conv);
40445         uint32_tArray ret_arr = NULL;
40446         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
40447         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 8);
40448         for (size_t m = 0; m < ret_var.datalen; m++) {
40449                 LDKNetAddress *ret_conv_12_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
40450                 *ret_conv_12_copy = ret_var.data[m];
40451                 uint32_t ret_conv_12_ref = (uintptr_t)ret_conv_12_copy;
40452                 ret_arr_ptr[m] = ret_conv_12_ref;
40453         }
40454         
40455         FREE(ret_var.data);
40456         return ret_arr;
40457 }
40458
40459 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_addresses"))) TS_NodeAnnouncementInfo_set_addresses(uint32_t this_ptr, uint32_tArray val) {
40460         LDKNodeAnnouncementInfo this_ptr_conv;
40461         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40462         this_ptr_conv.is_owned = false;
40463         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40464         LDKCVec_NetAddressZ val_constr;
40465         val_constr.datalen = val->arr_len;
40466         if (val_constr.datalen > 0)
40467                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
40468         else
40469                 val_constr.data = NULL;
40470         uint32_t* val_vals = val->elems;
40471         for (size_t m = 0; m < val_constr.datalen; m++) {
40472                 uint32_t val_conv_12 = val_vals[m];
40473                 void* val_conv_12_ptr = (void*)(((uintptr_t)val_conv_12) & ~1);
40474                 CHECK_ACCESS(val_conv_12_ptr);
40475                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
40476                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)val_conv_12) & ~1));
40477                 val_constr.data[m] = val_conv_12_conv;
40478         }
40479         FREE(val);
40480         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
40481 }
40482
40483 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_get_announcement_message"))) TS_NodeAnnouncementInfo_get_announcement_message(uint32_t this_ptr) {
40484         LDKNodeAnnouncementInfo this_ptr_conv;
40485         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40486         this_ptr_conv.is_owned = false;
40487         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40488         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
40489         uint32_t ret_ref = 0;
40490         if ((uintptr_t)ret_var.inner > 4096) {
40491                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40492                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40493         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40494                 ret_ref = (uintptr_t)ret_var.inner;
40495                 if (ret_var.is_owned) {
40496                         ret_ref |= 1;
40497                 }
40498         }
40499         return ret_ref;
40500 }
40501
40502 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_announcement_message"))) TS_NodeAnnouncementInfo_set_announcement_message(uint32_t this_ptr, uint32_t val) {
40503         LDKNodeAnnouncementInfo this_ptr_conv;
40504         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40505         this_ptr_conv.is_owned = false;
40506         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40507         LDKNodeAnnouncement val_conv;
40508         val_conv.inner = (void*)(val & (~1));
40509         val_conv.is_owned = (val & 1) || (val == 0);
40510         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40511         val_conv = NodeAnnouncement_clone(&val_conv);
40512         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
40513 }
40514
40515 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_new"))) TS_NodeAnnouncementInfo_new(uint32_t features_arg, int32_t last_update_arg, int8_tArray rgb_arg, uint32_t alias_arg, uint32_tArray addresses_arg, uint32_t announcement_message_arg) {
40516         LDKNodeFeatures features_arg_conv;
40517         features_arg_conv.inner = (void*)(features_arg & (~1));
40518         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
40519         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
40520         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
40521         LDKThreeBytes rgb_arg_ref;
40522         CHECK(rgb_arg->arr_len == 3);
40523         memcpy(rgb_arg_ref.data, rgb_arg->elems, 3); FREE(rgb_arg);
40524         LDKNodeAlias alias_arg_conv;
40525         alias_arg_conv.inner = (void*)(alias_arg & (~1));
40526         alias_arg_conv.is_owned = (alias_arg & 1) || (alias_arg == 0);
40527         CHECK_INNER_FIELD_ACCESS_OR_NULL(alias_arg_conv);
40528         alias_arg_conv = NodeAlias_clone(&alias_arg_conv);
40529         LDKCVec_NetAddressZ addresses_arg_constr;
40530         addresses_arg_constr.datalen = addresses_arg->arr_len;
40531         if (addresses_arg_constr.datalen > 0)
40532                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
40533         else
40534                 addresses_arg_constr.data = NULL;
40535         uint32_t* addresses_arg_vals = addresses_arg->elems;
40536         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
40537                 uint32_t addresses_arg_conv_12 = addresses_arg_vals[m];
40538                 void* addresses_arg_conv_12_ptr = (void*)(((uintptr_t)addresses_arg_conv_12) & ~1);
40539                 CHECK_ACCESS(addresses_arg_conv_12_ptr);
40540                 LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(addresses_arg_conv_12_ptr);
40541                 addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
40542         }
40543         FREE(addresses_arg);
40544         LDKNodeAnnouncement announcement_message_arg_conv;
40545         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
40546         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
40547         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_message_arg_conv);
40548         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
40549         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_conv, addresses_arg_constr, announcement_message_arg_conv);
40550         uint32_t ret_ref = 0;
40551         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40552         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40553         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40554         ret_ref = (uintptr_t)ret_var.inner;
40555         if (ret_var.is_owned) {
40556                 ret_ref |= 1;
40557         }
40558         return ret_ref;
40559 }
40560
40561 static inline uintptr_t NodeAnnouncementInfo_clone_ptr(LDKNodeAnnouncementInfo *NONNULL_PTR arg) {
40562         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(arg);
40563 uint32_t ret_ref = 0;
40564 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40565 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40566 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40567 ret_ref = (uintptr_t)ret_var.inner;
40568 if (ret_var.is_owned) {
40569         ret_ref |= 1;
40570 }
40571         return ret_ref;
40572 }
40573 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_clone_ptr"))) TS_NodeAnnouncementInfo_clone_ptr(uint32_t arg) {
40574         LDKNodeAnnouncementInfo arg_conv;
40575         arg_conv.inner = (void*)(arg & (~1));
40576         arg_conv.is_owned = false;
40577         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40578         uint32_t ret_conv = NodeAnnouncementInfo_clone_ptr(&arg_conv);
40579         return ret_conv;
40580 }
40581
40582 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_clone"))) TS_NodeAnnouncementInfo_clone(uint32_t orig) {
40583         LDKNodeAnnouncementInfo orig_conv;
40584         orig_conv.inner = (void*)(orig & (~1));
40585         orig_conv.is_owned = false;
40586         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40587         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
40588         uint32_t ret_ref = 0;
40589         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40590         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40591         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40592         ret_ref = (uintptr_t)ret_var.inner;
40593         if (ret_var.is_owned) {
40594                 ret_ref |= 1;
40595         }
40596         return ret_ref;
40597 }
40598
40599 int8_tArray  __attribute__((export_name("TS_NodeAnnouncementInfo_write"))) TS_NodeAnnouncementInfo_write(uint32_t obj) {
40600         LDKNodeAnnouncementInfo obj_conv;
40601         obj_conv.inner = (void*)(obj & (~1));
40602         obj_conv.is_owned = false;
40603         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40604         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
40605         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
40606         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
40607         CVec_u8Z_free(ret_var);
40608         return ret_arr;
40609 }
40610
40611 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_read"))) TS_NodeAnnouncementInfo_read(int8_tArray ser) {
40612         LDKu8slice ser_ref;
40613         ser_ref.datalen = ser->arr_len;
40614         ser_ref.data = ser->elems;
40615         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
40616         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
40617         FREE(ser);
40618         return (uint32_t)ret_conv;
40619 }
40620
40621 void  __attribute__((export_name("TS_NodeAlias_free"))) TS_NodeAlias_free(uint32_t this_obj) {
40622         LDKNodeAlias this_obj_conv;
40623         this_obj_conv.inner = (void*)(this_obj & (~1));
40624         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40625         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40626         NodeAlias_free(this_obj_conv);
40627 }
40628
40629 int8_tArray  __attribute__((export_name("TS_NodeAlias_get_a"))) TS_NodeAlias_get_a(uint32_t this_ptr) {
40630         LDKNodeAlias this_ptr_conv;
40631         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40632         this_ptr_conv.is_owned = false;
40633         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40634         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
40635         memcpy(ret_arr->elems, *NodeAlias_get_a(&this_ptr_conv), 32);
40636         return ret_arr;
40637 }
40638
40639 void  __attribute__((export_name("TS_NodeAlias_set_a"))) TS_NodeAlias_set_a(uint32_t this_ptr, int8_tArray val) {
40640         LDKNodeAlias this_ptr_conv;
40641         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40642         this_ptr_conv.is_owned = false;
40643         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40644         LDKThirtyTwoBytes val_ref;
40645         CHECK(val->arr_len == 32);
40646         memcpy(val_ref.data, val->elems, 32); FREE(val);
40647         NodeAlias_set_a(&this_ptr_conv, val_ref);
40648 }
40649
40650 uint32_t  __attribute__((export_name("TS_NodeAlias_new"))) TS_NodeAlias_new(int8_tArray a_arg) {
40651         LDKThirtyTwoBytes a_arg_ref;
40652         CHECK(a_arg->arr_len == 32);
40653         memcpy(a_arg_ref.data, a_arg->elems, 32); FREE(a_arg);
40654         LDKNodeAlias ret_var = NodeAlias_new(a_arg_ref);
40655         uint32_t ret_ref = 0;
40656         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40657         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40658         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40659         ret_ref = (uintptr_t)ret_var.inner;
40660         if (ret_var.is_owned) {
40661                 ret_ref |= 1;
40662         }
40663         return ret_ref;
40664 }
40665
40666 static inline uintptr_t NodeAlias_clone_ptr(LDKNodeAlias *NONNULL_PTR arg) {
40667         LDKNodeAlias ret_var = NodeAlias_clone(arg);
40668 uint32_t ret_ref = 0;
40669 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40670 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40671 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40672 ret_ref = (uintptr_t)ret_var.inner;
40673 if (ret_var.is_owned) {
40674         ret_ref |= 1;
40675 }
40676         return ret_ref;
40677 }
40678 uint32_t  __attribute__((export_name("TS_NodeAlias_clone_ptr"))) TS_NodeAlias_clone_ptr(uint32_t arg) {
40679         LDKNodeAlias arg_conv;
40680         arg_conv.inner = (void*)(arg & (~1));
40681         arg_conv.is_owned = false;
40682         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40683         uint32_t ret_conv = NodeAlias_clone_ptr(&arg_conv);
40684         return ret_conv;
40685 }
40686
40687 uint32_t  __attribute__((export_name("TS_NodeAlias_clone"))) TS_NodeAlias_clone(uint32_t orig) {
40688         LDKNodeAlias orig_conv;
40689         orig_conv.inner = (void*)(orig & (~1));
40690         orig_conv.is_owned = false;
40691         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40692         LDKNodeAlias ret_var = NodeAlias_clone(&orig_conv);
40693         uint32_t ret_ref = 0;
40694         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40695         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40696         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40697         ret_ref = (uintptr_t)ret_var.inner;
40698         if (ret_var.is_owned) {
40699                 ret_ref |= 1;
40700         }
40701         return ret_ref;
40702 }
40703
40704 int8_tArray  __attribute__((export_name("TS_NodeAlias_write"))) TS_NodeAlias_write(uint32_t obj) {
40705         LDKNodeAlias obj_conv;
40706         obj_conv.inner = (void*)(obj & (~1));
40707         obj_conv.is_owned = false;
40708         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40709         LDKCVec_u8Z ret_var = NodeAlias_write(&obj_conv);
40710         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
40711         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
40712         CVec_u8Z_free(ret_var);
40713         return ret_arr;
40714 }
40715
40716 uint32_t  __attribute__((export_name("TS_NodeAlias_read"))) TS_NodeAlias_read(int8_tArray ser) {
40717         LDKu8slice ser_ref;
40718         ser_ref.datalen = ser->arr_len;
40719         ser_ref.data = ser->elems;
40720         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
40721         *ret_conv = NodeAlias_read(ser_ref);
40722         FREE(ser);
40723         return (uint32_t)ret_conv;
40724 }
40725
40726 void  __attribute__((export_name("TS_NodeInfo_free"))) TS_NodeInfo_free(uint32_t this_obj) {
40727         LDKNodeInfo this_obj_conv;
40728         this_obj_conv.inner = (void*)(this_obj & (~1));
40729         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40730         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40731         NodeInfo_free(this_obj_conv);
40732 }
40733
40734 int64_tArray  __attribute__((export_name("TS_NodeInfo_get_channels"))) TS_NodeInfo_get_channels(uint32_t this_ptr) {
40735         LDKNodeInfo this_ptr_conv;
40736         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40737         this_ptr_conv.is_owned = false;
40738         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40739         LDKCVec_u64Z ret_var = NodeInfo_get_channels(&this_ptr_conv);
40740         int64_tArray ret_arr = NULL;
40741         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
40742         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
40743         for (size_t i = 0; i < ret_var.datalen; i++) {
40744                 int64_t ret_conv_8_conv = ret_var.data[i];
40745                 ret_arr_ptr[i] = ret_conv_8_conv;
40746         }
40747         
40748         FREE(ret_var.data);
40749         return ret_arr;
40750 }
40751
40752 void  __attribute__((export_name("TS_NodeInfo_set_channels"))) TS_NodeInfo_set_channels(uint32_t this_ptr, int64_tArray val) {
40753         LDKNodeInfo this_ptr_conv;
40754         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40755         this_ptr_conv.is_owned = false;
40756         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40757         LDKCVec_u64Z val_constr;
40758         val_constr.datalen = val->arr_len;
40759         if (val_constr.datalen > 0)
40760                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
40761         else
40762                 val_constr.data = NULL;
40763         int64_t* val_vals = val->elems;
40764         for (size_t i = 0; i < val_constr.datalen; i++) {
40765                 int64_t val_conv_8 = val_vals[i];
40766                 val_constr.data[i] = val_conv_8;
40767         }
40768         FREE(val);
40769         NodeInfo_set_channels(&this_ptr_conv, val_constr);
40770 }
40771
40772 uint32_t  __attribute__((export_name("TS_NodeInfo_get_lowest_inbound_channel_fees"))) TS_NodeInfo_get_lowest_inbound_channel_fees(uint32_t this_ptr) {
40773         LDKNodeInfo this_ptr_conv;
40774         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40775         this_ptr_conv.is_owned = false;
40776         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40777         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
40778         uint32_t ret_ref = 0;
40779         if ((uintptr_t)ret_var.inner > 4096) {
40780                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40781                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40782         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40783                 ret_ref = (uintptr_t)ret_var.inner;
40784                 if (ret_var.is_owned) {
40785                         ret_ref |= 1;
40786                 }
40787         }
40788         return ret_ref;
40789 }
40790
40791 void  __attribute__((export_name("TS_NodeInfo_set_lowest_inbound_channel_fees"))) TS_NodeInfo_set_lowest_inbound_channel_fees(uint32_t this_ptr, uint32_t val) {
40792         LDKNodeInfo this_ptr_conv;
40793         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40794         this_ptr_conv.is_owned = false;
40795         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40796         LDKRoutingFees val_conv;
40797         val_conv.inner = (void*)(val & (~1));
40798         val_conv.is_owned = (val & 1) || (val == 0);
40799         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40800         val_conv = RoutingFees_clone(&val_conv);
40801         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
40802 }
40803
40804 uint32_t  __attribute__((export_name("TS_NodeInfo_get_announcement_info"))) TS_NodeInfo_get_announcement_info(uint32_t this_ptr) {
40805         LDKNodeInfo this_ptr_conv;
40806         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40807         this_ptr_conv.is_owned = false;
40808         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40809         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
40810         uint32_t ret_ref = 0;
40811         if ((uintptr_t)ret_var.inner > 4096) {
40812                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40813                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40814         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40815                 ret_ref = (uintptr_t)ret_var.inner;
40816                 if (ret_var.is_owned) {
40817                         ret_ref |= 1;
40818                 }
40819         }
40820         return ret_ref;
40821 }
40822
40823 void  __attribute__((export_name("TS_NodeInfo_set_announcement_info"))) TS_NodeInfo_set_announcement_info(uint32_t this_ptr, uint32_t val) {
40824         LDKNodeInfo this_ptr_conv;
40825         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40826         this_ptr_conv.is_owned = false;
40827         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40828         LDKNodeAnnouncementInfo val_conv;
40829         val_conv.inner = (void*)(val & (~1));
40830         val_conv.is_owned = (val & 1) || (val == 0);
40831         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40832         val_conv = NodeAnnouncementInfo_clone(&val_conv);
40833         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
40834 }
40835
40836 uint32_t  __attribute__((export_name("TS_NodeInfo_new"))) TS_NodeInfo_new(int64_tArray channels_arg, uint32_t lowest_inbound_channel_fees_arg, uint32_t announcement_info_arg) {
40837         LDKCVec_u64Z channels_arg_constr;
40838         channels_arg_constr.datalen = channels_arg->arr_len;
40839         if (channels_arg_constr.datalen > 0)
40840                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
40841         else
40842                 channels_arg_constr.data = NULL;
40843         int64_t* channels_arg_vals = channels_arg->elems;
40844         for (size_t i = 0; i < channels_arg_constr.datalen; i++) {
40845                 int64_t channels_arg_conv_8 = channels_arg_vals[i];
40846                 channels_arg_constr.data[i] = channels_arg_conv_8;
40847         }
40848         FREE(channels_arg);
40849         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
40850         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
40851         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
40852         CHECK_INNER_FIELD_ACCESS_OR_NULL(lowest_inbound_channel_fees_arg_conv);
40853         lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
40854         LDKNodeAnnouncementInfo announcement_info_arg_conv;
40855         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
40856         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
40857         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_info_arg_conv);
40858         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
40859         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
40860         uint32_t ret_ref = 0;
40861         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40862         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40863         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40864         ret_ref = (uintptr_t)ret_var.inner;
40865         if (ret_var.is_owned) {
40866                 ret_ref |= 1;
40867         }
40868         return ret_ref;
40869 }
40870
40871 static inline uintptr_t NodeInfo_clone_ptr(LDKNodeInfo *NONNULL_PTR arg) {
40872         LDKNodeInfo ret_var = NodeInfo_clone(arg);
40873 uint32_t ret_ref = 0;
40874 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40875 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40876 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40877 ret_ref = (uintptr_t)ret_var.inner;
40878 if (ret_var.is_owned) {
40879         ret_ref |= 1;
40880 }
40881         return ret_ref;
40882 }
40883 uint32_t  __attribute__((export_name("TS_NodeInfo_clone_ptr"))) TS_NodeInfo_clone_ptr(uint32_t arg) {
40884         LDKNodeInfo arg_conv;
40885         arg_conv.inner = (void*)(arg & (~1));
40886         arg_conv.is_owned = false;
40887         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40888         uint32_t ret_conv = NodeInfo_clone_ptr(&arg_conv);
40889         return ret_conv;
40890 }
40891
40892 uint32_t  __attribute__((export_name("TS_NodeInfo_clone"))) TS_NodeInfo_clone(uint32_t orig) {
40893         LDKNodeInfo orig_conv;
40894         orig_conv.inner = (void*)(orig & (~1));
40895         orig_conv.is_owned = false;
40896         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40897         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
40898         uint32_t ret_ref = 0;
40899         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40900         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40901         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40902         ret_ref = (uintptr_t)ret_var.inner;
40903         if (ret_var.is_owned) {
40904                 ret_ref |= 1;
40905         }
40906         return ret_ref;
40907 }
40908
40909 int8_tArray  __attribute__((export_name("TS_NodeInfo_write"))) TS_NodeInfo_write(uint32_t obj) {
40910         LDKNodeInfo obj_conv;
40911         obj_conv.inner = (void*)(obj & (~1));
40912         obj_conv.is_owned = false;
40913         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40914         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
40915         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
40916         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
40917         CVec_u8Z_free(ret_var);
40918         return ret_arr;
40919 }
40920
40921 uint32_t  __attribute__((export_name("TS_NodeInfo_read"))) TS_NodeInfo_read(int8_tArray ser) {
40922         LDKu8slice ser_ref;
40923         ser_ref.datalen = ser->arr_len;
40924         ser_ref.data = ser->elems;
40925         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
40926         *ret_conv = NodeInfo_read(ser_ref);
40927         FREE(ser);
40928         return (uint32_t)ret_conv;
40929 }
40930
40931 int8_tArray  __attribute__((export_name("TS_NetworkGraph_write"))) TS_NetworkGraph_write(uint32_t obj) {
40932         LDKNetworkGraph obj_conv;
40933         obj_conv.inner = (void*)(obj & (~1));
40934         obj_conv.is_owned = false;
40935         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40936         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
40937         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
40938         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
40939         CVec_u8Z_free(ret_var);
40940         return ret_arr;
40941 }
40942
40943 uint32_t  __attribute__((export_name("TS_NetworkGraph_read"))) TS_NetworkGraph_read(int8_tArray ser, uint32_t arg) {
40944         LDKu8slice ser_ref;
40945         ser_ref.datalen = ser->arr_len;
40946         ser_ref.data = ser->elems;
40947         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
40948         CHECK_ACCESS(arg_ptr);
40949         LDKLogger arg_conv = *(LDKLogger*)(arg_ptr);
40950         if (arg_conv.free == LDKLogger_JCalls_free) {
40951                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
40952                 LDKLogger_JCalls_cloned(&arg_conv);
40953         }
40954         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
40955         *ret_conv = NetworkGraph_read(ser_ref, arg_conv);
40956         FREE(ser);
40957         return (uint32_t)ret_conv;
40958 }
40959
40960 uint32_t  __attribute__((export_name("TS_NetworkGraph_new"))) TS_NetworkGraph_new(int8_tArray genesis_hash, uint32_t logger) {
40961         LDKThirtyTwoBytes genesis_hash_ref;
40962         CHECK(genesis_hash->arr_len == 32);
40963         memcpy(genesis_hash_ref.data, genesis_hash->elems, 32); FREE(genesis_hash);
40964         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
40965         CHECK_ACCESS(logger_ptr);
40966         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
40967         if (logger_conv.free == LDKLogger_JCalls_free) {
40968                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
40969                 LDKLogger_JCalls_cloned(&logger_conv);
40970         }
40971         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref, logger_conv);
40972         uint32_t ret_ref = 0;
40973         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40974         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40975         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40976         ret_ref = (uintptr_t)ret_var.inner;
40977         if (ret_var.is_owned) {
40978                 ret_ref |= 1;
40979         }
40980         return ret_ref;
40981 }
40982
40983 uint32_t  __attribute__((export_name("TS_NetworkGraph_read_only"))) TS_NetworkGraph_read_only(uint32_t this_arg) {
40984         LDKNetworkGraph this_arg_conv;
40985         this_arg_conv.inner = (void*)(this_arg & (~1));
40986         this_arg_conv.is_owned = false;
40987         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40988         LDKReadOnlyNetworkGraph ret_var = NetworkGraph_read_only(&this_arg_conv);
40989         uint32_t ret_ref = 0;
40990         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40991         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40992         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40993         ret_ref = (uintptr_t)ret_var.inner;
40994         if (ret_var.is_owned) {
40995                 ret_ref |= 1;
40996         }
40997         return ret_ref;
40998 }
40999
41000 uint32_t  __attribute__((export_name("TS_NetworkGraph_get_last_rapid_gossip_sync_timestamp"))) TS_NetworkGraph_get_last_rapid_gossip_sync_timestamp(uint32_t this_arg) {
41001         LDKNetworkGraph this_arg_conv;
41002         this_arg_conv.inner = (void*)(this_arg & (~1));
41003         this_arg_conv.is_owned = false;
41004         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41005         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
41006         *ret_copy = NetworkGraph_get_last_rapid_gossip_sync_timestamp(&this_arg_conv);
41007         uint32_t ret_ref = (uintptr_t)ret_copy;
41008         return ret_ref;
41009 }
41010
41011 void  __attribute__((export_name("TS_NetworkGraph_set_last_rapid_gossip_sync_timestamp"))) TS_NetworkGraph_set_last_rapid_gossip_sync_timestamp(uint32_t this_arg, int32_t last_rapid_gossip_sync_timestamp) {
41012         LDKNetworkGraph this_arg_conv;
41013         this_arg_conv.inner = (void*)(this_arg & (~1));
41014         this_arg_conv.is_owned = false;
41015         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41016         NetworkGraph_set_last_rapid_gossip_sync_timestamp(&this_arg_conv, last_rapid_gossip_sync_timestamp);
41017 }
41018
41019 uint32_t  __attribute__((export_name("TS_NetworkGraph_update_node_from_announcement"))) TS_NetworkGraph_update_node_from_announcement(uint32_t this_arg, uint32_t msg) {
41020         LDKNetworkGraph this_arg_conv;
41021         this_arg_conv.inner = (void*)(this_arg & (~1));
41022         this_arg_conv.is_owned = false;
41023         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41024         LDKNodeAnnouncement msg_conv;
41025         msg_conv.inner = (void*)(msg & (~1));
41026         msg_conv.is_owned = false;
41027         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
41028         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
41029         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
41030         return (uint32_t)ret_conv;
41031 }
41032
41033 uint32_t  __attribute__((export_name("TS_NetworkGraph_update_node_from_unsigned_announcement"))) TS_NetworkGraph_update_node_from_unsigned_announcement(uint32_t this_arg, uint32_t msg) {
41034         LDKNetworkGraph this_arg_conv;
41035         this_arg_conv.inner = (void*)(this_arg & (~1));
41036         this_arg_conv.is_owned = false;
41037         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41038         LDKUnsignedNodeAnnouncement msg_conv;
41039         msg_conv.inner = (void*)(msg & (~1));
41040         msg_conv.is_owned = false;
41041         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
41042         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
41043         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
41044         return (uint32_t)ret_conv;
41045 }
41046
41047 uint32_t  __attribute__((export_name("TS_NetworkGraph_update_channel_from_announcement"))) TS_NetworkGraph_update_channel_from_announcement(uint32_t this_arg, uint32_t msg, uint32_t chain_access) {
41048         LDKNetworkGraph this_arg_conv;
41049         this_arg_conv.inner = (void*)(this_arg & (~1));
41050         this_arg_conv.is_owned = false;
41051         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41052         LDKChannelAnnouncement msg_conv;
41053         msg_conv.inner = (void*)(msg & (~1));
41054         msg_conv.is_owned = false;
41055         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
41056         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
41057         CHECK_ACCESS(chain_access_ptr);
41058         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
41059         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
41060         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
41061                 // Manually implement clone for Java trait instances
41062                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
41063                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41064                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
41065                 }
41066         }
41067         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
41068         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
41069         return (uint32_t)ret_conv;
41070 }
41071
41072 uint32_t  __attribute__((export_name("TS_NetworkGraph_update_channel_from_unsigned_announcement"))) TS_NetworkGraph_update_channel_from_unsigned_announcement(uint32_t this_arg, uint32_t msg, uint32_t chain_access) {
41073         LDKNetworkGraph this_arg_conv;
41074         this_arg_conv.inner = (void*)(this_arg & (~1));
41075         this_arg_conv.is_owned = false;
41076         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41077         LDKUnsignedChannelAnnouncement msg_conv;
41078         msg_conv.inner = (void*)(msg & (~1));
41079         msg_conv.is_owned = false;
41080         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
41081         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
41082         CHECK_ACCESS(chain_access_ptr);
41083         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
41084         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
41085         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
41086                 // Manually implement clone for Java trait instances
41087                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
41088                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41089                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
41090                 }
41091         }
41092         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
41093         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
41094         return (uint32_t)ret_conv;
41095 }
41096
41097 uint32_t  __attribute__((export_name("TS_NetworkGraph_add_channel_from_partial_announcement"))) TS_NetworkGraph_add_channel_from_partial_announcement(uint32_t this_arg, int64_t short_channel_id, int64_t timestamp, uint32_t features, int8_tArray node_id_1, int8_tArray node_id_2) {
41098         LDKNetworkGraph this_arg_conv;
41099         this_arg_conv.inner = (void*)(this_arg & (~1));
41100         this_arg_conv.is_owned = false;
41101         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41102         LDKChannelFeatures features_conv;
41103         features_conv.inner = (void*)(features & (~1));
41104         features_conv.is_owned = (features & 1) || (features == 0);
41105         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
41106         features_conv = ChannelFeatures_clone(&features_conv);
41107         LDKPublicKey node_id_1_ref;
41108         CHECK(node_id_1->arr_len == 33);
41109         memcpy(node_id_1_ref.compressed_form, node_id_1->elems, 33); FREE(node_id_1);
41110         LDKPublicKey node_id_2_ref;
41111         CHECK(node_id_2->arr_len == 33);
41112         memcpy(node_id_2_ref.compressed_form, node_id_2->elems, 33); FREE(node_id_2);
41113         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
41114         *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);
41115         return (uint32_t)ret_conv;
41116 }
41117
41118 void  __attribute__((export_name("TS_NetworkGraph_channel_failed"))) TS_NetworkGraph_channel_failed(uint32_t this_arg, int64_t short_channel_id, jboolean is_permanent) {
41119         LDKNetworkGraph this_arg_conv;
41120         this_arg_conv.inner = (void*)(this_arg & (~1));
41121         this_arg_conv.is_owned = false;
41122         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41123         NetworkGraph_channel_failed(&this_arg_conv, short_channel_id, is_permanent);
41124 }
41125
41126 void  __attribute__((export_name("TS_NetworkGraph_node_failed"))) TS_NetworkGraph_node_failed(uint32_t this_arg, int8_tArray _node_id, jboolean is_permanent) {
41127         LDKNetworkGraph this_arg_conv;
41128         this_arg_conv.inner = (void*)(this_arg & (~1));
41129         this_arg_conv.is_owned = false;
41130         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41131         LDKPublicKey _node_id_ref;
41132         CHECK(_node_id->arr_len == 33);
41133         memcpy(_node_id_ref.compressed_form, _node_id->elems, 33); FREE(_node_id);
41134         NetworkGraph_node_failed(&this_arg_conv, _node_id_ref, is_permanent);
41135 }
41136
41137 void  __attribute__((export_name("TS_NetworkGraph_remove_stale_channels_with_time"))) TS_NetworkGraph_remove_stale_channels_with_time(uint32_t this_arg, int64_t current_time_unix) {
41138         LDKNetworkGraph this_arg_conv;
41139         this_arg_conv.inner = (void*)(this_arg & (~1));
41140         this_arg_conv.is_owned = false;
41141         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41142         NetworkGraph_remove_stale_channels_with_time(&this_arg_conv, current_time_unix);
41143 }
41144
41145 uint32_t  __attribute__((export_name("TS_NetworkGraph_update_channel"))) TS_NetworkGraph_update_channel(uint32_t this_arg, uint32_t msg) {
41146         LDKNetworkGraph this_arg_conv;
41147         this_arg_conv.inner = (void*)(this_arg & (~1));
41148         this_arg_conv.is_owned = false;
41149         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41150         LDKChannelUpdate msg_conv;
41151         msg_conv.inner = (void*)(msg & (~1));
41152         msg_conv.is_owned = false;
41153         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
41154         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
41155         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
41156         return (uint32_t)ret_conv;
41157 }
41158
41159 uint32_t  __attribute__((export_name("TS_NetworkGraph_update_channel_unsigned"))) TS_NetworkGraph_update_channel_unsigned(uint32_t this_arg, uint32_t msg) {
41160         LDKNetworkGraph this_arg_conv;
41161         this_arg_conv.inner = (void*)(this_arg & (~1));
41162         this_arg_conv.is_owned = false;
41163         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41164         LDKUnsignedChannelUpdate msg_conv;
41165         msg_conv.inner = (void*)(msg & (~1));
41166         msg_conv.is_owned = false;
41167         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
41168         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
41169         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
41170         return (uint32_t)ret_conv;
41171 }
41172
41173 uint32_t  __attribute__((export_name("TS_ReadOnlyNetworkGraph_channel"))) TS_ReadOnlyNetworkGraph_channel(uint32_t this_arg, int64_t short_channel_id) {
41174         LDKReadOnlyNetworkGraph this_arg_conv;
41175         this_arg_conv.inner = (void*)(this_arg & (~1));
41176         this_arg_conv.is_owned = false;
41177         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41178         LDKChannelInfo ret_var = ReadOnlyNetworkGraph_channel(&this_arg_conv, short_channel_id);
41179         uint32_t ret_ref = 0;
41180         if ((uintptr_t)ret_var.inner > 4096) {
41181                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41182                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41183         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41184                 ret_ref = (uintptr_t)ret_var.inner;
41185                 if (ret_var.is_owned) {
41186                         ret_ref |= 1;
41187                 }
41188         }
41189         return ret_ref;
41190 }
41191
41192 int64_tArray  __attribute__((export_name("TS_ReadOnlyNetworkGraph_list_channels"))) TS_ReadOnlyNetworkGraph_list_channels(uint32_t this_arg) {
41193         LDKReadOnlyNetworkGraph this_arg_conv;
41194         this_arg_conv.inner = (void*)(this_arg & (~1));
41195         this_arg_conv.is_owned = false;
41196         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41197         LDKCVec_u64Z ret_var = ReadOnlyNetworkGraph_list_channels(&this_arg_conv);
41198         int64_tArray ret_arr = NULL;
41199         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
41200         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
41201         for (size_t i = 0; i < ret_var.datalen; i++) {
41202                 int64_t ret_conv_8_conv = ret_var.data[i];
41203                 ret_arr_ptr[i] = ret_conv_8_conv;
41204         }
41205         
41206         FREE(ret_var.data);
41207         return ret_arr;
41208 }
41209
41210 uint32_t  __attribute__((export_name("TS_ReadOnlyNetworkGraph_node"))) TS_ReadOnlyNetworkGraph_node(uint32_t this_arg, uint32_t node_id) {
41211         LDKReadOnlyNetworkGraph this_arg_conv;
41212         this_arg_conv.inner = (void*)(this_arg & (~1));
41213         this_arg_conv.is_owned = false;
41214         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41215         LDKNodeId node_id_conv;
41216         node_id_conv.inner = (void*)(node_id & (~1));
41217         node_id_conv.is_owned = false;
41218         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
41219         LDKNodeInfo ret_var = ReadOnlyNetworkGraph_node(&this_arg_conv, &node_id_conv);
41220         uint32_t ret_ref = 0;
41221         if ((uintptr_t)ret_var.inner > 4096) {
41222                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41223                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41224         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41225                 ret_ref = (uintptr_t)ret_var.inner;
41226                 if (ret_var.is_owned) {
41227                         ret_ref |= 1;
41228                 }
41229         }
41230         return ret_ref;
41231 }
41232
41233 uint32_tArray  __attribute__((export_name("TS_ReadOnlyNetworkGraph_list_nodes"))) TS_ReadOnlyNetworkGraph_list_nodes(uint32_t this_arg) {
41234         LDKReadOnlyNetworkGraph this_arg_conv;
41235         this_arg_conv.inner = (void*)(this_arg & (~1));
41236         this_arg_conv.is_owned = false;
41237         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41238         LDKCVec_NodeIdZ ret_var = ReadOnlyNetworkGraph_list_nodes(&this_arg_conv);
41239         uint32_tArray ret_arr = NULL;
41240         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
41241         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 8);
41242         for (size_t i = 0; i < ret_var.datalen; i++) {
41243                 LDKNodeId ret_conv_8_var = ret_var.data[i];
41244                 uint32_t ret_conv_8_ref = 0;
41245                 CHECK((((uintptr_t)ret_conv_8_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41246                 CHECK((((uintptr_t)&ret_conv_8_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41247                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_8_var);
41248                 ret_conv_8_ref = (uintptr_t)ret_conv_8_var.inner;
41249                 if (ret_conv_8_var.is_owned) {
41250                         ret_conv_8_ref |= 1;
41251                 }
41252                 ret_arr_ptr[i] = ret_conv_8_ref;
41253         }
41254         
41255         FREE(ret_var.data);
41256         return ret_arr;
41257 }
41258
41259 uint32_t  __attribute__((export_name("TS_ReadOnlyNetworkGraph_get_addresses"))) TS_ReadOnlyNetworkGraph_get_addresses(uint32_t this_arg, int8_tArray pubkey) {
41260         LDKReadOnlyNetworkGraph this_arg_conv;
41261         this_arg_conv.inner = (void*)(this_arg & (~1));
41262         this_arg_conv.is_owned = false;
41263         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41264         LDKPublicKey pubkey_ref;
41265         CHECK(pubkey->arr_len == 33);
41266         memcpy(pubkey_ref.compressed_form, pubkey->elems, 33); FREE(pubkey);
41267         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
41268         *ret_copy = ReadOnlyNetworkGraph_get_addresses(&this_arg_conv, pubkey_ref);
41269         uint32_t ret_ref = (uintptr_t)ret_copy;
41270         return ret_ref;
41271 }
41272
41273 void  __attribute__((export_name("TS_RouteHop_free"))) TS_RouteHop_free(uint32_t this_obj) {
41274         LDKRouteHop this_obj_conv;
41275         this_obj_conv.inner = (void*)(this_obj & (~1));
41276         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41277         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41278         RouteHop_free(this_obj_conv);
41279 }
41280
41281 int8_tArray  __attribute__((export_name("TS_RouteHop_get_pubkey"))) TS_RouteHop_get_pubkey(uint32_t this_ptr) {
41282         LDKRouteHop this_ptr_conv;
41283         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41284         this_ptr_conv.is_owned = false;
41285         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41286         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
41287         memcpy(ret_arr->elems, RouteHop_get_pubkey(&this_ptr_conv).compressed_form, 33);
41288         return ret_arr;
41289 }
41290
41291 void  __attribute__((export_name("TS_RouteHop_set_pubkey"))) TS_RouteHop_set_pubkey(uint32_t this_ptr, int8_tArray val) {
41292         LDKRouteHop this_ptr_conv;
41293         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41294         this_ptr_conv.is_owned = false;
41295         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41296         LDKPublicKey val_ref;
41297         CHECK(val->arr_len == 33);
41298         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
41299         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
41300 }
41301
41302 uint32_t  __attribute__((export_name("TS_RouteHop_get_node_features"))) TS_RouteHop_get_node_features(uint32_t this_ptr) {
41303         LDKRouteHop this_ptr_conv;
41304         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41305         this_ptr_conv.is_owned = false;
41306         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41307         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
41308         uint32_t ret_ref = 0;
41309         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41310         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41311         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41312         ret_ref = (uintptr_t)ret_var.inner;
41313         if (ret_var.is_owned) {
41314                 ret_ref |= 1;
41315         }
41316         return ret_ref;
41317 }
41318
41319 void  __attribute__((export_name("TS_RouteHop_set_node_features"))) TS_RouteHop_set_node_features(uint32_t this_ptr, uint32_t val) {
41320         LDKRouteHop this_ptr_conv;
41321         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41322         this_ptr_conv.is_owned = false;
41323         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41324         LDKNodeFeatures val_conv;
41325         val_conv.inner = (void*)(val & (~1));
41326         val_conv.is_owned = (val & 1) || (val == 0);
41327         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
41328         val_conv = NodeFeatures_clone(&val_conv);
41329         RouteHop_set_node_features(&this_ptr_conv, val_conv);
41330 }
41331
41332 int64_t  __attribute__((export_name("TS_RouteHop_get_short_channel_id"))) TS_RouteHop_get_short_channel_id(uint32_t this_ptr) {
41333         LDKRouteHop this_ptr_conv;
41334         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41335         this_ptr_conv.is_owned = false;
41336         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41337         int64_t ret_conv = RouteHop_get_short_channel_id(&this_ptr_conv);
41338         return ret_conv;
41339 }
41340
41341 void  __attribute__((export_name("TS_RouteHop_set_short_channel_id"))) TS_RouteHop_set_short_channel_id(uint32_t this_ptr, int64_t val) {
41342         LDKRouteHop this_ptr_conv;
41343         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41344         this_ptr_conv.is_owned = false;
41345         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41346         RouteHop_set_short_channel_id(&this_ptr_conv, val);
41347 }
41348
41349 uint32_t  __attribute__((export_name("TS_RouteHop_get_channel_features"))) TS_RouteHop_get_channel_features(uint32_t this_ptr) {
41350         LDKRouteHop this_ptr_conv;
41351         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41352         this_ptr_conv.is_owned = false;
41353         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41354         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
41355         uint32_t ret_ref = 0;
41356         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41357         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41358         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41359         ret_ref = (uintptr_t)ret_var.inner;
41360         if (ret_var.is_owned) {
41361                 ret_ref |= 1;
41362         }
41363         return ret_ref;
41364 }
41365
41366 void  __attribute__((export_name("TS_RouteHop_set_channel_features"))) TS_RouteHop_set_channel_features(uint32_t this_ptr, uint32_t val) {
41367         LDKRouteHop this_ptr_conv;
41368         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41369         this_ptr_conv.is_owned = false;
41370         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41371         LDKChannelFeatures val_conv;
41372         val_conv.inner = (void*)(val & (~1));
41373         val_conv.is_owned = (val & 1) || (val == 0);
41374         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
41375         val_conv = ChannelFeatures_clone(&val_conv);
41376         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
41377 }
41378
41379 int64_t  __attribute__((export_name("TS_RouteHop_get_fee_msat"))) TS_RouteHop_get_fee_msat(uint32_t this_ptr) {
41380         LDKRouteHop this_ptr_conv;
41381         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41382         this_ptr_conv.is_owned = false;
41383         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41384         int64_t ret_conv = RouteHop_get_fee_msat(&this_ptr_conv);
41385         return ret_conv;
41386 }
41387
41388 void  __attribute__((export_name("TS_RouteHop_set_fee_msat"))) TS_RouteHop_set_fee_msat(uint32_t this_ptr, int64_t val) {
41389         LDKRouteHop this_ptr_conv;
41390         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41391         this_ptr_conv.is_owned = false;
41392         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41393         RouteHop_set_fee_msat(&this_ptr_conv, val);
41394 }
41395
41396 int32_t  __attribute__((export_name("TS_RouteHop_get_cltv_expiry_delta"))) TS_RouteHop_get_cltv_expiry_delta(uint32_t this_ptr) {
41397         LDKRouteHop this_ptr_conv;
41398         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41399         this_ptr_conv.is_owned = false;
41400         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41401         int32_t ret_conv = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
41402         return ret_conv;
41403 }
41404
41405 void  __attribute__((export_name("TS_RouteHop_set_cltv_expiry_delta"))) TS_RouteHop_set_cltv_expiry_delta(uint32_t this_ptr, int32_t val) {
41406         LDKRouteHop this_ptr_conv;
41407         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41408         this_ptr_conv.is_owned = false;
41409         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41410         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
41411 }
41412
41413 uint32_t  __attribute__((export_name("TS_RouteHop_new"))) TS_RouteHop_new(int8_tArray pubkey_arg, uint32_t node_features_arg, int64_t short_channel_id_arg, uint32_t channel_features_arg, int64_t fee_msat_arg, int32_t cltv_expiry_delta_arg) {
41414         LDKPublicKey pubkey_arg_ref;
41415         CHECK(pubkey_arg->arr_len == 33);
41416         memcpy(pubkey_arg_ref.compressed_form, pubkey_arg->elems, 33); FREE(pubkey_arg);
41417         LDKNodeFeatures node_features_arg_conv;
41418         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
41419         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
41420         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_features_arg_conv);
41421         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
41422         LDKChannelFeatures channel_features_arg_conv;
41423         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
41424         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
41425         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_features_arg_conv);
41426         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
41427         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);
41428         uint32_t ret_ref = 0;
41429         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41430         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41431         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41432         ret_ref = (uintptr_t)ret_var.inner;
41433         if (ret_var.is_owned) {
41434                 ret_ref |= 1;
41435         }
41436         return ret_ref;
41437 }
41438
41439 static inline uintptr_t RouteHop_clone_ptr(LDKRouteHop *NONNULL_PTR arg) {
41440         LDKRouteHop ret_var = RouteHop_clone(arg);
41441 uint32_t ret_ref = 0;
41442 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41443 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41444 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41445 ret_ref = (uintptr_t)ret_var.inner;
41446 if (ret_var.is_owned) {
41447         ret_ref |= 1;
41448 }
41449         return ret_ref;
41450 }
41451 uint32_t  __attribute__((export_name("TS_RouteHop_clone_ptr"))) TS_RouteHop_clone_ptr(uint32_t arg) {
41452         LDKRouteHop arg_conv;
41453         arg_conv.inner = (void*)(arg & (~1));
41454         arg_conv.is_owned = false;
41455         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41456         uint32_t ret_conv = RouteHop_clone_ptr(&arg_conv);
41457         return ret_conv;
41458 }
41459
41460 uint32_t  __attribute__((export_name("TS_RouteHop_clone"))) TS_RouteHop_clone(uint32_t orig) {
41461         LDKRouteHop orig_conv;
41462         orig_conv.inner = (void*)(orig & (~1));
41463         orig_conv.is_owned = false;
41464         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41465         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
41466         uint32_t ret_ref = 0;
41467         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41468         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41469         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41470         ret_ref = (uintptr_t)ret_var.inner;
41471         if (ret_var.is_owned) {
41472                 ret_ref |= 1;
41473         }
41474         return ret_ref;
41475 }
41476
41477 int64_t  __attribute__((export_name("TS_RouteHop_hash"))) TS_RouteHop_hash(uint32_t o) {
41478         LDKRouteHop o_conv;
41479         o_conv.inner = (void*)(o & (~1));
41480         o_conv.is_owned = false;
41481         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
41482         int64_t ret_conv = RouteHop_hash(&o_conv);
41483         return ret_conv;
41484 }
41485
41486 jboolean  __attribute__((export_name("TS_RouteHop_eq"))) TS_RouteHop_eq(uint32_t a, uint32_t b) {
41487         LDKRouteHop a_conv;
41488         a_conv.inner = (void*)(a & (~1));
41489         a_conv.is_owned = false;
41490         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
41491         LDKRouteHop b_conv;
41492         b_conv.inner = (void*)(b & (~1));
41493         b_conv.is_owned = false;
41494         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
41495         jboolean ret_conv = RouteHop_eq(&a_conv, &b_conv);
41496         return ret_conv;
41497 }
41498
41499 int8_tArray  __attribute__((export_name("TS_RouteHop_write"))) TS_RouteHop_write(uint32_t obj) {
41500         LDKRouteHop obj_conv;
41501         obj_conv.inner = (void*)(obj & (~1));
41502         obj_conv.is_owned = false;
41503         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41504         LDKCVec_u8Z ret_var = RouteHop_write(&obj_conv);
41505         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
41506         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
41507         CVec_u8Z_free(ret_var);
41508         return ret_arr;
41509 }
41510
41511 uint32_t  __attribute__((export_name("TS_RouteHop_read"))) TS_RouteHop_read(int8_tArray ser) {
41512         LDKu8slice ser_ref;
41513         ser_ref.datalen = ser->arr_len;
41514         ser_ref.data = ser->elems;
41515         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
41516         *ret_conv = RouteHop_read(ser_ref);
41517         FREE(ser);
41518         return (uint32_t)ret_conv;
41519 }
41520
41521 void  __attribute__((export_name("TS_Route_free"))) TS_Route_free(uint32_t this_obj) {
41522         LDKRoute this_obj_conv;
41523         this_obj_conv.inner = (void*)(this_obj & (~1));
41524         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41525         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41526         Route_free(this_obj_conv);
41527 }
41528
41529 ptrArray  __attribute__((export_name("TS_Route_get_paths"))) TS_Route_get_paths(uint32_t this_ptr) {
41530         LDKRoute this_ptr_conv;
41531         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41532         this_ptr_conv.is_owned = false;
41533         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41534         LDKCVec_CVec_RouteHopZZ ret_var = Route_get_paths(&this_ptr_conv);
41535         ptrArray ret_arr = NULL;
41536         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
41537         uint32_tArray *ret_arr_ptr = (uint32_tArray*)(((uint8_t*)ret_arr) + 8);
41538         for (size_t m = 0; m < ret_var.datalen; m++) {
41539                 LDKCVec_RouteHopZ ret_conv_12_var = ret_var.data[m];
41540                 uint32_tArray ret_conv_12_arr = NULL;
41541                 ret_conv_12_arr = init_uint32_tArray(ret_conv_12_var.datalen, __LINE__);
41542                 uint32_t *ret_conv_12_arr_ptr = (uint32_t*)(((uint8_t*)ret_conv_12_arr) + 8);
41543                 for (size_t k = 0; k < ret_conv_12_var.datalen; k++) {
41544                         LDKRouteHop ret_conv_12_conv_10_var = ret_conv_12_var.data[k];
41545                         uint32_t ret_conv_12_conv_10_ref = 0;
41546                         CHECK((((uintptr_t)ret_conv_12_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41547                         CHECK((((uintptr_t)&ret_conv_12_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41548                         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_12_conv_10_var);
41549                         ret_conv_12_conv_10_ref = (uintptr_t)ret_conv_12_conv_10_var.inner;
41550                         if (ret_conv_12_conv_10_var.is_owned) {
41551                                 ret_conv_12_conv_10_ref |= 1;
41552                         }
41553                         ret_conv_12_arr_ptr[k] = ret_conv_12_conv_10_ref;
41554                 }
41555                 
41556                 FREE(ret_conv_12_var.data);
41557                 ret_arr_ptr[m] = ret_conv_12_arr;
41558         }
41559         
41560         FREE(ret_var.data);
41561         return ret_arr;
41562 }
41563
41564 void  __attribute__((export_name("TS_Route_set_paths"))) TS_Route_set_paths(uint32_t this_ptr, ptrArray val) {
41565         LDKRoute this_ptr_conv;
41566         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41567         this_ptr_conv.is_owned = false;
41568         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41569         LDKCVec_CVec_RouteHopZZ val_constr;
41570         val_constr.datalen = val->arr_len;
41571         if (val_constr.datalen > 0)
41572                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
41573         else
41574                 val_constr.data = NULL;
41575         uint32_tArray* val_vals = (void*) val->elems;
41576         for (size_t m = 0; m < val_constr.datalen; m++) {
41577                 uint32_tArray val_conv_12 = val_vals[m];
41578                 LDKCVec_RouteHopZ val_conv_12_constr;
41579                 val_conv_12_constr.datalen = val_conv_12->arr_len;
41580                 if (val_conv_12_constr.datalen > 0)
41581                         val_conv_12_constr.data = MALLOC(val_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
41582                 else
41583                         val_conv_12_constr.data = NULL;
41584                 uint32_t* val_conv_12_vals = val_conv_12->elems;
41585                 for (size_t k = 0; k < val_conv_12_constr.datalen; k++) {
41586                         uint32_t val_conv_12_conv_10 = val_conv_12_vals[k];
41587                         LDKRouteHop val_conv_12_conv_10_conv;
41588                         val_conv_12_conv_10_conv.inner = (void*)(val_conv_12_conv_10 & (~1));
41589                         val_conv_12_conv_10_conv.is_owned = (val_conv_12_conv_10 & 1) || (val_conv_12_conv_10 == 0);
41590                         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_12_conv_10_conv);
41591                         val_conv_12_conv_10_conv = RouteHop_clone(&val_conv_12_conv_10_conv);
41592                         val_conv_12_constr.data[k] = val_conv_12_conv_10_conv;
41593                 }
41594                 FREE(val_conv_12);
41595                 val_constr.data[m] = val_conv_12_constr;
41596         }
41597         FREE(val);
41598         Route_set_paths(&this_ptr_conv, val_constr);
41599 }
41600
41601 uint32_t  __attribute__((export_name("TS_Route_get_payment_params"))) TS_Route_get_payment_params(uint32_t this_ptr) {
41602         LDKRoute this_ptr_conv;
41603         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41604         this_ptr_conv.is_owned = false;
41605         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41606         LDKPaymentParameters ret_var = Route_get_payment_params(&this_ptr_conv);
41607         uint32_t ret_ref = 0;
41608         if ((uintptr_t)ret_var.inner > 4096) {
41609                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41610                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41611         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41612                 ret_ref = (uintptr_t)ret_var.inner;
41613                 if (ret_var.is_owned) {
41614                         ret_ref |= 1;
41615                 }
41616         }
41617         return ret_ref;
41618 }
41619
41620 void  __attribute__((export_name("TS_Route_set_payment_params"))) TS_Route_set_payment_params(uint32_t this_ptr, uint32_t val) {
41621         LDKRoute this_ptr_conv;
41622         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41623         this_ptr_conv.is_owned = false;
41624         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41625         LDKPaymentParameters val_conv;
41626         val_conv.inner = (void*)(val & (~1));
41627         val_conv.is_owned = (val & 1) || (val == 0);
41628         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
41629         val_conv = PaymentParameters_clone(&val_conv);
41630         Route_set_payment_params(&this_ptr_conv, val_conv);
41631 }
41632
41633 uint32_t  __attribute__((export_name("TS_Route_new"))) TS_Route_new(ptrArray paths_arg, uint32_t payment_params_arg) {
41634         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
41635         paths_arg_constr.datalen = paths_arg->arr_len;
41636         if (paths_arg_constr.datalen > 0)
41637                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
41638         else
41639                 paths_arg_constr.data = NULL;
41640         uint32_tArray* paths_arg_vals = (void*) paths_arg->elems;
41641         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
41642                 uint32_tArray paths_arg_conv_12 = paths_arg_vals[m];
41643                 LDKCVec_RouteHopZ paths_arg_conv_12_constr;
41644                 paths_arg_conv_12_constr.datalen = paths_arg_conv_12->arr_len;
41645                 if (paths_arg_conv_12_constr.datalen > 0)
41646                         paths_arg_conv_12_constr.data = MALLOC(paths_arg_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
41647                 else
41648                         paths_arg_conv_12_constr.data = NULL;
41649                 uint32_t* paths_arg_conv_12_vals = paths_arg_conv_12->elems;
41650                 for (size_t k = 0; k < paths_arg_conv_12_constr.datalen; k++) {
41651                         uint32_t paths_arg_conv_12_conv_10 = paths_arg_conv_12_vals[k];
41652                         LDKRouteHop paths_arg_conv_12_conv_10_conv;
41653                         paths_arg_conv_12_conv_10_conv.inner = (void*)(paths_arg_conv_12_conv_10 & (~1));
41654                         paths_arg_conv_12_conv_10_conv.is_owned = (paths_arg_conv_12_conv_10 & 1) || (paths_arg_conv_12_conv_10 == 0);
41655                         CHECK_INNER_FIELD_ACCESS_OR_NULL(paths_arg_conv_12_conv_10_conv);
41656                         paths_arg_conv_12_conv_10_conv = RouteHop_clone(&paths_arg_conv_12_conv_10_conv);
41657                         paths_arg_conv_12_constr.data[k] = paths_arg_conv_12_conv_10_conv;
41658                 }
41659                 FREE(paths_arg_conv_12);
41660                 paths_arg_constr.data[m] = paths_arg_conv_12_constr;
41661         }
41662         FREE(paths_arg);
41663         LDKPaymentParameters payment_params_arg_conv;
41664         payment_params_arg_conv.inner = (void*)(payment_params_arg & (~1));
41665         payment_params_arg_conv.is_owned = (payment_params_arg & 1) || (payment_params_arg == 0);
41666         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_arg_conv);
41667         payment_params_arg_conv = PaymentParameters_clone(&payment_params_arg_conv);
41668         LDKRoute ret_var = Route_new(paths_arg_constr, payment_params_arg_conv);
41669         uint32_t ret_ref = 0;
41670         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41671         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41672         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41673         ret_ref = (uintptr_t)ret_var.inner;
41674         if (ret_var.is_owned) {
41675                 ret_ref |= 1;
41676         }
41677         return ret_ref;
41678 }
41679
41680 static inline uintptr_t Route_clone_ptr(LDKRoute *NONNULL_PTR arg) {
41681         LDKRoute ret_var = Route_clone(arg);
41682 uint32_t ret_ref = 0;
41683 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41684 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41685 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41686 ret_ref = (uintptr_t)ret_var.inner;
41687 if (ret_var.is_owned) {
41688         ret_ref |= 1;
41689 }
41690         return ret_ref;
41691 }
41692 uint32_t  __attribute__((export_name("TS_Route_clone_ptr"))) TS_Route_clone_ptr(uint32_t arg) {
41693         LDKRoute arg_conv;
41694         arg_conv.inner = (void*)(arg & (~1));
41695         arg_conv.is_owned = false;
41696         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41697         uint32_t ret_conv = Route_clone_ptr(&arg_conv);
41698         return ret_conv;
41699 }
41700
41701 uint32_t  __attribute__((export_name("TS_Route_clone"))) TS_Route_clone(uint32_t orig) {
41702         LDKRoute orig_conv;
41703         orig_conv.inner = (void*)(orig & (~1));
41704         orig_conv.is_owned = false;
41705         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41706         LDKRoute ret_var = Route_clone(&orig_conv);
41707         uint32_t ret_ref = 0;
41708         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41709         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41710         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41711         ret_ref = (uintptr_t)ret_var.inner;
41712         if (ret_var.is_owned) {
41713                 ret_ref |= 1;
41714         }
41715         return ret_ref;
41716 }
41717
41718 int64_t  __attribute__((export_name("TS_Route_hash"))) TS_Route_hash(uint32_t o) {
41719         LDKRoute o_conv;
41720         o_conv.inner = (void*)(o & (~1));
41721         o_conv.is_owned = false;
41722         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
41723         int64_t ret_conv = Route_hash(&o_conv);
41724         return ret_conv;
41725 }
41726
41727 jboolean  __attribute__((export_name("TS_Route_eq"))) TS_Route_eq(uint32_t a, uint32_t b) {
41728         LDKRoute a_conv;
41729         a_conv.inner = (void*)(a & (~1));
41730         a_conv.is_owned = false;
41731         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
41732         LDKRoute b_conv;
41733         b_conv.inner = (void*)(b & (~1));
41734         b_conv.is_owned = false;
41735         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
41736         jboolean ret_conv = Route_eq(&a_conv, &b_conv);
41737         return ret_conv;
41738 }
41739
41740 int64_t  __attribute__((export_name("TS_Route_get_total_fees"))) TS_Route_get_total_fees(uint32_t this_arg) {
41741         LDKRoute this_arg_conv;
41742         this_arg_conv.inner = (void*)(this_arg & (~1));
41743         this_arg_conv.is_owned = false;
41744         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41745         int64_t ret_conv = Route_get_total_fees(&this_arg_conv);
41746         return ret_conv;
41747 }
41748
41749 int64_t  __attribute__((export_name("TS_Route_get_total_amount"))) TS_Route_get_total_amount(uint32_t this_arg) {
41750         LDKRoute this_arg_conv;
41751         this_arg_conv.inner = (void*)(this_arg & (~1));
41752         this_arg_conv.is_owned = false;
41753         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41754         int64_t ret_conv = Route_get_total_amount(&this_arg_conv);
41755         return ret_conv;
41756 }
41757
41758 int8_tArray  __attribute__((export_name("TS_Route_write"))) TS_Route_write(uint32_t obj) {
41759         LDKRoute obj_conv;
41760         obj_conv.inner = (void*)(obj & (~1));
41761         obj_conv.is_owned = false;
41762         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41763         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
41764         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
41765         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
41766         CVec_u8Z_free(ret_var);
41767         return ret_arr;
41768 }
41769
41770 uint32_t  __attribute__((export_name("TS_Route_read"))) TS_Route_read(int8_tArray ser) {
41771         LDKu8slice ser_ref;
41772         ser_ref.datalen = ser->arr_len;
41773         ser_ref.data = ser->elems;
41774         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
41775         *ret_conv = Route_read(ser_ref);
41776         FREE(ser);
41777         return (uint32_t)ret_conv;
41778 }
41779
41780 void  __attribute__((export_name("TS_RouteParameters_free"))) TS_RouteParameters_free(uint32_t this_obj) {
41781         LDKRouteParameters this_obj_conv;
41782         this_obj_conv.inner = (void*)(this_obj & (~1));
41783         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41784         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41785         RouteParameters_free(this_obj_conv);
41786 }
41787
41788 uint32_t  __attribute__((export_name("TS_RouteParameters_get_payment_params"))) TS_RouteParameters_get_payment_params(uint32_t this_ptr) {
41789         LDKRouteParameters this_ptr_conv;
41790         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41791         this_ptr_conv.is_owned = false;
41792         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41793         LDKPaymentParameters ret_var = RouteParameters_get_payment_params(&this_ptr_conv);
41794         uint32_t ret_ref = 0;
41795         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41796         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41797         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41798         ret_ref = (uintptr_t)ret_var.inner;
41799         if (ret_var.is_owned) {
41800                 ret_ref |= 1;
41801         }
41802         return ret_ref;
41803 }
41804
41805 void  __attribute__((export_name("TS_RouteParameters_set_payment_params"))) TS_RouteParameters_set_payment_params(uint32_t this_ptr, uint32_t val) {
41806         LDKRouteParameters this_ptr_conv;
41807         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41808         this_ptr_conv.is_owned = false;
41809         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41810         LDKPaymentParameters val_conv;
41811         val_conv.inner = (void*)(val & (~1));
41812         val_conv.is_owned = (val & 1) || (val == 0);
41813         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
41814         val_conv = PaymentParameters_clone(&val_conv);
41815         RouteParameters_set_payment_params(&this_ptr_conv, val_conv);
41816 }
41817
41818 int64_t  __attribute__((export_name("TS_RouteParameters_get_final_value_msat"))) TS_RouteParameters_get_final_value_msat(uint32_t this_ptr) {
41819         LDKRouteParameters this_ptr_conv;
41820         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41821         this_ptr_conv.is_owned = false;
41822         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41823         int64_t ret_conv = RouteParameters_get_final_value_msat(&this_ptr_conv);
41824         return ret_conv;
41825 }
41826
41827 void  __attribute__((export_name("TS_RouteParameters_set_final_value_msat"))) TS_RouteParameters_set_final_value_msat(uint32_t this_ptr, int64_t val) {
41828         LDKRouteParameters this_ptr_conv;
41829         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41830         this_ptr_conv.is_owned = false;
41831         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41832         RouteParameters_set_final_value_msat(&this_ptr_conv, val);
41833 }
41834
41835 int32_t  __attribute__((export_name("TS_RouteParameters_get_final_cltv_expiry_delta"))) TS_RouteParameters_get_final_cltv_expiry_delta(uint32_t this_ptr) {
41836         LDKRouteParameters this_ptr_conv;
41837         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41838         this_ptr_conv.is_owned = false;
41839         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41840         int32_t ret_conv = RouteParameters_get_final_cltv_expiry_delta(&this_ptr_conv);
41841         return ret_conv;
41842 }
41843
41844 void  __attribute__((export_name("TS_RouteParameters_set_final_cltv_expiry_delta"))) TS_RouteParameters_set_final_cltv_expiry_delta(uint32_t this_ptr, int32_t val) {
41845         LDKRouteParameters this_ptr_conv;
41846         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41847         this_ptr_conv.is_owned = false;
41848         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41849         RouteParameters_set_final_cltv_expiry_delta(&this_ptr_conv, val);
41850 }
41851
41852 uint32_t  __attribute__((export_name("TS_RouteParameters_new"))) TS_RouteParameters_new(uint32_t payment_params_arg, int64_t final_value_msat_arg, int32_t final_cltv_expiry_delta_arg) {
41853         LDKPaymentParameters payment_params_arg_conv;
41854         payment_params_arg_conv.inner = (void*)(payment_params_arg & (~1));
41855         payment_params_arg_conv.is_owned = (payment_params_arg & 1) || (payment_params_arg == 0);
41856         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_arg_conv);
41857         payment_params_arg_conv = PaymentParameters_clone(&payment_params_arg_conv);
41858         LDKRouteParameters ret_var = RouteParameters_new(payment_params_arg_conv, final_value_msat_arg, final_cltv_expiry_delta_arg);
41859         uint32_t ret_ref = 0;
41860         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41861         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41862         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41863         ret_ref = (uintptr_t)ret_var.inner;
41864         if (ret_var.is_owned) {
41865                 ret_ref |= 1;
41866         }
41867         return ret_ref;
41868 }
41869
41870 static inline uintptr_t RouteParameters_clone_ptr(LDKRouteParameters *NONNULL_PTR arg) {
41871         LDKRouteParameters ret_var = RouteParameters_clone(arg);
41872 uint32_t ret_ref = 0;
41873 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41874 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41875 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41876 ret_ref = (uintptr_t)ret_var.inner;
41877 if (ret_var.is_owned) {
41878         ret_ref |= 1;
41879 }
41880         return ret_ref;
41881 }
41882 uint32_t  __attribute__((export_name("TS_RouteParameters_clone_ptr"))) TS_RouteParameters_clone_ptr(uint32_t arg) {
41883         LDKRouteParameters arg_conv;
41884         arg_conv.inner = (void*)(arg & (~1));
41885         arg_conv.is_owned = false;
41886         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41887         uint32_t ret_conv = RouteParameters_clone_ptr(&arg_conv);
41888         return ret_conv;
41889 }
41890
41891 uint32_t  __attribute__((export_name("TS_RouteParameters_clone"))) TS_RouteParameters_clone(uint32_t orig) {
41892         LDKRouteParameters orig_conv;
41893         orig_conv.inner = (void*)(orig & (~1));
41894         orig_conv.is_owned = false;
41895         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41896         LDKRouteParameters ret_var = RouteParameters_clone(&orig_conv);
41897         uint32_t ret_ref = 0;
41898         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41899         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41900         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41901         ret_ref = (uintptr_t)ret_var.inner;
41902         if (ret_var.is_owned) {
41903                 ret_ref |= 1;
41904         }
41905         return ret_ref;
41906 }
41907
41908 int8_tArray  __attribute__((export_name("TS_RouteParameters_write"))) TS_RouteParameters_write(uint32_t obj) {
41909         LDKRouteParameters obj_conv;
41910         obj_conv.inner = (void*)(obj & (~1));
41911         obj_conv.is_owned = false;
41912         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41913         LDKCVec_u8Z ret_var = RouteParameters_write(&obj_conv);
41914         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
41915         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
41916         CVec_u8Z_free(ret_var);
41917         return ret_arr;
41918 }
41919
41920 uint32_t  __attribute__((export_name("TS_RouteParameters_read"))) TS_RouteParameters_read(int8_tArray ser) {
41921         LDKu8slice ser_ref;
41922         ser_ref.datalen = ser->arr_len;
41923         ser_ref.data = ser->elems;
41924         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
41925         *ret_conv = RouteParameters_read(ser_ref);
41926         FREE(ser);
41927         return (uint32_t)ret_conv;
41928 }
41929
41930 void  __attribute__((export_name("TS_PaymentParameters_free"))) TS_PaymentParameters_free(uint32_t this_obj) {
41931         LDKPaymentParameters this_obj_conv;
41932         this_obj_conv.inner = (void*)(this_obj & (~1));
41933         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41934         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41935         PaymentParameters_free(this_obj_conv);
41936 }
41937
41938 int8_tArray  __attribute__((export_name("TS_PaymentParameters_get_payee_pubkey"))) TS_PaymentParameters_get_payee_pubkey(uint32_t this_ptr) {
41939         LDKPaymentParameters this_ptr_conv;
41940         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41941         this_ptr_conv.is_owned = false;
41942         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41943         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
41944         memcpy(ret_arr->elems, PaymentParameters_get_payee_pubkey(&this_ptr_conv).compressed_form, 33);
41945         return ret_arr;
41946 }
41947
41948 void  __attribute__((export_name("TS_PaymentParameters_set_payee_pubkey"))) TS_PaymentParameters_set_payee_pubkey(uint32_t this_ptr, int8_tArray val) {
41949         LDKPaymentParameters this_ptr_conv;
41950         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41951         this_ptr_conv.is_owned = false;
41952         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41953         LDKPublicKey val_ref;
41954         CHECK(val->arr_len == 33);
41955         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
41956         PaymentParameters_set_payee_pubkey(&this_ptr_conv, val_ref);
41957 }
41958
41959 uint32_t  __attribute__((export_name("TS_PaymentParameters_get_features"))) TS_PaymentParameters_get_features(uint32_t this_ptr) {
41960         LDKPaymentParameters this_ptr_conv;
41961         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41962         this_ptr_conv.is_owned = false;
41963         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41964         LDKInvoiceFeatures ret_var = PaymentParameters_get_features(&this_ptr_conv);
41965         uint32_t ret_ref = 0;
41966         if ((uintptr_t)ret_var.inner > 4096) {
41967                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41968                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41969         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41970                 ret_ref = (uintptr_t)ret_var.inner;
41971                 if (ret_var.is_owned) {
41972                         ret_ref |= 1;
41973                 }
41974         }
41975         return ret_ref;
41976 }
41977
41978 void  __attribute__((export_name("TS_PaymentParameters_set_features"))) TS_PaymentParameters_set_features(uint32_t this_ptr, uint32_t val) {
41979         LDKPaymentParameters this_ptr_conv;
41980         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41981         this_ptr_conv.is_owned = false;
41982         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41983         LDKInvoiceFeatures val_conv;
41984         val_conv.inner = (void*)(val & (~1));
41985         val_conv.is_owned = (val & 1) || (val == 0);
41986         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
41987         val_conv = InvoiceFeatures_clone(&val_conv);
41988         PaymentParameters_set_features(&this_ptr_conv, val_conv);
41989 }
41990
41991 uint32_tArray  __attribute__((export_name("TS_PaymentParameters_get_route_hints"))) TS_PaymentParameters_get_route_hints(uint32_t this_ptr) {
41992         LDKPaymentParameters this_ptr_conv;
41993         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41994         this_ptr_conv.is_owned = false;
41995         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41996         LDKCVec_RouteHintZ ret_var = PaymentParameters_get_route_hints(&this_ptr_conv);
41997         uint32_tArray ret_arr = NULL;
41998         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
41999         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 8);
42000         for (size_t l = 0; l < ret_var.datalen; l++) {
42001                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
42002                 uint32_t ret_conv_11_ref = 0;
42003                 CHECK((((uintptr_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42004                 CHECK((((uintptr_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42005                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
42006                 ret_conv_11_ref = (uintptr_t)ret_conv_11_var.inner;
42007                 if (ret_conv_11_var.is_owned) {
42008                         ret_conv_11_ref |= 1;
42009                 }
42010                 ret_arr_ptr[l] = ret_conv_11_ref;
42011         }
42012         
42013         FREE(ret_var.data);
42014         return ret_arr;
42015 }
42016
42017 void  __attribute__((export_name("TS_PaymentParameters_set_route_hints"))) TS_PaymentParameters_set_route_hints(uint32_t this_ptr, uint32_tArray val) {
42018         LDKPaymentParameters this_ptr_conv;
42019         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42020         this_ptr_conv.is_owned = false;
42021         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42022         LDKCVec_RouteHintZ val_constr;
42023         val_constr.datalen = val->arr_len;
42024         if (val_constr.datalen > 0)
42025                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
42026         else
42027                 val_constr.data = NULL;
42028         uint32_t* val_vals = val->elems;
42029         for (size_t l = 0; l < val_constr.datalen; l++) {
42030                 uint32_t val_conv_11 = val_vals[l];
42031                 LDKRouteHint val_conv_11_conv;
42032                 val_conv_11_conv.inner = (void*)(val_conv_11 & (~1));
42033                 val_conv_11_conv.is_owned = (val_conv_11 & 1) || (val_conv_11 == 0);
42034                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_11_conv);
42035                 val_conv_11_conv = RouteHint_clone(&val_conv_11_conv);
42036                 val_constr.data[l] = val_conv_11_conv;
42037         }
42038         FREE(val);
42039         PaymentParameters_set_route_hints(&this_ptr_conv, val_constr);
42040 }
42041
42042 uint32_t  __attribute__((export_name("TS_PaymentParameters_get_expiry_time"))) TS_PaymentParameters_get_expiry_time(uint32_t this_ptr) {
42043         LDKPaymentParameters this_ptr_conv;
42044         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42045         this_ptr_conv.is_owned = false;
42046         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42047         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
42048         *ret_copy = PaymentParameters_get_expiry_time(&this_ptr_conv);
42049         uint32_t ret_ref = (uintptr_t)ret_copy;
42050         return ret_ref;
42051 }
42052
42053 void  __attribute__((export_name("TS_PaymentParameters_set_expiry_time"))) TS_PaymentParameters_set_expiry_time(uint32_t this_ptr, uint32_t val) {
42054         LDKPaymentParameters this_ptr_conv;
42055         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42056         this_ptr_conv.is_owned = false;
42057         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42058         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
42059         CHECK_ACCESS(val_ptr);
42060         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
42061         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
42062         PaymentParameters_set_expiry_time(&this_ptr_conv, val_conv);
42063 }
42064
42065 int32_t  __attribute__((export_name("TS_PaymentParameters_get_max_total_cltv_expiry_delta"))) TS_PaymentParameters_get_max_total_cltv_expiry_delta(uint32_t this_ptr) {
42066         LDKPaymentParameters this_ptr_conv;
42067         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42068         this_ptr_conv.is_owned = false;
42069         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42070         int32_t ret_conv = PaymentParameters_get_max_total_cltv_expiry_delta(&this_ptr_conv);
42071         return ret_conv;
42072 }
42073
42074 void  __attribute__((export_name("TS_PaymentParameters_set_max_total_cltv_expiry_delta"))) TS_PaymentParameters_set_max_total_cltv_expiry_delta(uint32_t this_ptr, int32_t val) {
42075         LDKPaymentParameters this_ptr_conv;
42076         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42077         this_ptr_conv.is_owned = false;
42078         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42079         PaymentParameters_set_max_total_cltv_expiry_delta(&this_ptr_conv, val);
42080 }
42081
42082 int8_t  __attribute__((export_name("TS_PaymentParameters_get_max_path_count"))) TS_PaymentParameters_get_max_path_count(uint32_t this_ptr) {
42083         LDKPaymentParameters this_ptr_conv;
42084         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42085         this_ptr_conv.is_owned = false;
42086         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42087         int8_t ret_conv = PaymentParameters_get_max_path_count(&this_ptr_conv);
42088         return ret_conv;
42089 }
42090
42091 void  __attribute__((export_name("TS_PaymentParameters_set_max_path_count"))) TS_PaymentParameters_set_max_path_count(uint32_t this_ptr, int8_t val) {
42092         LDKPaymentParameters this_ptr_conv;
42093         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42094         this_ptr_conv.is_owned = false;
42095         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42096         PaymentParameters_set_max_path_count(&this_ptr_conv, val);
42097 }
42098
42099 int8_t  __attribute__((export_name("TS_PaymentParameters_get_max_channel_saturation_power_of_half"))) TS_PaymentParameters_get_max_channel_saturation_power_of_half(uint32_t this_ptr) {
42100         LDKPaymentParameters this_ptr_conv;
42101         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42102         this_ptr_conv.is_owned = false;
42103         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42104         int8_t ret_conv = PaymentParameters_get_max_channel_saturation_power_of_half(&this_ptr_conv);
42105         return ret_conv;
42106 }
42107
42108 void  __attribute__((export_name("TS_PaymentParameters_set_max_channel_saturation_power_of_half"))) TS_PaymentParameters_set_max_channel_saturation_power_of_half(uint32_t this_ptr, int8_t val) {
42109         LDKPaymentParameters this_ptr_conv;
42110         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42111         this_ptr_conv.is_owned = false;
42112         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42113         PaymentParameters_set_max_channel_saturation_power_of_half(&this_ptr_conv, val);
42114 }
42115
42116 int64_tArray  __attribute__((export_name("TS_PaymentParameters_get_previously_failed_channels"))) TS_PaymentParameters_get_previously_failed_channels(uint32_t this_ptr) {
42117         LDKPaymentParameters this_ptr_conv;
42118         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42119         this_ptr_conv.is_owned = false;
42120         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42121         LDKCVec_u64Z ret_var = PaymentParameters_get_previously_failed_channels(&this_ptr_conv);
42122         int64_tArray ret_arr = NULL;
42123         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
42124         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
42125         for (size_t i = 0; i < ret_var.datalen; i++) {
42126                 int64_t ret_conv_8_conv = ret_var.data[i];
42127                 ret_arr_ptr[i] = ret_conv_8_conv;
42128         }
42129         
42130         FREE(ret_var.data);
42131         return ret_arr;
42132 }
42133
42134 void  __attribute__((export_name("TS_PaymentParameters_set_previously_failed_channels"))) TS_PaymentParameters_set_previously_failed_channels(uint32_t this_ptr, int64_tArray val) {
42135         LDKPaymentParameters this_ptr_conv;
42136         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42137         this_ptr_conv.is_owned = false;
42138         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42139         LDKCVec_u64Z val_constr;
42140         val_constr.datalen = val->arr_len;
42141         if (val_constr.datalen > 0)
42142                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
42143         else
42144                 val_constr.data = NULL;
42145         int64_t* val_vals = val->elems;
42146         for (size_t i = 0; i < val_constr.datalen; i++) {
42147                 int64_t val_conv_8 = val_vals[i];
42148                 val_constr.data[i] = val_conv_8;
42149         }
42150         FREE(val);
42151         PaymentParameters_set_previously_failed_channels(&this_ptr_conv, val_constr);
42152 }
42153
42154 uint32_t  __attribute__((export_name("TS_PaymentParameters_new"))) TS_PaymentParameters_new(int8_tArray payee_pubkey_arg, uint32_t features_arg, uint32_tArray route_hints_arg, uint32_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) {
42155         LDKPublicKey payee_pubkey_arg_ref;
42156         CHECK(payee_pubkey_arg->arr_len == 33);
42157         memcpy(payee_pubkey_arg_ref.compressed_form, payee_pubkey_arg->elems, 33); FREE(payee_pubkey_arg);
42158         LDKInvoiceFeatures features_arg_conv;
42159         features_arg_conv.inner = (void*)(features_arg & (~1));
42160         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
42161         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
42162         features_arg_conv = InvoiceFeatures_clone(&features_arg_conv);
42163         LDKCVec_RouteHintZ route_hints_arg_constr;
42164         route_hints_arg_constr.datalen = route_hints_arg->arr_len;
42165         if (route_hints_arg_constr.datalen > 0)
42166                 route_hints_arg_constr.data = MALLOC(route_hints_arg_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
42167         else
42168                 route_hints_arg_constr.data = NULL;
42169         uint32_t* route_hints_arg_vals = route_hints_arg->elems;
42170         for (size_t l = 0; l < route_hints_arg_constr.datalen; l++) {
42171                 uint32_t route_hints_arg_conv_11 = route_hints_arg_vals[l];
42172                 LDKRouteHint route_hints_arg_conv_11_conv;
42173                 route_hints_arg_conv_11_conv.inner = (void*)(route_hints_arg_conv_11 & (~1));
42174                 route_hints_arg_conv_11_conv.is_owned = (route_hints_arg_conv_11 & 1) || (route_hints_arg_conv_11 == 0);
42175                 CHECK_INNER_FIELD_ACCESS_OR_NULL(route_hints_arg_conv_11_conv);
42176                 route_hints_arg_conv_11_conv = RouteHint_clone(&route_hints_arg_conv_11_conv);
42177                 route_hints_arg_constr.data[l] = route_hints_arg_conv_11_conv;
42178         }
42179         FREE(route_hints_arg);
42180         void* expiry_time_arg_ptr = (void*)(((uintptr_t)expiry_time_arg) & ~1);
42181         CHECK_ACCESS(expiry_time_arg_ptr);
42182         LDKCOption_u64Z expiry_time_arg_conv = *(LDKCOption_u64Z*)(expiry_time_arg_ptr);
42183         expiry_time_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)expiry_time_arg) & ~1));
42184         LDKCVec_u64Z previously_failed_channels_arg_constr;
42185         previously_failed_channels_arg_constr.datalen = previously_failed_channels_arg->arr_len;
42186         if (previously_failed_channels_arg_constr.datalen > 0)
42187                 previously_failed_channels_arg_constr.data = MALLOC(previously_failed_channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
42188         else
42189                 previously_failed_channels_arg_constr.data = NULL;
42190         int64_t* previously_failed_channels_arg_vals = previously_failed_channels_arg->elems;
42191         for (size_t i = 0; i < previously_failed_channels_arg_constr.datalen; i++) {
42192                 int64_t previously_failed_channels_arg_conv_8 = previously_failed_channels_arg_vals[i];
42193                 previously_failed_channels_arg_constr.data[i] = previously_failed_channels_arg_conv_8;
42194         }
42195         FREE(previously_failed_channels_arg);
42196         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);
42197         uint32_t ret_ref = 0;
42198         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42199         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42200         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42201         ret_ref = (uintptr_t)ret_var.inner;
42202         if (ret_var.is_owned) {
42203                 ret_ref |= 1;
42204         }
42205         return ret_ref;
42206 }
42207
42208 static inline uintptr_t PaymentParameters_clone_ptr(LDKPaymentParameters *NONNULL_PTR arg) {
42209         LDKPaymentParameters ret_var = PaymentParameters_clone(arg);
42210 uint32_t ret_ref = 0;
42211 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42212 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42213 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42214 ret_ref = (uintptr_t)ret_var.inner;
42215 if (ret_var.is_owned) {
42216         ret_ref |= 1;
42217 }
42218         return ret_ref;
42219 }
42220 uint32_t  __attribute__((export_name("TS_PaymentParameters_clone_ptr"))) TS_PaymentParameters_clone_ptr(uint32_t arg) {
42221         LDKPaymentParameters arg_conv;
42222         arg_conv.inner = (void*)(arg & (~1));
42223         arg_conv.is_owned = false;
42224         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42225         uint32_t ret_conv = PaymentParameters_clone_ptr(&arg_conv);
42226         return ret_conv;
42227 }
42228
42229 uint32_t  __attribute__((export_name("TS_PaymentParameters_clone"))) TS_PaymentParameters_clone(uint32_t orig) {
42230         LDKPaymentParameters orig_conv;
42231         orig_conv.inner = (void*)(orig & (~1));
42232         orig_conv.is_owned = false;
42233         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42234         LDKPaymentParameters ret_var = PaymentParameters_clone(&orig_conv);
42235         uint32_t ret_ref = 0;
42236         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42237         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42238         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42239         ret_ref = (uintptr_t)ret_var.inner;
42240         if (ret_var.is_owned) {
42241                 ret_ref |= 1;
42242         }
42243         return ret_ref;
42244 }
42245
42246 int64_t  __attribute__((export_name("TS_PaymentParameters_hash"))) TS_PaymentParameters_hash(uint32_t o) {
42247         LDKPaymentParameters o_conv;
42248         o_conv.inner = (void*)(o & (~1));
42249         o_conv.is_owned = false;
42250         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
42251         int64_t ret_conv = PaymentParameters_hash(&o_conv);
42252         return ret_conv;
42253 }
42254
42255 jboolean  __attribute__((export_name("TS_PaymentParameters_eq"))) TS_PaymentParameters_eq(uint32_t a, uint32_t b) {
42256         LDKPaymentParameters a_conv;
42257         a_conv.inner = (void*)(a & (~1));
42258         a_conv.is_owned = false;
42259         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42260         LDKPaymentParameters b_conv;
42261         b_conv.inner = (void*)(b & (~1));
42262         b_conv.is_owned = false;
42263         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42264         jboolean ret_conv = PaymentParameters_eq(&a_conv, &b_conv);
42265         return ret_conv;
42266 }
42267
42268 int8_tArray  __attribute__((export_name("TS_PaymentParameters_write"))) TS_PaymentParameters_write(uint32_t obj) {
42269         LDKPaymentParameters obj_conv;
42270         obj_conv.inner = (void*)(obj & (~1));
42271         obj_conv.is_owned = false;
42272         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42273         LDKCVec_u8Z ret_var = PaymentParameters_write(&obj_conv);
42274         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
42275         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
42276         CVec_u8Z_free(ret_var);
42277         return ret_arr;
42278 }
42279
42280 uint32_t  __attribute__((export_name("TS_PaymentParameters_read"))) TS_PaymentParameters_read(int8_tArray ser) {
42281         LDKu8slice ser_ref;
42282         ser_ref.datalen = ser->arr_len;
42283         ser_ref.data = ser->elems;
42284         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
42285         *ret_conv = PaymentParameters_read(ser_ref);
42286         FREE(ser);
42287         return (uint32_t)ret_conv;
42288 }
42289
42290 uint32_t  __attribute__((export_name("TS_PaymentParameters_from_node_id"))) TS_PaymentParameters_from_node_id(int8_tArray payee_pubkey) {
42291         LDKPublicKey payee_pubkey_ref;
42292         CHECK(payee_pubkey->arr_len == 33);
42293         memcpy(payee_pubkey_ref.compressed_form, payee_pubkey->elems, 33); FREE(payee_pubkey);
42294         LDKPaymentParameters ret_var = PaymentParameters_from_node_id(payee_pubkey_ref);
42295         uint32_t ret_ref = 0;
42296         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42297         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42298         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42299         ret_ref = (uintptr_t)ret_var.inner;
42300         if (ret_var.is_owned) {
42301                 ret_ref |= 1;
42302         }
42303         return ret_ref;
42304 }
42305
42306 uint32_t  __attribute__((export_name("TS_PaymentParameters_for_keysend"))) TS_PaymentParameters_for_keysend(int8_tArray payee_pubkey) {
42307         LDKPublicKey payee_pubkey_ref;
42308         CHECK(payee_pubkey->arr_len == 33);
42309         memcpy(payee_pubkey_ref.compressed_form, payee_pubkey->elems, 33); FREE(payee_pubkey);
42310         LDKPaymentParameters ret_var = PaymentParameters_for_keysend(payee_pubkey_ref);
42311         uint32_t ret_ref = 0;
42312         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42313         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42314         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42315         ret_ref = (uintptr_t)ret_var.inner;
42316         if (ret_var.is_owned) {
42317                 ret_ref |= 1;
42318         }
42319         return ret_ref;
42320 }
42321
42322 void  __attribute__((export_name("TS_RouteHint_free"))) TS_RouteHint_free(uint32_t this_obj) {
42323         LDKRouteHint this_obj_conv;
42324         this_obj_conv.inner = (void*)(this_obj & (~1));
42325         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42326         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42327         RouteHint_free(this_obj_conv);
42328 }
42329
42330 uint32_tArray  __attribute__((export_name("TS_RouteHint_get_a"))) TS_RouteHint_get_a(uint32_t this_ptr) {
42331         LDKRouteHint this_ptr_conv;
42332         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42333         this_ptr_conv.is_owned = false;
42334         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42335         LDKCVec_RouteHintHopZ ret_var = RouteHint_get_a(&this_ptr_conv);
42336         uint32_tArray ret_arr = NULL;
42337         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
42338         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 8);
42339         for (size_t o = 0; o < ret_var.datalen; o++) {
42340                 LDKRouteHintHop ret_conv_14_var = ret_var.data[o];
42341                 uint32_t ret_conv_14_ref = 0;
42342                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42343                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42344                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
42345                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
42346                 if (ret_conv_14_var.is_owned) {
42347                         ret_conv_14_ref |= 1;
42348                 }
42349                 ret_arr_ptr[o] = ret_conv_14_ref;
42350         }
42351         
42352         FREE(ret_var.data);
42353         return ret_arr;
42354 }
42355
42356 void  __attribute__((export_name("TS_RouteHint_set_a"))) TS_RouteHint_set_a(uint32_t this_ptr, uint32_tArray val) {
42357         LDKRouteHint this_ptr_conv;
42358         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42359         this_ptr_conv.is_owned = false;
42360         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42361         LDKCVec_RouteHintHopZ val_constr;
42362         val_constr.datalen = val->arr_len;
42363         if (val_constr.datalen > 0)
42364                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
42365         else
42366                 val_constr.data = NULL;
42367         uint32_t* val_vals = val->elems;
42368         for (size_t o = 0; o < val_constr.datalen; o++) {
42369                 uint32_t val_conv_14 = val_vals[o];
42370                 LDKRouteHintHop val_conv_14_conv;
42371                 val_conv_14_conv.inner = (void*)(val_conv_14 & (~1));
42372                 val_conv_14_conv.is_owned = (val_conv_14 & 1) || (val_conv_14 == 0);
42373                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_14_conv);
42374                 val_conv_14_conv = RouteHintHop_clone(&val_conv_14_conv);
42375                 val_constr.data[o] = val_conv_14_conv;
42376         }
42377         FREE(val);
42378         RouteHint_set_a(&this_ptr_conv, val_constr);
42379 }
42380
42381 uint32_t  __attribute__((export_name("TS_RouteHint_new"))) TS_RouteHint_new(uint32_tArray a_arg) {
42382         LDKCVec_RouteHintHopZ a_arg_constr;
42383         a_arg_constr.datalen = a_arg->arr_len;
42384         if (a_arg_constr.datalen > 0)
42385                 a_arg_constr.data = MALLOC(a_arg_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
42386         else
42387                 a_arg_constr.data = NULL;
42388         uint32_t* a_arg_vals = a_arg->elems;
42389         for (size_t o = 0; o < a_arg_constr.datalen; o++) {
42390                 uint32_t a_arg_conv_14 = a_arg_vals[o];
42391                 LDKRouteHintHop a_arg_conv_14_conv;
42392                 a_arg_conv_14_conv.inner = (void*)(a_arg_conv_14 & (~1));
42393                 a_arg_conv_14_conv.is_owned = (a_arg_conv_14 & 1) || (a_arg_conv_14 == 0);
42394                 CHECK_INNER_FIELD_ACCESS_OR_NULL(a_arg_conv_14_conv);
42395                 a_arg_conv_14_conv = RouteHintHop_clone(&a_arg_conv_14_conv);
42396                 a_arg_constr.data[o] = a_arg_conv_14_conv;
42397         }
42398         FREE(a_arg);
42399         LDKRouteHint ret_var = RouteHint_new(a_arg_constr);
42400         uint32_t ret_ref = 0;
42401         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42402         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42403         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42404         ret_ref = (uintptr_t)ret_var.inner;
42405         if (ret_var.is_owned) {
42406                 ret_ref |= 1;
42407         }
42408         return ret_ref;
42409 }
42410
42411 static inline uintptr_t RouteHint_clone_ptr(LDKRouteHint *NONNULL_PTR arg) {
42412         LDKRouteHint ret_var = RouteHint_clone(arg);
42413 uint32_t ret_ref = 0;
42414 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42415 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42416 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42417 ret_ref = (uintptr_t)ret_var.inner;
42418 if (ret_var.is_owned) {
42419         ret_ref |= 1;
42420 }
42421         return ret_ref;
42422 }
42423 uint32_t  __attribute__((export_name("TS_RouteHint_clone_ptr"))) TS_RouteHint_clone_ptr(uint32_t arg) {
42424         LDKRouteHint arg_conv;
42425         arg_conv.inner = (void*)(arg & (~1));
42426         arg_conv.is_owned = false;
42427         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42428         uint32_t ret_conv = RouteHint_clone_ptr(&arg_conv);
42429         return ret_conv;
42430 }
42431
42432 uint32_t  __attribute__((export_name("TS_RouteHint_clone"))) TS_RouteHint_clone(uint32_t orig) {
42433         LDKRouteHint orig_conv;
42434         orig_conv.inner = (void*)(orig & (~1));
42435         orig_conv.is_owned = false;
42436         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42437         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
42438         uint32_t ret_ref = 0;
42439         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42440         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42441         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42442         ret_ref = (uintptr_t)ret_var.inner;
42443         if (ret_var.is_owned) {
42444                 ret_ref |= 1;
42445         }
42446         return ret_ref;
42447 }
42448
42449 int64_t  __attribute__((export_name("TS_RouteHint_hash"))) TS_RouteHint_hash(uint32_t o) {
42450         LDKRouteHint o_conv;
42451         o_conv.inner = (void*)(o & (~1));
42452         o_conv.is_owned = false;
42453         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
42454         int64_t ret_conv = RouteHint_hash(&o_conv);
42455         return ret_conv;
42456 }
42457
42458 jboolean  __attribute__((export_name("TS_RouteHint_eq"))) TS_RouteHint_eq(uint32_t a, uint32_t b) {
42459         LDKRouteHint a_conv;
42460         a_conv.inner = (void*)(a & (~1));
42461         a_conv.is_owned = false;
42462         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42463         LDKRouteHint b_conv;
42464         b_conv.inner = (void*)(b & (~1));
42465         b_conv.is_owned = false;
42466         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42467         jboolean ret_conv = RouteHint_eq(&a_conv, &b_conv);
42468         return ret_conv;
42469 }
42470
42471 int8_tArray  __attribute__((export_name("TS_RouteHint_write"))) TS_RouteHint_write(uint32_t obj) {
42472         LDKRouteHint obj_conv;
42473         obj_conv.inner = (void*)(obj & (~1));
42474         obj_conv.is_owned = false;
42475         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42476         LDKCVec_u8Z ret_var = RouteHint_write(&obj_conv);
42477         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
42478         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
42479         CVec_u8Z_free(ret_var);
42480         return ret_arr;
42481 }
42482
42483 uint32_t  __attribute__((export_name("TS_RouteHint_read"))) TS_RouteHint_read(int8_tArray ser) {
42484         LDKu8slice ser_ref;
42485         ser_ref.datalen = ser->arr_len;
42486         ser_ref.data = ser->elems;
42487         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
42488         *ret_conv = RouteHint_read(ser_ref);
42489         FREE(ser);
42490         return (uint32_t)ret_conv;
42491 }
42492
42493 void  __attribute__((export_name("TS_RouteHintHop_free"))) TS_RouteHintHop_free(uint32_t this_obj) {
42494         LDKRouteHintHop this_obj_conv;
42495         this_obj_conv.inner = (void*)(this_obj & (~1));
42496         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42497         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42498         RouteHintHop_free(this_obj_conv);
42499 }
42500
42501 int8_tArray  __attribute__((export_name("TS_RouteHintHop_get_src_node_id"))) TS_RouteHintHop_get_src_node_id(uint32_t this_ptr) {
42502         LDKRouteHintHop this_ptr_conv;
42503         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42504         this_ptr_conv.is_owned = false;
42505         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42506         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
42507         memcpy(ret_arr->elems, RouteHintHop_get_src_node_id(&this_ptr_conv).compressed_form, 33);
42508         return ret_arr;
42509 }
42510
42511 void  __attribute__((export_name("TS_RouteHintHop_set_src_node_id"))) TS_RouteHintHop_set_src_node_id(uint32_t this_ptr, int8_tArray val) {
42512         LDKRouteHintHop this_ptr_conv;
42513         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42514         this_ptr_conv.is_owned = false;
42515         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42516         LDKPublicKey val_ref;
42517         CHECK(val->arr_len == 33);
42518         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
42519         RouteHintHop_set_src_node_id(&this_ptr_conv, val_ref);
42520 }
42521
42522 int64_t  __attribute__((export_name("TS_RouteHintHop_get_short_channel_id"))) TS_RouteHintHop_get_short_channel_id(uint32_t this_ptr) {
42523         LDKRouteHintHop this_ptr_conv;
42524         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42525         this_ptr_conv.is_owned = false;
42526         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42527         int64_t ret_conv = RouteHintHop_get_short_channel_id(&this_ptr_conv);
42528         return ret_conv;
42529 }
42530
42531 void  __attribute__((export_name("TS_RouteHintHop_set_short_channel_id"))) TS_RouteHintHop_set_short_channel_id(uint32_t this_ptr, int64_t val) {
42532         LDKRouteHintHop this_ptr_conv;
42533         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42534         this_ptr_conv.is_owned = false;
42535         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42536         RouteHintHop_set_short_channel_id(&this_ptr_conv, val);
42537 }
42538
42539 uint32_t  __attribute__((export_name("TS_RouteHintHop_get_fees"))) TS_RouteHintHop_get_fees(uint32_t this_ptr) {
42540         LDKRouteHintHop this_ptr_conv;
42541         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42542         this_ptr_conv.is_owned = false;
42543         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42544         LDKRoutingFees ret_var = RouteHintHop_get_fees(&this_ptr_conv);
42545         uint32_t ret_ref = 0;
42546         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42547         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42548         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42549         ret_ref = (uintptr_t)ret_var.inner;
42550         if (ret_var.is_owned) {
42551                 ret_ref |= 1;
42552         }
42553         return ret_ref;
42554 }
42555
42556 void  __attribute__((export_name("TS_RouteHintHop_set_fees"))) TS_RouteHintHop_set_fees(uint32_t this_ptr, uint32_t val) {
42557         LDKRouteHintHop this_ptr_conv;
42558         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42559         this_ptr_conv.is_owned = false;
42560         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42561         LDKRoutingFees val_conv;
42562         val_conv.inner = (void*)(val & (~1));
42563         val_conv.is_owned = (val & 1) || (val == 0);
42564         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
42565         val_conv = RoutingFees_clone(&val_conv);
42566         RouteHintHop_set_fees(&this_ptr_conv, val_conv);
42567 }
42568
42569 int16_t  __attribute__((export_name("TS_RouteHintHop_get_cltv_expiry_delta"))) TS_RouteHintHop_get_cltv_expiry_delta(uint32_t this_ptr) {
42570         LDKRouteHintHop this_ptr_conv;
42571         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42572         this_ptr_conv.is_owned = false;
42573         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42574         int16_t ret_conv = RouteHintHop_get_cltv_expiry_delta(&this_ptr_conv);
42575         return ret_conv;
42576 }
42577
42578 void  __attribute__((export_name("TS_RouteHintHop_set_cltv_expiry_delta"))) TS_RouteHintHop_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
42579         LDKRouteHintHop this_ptr_conv;
42580         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42581         this_ptr_conv.is_owned = false;
42582         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42583         RouteHintHop_set_cltv_expiry_delta(&this_ptr_conv, val);
42584 }
42585
42586 uint32_t  __attribute__((export_name("TS_RouteHintHop_get_htlc_minimum_msat"))) TS_RouteHintHop_get_htlc_minimum_msat(uint32_t this_ptr) {
42587         LDKRouteHintHop this_ptr_conv;
42588         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42589         this_ptr_conv.is_owned = false;
42590         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42591         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
42592         *ret_copy = RouteHintHop_get_htlc_minimum_msat(&this_ptr_conv);
42593         uint32_t ret_ref = (uintptr_t)ret_copy;
42594         return ret_ref;
42595 }
42596
42597 void  __attribute__((export_name("TS_RouteHintHop_set_htlc_minimum_msat"))) TS_RouteHintHop_set_htlc_minimum_msat(uint32_t this_ptr, uint32_t val) {
42598         LDKRouteHintHop this_ptr_conv;
42599         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42600         this_ptr_conv.is_owned = false;
42601         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42602         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
42603         CHECK_ACCESS(val_ptr);
42604         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
42605         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
42606         RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
42607 }
42608
42609 uint32_t  __attribute__((export_name("TS_RouteHintHop_get_htlc_maximum_msat"))) TS_RouteHintHop_get_htlc_maximum_msat(uint32_t this_ptr) {
42610         LDKRouteHintHop this_ptr_conv;
42611         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42612         this_ptr_conv.is_owned = false;
42613         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42614         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
42615         *ret_copy = RouteHintHop_get_htlc_maximum_msat(&this_ptr_conv);
42616         uint32_t ret_ref = (uintptr_t)ret_copy;
42617         return ret_ref;
42618 }
42619
42620 void  __attribute__((export_name("TS_RouteHintHop_set_htlc_maximum_msat"))) TS_RouteHintHop_set_htlc_maximum_msat(uint32_t this_ptr, uint32_t val) {
42621         LDKRouteHintHop this_ptr_conv;
42622         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42623         this_ptr_conv.is_owned = false;
42624         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42625         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
42626         CHECK_ACCESS(val_ptr);
42627         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
42628         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
42629         RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
42630 }
42631
42632 uint32_t  __attribute__((export_name("TS_RouteHintHop_new"))) TS_RouteHintHop_new(int8_tArray src_node_id_arg, int64_t short_channel_id_arg, uint32_t fees_arg, int16_t cltv_expiry_delta_arg, uint32_t htlc_minimum_msat_arg, uint32_t htlc_maximum_msat_arg) {
42633         LDKPublicKey src_node_id_arg_ref;
42634         CHECK(src_node_id_arg->arr_len == 33);
42635         memcpy(src_node_id_arg_ref.compressed_form, src_node_id_arg->elems, 33); FREE(src_node_id_arg);
42636         LDKRoutingFees fees_arg_conv;
42637         fees_arg_conv.inner = (void*)(fees_arg & (~1));
42638         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
42639         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
42640         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
42641         void* htlc_minimum_msat_arg_ptr = (void*)(((uintptr_t)htlc_minimum_msat_arg) & ~1);
42642         CHECK_ACCESS(htlc_minimum_msat_arg_ptr);
42643         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_minimum_msat_arg_ptr);
42644         htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_minimum_msat_arg) & ~1));
42645         void* htlc_maximum_msat_arg_ptr = (void*)(((uintptr_t)htlc_maximum_msat_arg) & ~1);
42646         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
42647         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
42648         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_maximum_msat_arg) & ~1));
42649         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);
42650         uint32_t ret_ref = 0;
42651         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42652         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42653         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42654         ret_ref = (uintptr_t)ret_var.inner;
42655         if (ret_var.is_owned) {
42656                 ret_ref |= 1;
42657         }
42658         return ret_ref;
42659 }
42660
42661 static inline uintptr_t RouteHintHop_clone_ptr(LDKRouteHintHop *NONNULL_PTR arg) {
42662         LDKRouteHintHop ret_var = RouteHintHop_clone(arg);
42663 uint32_t ret_ref = 0;
42664 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42665 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42666 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42667 ret_ref = (uintptr_t)ret_var.inner;
42668 if (ret_var.is_owned) {
42669         ret_ref |= 1;
42670 }
42671         return ret_ref;
42672 }
42673 uint32_t  __attribute__((export_name("TS_RouteHintHop_clone_ptr"))) TS_RouteHintHop_clone_ptr(uint32_t arg) {
42674         LDKRouteHintHop arg_conv;
42675         arg_conv.inner = (void*)(arg & (~1));
42676         arg_conv.is_owned = false;
42677         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42678         uint32_t ret_conv = RouteHintHop_clone_ptr(&arg_conv);
42679         return ret_conv;
42680 }
42681
42682 uint32_t  __attribute__((export_name("TS_RouteHintHop_clone"))) TS_RouteHintHop_clone(uint32_t orig) {
42683         LDKRouteHintHop orig_conv;
42684         orig_conv.inner = (void*)(orig & (~1));
42685         orig_conv.is_owned = false;
42686         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42687         LDKRouteHintHop ret_var = RouteHintHop_clone(&orig_conv);
42688         uint32_t ret_ref = 0;
42689         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42690         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42691         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42692         ret_ref = (uintptr_t)ret_var.inner;
42693         if (ret_var.is_owned) {
42694                 ret_ref |= 1;
42695         }
42696         return ret_ref;
42697 }
42698
42699 int64_t  __attribute__((export_name("TS_RouteHintHop_hash"))) TS_RouteHintHop_hash(uint32_t o) {
42700         LDKRouteHintHop o_conv;
42701         o_conv.inner = (void*)(o & (~1));
42702         o_conv.is_owned = false;
42703         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
42704         int64_t ret_conv = RouteHintHop_hash(&o_conv);
42705         return ret_conv;
42706 }
42707
42708 jboolean  __attribute__((export_name("TS_RouteHintHop_eq"))) TS_RouteHintHop_eq(uint32_t a, uint32_t b) {
42709         LDKRouteHintHop a_conv;
42710         a_conv.inner = (void*)(a & (~1));
42711         a_conv.is_owned = false;
42712         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42713         LDKRouteHintHop b_conv;
42714         b_conv.inner = (void*)(b & (~1));
42715         b_conv.is_owned = false;
42716         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42717         jboolean ret_conv = RouteHintHop_eq(&a_conv, &b_conv);
42718         return ret_conv;
42719 }
42720
42721 int8_tArray  __attribute__((export_name("TS_RouteHintHop_write"))) TS_RouteHintHop_write(uint32_t obj) {
42722         LDKRouteHintHop obj_conv;
42723         obj_conv.inner = (void*)(obj & (~1));
42724         obj_conv.is_owned = false;
42725         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42726         LDKCVec_u8Z ret_var = RouteHintHop_write(&obj_conv);
42727         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
42728         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
42729         CVec_u8Z_free(ret_var);
42730         return ret_arr;
42731 }
42732
42733 uint32_t  __attribute__((export_name("TS_RouteHintHop_read"))) TS_RouteHintHop_read(int8_tArray ser) {
42734         LDKu8slice ser_ref;
42735         ser_ref.datalen = ser->arr_len;
42736         ser_ref.data = ser->elems;
42737         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
42738         *ret_conv = RouteHintHop_read(ser_ref);
42739         FREE(ser);
42740         return (uint32_t)ret_conv;
42741 }
42742
42743 uint32_t  __attribute__((export_name("TS_find_route"))) TS_find_route(int8_tArray our_node_pubkey, uint32_t route_params, uint32_t network_graph, uint32_tArray first_hops, uint32_t logger, uint32_t scorer, int8_tArray random_seed_bytes) {
42744         LDKPublicKey our_node_pubkey_ref;
42745         CHECK(our_node_pubkey->arr_len == 33);
42746         memcpy(our_node_pubkey_ref.compressed_form, our_node_pubkey->elems, 33); FREE(our_node_pubkey);
42747         LDKRouteParameters route_params_conv;
42748         route_params_conv.inner = (void*)(route_params & (~1));
42749         route_params_conv.is_owned = false;
42750         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
42751         LDKNetworkGraph network_graph_conv;
42752         network_graph_conv.inner = (void*)(network_graph & (~1));
42753         network_graph_conv.is_owned = false;
42754         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
42755         LDKCVec_ChannelDetailsZ first_hops_constr;
42756         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
42757         if (first_hops != 0) {
42758                 first_hops_constr.datalen = first_hops->arr_len;
42759                 if (first_hops_constr.datalen > 0)
42760                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
42761                 else
42762                         first_hops_constr.data = NULL;
42763                 uint32_t* first_hops_vals = first_hops->elems;
42764                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
42765                         uint32_t first_hops_conv_16 = first_hops_vals[q];
42766                         LDKChannelDetails first_hops_conv_16_conv;
42767                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
42768                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
42769                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
42770                         first_hops_constr.data[q] = first_hops_conv_16_conv;
42771                 }
42772                 FREE(first_hops);
42773                 first_hops_ptr = &first_hops_constr;
42774         }
42775         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
42776         CHECK_ACCESS(logger_ptr);
42777         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
42778         if (logger_conv.free == LDKLogger_JCalls_free) {
42779                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
42780                 LDKLogger_JCalls_cloned(&logger_conv);
42781         }
42782         void* scorer_ptr = (void*)(((uintptr_t)scorer) & ~1);
42783         if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
42784         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
42785         unsigned char random_seed_bytes_arr[32];
42786         CHECK(random_seed_bytes->arr_len == 32);
42787         memcpy(random_seed_bytes_arr, random_seed_bytes->elems, 32); FREE(random_seed_bytes);
42788         unsigned char (*random_seed_bytes_ref)[32] = &random_seed_bytes_arr;
42789         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
42790         *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);
42791         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
42792         return (uint32_t)ret_conv;
42793 }
42794
42795 uint32_t  __attribute__((export_name("TS_build_route_from_hops"))) TS_build_route_from_hops(int8_tArray our_node_pubkey, ptrArray hops, uint32_t route_params, uint32_t network_graph, uint32_t logger, int8_tArray random_seed_bytes) {
42796         LDKPublicKey our_node_pubkey_ref;
42797         CHECK(our_node_pubkey->arr_len == 33);
42798         memcpy(our_node_pubkey_ref.compressed_form, our_node_pubkey->elems, 33); FREE(our_node_pubkey);
42799         LDKCVec_PublicKeyZ hops_constr;
42800         hops_constr.datalen = hops->arr_len;
42801         if (hops_constr.datalen > 0)
42802                 hops_constr.data = MALLOC(hops_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
42803         else
42804                 hops_constr.data = NULL;
42805         int8_tArray* hops_vals = (void*) hops->elems;
42806         for (size_t m = 0; m < hops_constr.datalen; m++) {
42807                 int8_tArray hops_conv_12 = hops_vals[m];
42808                 LDKPublicKey hops_conv_12_ref;
42809                 CHECK(hops_conv_12->arr_len == 33);
42810                 memcpy(hops_conv_12_ref.compressed_form, hops_conv_12->elems, 33); FREE(hops_conv_12);
42811                 hops_constr.data[m] = hops_conv_12_ref;
42812         }
42813         FREE(hops);
42814         LDKRouteParameters route_params_conv;
42815         route_params_conv.inner = (void*)(route_params & (~1));
42816         route_params_conv.is_owned = false;
42817         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
42818         LDKNetworkGraph network_graph_conv;
42819         network_graph_conv.inner = (void*)(network_graph & (~1));
42820         network_graph_conv.is_owned = false;
42821         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
42822         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
42823         CHECK_ACCESS(logger_ptr);
42824         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
42825         if (logger_conv.free == LDKLogger_JCalls_free) {
42826                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
42827                 LDKLogger_JCalls_cloned(&logger_conv);
42828         }
42829         unsigned char random_seed_bytes_arr[32];
42830         CHECK(random_seed_bytes->arr_len == 32);
42831         memcpy(random_seed_bytes_arr, random_seed_bytes->elems, 32); FREE(random_seed_bytes);
42832         unsigned char (*random_seed_bytes_ref)[32] = &random_seed_bytes_arr;
42833         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
42834         *ret_conv = build_route_from_hops(our_node_pubkey_ref, hops_constr, &route_params_conv, &network_graph_conv, logger_conv, random_seed_bytes_ref);
42835         return (uint32_t)ret_conv;
42836 }
42837
42838 void  __attribute__((export_name("TS_Score_free"))) TS_Score_free(uint32_t this_ptr) {
42839         if ((this_ptr & 1) != 0) return;
42840         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
42841         CHECK_ACCESS(this_ptr_ptr);
42842         LDKScore this_ptr_conv = *(LDKScore*)(this_ptr_ptr);
42843         FREE((void*)this_ptr);
42844         Score_free(this_ptr_conv);
42845 }
42846
42847 void  __attribute__((export_name("TS_LockableScore_free"))) TS_LockableScore_free(uint32_t this_ptr) {
42848         if ((this_ptr & 1) != 0) return;
42849         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
42850         CHECK_ACCESS(this_ptr_ptr);
42851         LDKLockableScore this_ptr_conv = *(LDKLockableScore*)(this_ptr_ptr);
42852         FREE((void*)this_ptr);
42853         LockableScore_free(this_ptr_conv);
42854 }
42855
42856 void  __attribute__((export_name("TS_MultiThreadedLockableScore_free"))) TS_MultiThreadedLockableScore_free(uint32_t this_obj) {
42857         LDKMultiThreadedLockableScore this_obj_conv;
42858         this_obj_conv.inner = (void*)(this_obj & (~1));
42859         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42860         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42861         MultiThreadedLockableScore_free(this_obj_conv);
42862 }
42863
42864 int8_tArray  __attribute__((export_name("TS_MultiThreadedLockableScore_write"))) TS_MultiThreadedLockableScore_write(uint32_t obj) {
42865         LDKMultiThreadedLockableScore obj_conv;
42866         obj_conv.inner = (void*)(obj & (~1));
42867         obj_conv.is_owned = false;
42868         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42869         LDKCVec_u8Z ret_var = MultiThreadedLockableScore_write(&obj_conv);
42870         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
42871         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
42872         CVec_u8Z_free(ret_var);
42873         return ret_arr;
42874 }
42875
42876 uint32_t  __attribute__((export_name("TS_MultiThreadedLockableScore_new"))) TS_MultiThreadedLockableScore_new(uint32_t score) {
42877         void* score_ptr = (void*)(((uintptr_t)score) & ~1);
42878         CHECK_ACCESS(score_ptr);
42879         LDKScore score_conv = *(LDKScore*)(score_ptr);
42880         if (score_conv.free == LDKScore_JCalls_free) {
42881                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
42882                 LDKScore_JCalls_cloned(&score_conv);
42883         }
42884         LDKMultiThreadedLockableScore ret_var = MultiThreadedLockableScore_new(score_conv);
42885         uint32_t ret_ref = 0;
42886         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42887         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42888         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42889         ret_ref = (uintptr_t)ret_var.inner;
42890         if (ret_var.is_owned) {
42891                 ret_ref |= 1;
42892         }
42893         return ret_ref;
42894 }
42895
42896 void  __attribute__((export_name("TS_ChannelUsage_free"))) TS_ChannelUsage_free(uint32_t this_obj) {
42897         LDKChannelUsage this_obj_conv;
42898         this_obj_conv.inner = (void*)(this_obj & (~1));
42899         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42900         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42901         ChannelUsage_free(this_obj_conv);
42902 }
42903
42904 int64_t  __attribute__((export_name("TS_ChannelUsage_get_amount_msat"))) TS_ChannelUsage_get_amount_msat(uint32_t this_ptr) {
42905         LDKChannelUsage this_ptr_conv;
42906         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42907         this_ptr_conv.is_owned = false;
42908         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42909         int64_t ret_conv = ChannelUsage_get_amount_msat(&this_ptr_conv);
42910         return ret_conv;
42911 }
42912
42913 void  __attribute__((export_name("TS_ChannelUsage_set_amount_msat"))) TS_ChannelUsage_set_amount_msat(uint32_t this_ptr, int64_t val) {
42914         LDKChannelUsage this_ptr_conv;
42915         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42916         this_ptr_conv.is_owned = false;
42917         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42918         ChannelUsage_set_amount_msat(&this_ptr_conv, val);
42919 }
42920
42921 int64_t  __attribute__((export_name("TS_ChannelUsage_get_inflight_htlc_msat"))) TS_ChannelUsage_get_inflight_htlc_msat(uint32_t this_ptr) {
42922         LDKChannelUsage this_ptr_conv;
42923         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42924         this_ptr_conv.is_owned = false;
42925         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42926         int64_t ret_conv = ChannelUsage_get_inflight_htlc_msat(&this_ptr_conv);
42927         return ret_conv;
42928 }
42929
42930 void  __attribute__((export_name("TS_ChannelUsage_set_inflight_htlc_msat"))) TS_ChannelUsage_set_inflight_htlc_msat(uint32_t this_ptr, int64_t val) {
42931         LDKChannelUsage this_ptr_conv;
42932         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42933         this_ptr_conv.is_owned = false;
42934         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42935         ChannelUsage_set_inflight_htlc_msat(&this_ptr_conv, val);
42936 }
42937
42938 uint32_t  __attribute__((export_name("TS_ChannelUsage_get_effective_capacity"))) TS_ChannelUsage_get_effective_capacity(uint32_t this_ptr) {
42939         LDKChannelUsage this_ptr_conv;
42940         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42941         this_ptr_conv.is_owned = false;
42942         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42943         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
42944         *ret_copy = ChannelUsage_get_effective_capacity(&this_ptr_conv);
42945         uint32_t ret_ref = (uintptr_t)ret_copy;
42946         return ret_ref;
42947 }
42948
42949 void  __attribute__((export_name("TS_ChannelUsage_set_effective_capacity"))) TS_ChannelUsage_set_effective_capacity(uint32_t this_ptr, uint32_t val) {
42950         LDKChannelUsage this_ptr_conv;
42951         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42952         this_ptr_conv.is_owned = false;
42953         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42954         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
42955         CHECK_ACCESS(val_ptr);
42956         LDKEffectiveCapacity val_conv = *(LDKEffectiveCapacity*)(val_ptr);
42957         val_conv = EffectiveCapacity_clone((LDKEffectiveCapacity*)(((uintptr_t)val) & ~1));
42958         ChannelUsage_set_effective_capacity(&this_ptr_conv, val_conv);
42959 }
42960
42961 uint32_t  __attribute__((export_name("TS_ChannelUsage_new"))) TS_ChannelUsage_new(int64_t amount_msat_arg, int64_t inflight_htlc_msat_arg, uint32_t effective_capacity_arg) {
42962         void* effective_capacity_arg_ptr = (void*)(((uintptr_t)effective_capacity_arg) & ~1);
42963         CHECK_ACCESS(effective_capacity_arg_ptr);
42964         LDKEffectiveCapacity effective_capacity_arg_conv = *(LDKEffectiveCapacity*)(effective_capacity_arg_ptr);
42965         effective_capacity_arg_conv = EffectiveCapacity_clone((LDKEffectiveCapacity*)(((uintptr_t)effective_capacity_arg) & ~1));
42966         LDKChannelUsage ret_var = ChannelUsage_new(amount_msat_arg, inflight_htlc_msat_arg, effective_capacity_arg_conv);
42967         uint32_t ret_ref = 0;
42968         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42969         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42970         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42971         ret_ref = (uintptr_t)ret_var.inner;
42972         if (ret_var.is_owned) {
42973                 ret_ref |= 1;
42974         }
42975         return ret_ref;
42976 }
42977
42978 static inline uintptr_t ChannelUsage_clone_ptr(LDKChannelUsage *NONNULL_PTR arg) {
42979         LDKChannelUsage ret_var = ChannelUsage_clone(arg);
42980 uint32_t ret_ref = 0;
42981 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42982 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42983 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42984 ret_ref = (uintptr_t)ret_var.inner;
42985 if (ret_var.is_owned) {
42986         ret_ref |= 1;
42987 }
42988         return ret_ref;
42989 }
42990 uint32_t  __attribute__((export_name("TS_ChannelUsage_clone_ptr"))) TS_ChannelUsage_clone_ptr(uint32_t arg) {
42991         LDKChannelUsage arg_conv;
42992         arg_conv.inner = (void*)(arg & (~1));
42993         arg_conv.is_owned = false;
42994         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42995         uint32_t ret_conv = ChannelUsage_clone_ptr(&arg_conv);
42996         return ret_conv;
42997 }
42998
42999 uint32_t  __attribute__((export_name("TS_ChannelUsage_clone"))) TS_ChannelUsage_clone(uint32_t orig) {
43000         LDKChannelUsage orig_conv;
43001         orig_conv.inner = (void*)(orig & (~1));
43002         orig_conv.is_owned = false;
43003         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43004         LDKChannelUsage ret_var = ChannelUsage_clone(&orig_conv);
43005         uint32_t ret_ref = 0;
43006         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43007         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43008         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43009         ret_ref = (uintptr_t)ret_var.inner;
43010         if (ret_var.is_owned) {
43011                 ret_ref |= 1;
43012         }
43013         return ret_ref;
43014 }
43015
43016 void  __attribute__((export_name("TS_FixedPenaltyScorer_free"))) TS_FixedPenaltyScorer_free(uint32_t this_obj) {
43017         LDKFixedPenaltyScorer this_obj_conv;
43018         this_obj_conv.inner = (void*)(this_obj & (~1));
43019         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43020         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43021         FixedPenaltyScorer_free(this_obj_conv);
43022 }
43023
43024 static inline uintptr_t FixedPenaltyScorer_clone_ptr(LDKFixedPenaltyScorer *NONNULL_PTR arg) {
43025         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(arg);
43026 uint32_t ret_ref = 0;
43027 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43028 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43029 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43030 ret_ref = (uintptr_t)ret_var.inner;
43031 if (ret_var.is_owned) {
43032         ret_ref |= 1;
43033 }
43034         return ret_ref;
43035 }
43036 uint32_t  __attribute__((export_name("TS_FixedPenaltyScorer_clone_ptr"))) TS_FixedPenaltyScorer_clone_ptr(uint32_t arg) {
43037         LDKFixedPenaltyScorer arg_conv;
43038         arg_conv.inner = (void*)(arg & (~1));
43039         arg_conv.is_owned = false;
43040         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43041         uint32_t ret_conv = FixedPenaltyScorer_clone_ptr(&arg_conv);
43042         return ret_conv;
43043 }
43044
43045 uint32_t  __attribute__((export_name("TS_FixedPenaltyScorer_clone"))) TS_FixedPenaltyScorer_clone(uint32_t orig) {
43046         LDKFixedPenaltyScorer orig_conv;
43047         orig_conv.inner = (void*)(orig & (~1));
43048         orig_conv.is_owned = false;
43049         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43050         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(&orig_conv);
43051         uint32_t ret_ref = 0;
43052         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43053         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43054         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43055         ret_ref = (uintptr_t)ret_var.inner;
43056         if (ret_var.is_owned) {
43057                 ret_ref |= 1;
43058         }
43059         return ret_ref;
43060 }
43061
43062 uint32_t  __attribute__((export_name("TS_FixedPenaltyScorer_with_penalty"))) TS_FixedPenaltyScorer_with_penalty(int64_t penalty_msat) {
43063         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_with_penalty(penalty_msat);
43064         uint32_t ret_ref = 0;
43065         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43066         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43067         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43068         ret_ref = (uintptr_t)ret_var.inner;
43069         if (ret_var.is_owned) {
43070                 ret_ref |= 1;
43071         }
43072         return ret_ref;
43073 }
43074
43075 uint32_t  __attribute__((export_name("TS_FixedPenaltyScorer_as_Score"))) TS_FixedPenaltyScorer_as_Score(uint32_t this_arg) {
43076         LDKFixedPenaltyScorer this_arg_conv;
43077         this_arg_conv.inner = (void*)(this_arg & (~1));
43078         this_arg_conv.is_owned = false;
43079         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43080         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
43081         *ret_ret = FixedPenaltyScorer_as_Score(&this_arg_conv);
43082         return (uint32_t)ret_ret;
43083 }
43084
43085 int8_tArray  __attribute__((export_name("TS_FixedPenaltyScorer_write"))) TS_FixedPenaltyScorer_write(uint32_t obj) {
43086         LDKFixedPenaltyScorer obj_conv;
43087         obj_conv.inner = (void*)(obj & (~1));
43088         obj_conv.is_owned = false;
43089         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43090         LDKCVec_u8Z ret_var = FixedPenaltyScorer_write(&obj_conv);
43091         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
43092         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
43093         CVec_u8Z_free(ret_var);
43094         return ret_arr;
43095 }
43096
43097 uint32_t  __attribute__((export_name("TS_FixedPenaltyScorer_read"))) TS_FixedPenaltyScorer_read(int8_tArray ser, int64_t arg) {
43098         LDKu8slice ser_ref;
43099         ser_ref.datalen = ser->arr_len;
43100         ser_ref.data = ser->elems;
43101         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
43102         *ret_conv = FixedPenaltyScorer_read(ser_ref, arg);
43103         FREE(ser);
43104         return (uint32_t)ret_conv;
43105 }
43106
43107 void  __attribute__((export_name("TS_ProbabilisticScorer_free"))) TS_ProbabilisticScorer_free(uint32_t this_obj) {
43108         LDKProbabilisticScorer this_obj_conv;
43109         this_obj_conv.inner = (void*)(this_obj & (~1));
43110         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43111         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43112         ProbabilisticScorer_free(this_obj_conv);
43113 }
43114
43115 void  __attribute__((export_name("TS_ProbabilisticScoringParameters_free"))) TS_ProbabilisticScoringParameters_free(uint32_t this_obj) {
43116         LDKProbabilisticScoringParameters this_obj_conv;
43117         this_obj_conv.inner = (void*)(this_obj & (~1));
43118         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43119         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43120         ProbabilisticScoringParameters_free(this_obj_conv);
43121 }
43122
43123 int64_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_get_base_penalty_msat"))) TS_ProbabilisticScoringParameters_get_base_penalty_msat(uint32_t this_ptr) {
43124         LDKProbabilisticScoringParameters this_ptr_conv;
43125         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43126         this_ptr_conv.is_owned = false;
43127         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43128         int64_t ret_conv = ProbabilisticScoringParameters_get_base_penalty_msat(&this_ptr_conv);
43129         return ret_conv;
43130 }
43131
43132 void  __attribute__((export_name("TS_ProbabilisticScoringParameters_set_base_penalty_msat"))) TS_ProbabilisticScoringParameters_set_base_penalty_msat(uint32_t this_ptr, int64_t val) {
43133         LDKProbabilisticScoringParameters this_ptr_conv;
43134         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43135         this_ptr_conv.is_owned = false;
43136         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43137         ProbabilisticScoringParameters_set_base_penalty_msat(&this_ptr_conv, val);
43138 }
43139
43140 int64_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_get_base_penalty_amount_multiplier_msat"))) TS_ProbabilisticScoringParameters_get_base_penalty_amount_multiplier_msat(uint32_t this_ptr) {
43141         LDKProbabilisticScoringParameters this_ptr_conv;
43142         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43143         this_ptr_conv.is_owned = false;
43144         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43145         int64_t ret_conv = ProbabilisticScoringParameters_get_base_penalty_amount_multiplier_msat(&this_ptr_conv);
43146         return ret_conv;
43147 }
43148
43149 void  __attribute__((export_name("TS_ProbabilisticScoringParameters_set_base_penalty_amount_multiplier_msat"))) TS_ProbabilisticScoringParameters_set_base_penalty_amount_multiplier_msat(uint32_t this_ptr, int64_t val) {
43150         LDKProbabilisticScoringParameters this_ptr_conv;
43151         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43152         this_ptr_conv.is_owned = false;
43153         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43154         ProbabilisticScoringParameters_set_base_penalty_amount_multiplier_msat(&this_ptr_conv, val);
43155 }
43156
43157 int64_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat"))) TS_ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat(uint32_t this_ptr) {
43158         LDKProbabilisticScoringParameters this_ptr_conv;
43159         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43160         this_ptr_conv.is_owned = false;
43161         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43162         int64_t ret_conv = ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat(&this_ptr_conv);
43163         return ret_conv;
43164 }
43165
43166 void  __attribute__((export_name("TS_ProbabilisticScoringParameters_set_liquidity_penalty_multiplier_msat"))) TS_ProbabilisticScoringParameters_set_liquidity_penalty_multiplier_msat(uint32_t this_ptr, int64_t val) {
43167         LDKProbabilisticScoringParameters this_ptr_conv;
43168         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43169         this_ptr_conv.is_owned = false;
43170         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43171         ProbabilisticScoringParameters_set_liquidity_penalty_multiplier_msat(&this_ptr_conv, val);
43172 }
43173
43174 int64_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_get_liquidity_offset_half_life"))) TS_ProbabilisticScoringParameters_get_liquidity_offset_half_life(uint32_t this_ptr) {
43175         LDKProbabilisticScoringParameters this_ptr_conv;
43176         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43177         this_ptr_conv.is_owned = false;
43178         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43179         int64_t ret_conv = ProbabilisticScoringParameters_get_liquidity_offset_half_life(&this_ptr_conv);
43180         return ret_conv;
43181 }
43182
43183 void  __attribute__((export_name("TS_ProbabilisticScoringParameters_set_liquidity_offset_half_life"))) TS_ProbabilisticScoringParameters_set_liquidity_offset_half_life(uint32_t this_ptr, int64_t val) {
43184         LDKProbabilisticScoringParameters this_ptr_conv;
43185         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43186         this_ptr_conv.is_owned = false;
43187         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43188         ProbabilisticScoringParameters_set_liquidity_offset_half_life(&this_ptr_conv, val);
43189 }
43190
43191 int64_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_get_liquidity_penalty_amount_multiplier_msat"))) TS_ProbabilisticScoringParameters_get_liquidity_penalty_amount_multiplier_msat(uint32_t this_ptr) {
43192         LDKProbabilisticScoringParameters this_ptr_conv;
43193         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43194         this_ptr_conv.is_owned = false;
43195         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43196         int64_t ret_conv = ProbabilisticScoringParameters_get_liquidity_penalty_amount_multiplier_msat(&this_ptr_conv);
43197         return ret_conv;
43198 }
43199
43200 void  __attribute__((export_name("TS_ProbabilisticScoringParameters_set_liquidity_penalty_amount_multiplier_msat"))) TS_ProbabilisticScoringParameters_set_liquidity_penalty_amount_multiplier_msat(uint32_t this_ptr, int64_t val) {
43201         LDKProbabilisticScoringParameters this_ptr_conv;
43202         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43203         this_ptr_conv.is_owned = false;
43204         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43205         ProbabilisticScoringParameters_set_liquidity_penalty_amount_multiplier_msat(&this_ptr_conv, val);
43206 }
43207
43208 int64_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_get_anti_probing_penalty_msat"))) TS_ProbabilisticScoringParameters_get_anti_probing_penalty_msat(uint32_t this_ptr) {
43209         LDKProbabilisticScoringParameters this_ptr_conv;
43210         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43211         this_ptr_conv.is_owned = false;
43212         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43213         int64_t ret_conv = ProbabilisticScoringParameters_get_anti_probing_penalty_msat(&this_ptr_conv);
43214         return ret_conv;
43215 }
43216
43217 void  __attribute__((export_name("TS_ProbabilisticScoringParameters_set_anti_probing_penalty_msat"))) TS_ProbabilisticScoringParameters_set_anti_probing_penalty_msat(uint32_t this_ptr, int64_t val) {
43218         LDKProbabilisticScoringParameters this_ptr_conv;
43219         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43220         this_ptr_conv.is_owned = false;
43221         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43222         ProbabilisticScoringParameters_set_anti_probing_penalty_msat(&this_ptr_conv, val);
43223 }
43224
43225 int64_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_get_considered_impossible_penalty_msat"))) TS_ProbabilisticScoringParameters_get_considered_impossible_penalty_msat(uint32_t this_ptr) {
43226         LDKProbabilisticScoringParameters this_ptr_conv;
43227         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43228         this_ptr_conv.is_owned = false;
43229         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43230         int64_t ret_conv = ProbabilisticScoringParameters_get_considered_impossible_penalty_msat(&this_ptr_conv);
43231         return ret_conv;
43232 }
43233
43234 void  __attribute__((export_name("TS_ProbabilisticScoringParameters_set_considered_impossible_penalty_msat"))) TS_ProbabilisticScoringParameters_set_considered_impossible_penalty_msat(uint32_t this_ptr, int64_t val) {
43235         LDKProbabilisticScoringParameters this_ptr_conv;
43236         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43237         this_ptr_conv.is_owned = false;
43238         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43239         ProbabilisticScoringParameters_set_considered_impossible_penalty_msat(&this_ptr_conv, val);
43240 }
43241
43242 static inline uintptr_t ProbabilisticScoringParameters_clone_ptr(LDKProbabilisticScoringParameters *NONNULL_PTR arg) {
43243         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_clone(arg);
43244 uint32_t ret_ref = 0;
43245 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43246 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43247 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43248 ret_ref = (uintptr_t)ret_var.inner;
43249 if (ret_var.is_owned) {
43250         ret_ref |= 1;
43251 }
43252         return ret_ref;
43253 }
43254 uint32_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_clone_ptr"))) TS_ProbabilisticScoringParameters_clone_ptr(uint32_t arg) {
43255         LDKProbabilisticScoringParameters arg_conv;
43256         arg_conv.inner = (void*)(arg & (~1));
43257         arg_conv.is_owned = false;
43258         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43259         uint32_t ret_conv = ProbabilisticScoringParameters_clone_ptr(&arg_conv);
43260         return ret_conv;
43261 }
43262
43263 uint32_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_clone"))) TS_ProbabilisticScoringParameters_clone(uint32_t orig) {
43264         LDKProbabilisticScoringParameters orig_conv;
43265         orig_conv.inner = (void*)(orig & (~1));
43266         orig_conv.is_owned = false;
43267         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43268         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_clone(&orig_conv);
43269         uint32_t ret_ref = 0;
43270         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43271         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43272         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43273         ret_ref = (uintptr_t)ret_var.inner;
43274         if (ret_var.is_owned) {
43275                 ret_ref |= 1;
43276         }
43277         return ret_ref;
43278 }
43279
43280 uint32_t  __attribute__((export_name("TS_ProbabilisticScorer_new"))) TS_ProbabilisticScorer_new(uint32_t params, uint32_t network_graph, uint32_t logger) {
43281         LDKProbabilisticScoringParameters params_conv;
43282         params_conv.inner = (void*)(params & (~1));
43283         params_conv.is_owned = (params & 1) || (params == 0);
43284         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
43285         params_conv = ProbabilisticScoringParameters_clone(&params_conv);
43286         LDKNetworkGraph network_graph_conv;
43287         network_graph_conv.inner = (void*)(network_graph & (~1));
43288         network_graph_conv.is_owned = false;
43289         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
43290         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
43291         CHECK_ACCESS(logger_ptr);
43292         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
43293         if (logger_conv.free == LDKLogger_JCalls_free) {
43294                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
43295                 LDKLogger_JCalls_cloned(&logger_conv);
43296         }
43297         LDKProbabilisticScorer ret_var = ProbabilisticScorer_new(params_conv, &network_graph_conv, logger_conv);
43298         uint32_t ret_ref = 0;
43299         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43300         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43301         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43302         ret_ref = (uintptr_t)ret_var.inner;
43303         if (ret_var.is_owned) {
43304                 ret_ref |= 1;
43305         }
43306         return ret_ref;
43307 }
43308
43309 void  __attribute__((export_name("TS_ProbabilisticScorer_debug_log_liquidity_stats"))) TS_ProbabilisticScorer_debug_log_liquidity_stats(uint32_t this_arg) {
43310         LDKProbabilisticScorer this_arg_conv;
43311         this_arg_conv.inner = (void*)(this_arg & (~1));
43312         this_arg_conv.is_owned = false;
43313         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43314         ProbabilisticScorer_debug_log_liquidity_stats(&this_arg_conv);
43315 }
43316
43317 uint32_t  __attribute__((export_name("TS_ProbabilisticScorer_estimated_channel_liquidity_range"))) TS_ProbabilisticScorer_estimated_channel_liquidity_range(uint32_t this_arg, int64_t scid, uint32_t target) {
43318         LDKProbabilisticScorer this_arg_conv;
43319         this_arg_conv.inner = (void*)(this_arg & (~1));
43320         this_arg_conv.is_owned = false;
43321         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43322         LDKNodeId target_conv;
43323         target_conv.inner = (void*)(target & (~1));
43324         target_conv.is_owned = false;
43325         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
43326         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
43327         *ret_copy = ProbabilisticScorer_estimated_channel_liquidity_range(&this_arg_conv, scid, &target_conv);
43328         uint32_t ret_ref = (uintptr_t)ret_copy;
43329         return ret_ref;
43330 }
43331
43332 void  __attribute__((export_name("TS_ProbabilisticScorer_add_banned"))) TS_ProbabilisticScorer_add_banned(uint32_t this_arg, uint32_t node_id) {
43333         LDKProbabilisticScorer this_arg_conv;
43334         this_arg_conv.inner = (void*)(this_arg & (~1));
43335         this_arg_conv.is_owned = false;
43336         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43337         LDKNodeId node_id_conv;
43338         node_id_conv.inner = (void*)(node_id & (~1));
43339         node_id_conv.is_owned = false;
43340         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
43341         ProbabilisticScorer_add_banned(&this_arg_conv, &node_id_conv);
43342 }
43343
43344 void  __attribute__((export_name("TS_ProbabilisticScorer_remove_banned"))) TS_ProbabilisticScorer_remove_banned(uint32_t this_arg, uint32_t node_id) {
43345         LDKProbabilisticScorer this_arg_conv;
43346         this_arg_conv.inner = (void*)(this_arg & (~1));
43347         this_arg_conv.is_owned = false;
43348         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43349         LDKNodeId node_id_conv;
43350         node_id_conv.inner = (void*)(node_id & (~1));
43351         node_id_conv.is_owned = false;
43352         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
43353         ProbabilisticScorer_remove_banned(&this_arg_conv, &node_id_conv);
43354 }
43355
43356 void  __attribute__((export_name("TS_ProbabilisticScorer_set_manual_penalty"))) TS_ProbabilisticScorer_set_manual_penalty(uint32_t this_arg, uint32_t node_id, int64_t penalty) {
43357         LDKProbabilisticScorer this_arg_conv;
43358         this_arg_conv.inner = (void*)(this_arg & (~1));
43359         this_arg_conv.is_owned = false;
43360         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43361         LDKNodeId node_id_conv;
43362         node_id_conv.inner = (void*)(node_id & (~1));
43363         node_id_conv.is_owned = false;
43364         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
43365         ProbabilisticScorer_set_manual_penalty(&this_arg_conv, &node_id_conv, penalty);
43366 }
43367
43368 void  __attribute__((export_name("TS_ProbabilisticScorer_remove_manual_penalty"))) TS_ProbabilisticScorer_remove_manual_penalty(uint32_t this_arg, uint32_t node_id) {
43369         LDKProbabilisticScorer this_arg_conv;
43370         this_arg_conv.inner = (void*)(this_arg & (~1));
43371         this_arg_conv.is_owned = false;
43372         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43373         LDKNodeId node_id_conv;
43374         node_id_conv.inner = (void*)(node_id & (~1));
43375         node_id_conv.is_owned = false;
43376         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
43377         ProbabilisticScorer_remove_manual_penalty(&this_arg_conv, &node_id_conv);
43378 }
43379
43380 void  __attribute__((export_name("TS_ProbabilisticScorer_clear_manual_penalties"))) TS_ProbabilisticScorer_clear_manual_penalties(uint32_t this_arg) {
43381         LDKProbabilisticScorer this_arg_conv;
43382         this_arg_conv.inner = (void*)(this_arg & (~1));
43383         this_arg_conv.is_owned = false;
43384         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43385         ProbabilisticScorer_clear_manual_penalties(&this_arg_conv);
43386 }
43387
43388 void  __attribute__((export_name("TS_ProbabilisticScoringParameters_add_banned_from_list"))) TS_ProbabilisticScoringParameters_add_banned_from_list(uint32_t this_arg, uint32_tArray node_ids) {
43389         LDKProbabilisticScoringParameters this_arg_conv;
43390         this_arg_conv.inner = (void*)(this_arg & (~1));
43391         this_arg_conv.is_owned = false;
43392         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43393         LDKCVec_NodeIdZ node_ids_constr;
43394         node_ids_constr.datalen = node_ids->arr_len;
43395         if (node_ids_constr.datalen > 0)
43396                 node_ids_constr.data = MALLOC(node_ids_constr.datalen * sizeof(LDKNodeId), "LDKCVec_NodeIdZ Elements");
43397         else
43398                 node_ids_constr.data = NULL;
43399         uint32_t* node_ids_vals = node_ids->elems;
43400         for (size_t i = 0; i < node_ids_constr.datalen; i++) {
43401                 uint32_t node_ids_conv_8 = node_ids_vals[i];
43402                 LDKNodeId node_ids_conv_8_conv;
43403                 node_ids_conv_8_conv.inner = (void*)(node_ids_conv_8 & (~1));
43404                 node_ids_conv_8_conv.is_owned = (node_ids_conv_8 & 1) || (node_ids_conv_8 == 0);
43405                 CHECK_INNER_FIELD_ACCESS_OR_NULL(node_ids_conv_8_conv);
43406                 node_ids_conv_8_conv = NodeId_clone(&node_ids_conv_8_conv);
43407                 node_ids_constr.data[i] = node_ids_conv_8_conv;
43408         }
43409         FREE(node_ids);
43410         ProbabilisticScoringParameters_add_banned_from_list(&this_arg_conv, node_ids_constr);
43411 }
43412
43413 uint32_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_default"))) TS_ProbabilisticScoringParameters_default() {
43414         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_default();
43415         uint32_t ret_ref = 0;
43416         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43417         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43418         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43419         ret_ref = (uintptr_t)ret_var.inner;
43420         if (ret_var.is_owned) {
43421                 ret_ref |= 1;
43422         }
43423         return ret_ref;
43424 }
43425
43426 uint32_t  __attribute__((export_name("TS_ProbabilisticScorer_as_Score"))) TS_ProbabilisticScorer_as_Score(uint32_t this_arg) {
43427         LDKProbabilisticScorer this_arg_conv;
43428         this_arg_conv.inner = (void*)(this_arg & (~1));
43429         this_arg_conv.is_owned = false;
43430         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43431         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
43432         *ret_ret = ProbabilisticScorer_as_Score(&this_arg_conv);
43433         return (uint32_t)ret_ret;
43434 }
43435
43436 int8_tArray  __attribute__((export_name("TS_ProbabilisticScorer_write"))) TS_ProbabilisticScorer_write(uint32_t obj) {
43437         LDKProbabilisticScorer obj_conv;
43438         obj_conv.inner = (void*)(obj & (~1));
43439         obj_conv.is_owned = false;
43440         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43441         LDKCVec_u8Z ret_var = ProbabilisticScorer_write(&obj_conv);
43442         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
43443         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
43444         CVec_u8Z_free(ret_var);
43445         return ret_arr;
43446 }
43447
43448 uint32_t  __attribute__((export_name("TS_ProbabilisticScorer_read"))) TS_ProbabilisticScorer_read(int8_tArray ser, uint32_t arg_a, uint32_t arg_b, uint32_t arg_c) {
43449         LDKu8slice ser_ref;
43450         ser_ref.datalen = ser->arr_len;
43451         ser_ref.data = ser->elems;
43452         LDKProbabilisticScoringParameters arg_a_conv;
43453         arg_a_conv.inner = (void*)(arg_a & (~1));
43454         arg_a_conv.is_owned = (arg_a & 1) || (arg_a == 0);
43455         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_a_conv);
43456         arg_a_conv = ProbabilisticScoringParameters_clone(&arg_a_conv);
43457         LDKNetworkGraph arg_b_conv;
43458         arg_b_conv.inner = (void*)(arg_b & (~1));
43459         arg_b_conv.is_owned = false;
43460         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_b_conv);
43461         void* arg_c_ptr = (void*)(((uintptr_t)arg_c) & ~1);
43462         CHECK_ACCESS(arg_c_ptr);
43463         LDKLogger arg_c_conv = *(LDKLogger*)(arg_c_ptr);
43464         if (arg_c_conv.free == LDKLogger_JCalls_free) {
43465                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
43466                 LDKLogger_JCalls_cloned(&arg_c_conv);
43467         }
43468         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
43469         *ret_conv = ProbabilisticScorer_read(ser_ref, arg_a_conv, &arg_b_conv, arg_c_conv);
43470         FREE(ser);
43471         return (uint32_t)ret_conv;
43472 }
43473
43474 void  __attribute__((export_name("TS_ParseError_free"))) TS_ParseError_free(uint32_t this_ptr) {
43475         if ((this_ptr & 1) != 0) return;
43476         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
43477         CHECK_ACCESS(this_ptr_ptr);
43478         LDKParseError this_ptr_conv = *(LDKParseError*)(this_ptr_ptr);
43479         FREE((void*)this_ptr);
43480         ParseError_free(this_ptr_conv);
43481 }
43482
43483 static inline uintptr_t ParseError_clone_ptr(LDKParseError *NONNULL_PTR arg) {
43484         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43485         *ret_copy = ParseError_clone(arg);
43486 uint32_t ret_ref = (uintptr_t)ret_copy;
43487         return ret_ref;
43488 }
43489 uint32_t  __attribute__((export_name("TS_ParseError_clone_ptr"))) TS_ParseError_clone_ptr(uint32_t arg) {
43490         LDKParseError* arg_conv = (LDKParseError*)arg;
43491         uint32_t ret_conv = ParseError_clone_ptr(arg_conv);
43492         return ret_conv;
43493 }
43494
43495 uint32_t  __attribute__((export_name("TS_ParseError_clone"))) TS_ParseError_clone(uint32_t orig) {
43496         LDKParseError* orig_conv = (LDKParseError*)orig;
43497         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43498         *ret_copy = ParseError_clone(orig_conv);
43499         uint32_t ret_ref = (uintptr_t)ret_copy;
43500         return ret_ref;
43501 }
43502
43503 uint32_t  __attribute__((export_name("TS_ParseError_bech32_error"))) TS_ParseError_bech32_error(uint32_t a) {
43504         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
43505         CHECK_ACCESS(a_ptr);
43506         LDKBech32Error a_conv = *(LDKBech32Error*)(a_ptr);
43507         a_conv = Bech32Error_clone((LDKBech32Error*)(((uintptr_t)a) & ~1));
43508         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43509         *ret_copy = ParseError_bech32_error(a_conv);
43510         uint32_t ret_ref = (uintptr_t)ret_copy;
43511         return ret_ref;
43512 }
43513
43514 uint32_t  __attribute__((export_name("TS_ParseError_parse_amount_error"))) TS_ParseError_parse_amount_error(int32_t a) {
43515         
43516         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43517         *ret_copy = ParseError_parse_amount_error((LDKError){ ._dummy = 0 });
43518         uint32_t ret_ref = (uintptr_t)ret_copy;
43519         return ret_ref;
43520 }
43521
43522 uint32_t  __attribute__((export_name("TS_ParseError_malformed_signature"))) TS_ParseError_malformed_signature(uint32_t a) {
43523         LDKSecp256k1Error a_conv = LDKSecp256k1Error_from_js(a);
43524         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43525         *ret_copy = ParseError_malformed_signature(a_conv);
43526         uint32_t ret_ref = (uintptr_t)ret_copy;
43527         return ret_ref;
43528 }
43529
43530 uint32_t  __attribute__((export_name("TS_ParseError_bad_prefix"))) TS_ParseError_bad_prefix() {
43531         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43532         *ret_copy = ParseError_bad_prefix();
43533         uint32_t ret_ref = (uintptr_t)ret_copy;
43534         return ret_ref;
43535 }
43536
43537 uint32_t  __attribute__((export_name("TS_ParseError_unknown_currency"))) TS_ParseError_unknown_currency() {
43538         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43539         *ret_copy = ParseError_unknown_currency();
43540         uint32_t ret_ref = (uintptr_t)ret_copy;
43541         return ret_ref;
43542 }
43543
43544 uint32_t  __attribute__((export_name("TS_ParseError_unknown_si_prefix"))) TS_ParseError_unknown_si_prefix() {
43545         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43546         *ret_copy = ParseError_unknown_si_prefix();
43547         uint32_t ret_ref = (uintptr_t)ret_copy;
43548         return ret_ref;
43549 }
43550
43551 uint32_t  __attribute__((export_name("TS_ParseError_malformed_hrp"))) TS_ParseError_malformed_hrp() {
43552         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43553         *ret_copy = ParseError_malformed_hrp();
43554         uint32_t ret_ref = (uintptr_t)ret_copy;
43555         return ret_ref;
43556 }
43557
43558 uint32_t  __attribute__((export_name("TS_ParseError_too_short_data_part"))) TS_ParseError_too_short_data_part() {
43559         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43560         *ret_copy = ParseError_too_short_data_part();
43561         uint32_t ret_ref = (uintptr_t)ret_copy;
43562         return ret_ref;
43563 }
43564
43565 uint32_t  __attribute__((export_name("TS_ParseError_unexpected_end_of_tagged_fields"))) TS_ParseError_unexpected_end_of_tagged_fields() {
43566         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43567         *ret_copy = ParseError_unexpected_end_of_tagged_fields();
43568         uint32_t ret_ref = (uintptr_t)ret_copy;
43569         return ret_ref;
43570 }
43571
43572 uint32_t  __attribute__((export_name("TS_ParseError_description_decode_error"))) TS_ParseError_description_decode_error(int32_t a) {
43573         
43574         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43575         *ret_copy = ParseError_description_decode_error((LDKError){ ._dummy = 0 });
43576         uint32_t ret_ref = (uintptr_t)ret_copy;
43577         return ret_ref;
43578 }
43579
43580 uint32_t  __attribute__((export_name("TS_ParseError_padding_error"))) TS_ParseError_padding_error() {
43581         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43582         *ret_copy = ParseError_padding_error();
43583         uint32_t ret_ref = (uintptr_t)ret_copy;
43584         return ret_ref;
43585 }
43586
43587 uint32_t  __attribute__((export_name("TS_ParseError_integer_overflow_error"))) TS_ParseError_integer_overflow_error() {
43588         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43589         *ret_copy = ParseError_integer_overflow_error();
43590         uint32_t ret_ref = (uintptr_t)ret_copy;
43591         return ret_ref;
43592 }
43593
43594 uint32_t  __attribute__((export_name("TS_ParseError_invalid_seg_wit_program_length"))) TS_ParseError_invalid_seg_wit_program_length() {
43595         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43596         *ret_copy = ParseError_invalid_seg_wit_program_length();
43597         uint32_t ret_ref = (uintptr_t)ret_copy;
43598         return ret_ref;
43599 }
43600
43601 uint32_t  __attribute__((export_name("TS_ParseError_invalid_pub_key_hash_length"))) TS_ParseError_invalid_pub_key_hash_length() {
43602         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43603         *ret_copy = ParseError_invalid_pub_key_hash_length();
43604         uint32_t ret_ref = (uintptr_t)ret_copy;
43605         return ret_ref;
43606 }
43607
43608 uint32_t  __attribute__((export_name("TS_ParseError_invalid_script_hash_length"))) TS_ParseError_invalid_script_hash_length() {
43609         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43610         *ret_copy = ParseError_invalid_script_hash_length();
43611         uint32_t ret_ref = (uintptr_t)ret_copy;
43612         return ret_ref;
43613 }
43614
43615 uint32_t  __attribute__((export_name("TS_ParseError_invalid_recovery_id"))) TS_ParseError_invalid_recovery_id() {
43616         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43617         *ret_copy = ParseError_invalid_recovery_id();
43618         uint32_t ret_ref = (uintptr_t)ret_copy;
43619         return ret_ref;
43620 }
43621
43622 uint32_t  __attribute__((export_name("TS_ParseError_invalid_slice_length"))) TS_ParseError_invalid_slice_length(jstring a) {
43623         LDKStr a_conv = str_ref_to_owned_c(a);
43624         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43625         *ret_copy = ParseError_invalid_slice_length(a_conv);
43626         uint32_t ret_ref = (uintptr_t)ret_copy;
43627         return ret_ref;
43628 }
43629
43630 uint32_t  __attribute__((export_name("TS_ParseError_skip"))) TS_ParseError_skip() {
43631         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43632         *ret_copy = ParseError_skip();
43633         uint32_t ret_ref = (uintptr_t)ret_copy;
43634         return ret_ref;
43635 }
43636
43637 void  __attribute__((export_name("TS_ParseOrSemanticError_free"))) TS_ParseOrSemanticError_free(uint32_t this_ptr) {
43638         if ((this_ptr & 1) != 0) return;
43639         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
43640         CHECK_ACCESS(this_ptr_ptr);
43641         LDKParseOrSemanticError this_ptr_conv = *(LDKParseOrSemanticError*)(this_ptr_ptr);
43642         FREE((void*)this_ptr);
43643         ParseOrSemanticError_free(this_ptr_conv);
43644 }
43645
43646 static inline uintptr_t ParseOrSemanticError_clone_ptr(LDKParseOrSemanticError *NONNULL_PTR arg) {
43647         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
43648         *ret_copy = ParseOrSemanticError_clone(arg);
43649 uint32_t ret_ref = (uintptr_t)ret_copy;
43650         return ret_ref;
43651 }
43652 uint32_t  __attribute__((export_name("TS_ParseOrSemanticError_clone_ptr"))) TS_ParseOrSemanticError_clone_ptr(uint32_t arg) {
43653         LDKParseOrSemanticError* arg_conv = (LDKParseOrSemanticError*)arg;
43654         uint32_t ret_conv = ParseOrSemanticError_clone_ptr(arg_conv);
43655         return ret_conv;
43656 }
43657
43658 uint32_t  __attribute__((export_name("TS_ParseOrSemanticError_clone"))) TS_ParseOrSemanticError_clone(uint32_t orig) {
43659         LDKParseOrSemanticError* orig_conv = (LDKParseOrSemanticError*)orig;
43660         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
43661         *ret_copy = ParseOrSemanticError_clone(orig_conv);
43662         uint32_t ret_ref = (uintptr_t)ret_copy;
43663         return ret_ref;
43664 }
43665
43666 uint32_t  __attribute__((export_name("TS_ParseOrSemanticError_parse_error"))) TS_ParseOrSemanticError_parse_error(uint32_t a) {
43667         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
43668         CHECK_ACCESS(a_ptr);
43669         LDKParseError a_conv = *(LDKParseError*)(a_ptr);
43670         a_conv = ParseError_clone((LDKParseError*)(((uintptr_t)a) & ~1));
43671         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
43672         *ret_copy = ParseOrSemanticError_parse_error(a_conv);
43673         uint32_t ret_ref = (uintptr_t)ret_copy;
43674         return ret_ref;
43675 }
43676
43677 uint32_t  __attribute__((export_name("TS_ParseOrSemanticError_semantic_error"))) TS_ParseOrSemanticError_semantic_error(uint32_t a) {
43678         LDKSemanticError a_conv = LDKSemanticError_from_js(a);
43679         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
43680         *ret_copy = ParseOrSemanticError_semantic_error(a_conv);
43681         uint32_t ret_ref = (uintptr_t)ret_copy;
43682         return ret_ref;
43683 }
43684
43685 void  __attribute__((export_name("TS_Invoice_free"))) TS_Invoice_free(uint32_t this_obj) {
43686         LDKInvoice this_obj_conv;
43687         this_obj_conv.inner = (void*)(this_obj & (~1));
43688         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43689         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43690         Invoice_free(this_obj_conv);
43691 }
43692
43693 jboolean  __attribute__((export_name("TS_Invoice_eq"))) TS_Invoice_eq(uint32_t a, uint32_t b) {
43694         LDKInvoice a_conv;
43695         a_conv.inner = (void*)(a & (~1));
43696         a_conv.is_owned = false;
43697         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43698         LDKInvoice b_conv;
43699         b_conv.inner = (void*)(b & (~1));
43700         b_conv.is_owned = false;
43701         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43702         jboolean ret_conv = Invoice_eq(&a_conv, &b_conv);
43703         return ret_conv;
43704 }
43705
43706 static inline uintptr_t Invoice_clone_ptr(LDKInvoice *NONNULL_PTR arg) {
43707         LDKInvoice ret_var = Invoice_clone(arg);
43708 uint32_t ret_ref = 0;
43709 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43710 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43711 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43712 ret_ref = (uintptr_t)ret_var.inner;
43713 if (ret_var.is_owned) {
43714         ret_ref |= 1;
43715 }
43716         return ret_ref;
43717 }
43718 uint32_t  __attribute__((export_name("TS_Invoice_clone_ptr"))) TS_Invoice_clone_ptr(uint32_t arg) {
43719         LDKInvoice arg_conv;
43720         arg_conv.inner = (void*)(arg & (~1));
43721         arg_conv.is_owned = false;
43722         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43723         uint32_t ret_conv = Invoice_clone_ptr(&arg_conv);
43724         return ret_conv;
43725 }
43726
43727 uint32_t  __attribute__((export_name("TS_Invoice_clone"))) TS_Invoice_clone(uint32_t orig) {
43728         LDKInvoice orig_conv;
43729         orig_conv.inner = (void*)(orig & (~1));
43730         orig_conv.is_owned = false;
43731         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43732         LDKInvoice ret_var = Invoice_clone(&orig_conv);
43733         uint32_t ret_ref = 0;
43734         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43735         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43736         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43737         ret_ref = (uintptr_t)ret_var.inner;
43738         if (ret_var.is_owned) {
43739                 ret_ref |= 1;
43740         }
43741         return ret_ref;
43742 }
43743
43744 void  __attribute__((export_name("TS_SignedRawInvoice_free"))) TS_SignedRawInvoice_free(uint32_t this_obj) {
43745         LDKSignedRawInvoice this_obj_conv;
43746         this_obj_conv.inner = (void*)(this_obj & (~1));
43747         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43748         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43749         SignedRawInvoice_free(this_obj_conv);
43750 }
43751
43752 jboolean  __attribute__((export_name("TS_SignedRawInvoice_eq"))) TS_SignedRawInvoice_eq(uint32_t a, uint32_t b) {
43753         LDKSignedRawInvoice a_conv;
43754         a_conv.inner = (void*)(a & (~1));
43755         a_conv.is_owned = false;
43756         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43757         LDKSignedRawInvoice b_conv;
43758         b_conv.inner = (void*)(b & (~1));
43759         b_conv.is_owned = false;
43760         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43761         jboolean ret_conv = SignedRawInvoice_eq(&a_conv, &b_conv);
43762         return ret_conv;
43763 }
43764
43765 static inline uintptr_t SignedRawInvoice_clone_ptr(LDKSignedRawInvoice *NONNULL_PTR arg) {
43766         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(arg);
43767 uint32_t ret_ref = 0;
43768 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43769 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43770 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43771 ret_ref = (uintptr_t)ret_var.inner;
43772 if (ret_var.is_owned) {
43773         ret_ref |= 1;
43774 }
43775         return ret_ref;
43776 }
43777 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_clone_ptr"))) TS_SignedRawInvoice_clone_ptr(uint32_t arg) {
43778         LDKSignedRawInvoice arg_conv;
43779         arg_conv.inner = (void*)(arg & (~1));
43780         arg_conv.is_owned = false;
43781         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43782         uint32_t ret_conv = SignedRawInvoice_clone_ptr(&arg_conv);
43783         return ret_conv;
43784 }
43785
43786 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_clone"))) TS_SignedRawInvoice_clone(uint32_t orig) {
43787         LDKSignedRawInvoice orig_conv;
43788         orig_conv.inner = (void*)(orig & (~1));
43789         orig_conv.is_owned = false;
43790         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43791         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(&orig_conv);
43792         uint32_t ret_ref = 0;
43793         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43794         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43795         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43796         ret_ref = (uintptr_t)ret_var.inner;
43797         if (ret_var.is_owned) {
43798                 ret_ref |= 1;
43799         }
43800         return ret_ref;
43801 }
43802
43803 void  __attribute__((export_name("TS_RawInvoice_free"))) TS_RawInvoice_free(uint32_t this_obj) {
43804         LDKRawInvoice this_obj_conv;
43805         this_obj_conv.inner = (void*)(this_obj & (~1));
43806         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43807         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43808         RawInvoice_free(this_obj_conv);
43809 }
43810
43811 uint32_t  __attribute__((export_name("TS_RawInvoice_get_data"))) TS_RawInvoice_get_data(uint32_t this_ptr) {
43812         LDKRawInvoice this_ptr_conv;
43813         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43814         this_ptr_conv.is_owned = false;
43815         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43816         LDKRawDataPart ret_var = RawInvoice_get_data(&this_ptr_conv);
43817         uint32_t ret_ref = 0;
43818         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43819         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43820         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43821         ret_ref = (uintptr_t)ret_var.inner;
43822         if (ret_var.is_owned) {
43823                 ret_ref |= 1;
43824         }
43825         return ret_ref;
43826 }
43827
43828 void  __attribute__((export_name("TS_RawInvoice_set_data"))) TS_RawInvoice_set_data(uint32_t this_ptr, uint32_t val) {
43829         LDKRawInvoice this_ptr_conv;
43830         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43831         this_ptr_conv.is_owned = false;
43832         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43833         LDKRawDataPart val_conv;
43834         val_conv.inner = (void*)(val & (~1));
43835         val_conv.is_owned = (val & 1) || (val == 0);
43836         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43837         val_conv = RawDataPart_clone(&val_conv);
43838         RawInvoice_set_data(&this_ptr_conv, val_conv);
43839 }
43840
43841 jboolean  __attribute__((export_name("TS_RawInvoice_eq"))) TS_RawInvoice_eq(uint32_t a, uint32_t b) {
43842         LDKRawInvoice a_conv;
43843         a_conv.inner = (void*)(a & (~1));
43844         a_conv.is_owned = false;
43845         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43846         LDKRawInvoice b_conv;
43847         b_conv.inner = (void*)(b & (~1));
43848         b_conv.is_owned = false;
43849         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43850         jboolean ret_conv = RawInvoice_eq(&a_conv, &b_conv);
43851         return ret_conv;
43852 }
43853
43854 static inline uintptr_t RawInvoice_clone_ptr(LDKRawInvoice *NONNULL_PTR arg) {
43855         LDKRawInvoice ret_var = RawInvoice_clone(arg);
43856 uint32_t ret_ref = 0;
43857 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43858 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43859 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43860 ret_ref = (uintptr_t)ret_var.inner;
43861 if (ret_var.is_owned) {
43862         ret_ref |= 1;
43863 }
43864         return ret_ref;
43865 }
43866 uint32_t  __attribute__((export_name("TS_RawInvoice_clone_ptr"))) TS_RawInvoice_clone_ptr(uint32_t arg) {
43867         LDKRawInvoice arg_conv;
43868         arg_conv.inner = (void*)(arg & (~1));
43869         arg_conv.is_owned = false;
43870         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43871         uint32_t ret_conv = RawInvoice_clone_ptr(&arg_conv);
43872         return ret_conv;
43873 }
43874
43875 uint32_t  __attribute__((export_name("TS_RawInvoice_clone"))) TS_RawInvoice_clone(uint32_t orig) {
43876         LDKRawInvoice orig_conv;
43877         orig_conv.inner = (void*)(orig & (~1));
43878         orig_conv.is_owned = false;
43879         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43880         LDKRawInvoice ret_var = RawInvoice_clone(&orig_conv);
43881         uint32_t ret_ref = 0;
43882         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43883         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43884         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43885         ret_ref = (uintptr_t)ret_var.inner;
43886         if (ret_var.is_owned) {
43887                 ret_ref |= 1;
43888         }
43889         return ret_ref;
43890 }
43891
43892 void  __attribute__((export_name("TS_RawDataPart_free"))) TS_RawDataPart_free(uint32_t this_obj) {
43893         LDKRawDataPart this_obj_conv;
43894         this_obj_conv.inner = (void*)(this_obj & (~1));
43895         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43896         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43897         RawDataPart_free(this_obj_conv);
43898 }
43899
43900 uint32_t  __attribute__((export_name("TS_RawDataPart_get_timestamp"))) TS_RawDataPart_get_timestamp(uint32_t this_ptr) {
43901         LDKRawDataPart this_ptr_conv;
43902         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43903         this_ptr_conv.is_owned = false;
43904         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43905         LDKPositiveTimestamp ret_var = RawDataPart_get_timestamp(&this_ptr_conv);
43906         uint32_t ret_ref = 0;
43907         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43908         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43909         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43910         ret_ref = (uintptr_t)ret_var.inner;
43911         if (ret_var.is_owned) {
43912                 ret_ref |= 1;
43913         }
43914         return ret_ref;
43915 }
43916
43917 void  __attribute__((export_name("TS_RawDataPart_set_timestamp"))) TS_RawDataPart_set_timestamp(uint32_t this_ptr, uint32_t val) {
43918         LDKRawDataPart this_ptr_conv;
43919         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43920         this_ptr_conv.is_owned = false;
43921         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43922         LDKPositiveTimestamp val_conv;
43923         val_conv.inner = (void*)(val & (~1));
43924         val_conv.is_owned = (val & 1) || (val == 0);
43925         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43926         val_conv = PositiveTimestamp_clone(&val_conv);
43927         RawDataPart_set_timestamp(&this_ptr_conv, val_conv);
43928 }
43929
43930 jboolean  __attribute__((export_name("TS_RawDataPart_eq"))) TS_RawDataPart_eq(uint32_t a, uint32_t b) {
43931         LDKRawDataPart a_conv;
43932         a_conv.inner = (void*)(a & (~1));
43933         a_conv.is_owned = false;
43934         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43935         LDKRawDataPart b_conv;
43936         b_conv.inner = (void*)(b & (~1));
43937         b_conv.is_owned = false;
43938         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43939         jboolean ret_conv = RawDataPart_eq(&a_conv, &b_conv);
43940         return ret_conv;
43941 }
43942
43943 static inline uintptr_t RawDataPart_clone_ptr(LDKRawDataPart *NONNULL_PTR arg) {
43944         LDKRawDataPart ret_var = RawDataPart_clone(arg);
43945 uint32_t ret_ref = 0;
43946 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43947 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43948 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43949 ret_ref = (uintptr_t)ret_var.inner;
43950 if (ret_var.is_owned) {
43951         ret_ref |= 1;
43952 }
43953         return ret_ref;
43954 }
43955 uint32_t  __attribute__((export_name("TS_RawDataPart_clone_ptr"))) TS_RawDataPart_clone_ptr(uint32_t arg) {
43956         LDKRawDataPart arg_conv;
43957         arg_conv.inner = (void*)(arg & (~1));
43958         arg_conv.is_owned = false;
43959         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43960         uint32_t ret_conv = RawDataPart_clone_ptr(&arg_conv);
43961         return ret_conv;
43962 }
43963
43964 uint32_t  __attribute__((export_name("TS_RawDataPart_clone"))) TS_RawDataPart_clone(uint32_t orig) {
43965         LDKRawDataPart orig_conv;
43966         orig_conv.inner = (void*)(orig & (~1));
43967         orig_conv.is_owned = false;
43968         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43969         LDKRawDataPart ret_var = RawDataPart_clone(&orig_conv);
43970         uint32_t ret_ref = 0;
43971         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43972         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43973         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43974         ret_ref = (uintptr_t)ret_var.inner;
43975         if (ret_var.is_owned) {
43976                 ret_ref |= 1;
43977         }
43978         return ret_ref;
43979 }
43980
43981 void  __attribute__((export_name("TS_PositiveTimestamp_free"))) TS_PositiveTimestamp_free(uint32_t this_obj) {
43982         LDKPositiveTimestamp this_obj_conv;
43983         this_obj_conv.inner = (void*)(this_obj & (~1));
43984         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43985         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43986         PositiveTimestamp_free(this_obj_conv);
43987 }
43988
43989 jboolean  __attribute__((export_name("TS_PositiveTimestamp_eq"))) TS_PositiveTimestamp_eq(uint32_t a, uint32_t b) {
43990         LDKPositiveTimestamp a_conv;
43991         a_conv.inner = (void*)(a & (~1));
43992         a_conv.is_owned = false;
43993         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43994         LDKPositiveTimestamp b_conv;
43995         b_conv.inner = (void*)(b & (~1));
43996         b_conv.is_owned = false;
43997         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43998         jboolean ret_conv = PositiveTimestamp_eq(&a_conv, &b_conv);
43999         return ret_conv;
44000 }
44001
44002 static inline uintptr_t PositiveTimestamp_clone_ptr(LDKPositiveTimestamp *NONNULL_PTR arg) {
44003         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(arg);
44004 uint32_t ret_ref = 0;
44005 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44006 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44007 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44008 ret_ref = (uintptr_t)ret_var.inner;
44009 if (ret_var.is_owned) {
44010         ret_ref |= 1;
44011 }
44012         return ret_ref;
44013 }
44014 uint32_t  __attribute__((export_name("TS_PositiveTimestamp_clone_ptr"))) TS_PositiveTimestamp_clone_ptr(uint32_t arg) {
44015         LDKPositiveTimestamp arg_conv;
44016         arg_conv.inner = (void*)(arg & (~1));
44017         arg_conv.is_owned = false;
44018         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44019         uint32_t ret_conv = PositiveTimestamp_clone_ptr(&arg_conv);
44020         return ret_conv;
44021 }
44022
44023 uint32_t  __attribute__((export_name("TS_PositiveTimestamp_clone"))) TS_PositiveTimestamp_clone(uint32_t orig) {
44024         LDKPositiveTimestamp orig_conv;
44025         orig_conv.inner = (void*)(orig & (~1));
44026         orig_conv.is_owned = false;
44027         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44028         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(&orig_conv);
44029         uint32_t ret_ref = 0;
44030         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44031         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44032         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44033         ret_ref = (uintptr_t)ret_var.inner;
44034         if (ret_var.is_owned) {
44035                 ret_ref |= 1;
44036         }
44037         return ret_ref;
44038 }
44039
44040 uint32_t  __attribute__((export_name("TS_SiPrefix_clone"))) TS_SiPrefix_clone(uint32_t orig) {
44041         LDKSiPrefix* orig_conv = (LDKSiPrefix*)(orig & ~1);
44042         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_clone(orig_conv));
44043         return ret_conv;
44044 }
44045
44046 uint32_t  __attribute__((export_name("TS_SiPrefix_milli"))) TS_SiPrefix_milli() {
44047         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_milli());
44048         return ret_conv;
44049 }
44050
44051 uint32_t  __attribute__((export_name("TS_SiPrefix_micro"))) TS_SiPrefix_micro() {
44052         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_micro());
44053         return ret_conv;
44054 }
44055
44056 uint32_t  __attribute__((export_name("TS_SiPrefix_nano"))) TS_SiPrefix_nano() {
44057         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_nano());
44058         return ret_conv;
44059 }
44060
44061 uint32_t  __attribute__((export_name("TS_SiPrefix_pico"))) TS_SiPrefix_pico() {
44062         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_pico());
44063         return ret_conv;
44064 }
44065
44066 jboolean  __attribute__((export_name("TS_SiPrefix_eq"))) TS_SiPrefix_eq(uint32_t a, uint32_t b) {
44067         LDKSiPrefix* a_conv = (LDKSiPrefix*)(a & ~1);
44068         LDKSiPrefix* b_conv = (LDKSiPrefix*)(b & ~1);
44069         jboolean ret_conv = SiPrefix_eq(a_conv, b_conv);
44070         return ret_conv;
44071 }
44072
44073 int64_t  __attribute__((export_name("TS_SiPrefix_multiplier"))) TS_SiPrefix_multiplier(uint32_t this_arg) {
44074         LDKSiPrefix* this_arg_conv = (LDKSiPrefix*)(this_arg & ~1);
44075         int64_t ret_conv = SiPrefix_multiplier(this_arg_conv);
44076         return ret_conv;
44077 }
44078
44079 uint32_t  __attribute__((export_name("TS_Currency_clone"))) TS_Currency_clone(uint32_t orig) {
44080         LDKCurrency* orig_conv = (LDKCurrency*)(orig & ~1);
44081         uint32_t ret_conv = LDKCurrency_to_js(Currency_clone(orig_conv));
44082         return ret_conv;
44083 }
44084
44085 uint32_t  __attribute__((export_name("TS_Currency_bitcoin"))) TS_Currency_bitcoin() {
44086         uint32_t ret_conv = LDKCurrency_to_js(Currency_bitcoin());
44087         return ret_conv;
44088 }
44089
44090 uint32_t  __attribute__((export_name("TS_Currency_bitcoin_testnet"))) TS_Currency_bitcoin_testnet() {
44091         uint32_t ret_conv = LDKCurrency_to_js(Currency_bitcoin_testnet());
44092         return ret_conv;
44093 }
44094
44095 uint32_t  __attribute__((export_name("TS_Currency_regtest"))) TS_Currency_regtest() {
44096         uint32_t ret_conv = LDKCurrency_to_js(Currency_regtest());
44097         return ret_conv;
44098 }
44099
44100 uint32_t  __attribute__((export_name("TS_Currency_simnet"))) TS_Currency_simnet() {
44101         uint32_t ret_conv = LDKCurrency_to_js(Currency_simnet());
44102         return ret_conv;
44103 }
44104
44105 uint32_t  __attribute__((export_name("TS_Currency_signet"))) TS_Currency_signet() {
44106         uint32_t ret_conv = LDKCurrency_to_js(Currency_signet());
44107         return ret_conv;
44108 }
44109
44110 int64_t  __attribute__((export_name("TS_Currency_hash"))) TS_Currency_hash(uint32_t o) {
44111         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
44112         int64_t ret_conv = Currency_hash(o_conv);
44113         return ret_conv;
44114 }
44115
44116 jboolean  __attribute__((export_name("TS_Currency_eq"))) TS_Currency_eq(uint32_t a, uint32_t b) {
44117         LDKCurrency* a_conv = (LDKCurrency*)(a & ~1);
44118         LDKCurrency* b_conv = (LDKCurrency*)(b & ~1);
44119         jboolean ret_conv = Currency_eq(a_conv, b_conv);
44120         return ret_conv;
44121 }
44122
44123 void  __attribute__((export_name("TS_Sha256_free"))) TS_Sha256_free(uint32_t this_obj) {
44124         LDKSha256 this_obj_conv;
44125         this_obj_conv.inner = (void*)(this_obj & (~1));
44126         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44127         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44128         Sha256_free(this_obj_conv);
44129 }
44130
44131 static inline uintptr_t Sha256_clone_ptr(LDKSha256 *NONNULL_PTR arg) {
44132         LDKSha256 ret_var = Sha256_clone(arg);
44133 uint32_t ret_ref = 0;
44134 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44135 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44136 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44137 ret_ref = (uintptr_t)ret_var.inner;
44138 if (ret_var.is_owned) {
44139         ret_ref |= 1;
44140 }
44141         return ret_ref;
44142 }
44143 uint32_t  __attribute__((export_name("TS_Sha256_clone_ptr"))) TS_Sha256_clone_ptr(uint32_t arg) {
44144         LDKSha256 arg_conv;
44145         arg_conv.inner = (void*)(arg & (~1));
44146         arg_conv.is_owned = false;
44147         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44148         uint32_t ret_conv = Sha256_clone_ptr(&arg_conv);
44149         return ret_conv;
44150 }
44151
44152 uint32_t  __attribute__((export_name("TS_Sha256_clone"))) TS_Sha256_clone(uint32_t orig) {
44153         LDKSha256 orig_conv;
44154         orig_conv.inner = (void*)(orig & (~1));
44155         orig_conv.is_owned = false;
44156         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44157         LDKSha256 ret_var = Sha256_clone(&orig_conv);
44158         uint32_t ret_ref = 0;
44159         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44160         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44161         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44162         ret_ref = (uintptr_t)ret_var.inner;
44163         if (ret_var.is_owned) {
44164                 ret_ref |= 1;
44165         }
44166         return ret_ref;
44167 }
44168
44169 int64_t  __attribute__((export_name("TS_Sha256_hash"))) TS_Sha256_hash(uint32_t o) {
44170         LDKSha256 o_conv;
44171         o_conv.inner = (void*)(o & (~1));
44172         o_conv.is_owned = false;
44173         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
44174         int64_t ret_conv = Sha256_hash(&o_conv);
44175         return ret_conv;
44176 }
44177
44178 jboolean  __attribute__((export_name("TS_Sha256_eq"))) TS_Sha256_eq(uint32_t a, uint32_t b) {
44179         LDKSha256 a_conv;
44180         a_conv.inner = (void*)(a & (~1));
44181         a_conv.is_owned = false;
44182         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44183         LDKSha256 b_conv;
44184         b_conv.inner = (void*)(b & (~1));
44185         b_conv.is_owned = false;
44186         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44187         jboolean ret_conv = Sha256_eq(&a_conv, &b_conv);
44188         return ret_conv;
44189 }
44190
44191 void  __attribute__((export_name("TS_Description_free"))) TS_Description_free(uint32_t this_obj) {
44192         LDKDescription this_obj_conv;
44193         this_obj_conv.inner = (void*)(this_obj & (~1));
44194         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44195         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44196         Description_free(this_obj_conv);
44197 }
44198
44199 static inline uintptr_t Description_clone_ptr(LDKDescription *NONNULL_PTR arg) {
44200         LDKDescription ret_var = Description_clone(arg);
44201 uint32_t ret_ref = 0;
44202 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44203 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44204 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44205 ret_ref = (uintptr_t)ret_var.inner;
44206 if (ret_var.is_owned) {
44207         ret_ref |= 1;
44208 }
44209         return ret_ref;
44210 }
44211 uint32_t  __attribute__((export_name("TS_Description_clone_ptr"))) TS_Description_clone_ptr(uint32_t arg) {
44212         LDKDescription arg_conv;
44213         arg_conv.inner = (void*)(arg & (~1));
44214         arg_conv.is_owned = false;
44215         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44216         uint32_t ret_conv = Description_clone_ptr(&arg_conv);
44217         return ret_conv;
44218 }
44219
44220 uint32_t  __attribute__((export_name("TS_Description_clone"))) TS_Description_clone(uint32_t orig) {
44221         LDKDescription orig_conv;
44222         orig_conv.inner = (void*)(orig & (~1));
44223         orig_conv.is_owned = false;
44224         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44225         LDKDescription ret_var = Description_clone(&orig_conv);
44226         uint32_t ret_ref = 0;
44227         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44228         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44229         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44230         ret_ref = (uintptr_t)ret_var.inner;
44231         if (ret_var.is_owned) {
44232                 ret_ref |= 1;
44233         }
44234         return ret_ref;
44235 }
44236
44237 int64_t  __attribute__((export_name("TS_Description_hash"))) TS_Description_hash(uint32_t o) {
44238         LDKDescription o_conv;
44239         o_conv.inner = (void*)(o & (~1));
44240         o_conv.is_owned = false;
44241         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
44242         int64_t ret_conv = Description_hash(&o_conv);
44243         return ret_conv;
44244 }
44245
44246 jboolean  __attribute__((export_name("TS_Description_eq"))) TS_Description_eq(uint32_t a, uint32_t b) {
44247         LDKDescription a_conv;
44248         a_conv.inner = (void*)(a & (~1));
44249         a_conv.is_owned = false;
44250         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44251         LDKDescription b_conv;
44252         b_conv.inner = (void*)(b & (~1));
44253         b_conv.is_owned = false;
44254         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44255         jboolean ret_conv = Description_eq(&a_conv, &b_conv);
44256         return ret_conv;
44257 }
44258
44259 void  __attribute__((export_name("TS_PayeePubKey_free"))) TS_PayeePubKey_free(uint32_t this_obj) {
44260         LDKPayeePubKey this_obj_conv;
44261         this_obj_conv.inner = (void*)(this_obj & (~1));
44262         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44263         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44264         PayeePubKey_free(this_obj_conv);
44265 }
44266
44267 int8_tArray  __attribute__((export_name("TS_PayeePubKey_get_a"))) TS_PayeePubKey_get_a(uint32_t this_ptr) {
44268         LDKPayeePubKey this_ptr_conv;
44269         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44270         this_ptr_conv.is_owned = false;
44271         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44272         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
44273         memcpy(ret_arr->elems, PayeePubKey_get_a(&this_ptr_conv).compressed_form, 33);
44274         return ret_arr;
44275 }
44276
44277 void  __attribute__((export_name("TS_PayeePubKey_set_a"))) TS_PayeePubKey_set_a(uint32_t this_ptr, int8_tArray val) {
44278         LDKPayeePubKey this_ptr_conv;
44279         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44280         this_ptr_conv.is_owned = false;
44281         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44282         LDKPublicKey val_ref;
44283         CHECK(val->arr_len == 33);
44284         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
44285         PayeePubKey_set_a(&this_ptr_conv, val_ref);
44286 }
44287
44288 uint32_t  __attribute__((export_name("TS_PayeePubKey_new"))) TS_PayeePubKey_new(int8_tArray a_arg) {
44289         LDKPublicKey a_arg_ref;
44290         CHECK(a_arg->arr_len == 33);
44291         memcpy(a_arg_ref.compressed_form, a_arg->elems, 33); FREE(a_arg);
44292         LDKPayeePubKey ret_var = PayeePubKey_new(a_arg_ref);
44293         uint32_t ret_ref = 0;
44294         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44295         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44296         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44297         ret_ref = (uintptr_t)ret_var.inner;
44298         if (ret_var.is_owned) {
44299                 ret_ref |= 1;
44300         }
44301         return ret_ref;
44302 }
44303
44304 static inline uintptr_t PayeePubKey_clone_ptr(LDKPayeePubKey *NONNULL_PTR arg) {
44305         LDKPayeePubKey ret_var = PayeePubKey_clone(arg);
44306 uint32_t ret_ref = 0;
44307 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44308 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44309 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44310 ret_ref = (uintptr_t)ret_var.inner;
44311 if (ret_var.is_owned) {
44312         ret_ref |= 1;
44313 }
44314         return ret_ref;
44315 }
44316 uint32_t  __attribute__((export_name("TS_PayeePubKey_clone_ptr"))) TS_PayeePubKey_clone_ptr(uint32_t arg) {
44317         LDKPayeePubKey arg_conv;
44318         arg_conv.inner = (void*)(arg & (~1));
44319         arg_conv.is_owned = false;
44320         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44321         uint32_t ret_conv = PayeePubKey_clone_ptr(&arg_conv);
44322         return ret_conv;
44323 }
44324
44325 uint32_t  __attribute__((export_name("TS_PayeePubKey_clone"))) TS_PayeePubKey_clone(uint32_t orig) {
44326         LDKPayeePubKey orig_conv;
44327         orig_conv.inner = (void*)(orig & (~1));
44328         orig_conv.is_owned = false;
44329         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44330         LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv);
44331         uint32_t ret_ref = 0;
44332         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44333         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44334         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44335         ret_ref = (uintptr_t)ret_var.inner;
44336         if (ret_var.is_owned) {
44337                 ret_ref |= 1;
44338         }
44339         return ret_ref;
44340 }
44341
44342 int64_t  __attribute__((export_name("TS_PayeePubKey_hash"))) TS_PayeePubKey_hash(uint32_t o) {
44343         LDKPayeePubKey o_conv;
44344         o_conv.inner = (void*)(o & (~1));
44345         o_conv.is_owned = false;
44346         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
44347         int64_t ret_conv = PayeePubKey_hash(&o_conv);
44348         return ret_conv;
44349 }
44350
44351 jboolean  __attribute__((export_name("TS_PayeePubKey_eq"))) TS_PayeePubKey_eq(uint32_t a, uint32_t b) {
44352         LDKPayeePubKey a_conv;
44353         a_conv.inner = (void*)(a & (~1));
44354         a_conv.is_owned = false;
44355         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44356         LDKPayeePubKey b_conv;
44357         b_conv.inner = (void*)(b & (~1));
44358         b_conv.is_owned = false;
44359         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44360         jboolean ret_conv = PayeePubKey_eq(&a_conv, &b_conv);
44361         return ret_conv;
44362 }
44363
44364 void  __attribute__((export_name("TS_ExpiryTime_free"))) TS_ExpiryTime_free(uint32_t this_obj) {
44365         LDKExpiryTime this_obj_conv;
44366         this_obj_conv.inner = (void*)(this_obj & (~1));
44367         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44368         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44369         ExpiryTime_free(this_obj_conv);
44370 }
44371
44372 static inline uintptr_t ExpiryTime_clone_ptr(LDKExpiryTime *NONNULL_PTR arg) {
44373         LDKExpiryTime ret_var = ExpiryTime_clone(arg);
44374 uint32_t ret_ref = 0;
44375 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44376 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44377 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44378 ret_ref = (uintptr_t)ret_var.inner;
44379 if (ret_var.is_owned) {
44380         ret_ref |= 1;
44381 }
44382         return ret_ref;
44383 }
44384 uint32_t  __attribute__((export_name("TS_ExpiryTime_clone_ptr"))) TS_ExpiryTime_clone_ptr(uint32_t arg) {
44385         LDKExpiryTime arg_conv;
44386         arg_conv.inner = (void*)(arg & (~1));
44387         arg_conv.is_owned = false;
44388         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44389         uint32_t ret_conv = ExpiryTime_clone_ptr(&arg_conv);
44390         return ret_conv;
44391 }
44392
44393 uint32_t  __attribute__((export_name("TS_ExpiryTime_clone"))) TS_ExpiryTime_clone(uint32_t orig) {
44394         LDKExpiryTime orig_conv;
44395         orig_conv.inner = (void*)(orig & (~1));
44396         orig_conv.is_owned = false;
44397         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44398         LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv);
44399         uint32_t ret_ref = 0;
44400         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44401         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44402         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44403         ret_ref = (uintptr_t)ret_var.inner;
44404         if (ret_var.is_owned) {
44405                 ret_ref |= 1;
44406         }
44407         return ret_ref;
44408 }
44409
44410 int64_t  __attribute__((export_name("TS_ExpiryTime_hash"))) TS_ExpiryTime_hash(uint32_t o) {
44411         LDKExpiryTime o_conv;
44412         o_conv.inner = (void*)(o & (~1));
44413         o_conv.is_owned = false;
44414         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
44415         int64_t ret_conv = ExpiryTime_hash(&o_conv);
44416         return ret_conv;
44417 }
44418
44419 jboolean  __attribute__((export_name("TS_ExpiryTime_eq"))) TS_ExpiryTime_eq(uint32_t a, uint32_t b) {
44420         LDKExpiryTime a_conv;
44421         a_conv.inner = (void*)(a & (~1));
44422         a_conv.is_owned = false;
44423         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44424         LDKExpiryTime b_conv;
44425         b_conv.inner = (void*)(b & (~1));
44426         b_conv.is_owned = false;
44427         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44428         jboolean ret_conv = ExpiryTime_eq(&a_conv, &b_conv);
44429         return ret_conv;
44430 }
44431
44432 void  __attribute__((export_name("TS_MinFinalCltvExpiry_free"))) TS_MinFinalCltvExpiry_free(uint32_t this_obj) {
44433         LDKMinFinalCltvExpiry this_obj_conv;
44434         this_obj_conv.inner = (void*)(this_obj & (~1));
44435         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44436         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44437         MinFinalCltvExpiry_free(this_obj_conv);
44438 }
44439
44440 int64_t  __attribute__((export_name("TS_MinFinalCltvExpiry_get_a"))) TS_MinFinalCltvExpiry_get_a(uint32_t this_ptr) {
44441         LDKMinFinalCltvExpiry this_ptr_conv;
44442         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44443         this_ptr_conv.is_owned = false;
44444         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44445         int64_t ret_conv = MinFinalCltvExpiry_get_a(&this_ptr_conv);
44446         return ret_conv;
44447 }
44448
44449 void  __attribute__((export_name("TS_MinFinalCltvExpiry_set_a"))) TS_MinFinalCltvExpiry_set_a(uint32_t this_ptr, int64_t val) {
44450         LDKMinFinalCltvExpiry this_ptr_conv;
44451         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44452         this_ptr_conv.is_owned = false;
44453         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44454         MinFinalCltvExpiry_set_a(&this_ptr_conv, val);
44455 }
44456
44457 uint32_t  __attribute__((export_name("TS_MinFinalCltvExpiry_new"))) TS_MinFinalCltvExpiry_new(int64_t a_arg) {
44458         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_new(a_arg);
44459         uint32_t ret_ref = 0;
44460         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44461         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44462         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44463         ret_ref = (uintptr_t)ret_var.inner;
44464         if (ret_var.is_owned) {
44465                 ret_ref |= 1;
44466         }
44467         return ret_ref;
44468 }
44469
44470 static inline uintptr_t MinFinalCltvExpiry_clone_ptr(LDKMinFinalCltvExpiry *NONNULL_PTR arg) {
44471         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(arg);
44472 uint32_t ret_ref = 0;
44473 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44474 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44475 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44476 ret_ref = (uintptr_t)ret_var.inner;
44477 if (ret_var.is_owned) {
44478         ret_ref |= 1;
44479 }
44480         return ret_ref;
44481 }
44482 uint32_t  __attribute__((export_name("TS_MinFinalCltvExpiry_clone_ptr"))) TS_MinFinalCltvExpiry_clone_ptr(uint32_t arg) {
44483         LDKMinFinalCltvExpiry arg_conv;
44484         arg_conv.inner = (void*)(arg & (~1));
44485         arg_conv.is_owned = false;
44486         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44487         uint32_t ret_conv = MinFinalCltvExpiry_clone_ptr(&arg_conv);
44488         return ret_conv;
44489 }
44490
44491 uint32_t  __attribute__((export_name("TS_MinFinalCltvExpiry_clone"))) TS_MinFinalCltvExpiry_clone(uint32_t orig) {
44492         LDKMinFinalCltvExpiry orig_conv;
44493         orig_conv.inner = (void*)(orig & (~1));
44494         orig_conv.is_owned = false;
44495         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44496         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(&orig_conv);
44497         uint32_t ret_ref = 0;
44498         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44499         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44500         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44501         ret_ref = (uintptr_t)ret_var.inner;
44502         if (ret_var.is_owned) {
44503                 ret_ref |= 1;
44504         }
44505         return ret_ref;
44506 }
44507
44508 int64_t  __attribute__((export_name("TS_MinFinalCltvExpiry_hash"))) TS_MinFinalCltvExpiry_hash(uint32_t o) {
44509         LDKMinFinalCltvExpiry o_conv;
44510         o_conv.inner = (void*)(o & (~1));
44511         o_conv.is_owned = false;
44512         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
44513         int64_t ret_conv = MinFinalCltvExpiry_hash(&o_conv);
44514         return ret_conv;
44515 }
44516
44517 jboolean  __attribute__((export_name("TS_MinFinalCltvExpiry_eq"))) TS_MinFinalCltvExpiry_eq(uint32_t a, uint32_t b) {
44518         LDKMinFinalCltvExpiry a_conv;
44519         a_conv.inner = (void*)(a & (~1));
44520         a_conv.is_owned = false;
44521         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44522         LDKMinFinalCltvExpiry b_conv;
44523         b_conv.inner = (void*)(b & (~1));
44524         b_conv.is_owned = false;
44525         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44526         jboolean ret_conv = MinFinalCltvExpiry_eq(&a_conv, &b_conv);
44527         return ret_conv;
44528 }
44529
44530 void  __attribute__((export_name("TS_Fallback_free"))) TS_Fallback_free(uint32_t this_ptr) {
44531         if ((this_ptr & 1) != 0) return;
44532         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
44533         CHECK_ACCESS(this_ptr_ptr);
44534         LDKFallback this_ptr_conv = *(LDKFallback*)(this_ptr_ptr);
44535         FREE((void*)this_ptr);
44536         Fallback_free(this_ptr_conv);
44537 }
44538
44539 static inline uintptr_t Fallback_clone_ptr(LDKFallback *NONNULL_PTR arg) {
44540         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
44541         *ret_copy = Fallback_clone(arg);
44542 uint32_t ret_ref = (uintptr_t)ret_copy;
44543         return ret_ref;
44544 }
44545 uint32_t  __attribute__((export_name("TS_Fallback_clone_ptr"))) TS_Fallback_clone_ptr(uint32_t arg) {
44546         LDKFallback* arg_conv = (LDKFallback*)arg;
44547         uint32_t ret_conv = Fallback_clone_ptr(arg_conv);
44548         return ret_conv;
44549 }
44550
44551 uint32_t  __attribute__((export_name("TS_Fallback_clone"))) TS_Fallback_clone(uint32_t orig) {
44552         LDKFallback* orig_conv = (LDKFallback*)orig;
44553         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
44554         *ret_copy = Fallback_clone(orig_conv);
44555         uint32_t ret_ref = (uintptr_t)ret_copy;
44556         return ret_ref;
44557 }
44558
44559 uint32_t  __attribute__((export_name("TS_Fallback_seg_wit_program"))) TS_Fallback_seg_wit_program(int8_t version, int8_tArray program) {
44560         
44561         LDKCVec_u8Z program_ref;
44562         program_ref.datalen = program->arr_len;
44563         program_ref.data = MALLOC(program_ref.datalen, "LDKCVec_u8Z Bytes");
44564         memcpy(program_ref.data, program->elems, program_ref.datalen); FREE(program);
44565         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
44566         *ret_copy = Fallback_seg_wit_program((LDKu5){ ._0 = version }, program_ref);
44567         uint32_t ret_ref = (uintptr_t)ret_copy;
44568         return ret_ref;
44569 }
44570
44571 uint32_t  __attribute__((export_name("TS_Fallback_pub_key_hash"))) TS_Fallback_pub_key_hash(int8_tArray a) {
44572         LDKTwentyBytes a_ref;
44573         CHECK(a->arr_len == 20);
44574         memcpy(a_ref.data, a->elems, 20); FREE(a);
44575         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
44576         *ret_copy = Fallback_pub_key_hash(a_ref);
44577         uint32_t ret_ref = (uintptr_t)ret_copy;
44578         return ret_ref;
44579 }
44580
44581 uint32_t  __attribute__((export_name("TS_Fallback_script_hash"))) TS_Fallback_script_hash(int8_tArray a) {
44582         LDKTwentyBytes a_ref;
44583         CHECK(a->arr_len == 20);
44584         memcpy(a_ref.data, a->elems, 20); FREE(a);
44585         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
44586         *ret_copy = Fallback_script_hash(a_ref);
44587         uint32_t ret_ref = (uintptr_t)ret_copy;
44588         return ret_ref;
44589 }
44590
44591 int64_t  __attribute__((export_name("TS_Fallback_hash"))) TS_Fallback_hash(uint32_t o) {
44592         LDKFallback* o_conv = (LDKFallback*)o;
44593         int64_t ret_conv = Fallback_hash(o_conv);
44594         return ret_conv;
44595 }
44596
44597 jboolean  __attribute__((export_name("TS_Fallback_eq"))) TS_Fallback_eq(uint32_t a, uint32_t b) {
44598         LDKFallback* a_conv = (LDKFallback*)a;
44599         LDKFallback* b_conv = (LDKFallback*)b;
44600         jboolean ret_conv = Fallback_eq(a_conv, b_conv);
44601         return ret_conv;
44602 }
44603
44604 void  __attribute__((export_name("TS_InvoiceSignature_free"))) TS_InvoiceSignature_free(uint32_t this_obj) {
44605         LDKInvoiceSignature this_obj_conv;
44606         this_obj_conv.inner = (void*)(this_obj & (~1));
44607         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44608         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44609         InvoiceSignature_free(this_obj_conv);
44610 }
44611
44612 static inline uintptr_t InvoiceSignature_clone_ptr(LDKInvoiceSignature *NONNULL_PTR arg) {
44613         LDKInvoiceSignature ret_var = InvoiceSignature_clone(arg);
44614 uint32_t ret_ref = 0;
44615 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44616 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44617 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44618 ret_ref = (uintptr_t)ret_var.inner;
44619 if (ret_var.is_owned) {
44620         ret_ref |= 1;
44621 }
44622         return ret_ref;
44623 }
44624 uint32_t  __attribute__((export_name("TS_InvoiceSignature_clone_ptr"))) TS_InvoiceSignature_clone_ptr(uint32_t arg) {
44625         LDKInvoiceSignature arg_conv;
44626         arg_conv.inner = (void*)(arg & (~1));
44627         arg_conv.is_owned = false;
44628         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44629         uint32_t ret_conv = InvoiceSignature_clone_ptr(&arg_conv);
44630         return ret_conv;
44631 }
44632
44633 uint32_t  __attribute__((export_name("TS_InvoiceSignature_clone"))) TS_InvoiceSignature_clone(uint32_t orig) {
44634         LDKInvoiceSignature orig_conv;
44635         orig_conv.inner = (void*)(orig & (~1));
44636         orig_conv.is_owned = false;
44637         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44638         LDKInvoiceSignature ret_var = InvoiceSignature_clone(&orig_conv);
44639         uint32_t ret_ref = 0;
44640         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44641         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44642         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44643         ret_ref = (uintptr_t)ret_var.inner;
44644         if (ret_var.is_owned) {
44645                 ret_ref |= 1;
44646         }
44647         return ret_ref;
44648 }
44649
44650 jboolean  __attribute__((export_name("TS_InvoiceSignature_eq"))) TS_InvoiceSignature_eq(uint32_t a, uint32_t b) {
44651         LDKInvoiceSignature a_conv;
44652         a_conv.inner = (void*)(a & (~1));
44653         a_conv.is_owned = false;
44654         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44655         LDKInvoiceSignature b_conv;
44656         b_conv.inner = (void*)(b & (~1));
44657         b_conv.is_owned = false;
44658         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44659         jboolean ret_conv = InvoiceSignature_eq(&a_conv, &b_conv);
44660         return ret_conv;
44661 }
44662
44663 void  __attribute__((export_name("TS_PrivateRoute_free"))) TS_PrivateRoute_free(uint32_t this_obj) {
44664         LDKPrivateRoute this_obj_conv;
44665         this_obj_conv.inner = (void*)(this_obj & (~1));
44666         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44667         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44668         PrivateRoute_free(this_obj_conv);
44669 }
44670
44671 static inline uintptr_t PrivateRoute_clone_ptr(LDKPrivateRoute *NONNULL_PTR arg) {
44672         LDKPrivateRoute ret_var = PrivateRoute_clone(arg);
44673 uint32_t ret_ref = 0;
44674 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44675 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44676 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44677 ret_ref = (uintptr_t)ret_var.inner;
44678 if (ret_var.is_owned) {
44679         ret_ref |= 1;
44680 }
44681         return ret_ref;
44682 }
44683 uint32_t  __attribute__((export_name("TS_PrivateRoute_clone_ptr"))) TS_PrivateRoute_clone_ptr(uint32_t arg) {
44684         LDKPrivateRoute arg_conv;
44685         arg_conv.inner = (void*)(arg & (~1));
44686         arg_conv.is_owned = false;
44687         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44688         uint32_t ret_conv = PrivateRoute_clone_ptr(&arg_conv);
44689         return ret_conv;
44690 }
44691
44692 uint32_t  __attribute__((export_name("TS_PrivateRoute_clone"))) TS_PrivateRoute_clone(uint32_t orig) {
44693         LDKPrivateRoute orig_conv;
44694         orig_conv.inner = (void*)(orig & (~1));
44695         orig_conv.is_owned = false;
44696         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44697         LDKPrivateRoute ret_var = PrivateRoute_clone(&orig_conv);
44698         uint32_t ret_ref = 0;
44699         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44700         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44701         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44702         ret_ref = (uintptr_t)ret_var.inner;
44703         if (ret_var.is_owned) {
44704                 ret_ref |= 1;
44705         }
44706         return ret_ref;
44707 }
44708
44709 int64_t  __attribute__((export_name("TS_PrivateRoute_hash"))) TS_PrivateRoute_hash(uint32_t o) {
44710         LDKPrivateRoute o_conv;
44711         o_conv.inner = (void*)(o & (~1));
44712         o_conv.is_owned = false;
44713         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
44714         int64_t ret_conv = PrivateRoute_hash(&o_conv);
44715         return ret_conv;
44716 }
44717
44718 jboolean  __attribute__((export_name("TS_PrivateRoute_eq"))) TS_PrivateRoute_eq(uint32_t a, uint32_t b) {
44719         LDKPrivateRoute a_conv;
44720         a_conv.inner = (void*)(a & (~1));
44721         a_conv.is_owned = false;
44722         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44723         LDKPrivateRoute b_conv;
44724         b_conv.inner = (void*)(b & (~1));
44725         b_conv.is_owned = false;
44726         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44727         jboolean ret_conv = PrivateRoute_eq(&a_conv, &b_conv);
44728         return ret_conv;
44729 }
44730
44731 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_into_parts"))) TS_SignedRawInvoice_into_parts(uint32_t this_arg) {
44732         LDKSignedRawInvoice this_arg_conv;
44733         this_arg_conv.inner = (void*)(this_arg & (~1));
44734         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
44735         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44736         this_arg_conv = SignedRawInvoice_clone(&this_arg_conv);
44737         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
44738         *ret_conv = SignedRawInvoice_into_parts(this_arg_conv);
44739         return ((uint32_t)ret_conv);
44740 }
44741
44742 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_raw_invoice"))) TS_SignedRawInvoice_raw_invoice(uint32_t this_arg) {
44743         LDKSignedRawInvoice this_arg_conv;
44744         this_arg_conv.inner = (void*)(this_arg & (~1));
44745         this_arg_conv.is_owned = false;
44746         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44747         LDKRawInvoice ret_var = SignedRawInvoice_raw_invoice(&this_arg_conv);
44748         uint32_t ret_ref = 0;
44749         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44750         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44751         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44752         ret_ref = (uintptr_t)ret_var.inner;
44753         if (ret_var.is_owned) {
44754                 ret_ref |= 1;
44755         }
44756         return ret_ref;
44757 }
44758
44759 int8_tArray  __attribute__((export_name("TS_SignedRawInvoice_hash"))) TS_SignedRawInvoice_hash(uint32_t this_arg) {
44760         LDKSignedRawInvoice this_arg_conv;
44761         this_arg_conv.inner = (void*)(this_arg & (~1));
44762         this_arg_conv.is_owned = false;
44763         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44764         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
44765         memcpy(ret_arr->elems, *SignedRawInvoice_hash(&this_arg_conv), 32);
44766         return ret_arr;
44767 }
44768
44769 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_signature"))) TS_SignedRawInvoice_signature(uint32_t this_arg) {
44770         LDKSignedRawInvoice this_arg_conv;
44771         this_arg_conv.inner = (void*)(this_arg & (~1));
44772         this_arg_conv.is_owned = false;
44773         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44774         LDKInvoiceSignature ret_var = SignedRawInvoice_signature(&this_arg_conv);
44775         uint32_t ret_ref = 0;
44776         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44777         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44778         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44779         ret_ref = (uintptr_t)ret_var.inner;
44780         if (ret_var.is_owned) {
44781                 ret_ref |= 1;
44782         }
44783         return ret_ref;
44784 }
44785
44786 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_recover_payee_pub_key"))) TS_SignedRawInvoice_recover_payee_pub_key(uint32_t this_arg) {
44787         LDKSignedRawInvoice this_arg_conv;
44788         this_arg_conv.inner = (void*)(this_arg & (~1));
44789         this_arg_conv.is_owned = false;
44790         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44791         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
44792         *ret_conv = SignedRawInvoice_recover_payee_pub_key(&this_arg_conv);
44793         return (uint32_t)ret_conv;
44794 }
44795
44796 jboolean  __attribute__((export_name("TS_SignedRawInvoice_check_signature"))) TS_SignedRawInvoice_check_signature(uint32_t this_arg) {
44797         LDKSignedRawInvoice this_arg_conv;
44798         this_arg_conv.inner = (void*)(this_arg & (~1));
44799         this_arg_conv.is_owned = false;
44800         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44801         jboolean ret_conv = SignedRawInvoice_check_signature(&this_arg_conv);
44802         return ret_conv;
44803 }
44804
44805 int8_tArray  __attribute__((export_name("TS_RawInvoice_hash"))) TS_RawInvoice_hash(uint32_t this_arg) {
44806         LDKRawInvoice this_arg_conv;
44807         this_arg_conv.inner = (void*)(this_arg & (~1));
44808         this_arg_conv.is_owned = false;
44809         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44810         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
44811         memcpy(ret_arr->elems, RawInvoice_hash(&this_arg_conv).data, 32);
44812         return ret_arr;
44813 }
44814
44815 uint32_t  __attribute__((export_name("TS_RawInvoice_payment_hash"))) TS_RawInvoice_payment_hash(uint32_t this_arg) {
44816         LDKRawInvoice this_arg_conv;
44817         this_arg_conv.inner = (void*)(this_arg & (~1));
44818         this_arg_conv.is_owned = false;
44819         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44820         LDKSha256 ret_var = RawInvoice_payment_hash(&this_arg_conv);
44821         uint32_t ret_ref = 0;
44822         if ((uintptr_t)ret_var.inner > 4096) {
44823                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44824                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44825         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44826                 ret_ref = (uintptr_t)ret_var.inner;
44827                 if (ret_var.is_owned) {
44828                         ret_ref |= 1;
44829                 }
44830         }
44831         return ret_ref;
44832 }
44833
44834 uint32_t  __attribute__((export_name("TS_RawInvoice_description"))) TS_RawInvoice_description(uint32_t this_arg) {
44835         LDKRawInvoice this_arg_conv;
44836         this_arg_conv.inner = (void*)(this_arg & (~1));
44837         this_arg_conv.is_owned = false;
44838         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44839         LDKDescription ret_var = RawInvoice_description(&this_arg_conv);
44840         uint32_t ret_ref = 0;
44841         if ((uintptr_t)ret_var.inner > 4096) {
44842                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44843                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44844         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44845                 ret_ref = (uintptr_t)ret_var.inner;
44846                 if (ret_var.is_owned) {
44847                         ret_ref |= 1;
44848                 }
44849         }
44850         return ret_ref;
44851 }
44852
44853 uint32_t  __attribute__((export_name("TS_RawInvoice_payee_pub_key"))) TS_RawInvoice_payee_pub_key(uint32_t this_arg) {
44854         LDKRawInvoice this_arg_conv;
44855         this_arg_conv.inner = (void*)(this_arg & (~1));
44856         this_arg_conv.is_owned = false;
44857         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44858         LDKPayeePubKey ret_var = RawInvoice_payee_pub_key(&this_arg_conv);
44859         uint32_t ret_ref = 0;
44860         if ((uintptr_t)ret_var.inner > 4096) {
44861                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44862                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44863         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44864                 ret_ref = (uintptr_t)ret_var.inner;
44865                 if (ret_var.is_owned) {
44866                         ret_ref |= 1;
44867                 }
44868         }
44869         return ret_ref;
44870 }
44871
44872 uint32_t  __attribute__((export_name("TS_RawInvoice_description_hash"))) TS_RawInvoice_description_hash(uint32_t this_arg) {
44873         LDKRawInvoice this_arg_conv;
44874         this_arg_conv.inner = (void*)(this_arg & (~1));
44875         this_arg_conv.is_owned = false;
44876         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44877         LDKSha256 ret_var = RawInvoice_description_hash(&this_arg_conv);
44878         uint32_t ret_ref = 0;
44879         if ((uintptr_t)ret_var.inner > 4096) {
44880                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44881                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44882         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44883                 ret_ref = (uintptr_t)ret_var.inner;
44884                 if (ret_var.is_owned) {
44885                         ret_ref |= 1;
44886                 }
44887         }
44888         return ret_ref;
44889 }
44890
44891 uint32_t  __attribute__((export_name("TS_RawInvoice_expiry_time"))) TS_RawInvoice_expiry_time(uint32_t this_arg) {
44892         LDKRawInvoice this_arg_conv;
44893         this_arg_conv.inner = (void*)(this_arg & (~1));
44894         this_arg_conv.is_owned = false;
44895         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44896         LDKExpiryTime ret_var = RawInvoice_expiry_time(&this_arg_conv);
44897         uint32_t ret_ref = 0;
44898         if ((uintptr_t)ret_var.inner > 4096) {
44899                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44900                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44901         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44902                 ret_ref = (uintptr_t)ret_var.inner;
44903                 if (ret_var.is_owned) {
44904                         ret_ref |= 1;
44905                 }
44906         }
44907         return ret_ref;
44908 }
44909
44910 uint32_t  __attribute__((export_name("TS_RawInvoice_min_final_cltv_expiry"))) TS_RawInvoice_min_final_cltv_expiry(uint32_t this_arg) {
44911         LDKRawInvoice this_arg_conv;
44912         this_arg_conv.inner = (void*)(this_arg & (~1));
44913         this_arg_conv.is_owned = false;
44914         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44915         LDKMinFinalCltvExpiry ret_var = RawInvoice_min_final_cltv_expiry(&this_arg_conv);
44916         uint32_t ret_ref = 0;
44917         if ((uintptr_t)ret_var.inner > 4096) {
44918                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44919                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44920         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44921                 ret_ref = (uintptr_t)ret_var.inner;
44922                 if (ret_var.is_owned) {
44923                         ret_ref |= 1;
44924                 }
44925         }
44926         return ret_ref;
44927 }
44928
44929 int8_tArray  __attribute__((export_name("TS_RawInvoice_payment_secret"))) TS_RawInvoice_payment_secret(uint32_t this_arg) {
44930         LDKRawInvoice this_arg_conv;
44931         this_arg_conv.inner = (void*)(this_arg & (~1));
44932         this_arg_conv.is_owned = false;
44933         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44934         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
44935         memcpy(ret_arr->elems, RawInvoice_payment_secret(&this_arg_conv).data, 32);
44936         return ret_arr;
44937 }
44938
44939 uint32_t  __attribute__((export_name("TS_RawInvoice_features"))) TS_RawInvoice_features(uint32_t this_arg) {
44940         LDKRawInvoice this_arg_conv;
44941         this_arg_conv.inner = (void*)(this_arg & (~1));
44942         this_arg_conv.is_owned = false;
44943         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44944         LDKInvoiceFeatures ret_var = RawInvoice_features(&this_arg_conv);
44945         uint32_t ret_ref = 0;
44946         if ((uintptr_t)ret_var.inner > 4096) {
44947                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44948                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44949         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44950                 ret_ref = (uintptr_t)ret_var.inner;
44951                 if (ret_var.is_owned) {
44952                         ret_ref |= 1;
44953                 }
44954         }
44955         return ret_ref;
44956 }
44957
44958 uint32_tArray  __attribute__((export_name("TS_RawInvoice_private_routes"))) TS_RawInvoice_private_routes(uint32_t this_arg) {
44959         LDKRawInvoice this_arg_conv;
44960         this_arg_conv.inner = (void*)(this_arg & (~1));
44961         this_arg_conv.is_owned = false;
44962         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44963         LDKCVec_PrivateRouteZ ret_var = RawInvoice_private_routes(&this_arg_conv);
44964         uint32_tArray ret_arr = NULL;
44965         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
44966         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 8);
44967         for (size_t o = 0; o < ret_var.datalen; o++) {
44968                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
44969                 uint32_t ret_conv_14_ref = 0;
44970                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44971                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44972                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
44973                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
44974                 if (ret_conv_14_var.is_owned) {
44975                         ret_conv_14_ref |= 1;
44976                 }
44977                 ret_arr_ptr[o] = ret_conv_14_ref;
44978         }
44979         
44980         FREE(ret_var.data);
44981         return ret_arr;
44982 }
44983
44984 uint32_t  __attribute__((export_name("TS_RawInvoice_amount_pico_btc"))) TS_RawInvoice_amount_pico_btc(uint32_t this_arg) {
44985         LDKRawInvoice this_arg_conv;
44986         this_arg_conv.inner = (void*)(this_arg & (~1));
44987         this_arg_conv.is_owned = false;
44988         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44989         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
44990         *ret_copy = RawInvoice_amount_pico_btc(&this_arg_conv);
44991         uint32_t ret_ref = (uintptr_t)ret_copy;
44992         return ret_ref;
44993 }
44994
44995 uint32_t  __attribute__((export_name("TS_RawInvoice_currency"))) TS_RawInvoice_currency(uint32_t this_arg) {
44996         LDKRawInvoice this_arg_conv;
44997         this_arg_conv.inner = (void*)(this_arg & (~1));
44998         this_arg_conv.is_owned = false;
44999         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45000         uint32_t ret_conv = LDKCurrency_to_js(RawInvoice_currency(&this_arg_conv));
45001         return ret_conv;
45002 }
45003
45004 uint32_t  __attribute__((export_name("TS_PositiveTimestamp_from_unix_timestamp"))) TS_PositiveTimestamp_from_unix_timestamp(int64_t unix_seconds) {
45005         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
45006         *ret_conv = PositiveTimestamp_from_unix_timestamp(unix_seconds);
45007         return (uint32_t)ret_conv;
45008 }
45009
45010 uint32_t  __attribute__((export_name("TS_PositiveTimestamp_from_duration_since_epoch"))) TS_PositiveTimestamp_from_duration_since_epoch(int64_t duration) {
45011         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
45012         *ret_conv = PositiveTimestamp_from_duration_since_epoch(duration);
45013         return (uint32_t)ret_conv;
45014 }
45015
45016 int64_t  __attribute__((export_name("TS_PositiveTimestamp_as_unix_timestamp"))) TS_PositiveTimestamp_as_unix_timestamp(uint32_t this_arg) {
45017         LDKPositiveTimestamp this_arg_conv;
45018         this_arg_conv.inner = (void*)(this_arg & (~1));
45019         this_arg_conv.is_owned = false;
45020         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45021         int64_t ret_conv = PositiveTimestamp_as_unix_timestamp(&this_arg_conv);
45022         return ret_conv;
45023 }
45024
45025 int64_t  __attribute__((export_name("TS_PositiveTimestamp_as_duration_since_epoch"))) TS_PositiveTimestamp_as_duration_since_epoch(uint32_t this_arg) {
45026         LDKPositiveTimestamp this_arg_conv;
45027         this_arg_conv.inner = (void*)(this_arg & (~1));
45028         this_arg_conv.is_owned = false;
45029         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45030         int64_t ret_conv = PositiveTimestamp_as_duration_since_epoch(&this_arg_conv);
45031         return ret_conv;
45032 }
45033
45034 uint32_t  __attribute__((export_name("TS_Invoice_into_signed_raw"))) TS_Invoice_into_signed_raw(uint32_t this_arg) {
45035         LDKInvoice this_arg_conv;
45036         this_arg_conv.inner = (void*)(this_arg & (~1));
45037         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
45038         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45039         this_arg_conv = Invoice_clone(&this_arg_conv);
45040         LDKSignedRawInvoice ret_var = Invoice_into_signed_raw(this_arg_conv);
45041         uint32_t ret_ref = 0;
45042         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45043         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45044         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45045         ret_ref = (uintptr_t)ret_var.inner;
45046         if (ret_var.is_owned) {
45047                 ret_ref |= 1;
45048         }
45049         return ret_ref;
45050 }
45051
45052 uint32_t  __attribute__((export_name("TS_Invoice_check_signature"))) TS_Invoice_check_signature(uint32_t this_arg) {
45053         LDKInvoice this_arg_conv;
45054         this_arg_conv.inner = (void*)(this_arg & (~1));
45055         this_arg_conv.is_owned = false;
45056         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45057         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
45058         *ret_conv = Invoice_check_signature(&this_arg_conv);
45059         return (uint32_t)ret_conv;
45060 }
45061
45062 uint32_t  __attribute__((export_name("TS_Invoice_from_signed"))) TS_Invoice_from_signed(uint32_t signed_invoice) {
45063         LDKSignedRawInvoice signed_invoice_conv;
45064         signed_invoice_conv.inner = (void*)(signed_invoice & (~1));
45065         signed_invoice_conv.is_owned = (signed_invoice & 1) || (signed_invoice == 0);
45066         CHECK_INNER_FIELD_ACCESS_OR_NULL(signed_invoice_conv);
45067         signed_invoice_conv = SignedRawInvoice_clone(&signed_invoice_conv);
45068         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
45069         *ret_conv = Invoice_from_signed(signed_invoice_conv);
45070         return (uint32_t)ret_conv;
45071 }
45072
45073 int64_t  __attribute__((export_name("TS_Invoice_duration_since_epoch"))) TS_Invoice_duration_since_epoch(uint32_t this_arg) {
45074         LDKInvoice this_arg_conv;
45075         this_arg_conv.inner = (void*)(this_arg & (~1));
45076         this_arg_conv.is_owned = false;
45077         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45078         int64_t ret_conv = Invoice_duration_since_epoch(&this_arg_conv);
45079         return ret_conv;
45080 }
45081
45082 int8_tArray  __attribute__((export_name("TS_Invoice_payment_hash"))) TS_Invoice_payment_hash(uint32_t this_arg) {
45083         LDKInvoice this_arg_conv;
45084         this_arg_conv.inner = (void*)(this_arg & (~1));
45085         this_arg_conv.is_owned = false;
45086         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45087         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
45088         memcpy(ret_arr->elems, *Invoice_payment_hash(&this_arg_conv), 32);
45089         return ret_arr;
45090 }
45091
45092 int8_tArray  __attribute__((export_name("TS_Invoice_payee_pub_key"))) TS_Invoice_payee_pub_key(uint32_t this_arg) {
45093         LDKInvoice this_arg_conv;
45094         this_arg_conv.inner = (void*)(this_arg & (~1));
45095         this_arg_conv.is_owned = false;
45096         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45097         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
45098         memcpy(ret_arr->elems, Invoice_payee_pub_key(&this_arg_conv).compressed_form, 33);
45099         return ret_arr;
45100 }
45101
45102 int8_tArray  __attribute__((export_name("TS_Invoice_payment_secret"))) TS_Invoice_payment_secret(uint32_t this_arg) {
45103         LDKInvoice this_arg_conv;
45104         this_arg_conv.inner = (void*)(this_arg & (~1));
45105         this_arg_conv.is_owned = false;
45106         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45107         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
45108         memcpy(ret_arr->elems, *Invoice_payment_secret(&this_arg_conv), 32);
45109         return ret_arr;
45110 }
45111
45112 uint32_t  __attribute__((export_name("TS_Invoice_features"))) TS_Invoice_features(uint32_t this_arg) {
45113         LDKInvoice this_arg_conv;
45114         this_arg_conv.inner = (void*)(this_arg & (~1));
45115         this_arg_conv.is_owned = false;
45116         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45117         LDKInvoiceFeatures ret_var = Invoice_features(&this_arg_conv);
45118         uint32_t ret_ref = 0;
45119         if ((uintptr_t)ret_var.inner > 4096) {
45120                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45121                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45122         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45123                 ret_ref = (uintptr_t)ret_var.inner;
45124                 if (ret_var.is_owned) {
45125                         ret_ref |= 1;
45126                 }
45127         }
45128         return ret_ref;
45129 }
45130
45131 int8_tArray  __attribute__((export_name("TS_Invoice_recover_payee_pub_key"))) TS_Invoice_recover_payee_pub_key(uint32_t this_arg) {
45132         LDKInvoice this_arg_conv;
45133         this_arg_conv.inner = (void*)(this_arg & (~1));
45134         this_arg_conv.is_owned = false;
45135         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45136         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
45137         memcpy(ret_arr->elems, Invoice_recover_payee_pub_key(&this_arg_conv).compressed_form, 33);
45138         return ret_arr;
45139 }
45140
45141 int64_t  __attribute__((export_name("TS_Invoice_expiry_time"))) TS_Invoice_expiry_time(uint32_t this_arg) {
45142         LDKInvoice this_arg_conv;
45143         this_arg_conv.inner = (void*)(this_arg & (~1));
45144         this_arg_conv.is_owned = false;
45145         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45146         int64_t ret_conv = Invoice_expiry_time(&this_arg_conv);
45147         return ret_conv;
45148 }
45149
45150 jboolean  __attribute__((export_name("TS_Invoice_would_expire"))) TS_Invoice_would_expire(uint32_t this_arg, int64_t at_time) {
45151         LDKInvoice this_arg_conv;
45152         this_arg_conv.inner = (void*)(this_arg & (~1));
45153         this_arg_conv.is_owned = false;
45154         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45155         jboolean ret_conv = Invoice_would_expire(&this_arg_conv, at_time);
45156         return ret_conv;
45157 }
45158
45159 int64_t  __attribute__((export_name("TS_Invoice_min_final_cltv_expiry"))) TS_Invoice_min_final_cltv_expiry(uint32_t this_arg) {
45160         LDKInvoice this_arg_conv;
45161         this_arg_conv.inner = (void*)(this_arg & (~1));
45162         this_arg_conv.is_owned = false;
45163         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45164         int64_t ret_conv = Invoice_min_final_cltv_expiry(&this_arg_conv);
45165         return ret_conv;
45166 }
45167
45168 uint32_tArray  __attribute__((export_name("TS_Invoice_private_routes"))) TS_Invoice_private_routes(uint32_t this_arg) {
45169         LDKInvoice this_arg_conv;
45170         this_arg_conv.inner = (void*)(this_arg & (~1));
45171         this_arg_conv.is_owned = false;
45172         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45173         LDKCVec_PrivateRouteZ ret_var = Invoice_private_routes(&this_arg_conv);
45174         uint32_tArray ret_arr = NULL;
45175         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
45176         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 8);
45177         for (size_t o = 0; o < ret_var.datalen; o++) {
45178                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
45179                 uint32_t ret_conv_14_ref = 0;
45180                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45181                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45182                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
45183                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
45184                 if (ret_conv_14_var.is_owned) {
45185                         ret_conv_14_ref |= 1;
45186                 }
45187                 ret_arr_ptr[o] = ret_conv_14_ref;
45188         }
45189         
45190         FREE(ret_var.data);
45191         return ret_arr;
45192 }
45193
45194 uint32_tArray  __attribute__((export_name("TS_Invoice_route_hints"))) TS_Invoice_route_hints(uint32_t this_arg) {
45195         LDKInvoice this_arg_conv;
45196         this_arg_conv.inner = (void*)(this_arg & (~1));
45197         this_arg_conv.is_owned = false;
45198         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45199         LDKCVec_RouteHintZ ret_var = Invoice_route_hints(&this_arg_conv);
45200         uint32_tArray ret_arr = NULL;
45201         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
45202         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 8);
45203         for (size_t l = 0; l < ret_var.datalen; l++) {
45204                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
45205                 uint32_t ret_conv_11_ref = 0;
45206                 CHECK((((uintptr_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45207                 CHECK((((uintptr_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45208                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
45209                 ret_conv_11_ref = (uintptr_t)ret_conv_11_var.inner;
45210                 if (ret_conv_11_var.is_owned) {
45211                         ret_conv_11_ref |= 1;
45212                 }
45213                 ret_arr_ptr[l] = ret_conv_11_ref;
45214         }
45215         
45216         FREE(ret_var.data);
45217         return ret_arr;
45218 }
45219
45220 uint32_t  __attribute__((export_name("TS_Invoice_currency"))) TS_Invoice_currency(uint32_t this_arg) {
45221         LDKInvoice this_arg_conv;
45222         this_arg_conv.inner = (void*)(this_arg & (~1));
45223         this_arg_conv.is_owned = false;
45224         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45225         uint32_t ret_conv = LDKCurrency_to_js(Invoice_currency(&this_arg_conv));
45226         return ret_conv;
45227 }
45228
45229 uint32_t  __attribute__((export_name("TS_Invoice_amount_milli_satoshis"))) TS_Invoice_amount_milli_satoshis(uint32_t this_arg) {
45230         LDKInvoice this_arg_conv;
45231         this_arg_conv.inner = (void*)(this_arg & (~1));
45232         this_arg_conv.is_owned = false;
45233         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45234         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
45235         *ret_copy = Invoice_amount_milli_satoshis(&this_arg_conv);
45236         uint32_t ret_ref = (uintptr_t)ret_copy;
45237         return ret_ref;
45238 }
45239
45240 uint32_t  __attribute__((export_name("TS_Description_new"))) TS_Description_new(jstring description) {
45241         LDKStr description_conv = str_ref_to_owned_c(description);
45242         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
45243         *ret_conv = Description_new(description_conv);
45244         return (uint32_t)ret_conv;
45245 }
45246
45247 jstring  __attribute__((export_name("TS_Description_into_inner"))) TS_Description_into_inner(uint32_t this_arg) {
45248         LDKDescription this_arg_conv;
45249         this_arg_conv.inner = (void*)(this_arg & (~1));
45250         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
45251         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45252         this_arg_conv = Description_clone(&this_arg_conv);
45253         LDKStr ret_str = Description_into_inner(this_arg_conv);
45254         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
45255         Str_free(ret_str);
45256         return ret_conv;
45257 }
45258
45259 uint32_t  __attribute__((export_name("TS_ExpiryTime_from_seconds"))) TS_ExpiryTime_from_seconds(int64_t seconds) {
45260         LDKExpiryTime ret_var = ExpiryTime_from_seconds(seconds);
45261         uint32_t ret_ref = 0;
45262         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45263         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45264         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45265         ret_ref = (uintptr_t)ret_var.inner;
45266         if (ret_var.is_owned) {
45267                 ret_ref |= 1;
45268         }
45269         return ret_ref;
45270 }
45271
45272 uint32_t  __attribute__((export_name("TS_ExpiryTime_from_duration"))) TS_ExpiryTime_from_duration(int64_t duration) {
45273         LDKExpiryTime ret_var = ExpiryTime_from_duration(duration);
45274         uint32_t ret_ref = 0;
45275         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45276         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45277         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45278         ret_ref = (uintptr_t)ret_var.inner;
45279         if (ret_var.is_owned) {
45280                 ret_ref |= 1;
45281         }
45282         return ret_ref;
45283 }
45284
45285 int64_t  __attribute__((export_name("TS_ExpiryTime_as_seconds"))) TS_ExpiryTime_as_seconds(uint32_t this_arg) {
45286         LDKExpiryTime this_arg_conv;
45287         this_arg_conv.inner = (void*)(this_arg & (~1));
45288         this_arg_conv.is_owned = false;
45289         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45290         int64_t ret_conv = ExpiryTime_as_seconds(&this_arg_conv);
45291         return ret_conv;
45292 }
45293
45294 int64_t  __attribute__((export_name("TS_ExpiryTime_as_duration"))) TS_ExpiryTime_as_duration(uint32_t this_arg) {
45295         LDKExpiryTime this_arg_conv;
45296         this_arg_conv.inner = (void*)(this_arg & (~1));
45297         this_arg_conv.is_owned = false;
45298         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45299         int64_t ret_conv = ExpiryTime_as_duration(&this_arg_conv);
45300         return ret_conv;
45301 }
45302
45303 uint32_t  __attribute__((export_name("TS_PrivateRoute_new"))) TS_PrivateRoute_new(uint32_t hops) {
45304         LDKRouteHint hops_conv;
45305         hops_conv.inner = (void*)(hops & (~1));
45306         hops_conv.is_owned = (hops & 1) || (hops == 0);
45307         CHECK_INNER_FIELD_ACCESS_OR_NULL(hops_conv);
45308         hops_conv = RouteHint_clone(&hops_conv);
45309         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
45310         *ret_conv = PrivateRoute_new(hops_conv);
45311         return (uint32_t)ret_conv;
45312 }
45313
45314 uint32_t  __attribute__((export_name("TS_PrivateRoute_into_inner"))) TS_PrivateRoute_into_inner(uint32_t this_arg) {
45315         LDKPrivateRoute this_arg_conv;
45316         this_arg_conv.inner = (void*)(this_arg & (~1));
45317         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
45318         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45319         this_arg_conv = PrivateRoute_clone(&this_arg_conv);
45320         LDKRouteHint ret_var = PrivateRoute_into_inner(this_arg_conv);
45321         uint32_t ret_ref = 0;
45322         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45323         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45324         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45325         ret_ref = (uintptr_t)ret_var.inner;
45326         if (ret_var.is_owned) {
45327                 ret_ref |= 1;
45328         }
45329         return ret_ref;
45330 }
45331
45332 uint32_t  __attribute__((export_name("TS_CreationError_clone"))) TS_CreationError_clone(uint32_t orig) {
45333         LDKCreationError* orig_conv = (LDKCreationError*)(orig & ~1);
45334         uint32_t ret_conv = LDKCreationError_to_js(CreationError_clone(orig_conv));
45335         return ret_conv;
45336 }
45337
45338 uint32_t  __attribute__((export_name("TS_CreationError_description_too_long"))) TS_CreationError_description_too_long() {
45339         uint32_t ret_conv = LDKCreationError_to_js(CreationError_description_too_long());
45340         return ret_conv;
45341 }
45342
45343 uint32_t  __attribute__((export_name("TS_CreationError_route_too_long"))) TS_CreationError_route_too_long() {
45344         uint32_t ret_conv = LDKCreationError_to_js(CreationError_route_too_long());
45345         return ret_conv;
45346 }
45347
45348 uint32_t  __attribute__((export_name("TS_CreationError_timestamp_out_of_bounds"))) TS_CreationError_timestamp_out_of_bounds() {
45349         uint32_t ret_conv = LDKCreationError_to_js(CreationError_timestamp_out_of_bounds());
45350         return ret_conv;
45351 }
45352
45353 uint32_t  __attribute__((export_name("TS_CreationError_invalid_amount"))) TS_CreationError_invalid_amount() {
45354         uint32_t ret_conv = LDKCreationError_to_js(CreationError_invalid_amount());
45355         return ret_conv;
45356 }
45357
45358 uint32_t  __attribute__((export_name("TS_CreationError_missing_route_hints"))) TS_CreationError_missing_route_hints() {
45359         uint32_t ret_conv = LDKCreationError_to_js(CreationError_missing_route_hints());
45360         return ret_conv;
45361 }
45362
45363 jboolean  __attribute__((export_name("TS_CreationError_eq"))) TS_CreationError_eq(uint32_t a, uint32_t b) {
45364         LDKCreationError* a_conv = (LDKCreationError*)(a & ~1);
45365         LDKCreationError* b_conv = (LDKCreationError*)(b & ~1);
45366         jboolean ret_conv = CreationError_eq(a_conv, b_conv);
45367         return ret_conv;
45368 }
45369
45370 jstring  __attribute__((export_name("TS_CreationError_to_str"))) TS_CreationError_to_str(uint32_t o) {
45371         LDKCreationError* o_conv = (LDKCreationError*)(o & ~1);
45372         LDKStr ret_str = CreationError_to_str(o_conv);
45373         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
45374         Str_free(ret_str);
45375         return ret_conv;
45376 }
45377
45378 uint32_t  __attribute__((export_name("TS_SemanticError_clone"))) TS_SemanticError_clone(uint32_t orig) {
45379         LDKSemanticError* orig_conv = (LDKSemanticError*)(orig & ~1);
45380         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_clone(orig_conv));
45381         return ret_conv;
45382 }
45383
45384 uint32_t  __attribute__((export_name("TS_SemanticError_no_payment_hash"))) TS_SemanticError_no_payment_hash() {
45385         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_no_payment_hash());
45386         return ret_conv;
45387 }
45388
45389 uint32_t  __attribute__((export_name("TS_SemanticError_multiple_payment_hashes"))) TS_SemanticError_multiple_payment_hashes() {
45390         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_multiple_payment_hashes());
45391         return ret_conv;
45392 }
45393
45394 uint32_t  __attribute__((export_name("TS_SemanticError_no_description"))) TS_SemanticError_no_description() {
45395         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_no_description());
45396         return ret_conv;
45397 }
45398
45399 uint32_t  __attribute__((export_name("TS_SemanticError_multiple_descriptions"))) TS_SemanticError_multiple_descriptions() {
45400         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_multiple_descriptions());
45401         return ret_conv;
45402 }
45403
45404 uint32_t  __attribute__((export_name("TS_SemanticError_no_payment_secret"))) TS_SemanticError_no_payment_secret() {
45405         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_no_payment_secret());
45406         return ret_conv;
45407 }
45408
45409 uint32_t  __attribute__((export_name("TS_SemanticError_multiple_payment_secrets"))) TS_SemanticError_multiple_payment_secrets() {
45410         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_multiple_payment_secrets());
45411         return ret_conv;
45412 }
45413
45414 uint32_t  __attribute__((export_name("TS_SemanticError_invalid_features"))) TS_SemanticError_invalid_features() {
45415         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_invalid_features());
45416         return ret_conv;
45417 }
45418
45419 uint32_t  __attribute__((export_name("TS_SemanticError_invalid_recovery_id"))) TS_SemanticError_invalid_recovery_id() {
45420         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_invalid_recovery_id());
45421         return ret_conv;
45422 }
45423
45424 uint32_t  __attribute__((export_name("TS_SemanticError_invalid_signature"))) TS_SemanticError_invalid_signature() {
45425         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_invalid_signature());
45426         return ret_conv;
45427 }
45428
45429 uint32_t  __attribute__((export_name("TS_SemanticError_imprecise_amount"))) TS_SemanticError_imprecise_amount() {
45430         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_imprecise_amount());
45431         return ret_conv;
45432 }
45433
45434 jboolean  __attribute__((export_name("TS_SemanticError_eq"))) TS_SemanticError_eq(uint32_t a, uint32_t b) {
45435         LDKSemanticError* a_conv = (LDKSemanticError*)(a & ~1);
45436         LDKSemanticError* b_conv = (LDKSemanticError*)(b & ~1);
45437         jboolean ret_conv = SemanticError_eq(a_conv, b_conv);
45438         return ret_conv;
45439 }
45440
45441 jstring  __attribute__((export_name("TS_SemanticError_to_str"))) TS_SemanticError_to_str(uint32_t o) {
45442         LDKSemanticError* o_conv = (LDKSemanticError*)(o & ~1);
45443         LDKStr ret_str = SemanticError_to_str(o_conv);
45444         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
45445         Str_free(ret_str);
45446         return ret_conv;
45447 }
45448
45449 void  __attribute__((export_name("TS_SignOrCreationError_free"))) TS_SignOrCreationError_free(uint32_t this_ptr) {
45450         if ((this_ptr & 1) != 0) return;
45451         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
45452         CHECK_ACCESS(this_ptr_ptr);
45453         LDKSignOrCreationError this_ptr_conv = *(LDKSignOrCreationError*)(this_ptr_ptr);
45454         FREE((void*)this_ptr);
45455         SignOrCreationError_free(this_ptr_conv);
45456 }
45457
45458 static inline uintptr_t SignOrCreationError_clone_ptr(LDKSignOrCreationError *NONNULL_PTR arg) {
45459         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
45460         *ret_copy = SignOrCreationError_clone(arg);
45461 uint32_t ret_ref = (uintptr_t)ret_copy;
45462         return ret_ref;
45463 }
45464 uint32_t  __attribute__((export_name("TS_SignOrCreationError_clone_ptr"))) TS_SignOrCreationError_clone_ptr(uint32_t arg) {
45465         LDKSignOrCreationError* arg_conv = (LDKSignOrCreationError*)arg;
45466         uint32_t ret_conv = SignOrCreationError_clone_ptr(arg_conv);
45467         return ret_conv;
45468 }
45469
45470 uint32_t  __attribute__((export_name("TS_SignOrCreationError_clone"))) TS_SignOrCreationError_clone(uint32_t orig) {
45471         LDKSignOrCreationError* orig_conv = (LDKSignOrCreationError*)orig;
45472         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
45473         *ret_copy = SignOrCreationError_clone(orig_conv);
45474         uint32_t ret_ref = (uintptr_t)ret_copy;
45475         return ret_ref;
45476 }
45477
45478 uint32_t  __attribute__((export_name("TS_SignOrCreationError_sign_error"))) TS_SignOrCreationError_sign_error() {
45479         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
45480         *ret_copy = SignOrCreationError_sign_error();
45481         uint32_t ret_ref = (uintptr_t)ret_copy;
45482         return ret_ref;
45483 }
45484
45485 uint32_t  __attribute__((export_name("TS_SignOrCreationError_creation_error"))) TS_SignOrCreationError_creation_error(uint32_t a) {
45486         LDKCreationError a_conv = LDKCreationError_from_js(a);
45487         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
45488         *ret_copy = SignOrCreationError_creation_error(a_conv);
45489         uint32_t ret_ref = (uintptr_t)ret_copy;
45490         return ret_ref;
45491 }
45492
45493 jboolean  __attribute__((export_name("TS_SignOrCreationError_eq"))) TS_SignOrCreationError_eq(uint32_t a, uint32_t b) {
45494         LDKSignOrCreationError* a_conv = (LDKSignOrCreationError*)a;
45495         LDKSignOrCreationError* b_conv = (LDKSignOrCreationError*)b;
45496         jboolean ret_conv = SignOrCreationError_eq(a_conv, b_conv);
45497         return ret_conv;
45498 }
45499
45500 jstring  __attribute__((export_name("TS_SignOrCreationError_to_str"))) TS_SignOrCreationError_to_str(uint32_t o) {
45501         LDKSignOrCreationError* o_conv = (LDKSignOrCreationError*)o;
45502         LDKStr ret_str = SignOrCreationError_to_str(o_conv);
45503         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
45504         Str_free(ret_str);
45505         return ret_conv;
45506 }
45507
45508 void  __attribute__((export_name("TS_InvoicePayer_free"))) TS_InvoicePayer_free(uint32_t this_obj) {
45509         LDKInvoicePayer this_obj_conv;
45510         this_obj_conv.inner = (void*)(this_obj & (~1));
45511         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
45512         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45513         InvoicePayer_free(this_obj_conv);
45514 }
45515
45516 void  __attribute__((export_name("TS_Payer_free"))) TS_Payer_free(uint32_t this_ptr) {
45517         if ((this_ptr & 1) != 0) return;
45518         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
45519         CHECK_ACCESS(this_ptr_ptr);
45520         LDKPayer this_ptr_conv = *(LDKPayer*)(this_ptr_ptr);
45521         FREE((void*)this_ptr);
45522         Payer_free(this_ptr_conv);
45523 }
45524
45525 void  __attribute__((export_name("TS_Router_free"))) TS_Router_free(uint32_t this_ptr) {
45526         if ((this_ptr & 1) != 0) return;
45527         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
45528         CHECK_ACCESS(this_ptr_ptr);
45529         LDKRouter this_ptr_conv = *(LDKRouter*)(this_ptr_ptr);
45530         FREE((void*)this_ptr);
45531         Router_free(this_ptr_conv);
45532 }
45533
45534 void  __attribute__((export_name("TS_Retry_free"))) TS_Retry_free(uint32_t this_ptr) {
45535         if ((this_ptr & 1) != 0) return;
45536         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
45537         CHECK_ACCESS(this_ptr_ptr);
45538         LDKRetry this_ptr_conv = *(LDKRetry*)(this_ptr_ptr);
45539         FREE((void*)this_ptr);
45540         Retry_free(this_ptr_conv);
45541 }
45542
45543 static inline uintptr_t Retry_clone_ptr(LDKRetry *NONNULL_PTR arg) {
45544         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
45545         *ret_copy = Retry_clone(arg);
45546 uint32_t ret_ref = (uintptr_t)ret_copy;
45547         return ret_ref;
45548 }
45549 uint32_t  __attribute__((export_name("TS_Retry_clone_ptr"))) TS_Retry_clone_ptr(uint32_t arg) {
45550         LDKRetry* arg_conv = (LDKRetry*)arg;
45551         uint32_t ret_conv = Retry_clone_ptr(arg_conv);
45552         return ret_conv;
45553 }
45554
45555 uint32_t  __attribute__((export_name("TS_Retry_clone"))) TS_Retry_clone(uint32_t orig) {
45556         LDKRetry* orig_conv = (LDKRetry*)orig;
45557         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
45558         *ret_copy = Retry_clone(orig_conv);
45559         uint32_t ret_ref = (uintptr_t)ret_copy;
45560         return ret_ref;
45561 }
45562
45563 uint32_t  __attribute__((export_name("TS_Retry_attempts"))) TS_Retry_attempts(uint32_t a) {
45564         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
45565         *ret_copy = Retry_attempts(a);
45566         uint32_t ret_ref = (uintptr_t)ret_copy;
45567         return ret_ref;
45568 }
45569
45570 jboolean  __attribute__((export_name("TS_Retry_eq"))) TS_Retry_eq(uint32_t a, uint32_t b) {
45571         LDKRetry* a_conv = (LDKRetry*)a;
45572         LDKRetry* b_conv = (LDKRetry*)b;
45573         jboolean ret_conv = Retry_eq(a_conv, b_conv);
45574         return ret_conv;
45575 }
45576
45577 int64_t  __attribute__((export_name("TS_Retry_hash"))) TS_Retry_hash(uint32_t o) {
45578         LDKRetry* o_conv = (LDKRetry*)o;
45579         int64_t ret_conv = Retry_hash(o_conv);
45580         return ret_conv;
45581 }
45582
45583 void  __attribute__((export_name("TS_PaymentError_free"))) TS_PaymentError_free(uint32_t this_ptr) {
45584         if ((this_ptr & 1) != 0) return;
45585         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
45586         CHECK_ACCESS(this_ptr_ptr);
45587         LDKPaymentError this_ptr_conv = *(LDKPaymentError*)(this_ptr_ptr);
45588         FREE((void*)this_ptr);
45589         PaymentError_free(this_ptr_conv);
45590 }
45591
45592 static inline uintptr_t PaymentError_clone_ptr(LDKPaymentError *NONNULL_PTR arg) {
45593         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
45594         *ret_copy = PaymentError_clone(arg);
45595 uint32_t ret_ref = (uintptr_t)ret_copy;
45596         return ret_ref;
45597 }
45598 uint32_t  __attribute__((export_name("TS_PaymentError_clone_ptr"))) TS_PaymentError_clone_ptr(uint32_t arg) {
45599         LDKPaymentError* arg_conv = (LDKPaymentError*)arg;
45600         uint32_t ret_conv = PaymentError_clone_ptr(arg_conv);
45601         return ret_conv;
45602 }
45603
45604 uint32_t  __attribute__((export_name("TS_PaymentError_clone"))) TS_PaymentError_clone(uint32_t orig) {
45605         LDKPaymentError* orig_conv = (LDKPaymentError*)orig;
45606         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
45607         *ret_copy = PaymentError_clone(orig_conv);
45608         uint32_t ret_ref = (uintptr_t)ret_copy;
45609         return ret_ref;
45610 }
45611
45612 uint32_t  __attribute__((export_name("TS_PaymentError_invoice"))) TS_PaymentError_invoice(jstring a) {
45613         LDKStr a_conv = str_ref_to_owned_c(a);
45614         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
45615         *ret_copy = PaymentError_invoice(a_conv);
45616         uint32_t ret_ref = (uintptr_t)ret_copy;
45617         return ret_ref;
45618 }
45619
45620 uint32_t  __attribute__((export_name("TS_PaymentError_routing"))) TS_PaymentError_routing(uint32_t a) {
45621         LDKLightningError a_conv;
45622         a_conv.inner = (void*)(a & (~1));
45623         a_conv.is_owned = (a & 1) || (a == 0);
45624         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
45625         a_conv = LightningError_clone(&a_conv);
45626         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
45627         *ret_copy = PaymentError_routing(a_conv);
45628         uint32_t ret_ref = (uintptr_t)ret_copy;
45629         return ret_ref;
45630 }
45631
45632 uint32_t  __attribute__((export_name("TS_PaymentError_sending"))) TS_PaymentError_sending(uint32_t a) {
45633         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
45634         CHECK_ACCESS(a_ptr);
45635         LDKPaymentSendFailure a_conv = *(LDKPaymentSendFailure*)(a_ptr);
45636         a_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)a) & ~1));
45637         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
45638         *ret_copy = PaymentError_sending(a_conv);
45639         uint32_t ret_ref = (uintptr_t)ret_copy;
45640         return ret_ref;
45641 }
45642
45643 uint32_t  __attribute__((export_name("TS_InvoicePayer_new"))) TS_InvoicePayer_new(uint32_t payer, uint32_t router, uint32_t scorer, uint32_t logger, uint32_t event_handler, uint32_t retry) {
45644         void* payer_ptr = (void*)(((uintptr_t)payer) & ~1);
45645         CHECK_ACCESS(payer_ptr);
45646         LDKPayer payer_conv = *(LDKPayer*)(payer_ptr);
45647         if (payer_conv.free == LDKPayer_JCalls_free) {
45648                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
45649                 LDKPayer_JCalls_cloned(&payer_conv);
45650         }
45651         void* router_ptr = (void*)(((uintptr_t)router) & ~1);
45652         CHECK_ACCESS(router_ptr);
45653         LDKRouter router_conv = *(LDKRouter*)(router_ptr);
45654         if (router_conv.free == LDKRouter_JCalls_free) {
45655                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
45656                 LDKRouter_JCalls_cloned(&router_conv);
45657         }
45658         LDKMultiThreadedLockableScore scorer_conv;
45659         scorer_conv.inner = (void*)(scorer & (~1));
45660         scorer_conv.is_owned = false;
45661         CHECK_INNER_FIELD_ACCESS_OR_NULL(scorer_conv);
45662         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
45663         CHECK_ACCESS(logger_ptr);
45664         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
45665         if (logger_conv.free == LDKLogger_JCalls_free) {
45666                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
45667                 LDKLogger_JCalls_cloned(&logger_conv);
45668         }
45669         void* event_handler_ptr = (void*)(((uintptr_t)event_handler) & ~1);
45670         CHECK_ACCESS(event_handler_ptr);
45671         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
45672         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
45673                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
45674                 LDKEventHandler_JCalls_cloned(&event_handler_conv);
45675         }
45676         void* retry_ptr = (void*)(((uintptr_t)retry) & ~1);
45677         CHECK_ACCESS(retry_ptr);
45678         LDKRetry retry_conv = *(LDKRetry*)(retry_ptr);
45679         retry_conv = Retry_clone((LDKRetry*)(((uintptr_t)retry) & ~1));
45680         LDKInvoicePayer ret_var = InvoicePayer_new(payer_conv, router_conv, &scorer_conv, logger_conv, event_handler_conv, retry_conv);
45681         uint32_t ret_ref = 0;
45682         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45683         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45684         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45685         ret_ref = (uintptr_t)ret_var.inner;
45686         if (ret_var.is_owned) {
45687                 ret_ref |= 1;
45688         }
45689         return ret_ref;
45690 }
45691
45692 uint32_t  __attribute__((export_name("TS_InvoicePayer_pay_invoice"))) TS_InvoicePayer_pay_invoice(uint32_t this_arg, uint32_t invoice) {
45693         LDKInvoicePayer this_arg_conv;
45694         this_arg_conv.inner = (void*)(this_arg & (~1));
45695         this_arg_conv.is_owned = false;
45696         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45697         LDKInvoice invoice_conv;
45698         invoice_conv.inner = (void*)(invoice & (~1));
45699         invoice_conv.is_owned = false;
45700         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
45701         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
45702         *ret_conv = InvoicePayer_pay_invoice(&this_arg_conv, &invoice_conv);
45703         return (uint32_t)ret_conv;
45704 }
45705
45706 uint32_t  __attribute__((export_name("TS_InvoicePayer_pay_zero_value_invoice"))) TS_InvoicePayer_pay_zero_value_invoice(uint32_t this_arg, uint32_t invoice, int64_t amount_msats) {
45707         LDKInvoicePayer this_arg_conv;
45708         this_arg_conv.inner = (void*)(this_arg & (~1));
45709         this_arg_conv.is_owned = false;
45710         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45711         LDKInvoice invoice_conv;
45712         invoice_conv.inner = (void*)(invoice & (~1));
45713         invoice_conv.is_owned = false;
45714         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
45715         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
45716         *ret_conv = InvoicePayer_pay_zero_value_invoice(&this_arg_conv, &invoice_conv, amount_msats);
45717         return (uint32_t)ret_conv;
45718 }
45719
45720 uint32_t  __attribute__((export_name("TS_InvoicePayer_pay_pubkey"))) TS_InvoicePayer_pay_pubkey(uint32_t this_arg, int8_tArray pubkey, int8_tArray payment_preimage, int64_t amount_msats, int32_t final_cltv_expiry_delta) {
45721         LDKInvoicePayer this_arg_conv;
45722         this_arg_conv.inner = (void*)(this_arg & (~1));
45723         this_arg_conv.is_owned = false;
45724         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45725         LDKPublicKey pubkey_ref;
45726         CHECK(pubkey->arr_len == 33);
45727         memcpy(pubkey_ref.compressed_form, pubkey->elems, 33); FREE(pubkey);
45728         LDKThirtyTwoBytes payment_preimage_ref;
45729         CHECK(payment_preimage->arr_len == 32);
45730         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
45731         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
45732         *ret_conv = InvoicePayer_pay_pubkey(&this_arg_conv, pubkey_ref, payment_preimage_ref, amount_msats, final_cltv_expiry_delta);
45733         return (uint32_t)ret_conv;
45734 }
45735
45736 void  __attribute__((export_name("TS_InvoicePayer_remove_cached_payment"))) TS_InvoicePayer_remove_cached_payment(uint32_t this_arg, int8_tArray payment_hash) {
45737         LDKInvoicePayer this_arg_conv;
45738         this_arg_conv.inner = (void*)(this_arg & (~1));
45739         this_arg_conv.is_owned = false;
45740         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45741         unsigned char payment_hash_arr[32];
45742         CHECK(payment_hash->arr_len == 32);
45743         memcpy(payment_hash_arr, payment_hash->elems, 32); FREE(payment_hash);
45744         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
45745         InvoicePayer_remove_cached_payment(&this_arg_conv, payment_hash_ref);
45746 }
45747
45748 uint32_t  __attribute__((export_name("TS_InvoicePayer_as_EventHandler"))) TS_InvoicePayer_as_EventHandler(uint32_t this_arg) {
45749         LDKInvoicePayer this_arg_conv;
45750         this_arg_conv.inner = (void*)(this_arg & (~1));
45751         this_arg_conv.is_owned = false;
45752         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45753         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
45754         *ret_ret = InvoicePayer_as_EventHandler(&this_arg_conv);
45755         return (uint32_t)ret_ret;
45756 }
45757
45758 uint32_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(uint32_t channelmanager, uint32_t keys_manager, uint32_t network, uint32_t amt_msat, uint32_t description_hash, int64_t duration_since_epoch, int32_t invoice_expiry_delta_secs) {
45759         LDKChannelManager channelmanager_conv;
45760         channelmanager_conv.inner = (void*)(channelmanager & (~1));
45761         channelmanager_conv.is_owned = false;
45762         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
45763         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
45764         CHECK_ACCESS(keys_manager_ptr);
45765         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
45766         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
45767                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
45768                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
45769         }
45770         LDKCurrency network_conv = LDKCurrency_from_js(network);
45771         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
45772         CHECK_ACCESS(amt_msat_ptr);
45773         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
45774         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
45775         LDKSha256 description_hash_conv;
45776         description_hash_conv.inner = (void*)(description_hash & (~1));
45777         description_hash_conv.is_owned = (description_hash & 1) || (description_hash == 0);
45778         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
45779         description_hash_conv = Sha256_clone(&description_hash_conv);
45780         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
45781         *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);
45782         return (uint32_t)ret_conv;
45783 }
45784
45785 uint32_t  __attribute__((export_name("TS_create_invoice_from_channelmanager_and_duration_since_epoch"))) TS_create_invoice_from_channelmanager_and_duration_since_epoch(uint32_t channelmanager, uint32_t keys_manager, uint32_t network, uint32_t amt_msat, jstring description, int64_t duration_since_epoch, int32_t invoice_expiry_delta_secs) {
45786         LDKChannelManager channelmanager_conv;
45787         channelmanager_conv.inner = (void*)(channelmanager & (~1));
45788         channelmanager_conv.is_owned = false;
45789         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
45790         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
45791         CHECK_ACCESS(keys_manager_ptr);
45792         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
45793         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
45794                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
45795                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
45796         }
45797         LDKCurrency network_conv = LDKCurrency_from_js(network);
45798         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
45799         CHECK_ACCESS(amt_msat_ptr);
45800         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
45801         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
45802         LDKStr description_conv = str_ref_to_owned_c(description);
45803         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
45804         *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);
45805         return (uint32_t)ret_conv;
45806 }
45807
45808 void  __attribute__((export_name("TS_DefaultRouter_free"))) TS_DefaultRouter_free(uint32_t this_obj) {
45809         LDKDefaultRouter this_obj_conv;
45810         this_obj_conv.inner = (void*)(this_obj & (~1));
45811         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
45812         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45813         DefaultRouter_free(this_obj_conv);
45814 }
45815
45816 uint32_t  __attribute__((export_name("TS_DefaultRouter_new"))) TS_DefaultRouter_new(uint32_t network_graph, uint32_t logger, int8_tArray random_seed_bytes) {
45817         LDKNetworkGraph network_graph_conv;
45818         network_graph_conv.inner = (void*)(network_graph & (~1));
45819         network_graph_conv.is_owned = false;
45820         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
45821         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
45822         CHECK_ACCESS(logger_ptr);
45823         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
45824         if (logger_conv.free == LDKLogger_JCalls_free) {
45825                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
45826                 LDKLogger_JCalls_cloned(&logger_conv);
45827         }
45828         LDKThirtyTwoBytes random_seed_bytes_ref;
45829         CHECK(random_seed_bytes->arr_len == 32);
45830         memcpy(random_seed_bytes_ref.data, random_seed_bytes->elems, 32); FREE(random_seed_bytes);
45831         LDKDefaultRouter ret_var = DefaultRouter_new(&network_graph_conv, logger_conv, random_seed_bytes_ref);
45832         uint32_t ret_ref = 0;
45833         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45834         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45835         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45836         ret_ref = (uintptr_t)ret_var.inner;
45837         if (ret_var.is_owned) {
45838                 ret_ref |= 1;
45839         }
45840         return ret_ref;
45841 }
45842
45843 uint32_t  __attribute__((export_name("TS_DefaultRouter_as_Router"))) TS_DefaultRouter_as_Router(uint32_t this_arg) {
45844         LDKDefaultRouter this_arg_conv;
45845         this_arg_conv.inner = (void*)(this_arg & (~1));
45846         this_arg_conv.is_owned = false;
45847         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45848         LDKRouter* ret_ret = MALLOC(sizeof(LDKRouter), "LDKRouter");
45849         *ret_ret = DefaultRouter_as_Router(&this_arg_conv);
45850         return (uint32_t)ret_ret;
45851 }
45852
45853 uint32_t  __attribute__((export_name("TS_ChannelManager_as_Payer"))) TS_ChannelManager_as_Payer(uint32_t this_arg) {
45854         LDKChannelManager this_arg_conv;
45855         this_arg_conv.inner = (void*)(this_arg & (~1));
45856         this_arg_conv.is_owned = false;
45857         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45858         LDKPayer* ret_ret = MALLOC(sizeof(LDKPayer), "LDKPayer");
45859         *ret_ret = ChannelManager_as_Payer(&this_arg_conv);
45860         return (uint32_t)ret_ret;
45861 }
45862
45863 uint32_t  __attribute__((export_name("TS_SiPrefix_from_str"))) TS_SiPrefix_from_str(jstring s) {
45864         LDKStr s_conv = str_ref_to_owned_c(s);
45865         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
45866         *ret_conv = SiPrefix_from_str(s_conv);
45867         return (uint32_t)ret_conv;
45868 }
45869
45870 uint32_t  __attribute__((export_name("TS_Invoice_from_str"))) TS_Invoice_from_str(jstring s) {
45871         LDKStr s_conv = str_ref_to_owned_c(s);
45872         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
45873         *ret_conv = Invoice_from_str(s_conv);
45874         return (uint32_t)ret_conv;
45875 }
45876
45877 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_from_str"))) TS_SignedRawInvoice_from_str(jstring s) {
45878         LDKStr s_conv = str_ref_to_owned_c(s);
45879         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
45880         *ret_conv = SignedRawInvoice_from_str(s_conv);
45881         return (uint32_t)ret_conv;
45882 }
45883
45884 jstring  __attribute__((export_name("TS_ParseError_to_str"))) TS_ParseError_to_str(uint32_t o) {
45885         LDKParseError* o_conv = (LDKParseError*)o;
45886         LDKStr ret_str = ParseError_to_str(o_conv);
45887         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
45888         Str_free(ret_str);
45889         return ret_conv;
45890 }
45891
45892 jstring  __attribute__((export_name("TS_ParseOrSemanticError_to_str"))) TS_ParseOrSemanticError_to_str(uint32_t o) {
45893         LDKParseOrSemanticError* o_conv = (LDKParseOrSemanticError*)o;
45894         LDKStr ret_str = ParseOrSemanticError_to_str(o_conv);
45895         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
45896         Str_free(ret_str);
45897         return ret_conv;
45898 }
45899
45900 jstring  __attribute__((export_name("TS_Invoice_to_str"))) TS_Invoice_to_str(uint32_t o) {
45901         LDKInvoice o_conv;
45902         o_conv.inner = (void*)(o & (~1));
45903         o_conv.is_owned = false;
45904         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
45905         LDKStr ret_str = Invoice_to_str(&o_conv);
45906         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
45907         Str_free(ret_str);
45908         return ret_conv;
45909 }
45910
45911 jstring  __attribute__((export_name("TS_SignedRawInvoice_to_str"))) TS_SignedRawInvoice_to_str(uint32_t o) {
45912         LDKSignedRawInvoice o_conv;
45913         o_conv.inner = (void*)(o & (~1));
45914         o_conv.is_owned = false;
45915         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
45916         LDKStr ret_str = SignedRawInvoice_to_str(&o_conv);
45917         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
45918         Str_free(ret_str);
45919         return ret_conv;
45920 }
45921
45922 jstring  __attribute__((export_name("TS_Currency_to_str"))) TS_Currency_to_str(uint32_t o) {
45923         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
45924         LDKStr ret_str = Currency_to_str(o_conv);
45925         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
45926         Str_free(ret_str);
45927         return ret_conv;
45928 }
45929
45930 jstring  __attribute__((export_name("TS_SiPrefix_to_str"))) TS_SiPrefix_to_str(uint32_t o) {
45931         LDKSiPrefix* o_conv = (LDKSiPrefix*)(o & ~1);
45932         LDKStr ret_str = SiPrefix_to_str(o_conv);
45933         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
45934         Str_free(ret_str);
45935         return ret_conv;
45936 }
45937