[TS] Update auto-generated bindings with changes + upstream changes
[ldk-java] / ts / bindings.c
1 #define LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ LDKCVec_TransactionOutputsZ
2 #define CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free CVec_TransactionOutputsZ_free
3 #include "js-wasm.h"
4 #include <stdatomic.h>
5 #include <lightning.h>
6
7 // These should be provided...somehow...
8 void *memset(void *s, int c, size_t n);
9 void *memcpy(void *dest, const void *src, size_t n);
10 int memcmp(const void *s1, const void *s2, size_t n);
11
12 extern void __attribute__((noreturn)) abort(void);
13 static inline void assert(bool expression) {
14         if (!expression) { abort(); }
15 }
16
17 uint32_t __attribute__((export_name("test_bigint_pass_deadbeef0badf00d"))) test_bigint_pass_deadbeef0badf00d(uint64_t val) {
18         return val == 0xdeadbeef0badf00dULL;
19 }
20
21
22 void *malloc(size_t size);
23 void free(void *ptr);
24
25 #define MALLOC(a, _) malloc(a)
26 #define do_MALLOC(a, _b, _c) malloc(a)
27 #define FREE(p) if ((unsigned long)(p) > 4096) { free(p); }
28 #define DO_ASSERT(a) (void)(a)
29 #define CHECK(a)
30 #define CHECK_ACCESS(p)
31 #define CHECK_INNER_FIELD_ACCESS_OR_NULL(v)
32
33 // We assume that CVec_u8Z and u8slice are the same size and layout (and thus pointers to the two can be mixed)
34 _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKu8slice), "Vec<u8> and [u8] need to have been mapped identically");
35 _Static_assert(offsetof(LDKCVec_u8Z, data) == offsetof(LDKu8slice, data), "Vec<u8> and [u8] need to have been mapped identically");
36 _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKu8slice, datalen), "Vec<u8> and [u8] need to have been mapped identically");
37
38 _Static_assert(sizeof(void*) == 4, "Pointers mut be 32 bits");
39
40 #define DECL_ARR_TYPE(ty, name) \
41         struct name##array { \
42                 uint64_t arr_len; /* uint32_t would suffice but we want to align uint64_ts as well */ \
43                 ty elems[]; \
44         }; \
45         typedef struct name##array * name##Array; \
46         static inline name##Array init_##name##Array(size_t arr_len, int lineno) { \
47                 name##Array arr = (name##Array)do_MALLOC(arr_len * sizeof(ty) + sizeof(uint64_t), #name" array init", lineno); \
48                 arr->arr_len = arr_len; \
49                 return arr; \
50         }
51
52 DECL_ARR_TYPE(int64_t, int64_t);
53 DECL_ARR_TYPE(int8_t, int8_t);
54 DECL_ARR_TYPE(uint32_t, uint32_t);
55 DECL_ARR_TYPE(void*, ptr);
56 DECL_ARR_TYPE(char, char);
57 typedef charArray jstring;
58
59 static inline jstring str_ref_to_ts(const char* chars, size_t len) {
60         charArray arr = init_charArray(len, __LINE__);
61         memcpy(arr->elems, chars, len);
62         return arr;
63 }
64 static inline LDKStr str_ref_to_owned_c(const jstring str) {
65         char* newchars = MALLOC(str->arr_len + 1, "String chars");
66         memcpy(newchars, str->elems, str->arr_len);
67         newchars[str->arr_len] = 0;
68         LDKStr res = {
69                 .chars = newchars,
70                 .len = str->arr_len,
71                 .chars_is_owned = true
72         };
73         return res;
74 }
75
76 typedef bool jboolean;
77
78 uint32_t __attribute__((export_name("TS_malloc"))) TS_malloc(uint32_t size) {
79         return (uint32_t)MALLOC(size, "JS-Called malloc");
80 }
81 void __attribute__((export_name("TS_free"))) TS_free(uint32_t ptr) {
82         FREE((void*)ptr);
83 }
84
85 jstring __attribute__((export_name("TS_get_ldk_c_bindings_version"))) TS_get_ldk_c_bindings_version() {
86         const char *res = check_get_ldk_bindings_version();
87         if (res == NULL) return NULL;
88         return str_ref_to_ts(res, strlen(res));
89 }
90 jstring __attribute__((export_name("TS_get_ldk_version"))) get_ldk_version() {
91         const char *res = check_get_ldk_version();
92         if (res == NULL) return NULL;
93         return str_ref_to_ts(res, strlen(res));
94 }
95 #include "version.c"
96 static inline struct LDKThirtyTwoBytes ThirtyTwoBytes_clone(const struct LDKThirtyTwoBytes *orig) { struct LDKThirtyTwoBytes ret; memcpy(ret.data, orig->data, 32); return ret; }
97 static inline LDKAccessError LDKAccessError_from_js(int32_t ord) {
98         switch (ord) {
99                 case 0: return LDKAccessError_UnknownChain;
100                 case 1: return LDKAccessError_UnknownTx;
101         }
102         abort();
103 }
104 static inline int32_t LDKAccessError_to_js(LDKAccessError val) {
105         switch (val) {
106                 case LDKAccessError_UnknownChain: return 0;
107                 case LDKAccessError_UnknownTx: return 1;
108                 default: abort();
109         }
110 }
111 static inline LDKCOption_NoneZ LDKCOption_NoneZ_from_js(int32_t ord) {
112         switch (ord) {
113                 case 0: return LDKCOption_NoneZ_Some;
114                 case 1: return LDKCOption_NoneZ_None;
115         }
116         abort();
117 }
118 static inline int32_t LDKCOption_NoneZ_to_js(LDKCOption_NoneZ val) {
119         switch (val) {
120                 case LDKCOption_NoneZ_Some: return 0;
121                 case LDKCOption_NoneZ_None: return 1;
122                 default: abort();
123         }
124 }
125 static inline LDKChannelMonitorUpdateErr LDKChannelMonitorUpdateErr_from_js(int32_t ord) {
126         switch (ord) {
127                 case 0: return LDKChannelMonitorUpdateErr_TemporaryFailure;
128                 case 1: return LDKChannelMonitorUpdateErr_PermanentFailure;
129         }
130         abort();
131 }
132 static inline int32_t LDKChannelMonitorUpdateErr_to_js(LDKChannelMonitorUpdateErr val) {
133         switch (val) {
134                 case LDKChannelMonitorUpdateErr_TemporaryFailure: return 0;
135                 case LDKChannelMonitorUpdateErr_PermanentFailure: return 1;
136                 default: abort();
137         }
138 }
139 static inline LDKConfirmationTarget LDKConfirmationTarget_from_js(int32_t ord) {
140         switch (ord) {
141                 case 0: return LDKConfirmationTarget_Background;
142                 case 1: return LDKConfirmationTarget_Normal;
143                 case 2: return LDKConfirmationTarget_HighPriority;
144         }
145         abort();
146 }
147 static inline int32_t LDKConfirmationTarget_to_js(LDKConfirmationTarget val) {
148         switch (val) {
149                 case LDKConfirmationTarget_Background: return 0;
150                 case LDKConfirmationTarget_Normal: return 1;
151                 case LDKConfirmationTarget_HighPriority: return 2;
152                 default: abort();
153         }
154 }
155 static inline LDKCreationError LDKCreationError_from_js(int32_t ord) {
156         switch (ord) {
157                 case 0: return LDKCreationError_DescriptionTooLong;
158                 case 1: return LDKCreationError_RouteTooLong;
159                 case 2: return LDKCreationError_TimestampOutOfBounds;
160                 case 3: return LDKCreationError_InvalidAmount;
161                 case 4: return LDKCreationError_MissingRouteHints;
162         }
163         abort();
164 }
165 static inline int32_t LDKCreationError_to_js(LDKCreationError val) {
166         switch (val) {
167                 case LDKCreationError_DescriptionTooLong: return 0;
168                 case LDKCreationError_RouteTooLong: return 1;
169                 case LDKCreationError_TimestampOutOfBounds: return 2;
170                 case LDKCreationError_InvalidAmount: return 3;
171                 case LDKCreationError_MissingRouteHints: return 4;
172                 default: abort();
173         }
174 }
175 static inline LDKCurrency LDKCurrency_from_js(int32_t ord) {
176         switch (ord) {
177                 case 0: return LDKCurrency_Bitcoin;
178                 case 1: return LDKCurrency_BitcoinTestnet;
179                 case 2: return LDKCurrency_Regtest;
180                 case 3: return LDKCurrency_Simnet;
181                 case 4: return LDKCurrency_Signet;
182         }
183         abort();
184 }
185 static inline int32_t LDKCurrency_to_js(LDKCurrency val) {
186         switch (val) {
187                 case LDKCurrency_Bitcoin: return 0;
188                 case LDKCurrency_BitcoinTestnet: return 1;
189                 case LDKCurrency_Regtest: return 2;
190                 case LDKCurrency_Simnet: return 3;
191                 case LDKCurrency_Signet: return 4;
192                 default: abort();
193         }
194 }
195 static inline LDKIOError LDKIOError_from_js(int32_t ord) {
196         switch (ord) {
197                 case 0: return LDKIOError_NotFound;
198                 case 1: return LDKIOError_PermissionDenied;
199                 case 2: return LDKIOError_ConnectionRefused;
200                 case 3: return LDKIOError_ConnectionReset;
201                 case 4: return LDKIOError_ConnectionAborted;
202                 case 5: return LDKIOError_NotConnected;
203                 case 6: return LDKIOError_AddrInUse;
204                 case 7: return LDKIOError_AddrNotAvailable;
205                 case 8: return LDKIOError_BrokenPipe;
206                 case 9: return LDKIOError_AlreadyExists;
207                 case 10: return LDKIOError_WouldBlock;
208                 case 11: return LDKIOError_InvalidInput;
209                 case 12: return LDKIOError_InvalidData;
210                 case 13: return LDKIOError_TimedOut;
211                 case 14: return LDKIOError_WriteZero;
212                 case 15: return LDKIOError_Interrupted;
213                 case 16: return LDKIOError_Other;
214                 case 17: return LDKIOError_UnexpectedEof;
215         }
216         abort();
217 }
218 static inline int32_t LDKIOError_to_js(LDKIOError val) {
219         switch (val) {
220                 case LDKIOError_NotFound: return 0;
221                 case LDKIOError_PermissionDenied: return 1;
222                 case LDKIOError_ConnectionRefused: return 2;
223                 case LDKIOError_ConnectionReset: return 3;
224                 case LDKIOError_ConnectionAborted: return 4;
225                 case LDKIOError_NotConnected: return 5;
226                 case LDKIOError_AddrInUse: return 6;
227                 case LDKIOError_AddrNotAvailable: return 7;
228                 case LDKIOError_BrokenPipe: return 8;
229                 case LDKIOError_AlreadyExists: return 9;
230                 case LDKIOError_WouldBlock: return 10;
231                 case LDKIOError_InvalidInput: return 11;
232                 case LDKIOError_InvalidData: return 12;
233                 case LDKIOError_TimedOut: return 13;
234                 case LDKIOError_WriteZero: return 14;
235                 case LDKIOError_Interrupted: return 15;
236                 case LDKIOError_Other: return 16;
237                 case LDKIOError_UnexpectedEof: return 17;
238                 default: abort();
239         }
240 }
241 static inline LDKLevel LDKLevel_from_js(int32_t ord) {
242         switch (ord) {
243                 case 0: return LDKLevel_Gossip;
244                 case 1: return LDKLevel_Trace;
245                 case 2: return LDKLevel_Debug;
246                 case 3: return LDKLevel_Info;
247                 case 4: return LDKLevel_Warn;
248                 case 5: return LDKLevel_Error;
249         }
250         abort();
251 }
252 static inline int32_t LDKLevel_to_js(LDKLevel val) {
253         switch (val) {
254                 case LDKLevel_Gossip: return 0;
255                 case LDKLevel_Trace: return 1;
256                 case LDKLevel_Debug: return 2;
257                 case LDKLevel_Info: return 3;
258                 case LDKLevel_Warn: return 4;
259                 case LDKLevel_Error: return 5;
260                 default: abort();
261         }
262 }
263 static inline LDKNetwork LDKNetwork_from_js(int32_t ord) {
264         switch (ord) {
265                 case 0: return LDKNetwork_Bitcoin;
266                 case 1: return LDKNetwork_Testnet;
267                 case 2: return LDKNetwork_Regtest;
268                 case 3: return LDKNetwork_Signet;
269         }
270         abort();
271 }
272 static inline int32_t LDKNetwork_to_js(LDKNetwork val) {
273         switch (val) {
274                 case LDKNetwork_Bitcoin: return 0;
275                 case LDKNetwork_Testnet: return 1;
276                 case LDKNetwork_Regtest: return 2;
277                 case LDKNetwork_Signet: return 3;
278                 default: abort();
279         }
280 }
281 static inline LDKRecipient LDKRecipient_from_js(int32_t ord) {
282         switch (ord) {
283                 case 0: return LDKRecipient_Node;
284                 case 1: return LDKRecipient_PhantomNode;
285         }
286         abort();
287 }
288 static inline int32_t LDKRecipient_to_js(LDKRecipient val) {
289         switch (val) {
290                 case LDKRecipient_Node: return 0;
291                 case LDKRecipient_PhantomNode: return 1;
292                 default: abort();
293         }
294 }
295 static inline LDKSecp256k1Error LDKSecp256k1Error_from_js(int32_t ord) {
296         switch (ord) {
297                 case 0: return LDKSecp256k1Error_IncorrectSignature;
298                 case 1: return LDKSecp256k1Error_InvalidMessage;
299                 case 2: return LDKSecp256k1Error_InvalidPublicKey;
300                 case 3: return LDKSecp256k1Error_InvalidSignature;
301                 case 4: return LDKSecp256k1Error_InvalidSecretKey;
302                 case 5: return LDKSecp256k1Error_InvalidSharedSecret;
303                 case 6: return LDKSecp256k1Error_InvalidRecoveryId;
304                 case 7: return LDKSecp256k1Error_InvalidTweak;
305                 case 8: return LDKSecp256k1Error_NotEnoughMemory;
306                 case 9: return LDKSecp256k1Error_InvalidPublicKeySum;
307                 case 10: return LDKSecp256k1Error_InvalidParityValue;
308         }
309         abort();
310 }
311 static inline int32_t LDKSecp256k1Error_to_js(LDKSecp256k1Error val) {
312         switch (val) {
313                 case LDKSecp256k1Error_IncorrectSignature: return 0;
314                 case LDKSecp256k1Error_InvalidMessage: return 1;
315                 case LDKSecp256k1Error_InvalidPublicKey: return 2;
316                 case LDKSecp256k1Error_InvalidSignature: return 3;
317                 case LDKSecp256k1Error_InvalidSecretKey: return 4;
318                 case LDKSecp256k1Error_InvalidSharedSecret: return 5;
319                 case LDKSecp256k1Error_InvalidRecoveryId: return 6;
320                 case LDKSecp256k1Error_InvalidTweak: return 7;
321                 case LDKSecp256k1Error_NotEnoughMemory: return 8;
322                 case LDKSecp256k1Error_InvalidPublicKeySum: return 9;
323                 case LDKSecp256k1Error_InvalidParityValue: return 10;
324                 default: abort();
325         }
326 }
327 static inline LDKSemanticError LDKSemanticError_from_js(int32_t ord) {
328         switch (ord) {
329                 case 0: return LDKSemanticError_NoPaymentHash;
330                 case 1: return LDKSemanticError_MultiplePaymentHashes;
331                 case 2: return LDKSemanticError_NoDescription;
332                 case 3: return LDKSemanticError_MultipleDescriptions;
333                 case 4: return LDKSemanticError_NoPaymentSecret;
334                 case 5: return LDKSemanticError_MultiplePaymentSecrets;
335                 case 6: return LDKSemanticError_InvalidFeatures;
336                 case 7: return LDKSemanticError_InvalidRecoveryId;
337                 case 8: return LDKSemanticError_InvalidSignature;
338                 case 9: return LDKSemanticError_ImpreciseAmount;
339         }
340         abort();
341 }
342 static inline int32_t LDKSemanticError_to_js(LDKSemanticError val) {
343         switch (val) {
344                 case LDKSemanticError_NoPaymentHash: return 0;
345                 case LDKSemanticError_MultiplePaymentHashes: return 1;
346                 case LDKSemanticError_NoDescription: return 2;
347                 case LDKSemanticError_MultipleDescriptions: return 3;
348                 case LDKSemanticError_NoPaymentSecret: return 4;
349                 case LDKSemanticError_MultiplePaymentSecrets: return 5;
350                 case LDKSemanticError_InvalidFeatures: return 6;
351                 case LDKSemanticError_InvalidRecoveryId: return 7;
352                 case LDKSemanticError_InvalidSignature: return 8;
353                 case LDKSemanticError_ImpreciseAmount: return 9;
354                 default: abort();
355         }
356 }
357 static inline LDKSiPrefix LDKSiPrefix_from_js(int32_t ord) {
358         switch (ord) {
359                 case 0: return LDKSiPrefix_Milli;
360                 case 1: return LDKSiPrefix_Micro;
361                 case 2: return LDKSiPrefix_Nano;
362                 case 3: return LDKSiPrefix_Pico;
363         }
364         abort();
365 }
366 static inline int32_t LDKSiPrefix_to_js(LDKSiPrefix val) {
367         switch (val) {
368                 case LDKSiPrefix_Milli: return 0;
369                 case LDKSiPrefix_Micro: return 1;
370                 case LDKSiPrefix_Nano: return 2;
371                 case LDKSiPrefix_Pico: return 3;
372                 default: abort();
373         }
374 }
375 uint32_t __attribute__((export_name("TS_LDKBech32Error_ty_from_ptr"))) TS_LDKBech32Error_ty_from_ptr(uint32_t ptr) {
376         LDKBech32Error *obj = (LDKBech32Error*)(ptr & ~1);
377         switch(obj->tag) {
378                 case LDKBech32Error_MissingSeparator: return 0;
379                 case LDKBech32Error_InvalidChecksum: return 1;
380                 case LDKBech32Error_InvalidLength: return 2;
381                 case LDKBech32Error_InvalidChar: return 3;
382                 case LDKBech32Error_InvalidData: return 4;
383                 case LDKBech32Error_InvalidPadding: return 5;
384                 case LDKBech32Error_MixedCase: return 6;
385                 default: abort();
386         }
387 }
388 int32_t __attribute__((export_name("TS_LDKBech32Error_InvalidChar_get_invalid_char"))) TS_LDKBech32Error_InvalidChar_get_invalid_char(uint32_t ptr) {
389         LDKBech32Error *obj = (LDKBech32Error*)(ptr & ~1);
390         assert(obj->tag == LDKBech32Error_InvalidChar);
391                         int32_t invalid_char_conv = obj->invalid_char;
392         return invalid_char_conv;
393 }
394 int8_t __attribute__((export_name("TS_LDKBech32Error_InvalidData_get_invalid_data"))) TS_LDKBech32Error_InvalidData_get_invalid_data(uint32_t ptr) {
395         LDKBech32Error *obj = (LDKBech32Error*)(ptr & ~1);
396         assert(obj->tag == LDKBech32Error_InvalidData);
397                         int8_t invalid_data_conv = obj->invalid_data;
398         return invalid_data_conv;
399 }
400 static inline LDKCVec_u8Z CVec_u8Z_clone(const LDKCVec_u8Z *orig) {
401         LDKCVec_u8Z ret = { .data = MALLOC(sizeof(int8_t) * orig->datalen, "LDKCVec_u8Z clone bytes"), .datalen = orig->datalen };
402         memcpy(ret.data, orig->data, sizeof(int8_t) * ret.datalen);
403         return ret;
404 }
405 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) {
406         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
407         LDKCVec_u8Z ret_var = TxOut_get_script_pubkey(thing_conv);
408         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
409         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
410         CVec_u8Z_free(ret_var);
411         return ret_arr;
412 }
413
414 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) {
415         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
416         int64_t ret_conv = TxOut_get_value(thing_conv);
417         return ret_conv;
418 }
419
420 static inline void CResult_NoneNoneZ_get_ok(LDKCResult_NoneNoneZ *NONNULL_PTR owner){
421 CHECK(owner->result_ok);
422         return *owner->contents.result;
423 }
424 void  __attribute__((export_name("TS_CResult_NoneNoneZ_get_ok"))) TS_CResult_NoneNoneZ_get_ok(uint32_t owner) {
425         LDKCResult_NoneNoneZ* owner_conv = (LDKCResult_NoneNoneZ*)(owner & ~1);
426         CResult_NoneNoneZ_get_ok(owner_conv);
427 }
428
429 static inline void CResult_NoneNoneZ_get_err(LDKCResult_NoneNoneZ *NONNULL_PTR owner){
430 CHECK(!owner->result_ok);
431         return *owner->contents.err;
432 }
433 void  __attribute__((export_name("TS_CResult_NoneNoneZ_get_err"))) TS_CResult_NoneNoneZ_get_err(uint32_t owner) {
434         LDKCResult_NoneNoneZ* owner_conv = (LDKCResult_NoneNoneZ*)(owner & ~1);
435         CResult_NoneNoneZ_get_err(owner_conv);
436 }
437
438 static inline struct LDKCounterpartyCommitmentSecrets CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR owner){
439 CHECK(owner->result_ok);
440         return CounterpartyCommitmentSecrets_clone(&*owner->contents.result);
441 }
442 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(uint32_t owner) {
443         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(owner & ~1);
444         LDKCounterpartyCommitmentSecrets ret_var = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(owner_conv);
445         uint32_t ret_ref = 0;
446         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
447         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
448         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
449         ret_ref = (uintptr_t)ret_var.inner;
450         if (ret_var.is_owned) {
451                 ret_ref |= 1;
452         }
453         return ret_ref;
454 }
455
456 static inline struct LDKDecodeError CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR owner){
457 CHECK(!owner->result_ok);
458         return DecodeError_clone(&*owner->contents.err);
459 }
460 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(uint32_t owner) {
461         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(owner & ~1);
462         LDKDecodeError ret_var = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(owner_conv);
463         uint32_t ret_ref = 0;
464         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
465         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
466         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
467         ret_ref = (uintptr_t)ret_var.inner;
468         if (ret_var.is_owned) {
469                 ret_ref |= 1;
470         }
471         return ret_ref;
472 }
473
474 static inline struct LDKSecretKey CResult_SecretKeyErrorZ_get_ok(LDKCResult_SecretKeyErrorZ *NONNULL_PTR owner){
475 CHECK(owner->result_ok);
476         return *owner->contents.result;
477 }
478 int8_tArray  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_get_ok"))) TS_CResult_SecretKeyErrorZ_get_ok(uint32_t owner) {
479         LDKCResult_SecretKeyErrorZ* owner_conv = (LDKCResult_SecretKeyErrorZ*)(owner & ~1);
480         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
481         memcpy(ret_arr->elems, CResult_SecretKeyErrorZ_get_ok(owner_conv).bytes, 32);
482         return ret_arr;
483 }
484
485 static inline enum LDKSecp256k1Error CResult_SecretKeyErrorZ_get_err(LDKCResult_SecretKeyErrorZ *NONNULL_PTR owner){
486 CHECK(!owner->result_ok);
487         return *owner->contents.err;
488 }
489 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_get_err"))) TS_CResult_SecretKeyErrorZ_get_err(uint32_t owner) {
490         LDKCResult_SecretKeyErrorZ* owner_conv = (LDKCResult_SecretKeyErrorZ*)(owner & ~1);
491         uint32_t ret_conv = LDKSecp256k1Error_to_js(CResult_SecretKeyErrorZ_get_err(owner_conv));
492         return ret_conv;
493 }
494
495 static inline struct LDKPublicKey CResult_PublicKeyErrorZ_get_ok(LDKCResult_PublicKeyErrorZ *NONNULL_PTR owner){
496 CHECK(owner->result_ok);
497         return *owner->contents.result;
498 }
499 int8_tArray  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_get_ok"))) TS_CResult_PublicKeyErrorZ_get_ok(uint32_t owner) {
500         LDKCResult_PublicKeyErrorZ* owner_conv = (LDKCResult_PublicKeyErrorZ*)(owner & ~1);
501         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
502         memcpy(ret_arr->elems, CResult_PublicKeyErrorZ_get_ok(owner_conv).compressed_form, 33);
503         return ret_arr;
504 }
505
506 static inline enum LDKSecp256k1Error CResult_PublicKeyErrorZ_get_err(LDKCResult_PublicKeyErrorZ *NONNULL_PTR owner){
507 CHECK(!owner->result_ok);
508         return *owner->contents.err;
509 }
510 uint32_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_get_err"))) TS_CResult_PublicKeyErrorZ_get_err(uint32_t owner) {
511         LDKCResult_PublicKeyErrorZ* owner_conv = (LDKCResult_PublicKeyErrorZ*)(owner & ~1);
512         uint32_t ret_conv = LDKSecp256k1Error_to_js(CResult_PublicKeyErrorZ_get_err(owner_conv));
513         return ret_conv;
514 }
515
516 static inline struct LDKTxCreationKeys CResult_TxCreationKeysDecodeErrorZ_get_ok(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR owner){
517 CHECK(owner->result_ok);
518         return TxCreationKeys_clone(&*owner->contents.result);
519 }
520 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_get_ok"))) TS_CResult_TxCreationKeysDecodeErrorZ_get_ok(uint32_t owner) {
521         LDKCResult_TxCreationKeysDecodeErrorZ* owner_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(owner & ~1);
522         LDKTxCreationKeys ret_var = CResult_TxCreationKeysDecodeErrorZ_get_ok(owner_conv);
523         uint32_t ret_ref = 0;
524         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
525         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
526         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
527         ret_ref = (uintptr_t)ret_var.inner;
528         if (ret_var.is_owned) {
529                 ret_ref |= 1;
530         }
531         return ret_ref;
532 }
533
534 static inline struct LDKDecodeError CResult_TxCreationKeysDecodeErrorZ_get_err(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR owner){
535 CHECK(!owner->result_ok);
536         return DecodeError_clone(&*owner->contents.err);
537 }
538 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_get_err"))) TS_CResult_TxCreationKeysDecodeErrorZ_get_err(uint32_t owner) {
539         LDKCResult_TxCreationKeysDecodeErrorZ* owner_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(owner & ~1);
540         LDKDecodeError ret_var = CResult_TxCreationKeysDecodeErrorZ_get_err(owner_conv);
541         uint32_t ret_ref = 0;
542         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
543         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
544         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
545         ret_ref = (uintptr_t)ret_var.inner;
546         if (ret_var.is_owned) {
547                 ret_ref |= 1;
548         }
549         return ret_ref;
550 }
551
552 static inline struct LDKChannelPublicKeys CResult_ChannelPublicKeysDecodeErrorZ_get_ok(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR owner){
553 CHECK(owner->result_ok);
554         return ChannelPublicKeys_clone(&*owner->contents.result);
555 }
556 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_get_ok"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_get_ok(uint32_t owner) {
557         LDKCResult_ChannelPublicKeysDecodeErrorZ* owner_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(owner & ~1);
558         LDKChannelPublicKeys ret_var = CResult_ChannelPublicKeysDecodeErrorZ_get_ok(owner_conv);
559         uint32_t ret_ref = 0;
560         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
561         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
562         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
563         ret_ref = (uintptr_t)ret_var.inner;
564         if (ret_var.is_owned) {
565                 ret_ref |= 1;
566         }
567         return ret_ref;
568 }
569
570 static inline struct LDKDecodeError CResult_ChannelPublicKeysDecodeErrorZ_get_err(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR owner){
571 CHECK(!owner->result_ok);
572         return DecodeError_clone(&*owner->contents.err);
573 }
574 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_get_err"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_get_err(uint32_t owner) {
575         LDKCResult_ChannelPublicKeysDecodeErrorZ* owner_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(owner & ~1);
576         LDKDecodeError ret_var = CResult_ChannelPublicKeysDecodeErrorZ_get_err(owner_conv);
577         uint32_t ret_ref = 0;
578         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
579         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
580         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
581         ret_ref = (uintptr_t)ret_var.inner;
582         if (ret_var.is_owned) {
583                 ret_ref |= 1;
584         }
585         return ret_ref;
586 }
587
588 static inline struct LDKTxCreationKeys CResult_TxCreationKeysErrorZ_get_ok(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR owner){
589 CHECK(owner->result_ok);
590         return TxCreationKeys_clone(&*owner->contents.result);
591 }
592 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_get_ok"))) TS_CResult_TxCreationKeysErrorZ_get_ok(uint32_t owner) {
593         LDKCResult_TxCreationKeysErrorZ* owner_conv = (LDKCResult_TxCreationKeysErrorZ*)(owner & ~1);
594         LDKTxCreationKeys ret_var = CResult_TxCreationKeysErrorZ_get_ok(owner_conv);
595         uint32_t ret_ref = 0;
596         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
597         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
598         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
599         ret_ref = (uintptr_t)ret_var.inner;
600         if (ret_var.is_owned) {
601                 ret_ref |= 1;
602         }
603         return ret_ref;
604 }
605
606 static inline enum LDKSecp256k1Error CResult_TxCreationKeysErrorZ_get_err(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR owner){
607 CHECK(!owner->result_ok);
608         return *owner->contents.err;
609 }
610 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_get_err"))) TS_CResult_TxCreationKeysErrorZ_get_err(uint32_t owner) {
611         LDKCResult_TxCreationKeysErrorZ* owner_conv = (LDKCResult_TxCreationKeysErrorZ*)(owner & ~1);
612         uint32_t ret_conv = LDKSecp256k1Error_to_js(CResult_TxCreationKeysErrorZ_get_err(owner_conv));
613         return ret_conv;
614 }
615
616 uint32_t __attribute__((export_name("TS_LDKCOption_u32Z_ty_from_ptr"))) TS_LDKCOption_u32Z_ty_from_ptr(uint32_t ptr) {
617         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)(ptr & ~1);
618         switch(obj->tag) {
619                 case LDKCOption_u32Z_Some: return 0;
620                 case LDKCOption_u32Z_None: return 1;
621                 default: abort();
622         }
623 }
624 int32_t __attribute__((export_name("TS_LDKCOption_u32Z_Some_get_some"))) TS_LDKCOption_u32Z_Some_get_some(uint32_t ptr) {
625         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)(ptr & ~1);
626         assert(obj->tag == LDKCOption_u32Z_Some);
627                         int32_t some_conv = obj->some;
628         return some_conv;
629 }
630 static inline struct LDKHTLCOutputInCommitment CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR owner){
631 CHECK(owner->result_ok);
632         return HTLCOutputInCommitment_clone(&*owner->contents.result);
633 }
634 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(uint32_t owner) {
635         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* owner_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(owner & ~1);
636         LDKHTLCOutputInCommitment ret_var = CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(owner_conv);
637         uint32_t ret_ref = 0;
638         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
639         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
640         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
641         ret_ref = (uintptr_t)ret_var.inner;
642         if (ret_var.is_owned) {
643                 ret_ref |= 1;
644         }
645         return ret_ref;
646 }
647
648 static inline struct LDKDecodeError CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR owner){
649 CHECK(!owner->result_ok);
650         return DecodeError_clone(&*owner->contents.err);
651 }
652 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(uint32_t owner) {
653         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* owner_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(owner & ~1);
654         LDKDecodeError ret_var = CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(owner_conv);
655         uint32_t ret_ref = 0;
656         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
657         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
658         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
659         ret_ref = (uintptr_t)ret_var.inner;
660         if (ret_var.is_owned) {
661                 ret_ref |= 1;
662         }
663         return ret_ref;
664 }
665
666 static inline struct LDKCounterpartyChannelTransactionParameters CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
667 CHECK(owner->result_ok);
668         return CounterpartyChannelTransactionParameters_clone(&*owner->contents.result);
669 }
670 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(uint32_t owner) {
671         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
672         LDKCounterpartyChannelTransactionParameters ret_var = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(owner_conv);
673         uint32_t ret_ref = 0;
674         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
675         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
676         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
677         ret_ref = (uintptr_t)ret_var.inner;
678         if (ret_var.is_owned) {
679                 ret_ref |= 1;
680         }
681         return ret_ref;
682 }
683
684 static inline struct LDKDecodeError CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
685 CHECK(!owner->result_ok);
686         return DecodeError_clone(&*owner->contents.err);
687 }
688 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(uint32_t owner) {
689         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
690         LDKDecodeError ret_var = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(owner_conv);
691         uint32_t ret_ref = 0;
692         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
693         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
694         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
695         ret_ref = (uintptr_t)ret_var.inner;
696         if (ret_var.is_owned) {
697                 ret_ref |= 1;
698         }
699         return ret_ref;
700 }
701
702 static inline struct LDKChannelTransactionParameters CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
703 CHECK(owner->result_ok);
704         return ChannelTransactionParameters_clone(&*owner->contents.result);
705 }
706 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_get_ok"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(uint32_t owner) {
707         LDKCResult_ChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
708         LDKChannelTransactionParameters ret_var = CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(owner_conv);
709         uint32_t ret_ref = 0;
710         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
711         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
712         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
713         ret_ref = (uintptr_t)ret_var.inner;
714         if (ret_var.is_owned) {
715                 ret_ref |= 1;
716         }
717         return ret_ref;
718 }
719
720 static inline struct LDKDecodeError CResult_ChannelTransactionParametersDecodeErrorZ_get_err(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
721 CHECK(!owner->result_ok);
722         return DecodeError_clone(&*owner->contents.err);
723 }
724 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_get_err"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_get_err(uint32_t owner) {
725         LDKCResult_ChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
726         LDKDecodeError ret_var = CResult_ChannelTransactionParametersDecodeErrorZ_get_err(owner_conv);
727         uint32_t ret_ref = 0;
728         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
729         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
730         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
731         ret_ref = (uintptr_t)ret_var.inner;
732         if (ret_var.is_owned) {
733                 ret_ref |= 1;
734         }
735         return ret_ref;
736 }
737
738 static inline struct LDKHolderCommitmentTransaction CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
739 CHECK(owner->result_ok);
740         return HolderCommitmentTransaction_clone(&*owner->contents.result);
741 }
742 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(uint32_t owner) {
743         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(owner & ~1);
744         LDKHolderCommitmentTransaction ret_var = CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
745         uint32_t ret_ref = 0;
746         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
747         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
748         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
749         ret_ref = (uintptr_t)ret_var.inner;
750         if (ret_var.is_owned) {
751                 ret_ref |= 1;
752         }
753         return ret_ref;
754 }
755
756 static inline struct LDKDecodeError CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
757 CHECK(!owner->result_ok);
758         return DecodeError_clone(&*owner->contents.err);
759 }
760 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_get_err"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(uint32_t owner) {
761         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(owner & ~1);
762         LDKDecodeError ret_var = CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(owner_conv);
763         uint32_t ret_ref = 0;
764         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
765         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
766         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
767         ret_ref = (uintptr_t)ret_var.inner;
768         if (ret_var.is_owned) {
769                 ret_ref |= 1;
770         }
771         return ret_ref;
772 }
773
774 static inline struct LDKBuiltCommitmentTransaction CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
775 CHECK(owner->result_ok);
776         return BuiltCommitmentTransaction_clone(&*owner->contents.result);
777 }
778 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(uint32_t owner) {
779         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(owner & ~1);
780         LDKBuiltCommitmentTransaction ret_var = CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
781         uint32_t ret_ref = 0;
782         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
783         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
784         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
785         ret_ref = (uintptr_t)ret_var.inner;
786         if (ret_var.is_owned) {
787                 ret_ref |= 1;
788         }
789         return ret_ref;
790 }
791
792 static inline struct LDKDecodeError CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
793 CHECK(!owner->result_ok);
794         return DecodeError_clone(&*owner->contents.err);
795 }
796 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(uint32_t owner) {
797         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(owner & ~1);
798         LDKDecodeError ret_var = CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(owner_conv);
799         uint32_t ret_ref = 0;
800         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
801         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
802         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
803         ret_ref = (uintptr_t)ret_var.inner;
804         if (ret_var.is_owned) {
805                 ret_ref |= 1;
806         }
807         return ret_ref;
808 }
809
810 static inline struct LDKTrustedClosingTransaction *CResult_TrustedClosingTransactionNoneZ_get_ok(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner){
811 CHECK(owner->result_ok);
812         return &*owner->contents.result;
813 }
814 uint32_t  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_get_ok"))) TS_CResult_TrustedClosingTransactionNoneZ_get_ok(uint32_t owner) {
815         LDKCResult_TrustedClosingTransactionNoneZ* owner_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(owner & ~1);
816         LDKTrustedClosingTransaction ret_var = *CResult_TrustedClosingTransactionNoneZ_get_ok(owner_conv);
817         uint32_t ret_ref = 0;
818         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
819         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
820         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
821         ret_ref = (uintptr_t)ret_var.inner & ~1;
822         return ret_ref;
823 }
824
825 static inline void CResult_TrustedClosingTransactionNoneZ_get_err(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner){
826 CHECK(!owner->result_ok);
827         return *owner->contents.err;
828 }
829 void  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_get_err"))) TS_CResult_TrustedClosingTransactionNoneZ_get_err(uint32_t owner) {
830         LDKCResult_TrustedClosingTransactionNoneZ* owner_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(owner & ~1);
831         CResult_TrustedClosingTransactionNoneZ_get_err(owner_conv);
832 }
833
834 static inline struct LDKCommitmentTransaction CResult_CommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
835 CHECK(owner->result_ok);
836         return CommitmentTransaction_clone(&*owner->contents.result);
837 }
838 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_get_ok"))) TS_CResult_CommitmentTransactionDecodeErrorZ_get_ok(uint32_t owner) {
839         LDKCResult_CommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(owner & ~1);
840         LDKCommitmentTransaction ret_var = CResult_CommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
841         uint32_t ret_ref = 0;
842         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
843         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
844         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
845         ret_ref = (uintptr_t)ret_var.inner;
846         if (ret_var.is_owned) {
847                 ret_ref |= 1;
848         }
849         return ret_ref;
850 }
851
852 static inline struct LDKDecodeError CResult_CommitmentTransactionDecodeErrorZ_get_err(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
853 CHECK(!owner->result_ok);
854         return DecodeError_clone(&*owner->contents.err);
855 }
856 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_get_err"))) TS_CResult_CommitmentTransactionDecodeErrorZ_get_err(uint32_t owner) {
857         LDKCResult_CommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(owner & ~1);
858         LDKDecodeError ret_var = CResult_CommitmentTransactionDecodeErrorZ_get_err(owner_conv);
859         uint32_t ret_ref = 0;
860         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
861         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
862         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
863         ret_ref = (uintptr_t)ret_var.inner;
864         if (ret_var.is_owned) {
865                 ret_ref |= 1;
866         }
867         return ret_ref;
868 }
869
870 static inline struct LDKTrustedCommitmentTransaction *CResult_TrustedCommitmentTransactionNoneZ_get_ok(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner){
871 CHECK(owner->result_ok);
872         return &*owner->contents.result;
873 }
874 uint32_t  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_get_ok"))) TS_CResult_TrustedCommitmentTransactionNoneZ_get_ok(uint32_t owner) {
875         LDKCResult_TrustedCommitmentTransactionNoneZ* owner_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(owner & ~1);
876         LDKTrustedCommitmentTransaction ret_var = *CResult_TrustedCommitmentTransactionNoneZ_get_ok(owner_conv);
877         uint32_t ret_ref = 0;
878         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
879         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
880         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
881         ret_ref = (uintptr_t)ret_var.inner & ~1;
882         return ret_ref;
883 }
884
885 static inline void CResult_TrustedCommitmentTransactionNoneZ_get_err(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner){
886 CHECK(!owner->result_ok);
887         return *owner->contents.err;
888 }
889 void  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_get_err"))) TS_CResult_TrustedCommitmentTransactionNoneZ_get_err(uint32_t owner) {
890         LDKCResult_TrustedCommitmentTransactionNoneZ* owner_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(owner & ~1);
891         CResult_TrustedCommitmentTransactionNoneZ_get_err(owner_conv);
892 }
893
894 static inline struct LDKCVec_SignatureZ CResult_CVec_SignatureZNoneZ_get_ok(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR owner){
895 CHECK(owner->result_ok);
896         return *owner->contents.result;
897 }
898 ptrArray  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_get_ok"))) TS_CResult_CVec_SignatureZNoneZ_get_ok(uint32_t owner) {
899         LDKCResult_CVec_SignatureZNoneZ* owner_conv = (LDKCResult_CVec_SignatureZNoneZ*)(owner & ~1);
900         LDKCVec_SignatureZ ret_var = CResult_CVec_SignatureZNoneZ_get_ok(owner_conv);
901         ptrArray ret_arr = NULL;
902         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
903         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 8);
904         for (size_t m = 0; m < ret_var.datalen; m++) {
905                 int8_tArray ret_conv_12_arr = init_int8_tArray(64, __LINE__);
906                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].compact_form, 64);
907                 ret_arr_ptr[m] = ret_conv_12_arr;
908         }
909         
910         return ret_arr;
911 }
912
913 static inline void CResult_CVec_SignatureZNoneZ_get_err(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR owner){
914 CHECK(!owner->result_ok);
915         return *owner->contents.err;
916 }
917 void  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_get_err"))) TS_CResult_CVec_SignatureZNoneZ_get_err(uint32_t owner) {
918         LDKCResult_CVec_SignatureZNoneZ* owner_conv = (LDKCResult_CVec_SignatureZNoneZ*)(owner & ~1);
919         CResult_CVec_SignatureZNoneZ_get_err(owner_conv);
920 }
921
922 static inline struct LDKShutdownScript CResult_ShutdownScriptDecodeErrorZ_get_ok(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR owner){
923 CHECK(owner->result_ok);
924         return ShutdownScript_clone(&*owner->contents.result);
925 }
926 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_get_ok"))) TS_CResult_ShutdownScriptDecodeErrorZ_get_ok(uint32_t owner) {
927         LDKCResult_ShutdownScriptDecodeErrorZ* owner_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(owner & ~1);
928         LDKShutdownScript ret_var = CResult_ShutdownScriptDecodeErrorZ_get_ok(owner_conv);
929         uint32_t ret_ref = 0;
930         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
931         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
932         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
933         ret_ref = (uintptr_t)ret_var.inner;
934         if (ret_var.is_owned) {
935                 ret_ref |= 1;
936         }
937         return ret_ref;
938 }
939
940 static inline struct LDKDecodeError CResult_ShutdownScriptDecodeErrorZ_get_err(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR owner){
941 CHECK(!owner->result_ok);
942         return DecodeError_clone(&*owner->contents.err);
943 }
944 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_get_err"))) TS_CResult_ShutdownScriptDecodeErrorZ_get_err(uint32_t owner) {
945         LDKCResult_ShutdownScriptDecodeErrorZ* owner_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(owner & ~1);
946         LDKDecodeError ret_var = CResult_ShutdownScriptDecodeErrorZ_get_err(owner_conv);
947         uint32_t ret_ref = 0;
948         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
949         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
950         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
951         ret_ref = (uintptr_t)ret_var.inner;
952         if (ret_var.is_owned) {
953                 ret_ref |= 1;
954         }
955         return ret_ref;
956 }
957
958 static inline struct LDKShutdownScript CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR owner){
959 CHECK(owner->result_ok);
960         return ShutdownScript_clone(&*owner->contents.result);
961 }
962 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(uint32_t owner) {
963         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* owner_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(owner & ~1);
964         LDKShutdownScript ret_var = CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(owner_conv);
965         uint32_t ret_ref = 0;
966         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
967         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
968         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
969         ret_ref = (uintptr_t)ret_var.inner;
970         if (ret_var.is_owned) {
971                 ret_ref |= 1;
972         }
973         return ret_ref;
974 }
975
976 static inline struct LDKInvalidShutdownScript CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR owner){
977 CHECK(!owner->result_ok);
978         return InvalidShutdownScript_clone(&*owner->contents.err);
979 }
980 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_get_err"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(uint32_t owner) {
981         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* owner_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(owner & ~1);
982         LDKInvalidShutdownScript ret_var = CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(owner_conv);
983         uint32_t ret_ref = 0;
984         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
985         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
986         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
987         ret_ref = (uintptr_t)ret_var.inner;
988         if (ret_var.is_owned) {
989                 ret_ref |= 1;
990         }
991         return ret_ref;
992 }
993
994 static inline struct LDKRouteHop CResult_RouteHopDecodeErrorZ_get_ok(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR owner){
995 CHECK(owner->result_ok);
996         return RouteHop_clone(&*owner->contents.result);
997 }
998 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_get_ok"))) TS_CResult_RouteHopDecodeErrorZ_get_ok(uint32_t owner) {
999         LDKCResult_RouteHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHopDecodeErrorZ*)(owner & ~1);
1000         LDKRouteHop ret_var = CResult_RouteHopDecodeErrorZ_get_ok(owner_conv);
1001         uint32_t ret_ref = 0;
1002         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1003         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1004         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1005         ret_ref = (uintptr_t)ret_var.inner;
1006         if (ret_var.is_owned) {
1007                 ret_ref |= 1;
1008         }
1009         return ret_ref;
1010 }
1011
1012 static inline struct LDKDecodeError CResult_RouteHopDecodeErrorZ_get_err(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR owner){
1013 CHECK(!owner->result_ok);
1014         return DecodeError_clone(&*owner->contents.err);
1015 }
1016 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_get_err"))) TS_CResult_RouteHopDecodeErrorZ_get_err(uint32_t owner) {
1017         LDKCResult_RouteHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHopDecodeErrorZ*)(owner & ~1);
1018         LDKDecodeError ret_var = CResult_RouteHopDecodeErrorZ_get_err(owner_conv);
1019         uint32_t ret_ref = 0;
1020         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1021         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1022         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1023         ret_ref = (uintptr_t)ret_var.inner;
1024         if (ret_var.is_owned) {
1025                 ret_ref |= 1;
1026         }
1027         return ret_ref;
1028 }
1029
1030 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
1031         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
1032         for (size_t i = 0; i < ret.datalen; i++) {
1033                 ret.data[i] = RouteHop_clone(&orig->data[i]);
1034         }
1035         return ret;
1036 }
1037 static inline LDKCVec_CVec_RouteHopZZ CVec_CVec_RouteHopZZ_clone(const LDKCVec_CVec_RouteHopZZ *orig) {
1038         LDKCVec_CVec_RouteHopZZ ret = { .data = MALLOC(sizeof(LDKCVec_RouteHopZ) * orig->datalen, "LDKCVec_CVec_RouteHopZZ clone bytes"), .datalen = orig->datalen };
1039         for (size_t i = 0; i < ret.datalen; i++) {
1040                 ret.data[i] = CVec_RouteHopZ_clone(&orig->data[i]);
1041         }
1042         return ret;
1043 }
1044 static inline struct LDKRoute CResult_RouteDecodeErrorZ_get_ok(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR owner){
1045 CHECK(owner->result_ok);
1046         return Route_clone(&*owner->contents.result);
1047 }
1048 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_get_ok"))) TS_CResult_RouteDecodeErrorZ_get_ok(uint32_t owner) {
1049         LDKCResult_RouteDecodeErrorZ* owner_conv = (LDKCResult_RouteDecodeErrorZ*)(owner & ~1);
1050         LDKRoute ret_var = CResult_RouteDecodeErrorZ_get_ok(owner_conv);
1051         uint32_t ret_ref = 0;
1052         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1053         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1054         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1055         ret_ref = (uintptr_t)ret_var.inner;
1056         if (ret_var.is_owned) {
1057                 ret_ref |= 1;
1058         }
1059         return ret_ref;
1060 }
1061
1062 static inline struct LDKDecodeError CResult_RouteDecodeErrorZ_get_err(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR owner){
1063 CHECK(!owner->result_ok);
1064         return DecodeError_clone(&*owner->contents.err);
1065 }
1066 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_get_err"))) TS_CResult_RouteDecodeErrorZ_get_err(uint32_t owner) {
1067         LDKCResult_RouteDecodeErrorZ* owner_conv = (LDKCResult_RouteDecodeErrorZ*)(owner & ~1);
1068         LDKDecodeError ret_var = CResult_RouteDecodeErrorZ_get_err(owner_conv);
1069         uint32_t ret_ref = 0;
1070         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1071         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1072         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1073         ret_ref = (uintptr_t)ret_var.inner;
1074         if (ret_var.is_owned) {
1075                 ret_ref |= 1;
1076         }
1077         return ret_ref;
1078 }
1079
1080 static inline struct LDKRouteParameters CResult_RouteParametersDecodeErrorZ_get_ok(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR owner){
1081 CHECK(owner->result_ok);
1082         return RouteParameters_clone(&*owner->contents.result);
1083 }
1084 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_get_ok"))) TS_CResult_RouteParametersDecodeErrorZ_get_ok(uint32_t owner) {
1085         LDKCResult_RouteParametersDecodeErrorZ* owner_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(owner & ~1);
1086         LDKRouteParameters ret_var = CResult_RouteParametersDecodeErrorZ_get_ok(owner_conv);
1087         uint32_t ret_ref = 0;
1088         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1089         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1090         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1091         ret_ref = (uintptr_t)ret_var.inner;
1092         if (ret_var.is_owned) {
1093                 ret_ref |= 1;
1094         }
1095         return ret_ref;
1096 }
1097
1098 static inline struct LDKDecodeError CResult_RouteParametersDecodeErrorZ_get_err(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR owner){
1099 CHECK(!owner->result_ok);
1100         return DecodeError_clone(&*owner->contents.err);
1101 }
1102 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_get_err"))) TS_CResult_RouteParametersDecodeErrorZ_get_err(uint32_t owner) {
1103         LDKCResult_RouteParametersDecodeErrorZ* owner_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(owner & ~1);
1104         LDKDecodeError ret_var = CResult_RouteParametersDecodeErrorZ_get_err(owner_conv);
1105         uint32_t ret_ref = 0;
1106         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1107         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1108         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1109         ret_ref = (uintptr_t)ret_var.inner;
1110         if (ret_var.is_owned) {
1111                 ret_ref |= 1;
1112         }
1113         return ret_ref;
1114 }
1115
1116 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
1117         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
1118         for (size_t i = 0; i < ret.datalen; i++) {
1119                 ret.data[i] = RouteHint_clone(&orig->data[i]);
1120         }
1121         return ret;
1122 }
1123 uint32_t __attribute__((export_name("TS_LDKCOption_u64Z_ty_from_ptr"))) TS_LDKCOption_u64Z_ty_from_ptr(uint32_t ptr) {
1124         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)(ptr & ~1);
1125         switch(obj->tag) {
1126                 case LDKCOption_u64Z_Some: return 0;
1127                 case LDKCOption_u64Z_None: return 1;
1128                 default: abort();
1129         }
1130 }
1131 int64_t __attribute__((export_name("TS_LDKCOption_u64Z_Some_get_some"))) TS_LDKCOption_u64Z_Some_get_some(uint32_t ptr) {
1132         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)(ptr & ~1);
1133         assert(obj->tag == LDKCOption_u64Z_Some);
1134                         int64_t some_conv = obj->some;
1135         return some_conv;
1136 }
1137 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
1138         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
1139         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
1140         return ret;
1141 }
1142 static inline struct LDKPaymentParameters CResult_PaymentParametersDecodeErrorZ_get_ok(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR owner){
1143 CHECK(owner->result_ok);
1144         return PaymentParameters_clone(&*owner->contents.result);
1145 }
1146 uint32_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_get_ok"))) TS_CResult_PaymentParametersDecodeErrorZ_get_ok(uint32_t owner) {
1147         LDKCResult_PaymentParametersDecodeErrorZ* owner_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(owner & ~1);
1148         LDKPaymentParameters ret_var = CResult_PaymentParametersDecodeErrorZ_get_ok(owner_conv);
1149         uint32_t ret_ref = 0;
1150         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1151         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1152         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1153         ret_ref = (uintptr_t)ret_var.inner;
1154         if (ret_var.is_owned) {
1155                 ret_ref |= 1;
1156         }
1157         return ret_ref;
1158 }
1159
1160 static inline struct LDKDecodeError CResult_PaymentParametersDecodeErrorZ_get_err(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR owner){
1161 CHECK(!owner->result_ok);
1162         return DecodeError_clone(&*owner->contents.err);
1163 }
1164 uint32_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_get_err"))) TS_CResult_PaymentParametersDecodeErrorZ_get_err(uint32_t owner) {
1165         LDKCResult_PaymentParametersDecodeErrorZ* owner_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(owner & ~1);
1166         LDKDecodeError ret_var = CResult_PaymentParametersDecodeErrorZ_get_err(owner_conv);
1167         uint32_t ret_ref = 0;
1168         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1169         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1170         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1171         ret_ref = (uintptr_t)ret_var.inner;
1172         if (ret_var.is_owned) {
1173                 ret_ref |= 1;
1174         }
1175         return ret_ref;
1176 }
1177
1178 static inline LDKCVec_RouteHintHopZ CVec_RouteHintHopZ_clone(const LDKCVec_RouteHintHopZ *orig) {
1179         LDKCVec_RouteHintHopZ ret = { .data = MALLOC(sizeof(LDKRouteHintHop) * orig->datalen, "LDKCVec_RouteHintHopZ clone bytes"), .datalen = orig->datalen };
1180         for (size_t i = 0; i < ret.datalen; i++) {
1181                 ret.data[i] = RouteHintHop_clone(&orig->data[i]);
1182         }
1183         return ret;
1184 }
1185 static inline struct LDKRouteHint CResult_RouteHintDecodeErrorZ_get_ok(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
1186 CHECK(owner->result_ok);
1187         return RouteHint_clone(&*owner->contents.result);
1188 }
1189 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_get_ok"))) TS_CResult_RouteHintDecodeErrorZ_get_ok(uint32_t owner) {
1190         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)(owner & ~1);
1191         LDKRouteHint ret_var = CResult_RouteHintDecodeErrorZ_get_ok(owner_conv);
1192         uint32_t ret_ref = 0;
1193         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1194         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1195         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1196         ret_ref = (uintptr_t)ret_var.inner;
1197         if (ret_var.is_owned) {
1198                 ret_ref |= 1;
1199         }
1200         return ret_ref;
1201 }
1202
1203 static inline struct LDKDecodeError CResult_RouteHintDecodeErrorZ_get_err(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
1204 CHECK(!owner->result_ok);
1205         return DecodeError_clone(&*owner->contents.err);
1206 }
1207 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_get_err"))) TS_CResult_RouteHintDecodeErrorZ_get_err(uint32_t owner) {
1208         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)(owner & ~1);
1209         LDKDecodeError ret_var = CResult_RouteHintDecodeErrorZ_get_err(owner_conv);
1210         uint32_t ret_ref = 0;
1211         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1212         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1213         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1214         ret_ref = (uintptr_t)ret_var.inner;
1215         if (ret_var.is_owned) {
1216                 ret_ref |= 1;
1217         }
1218         return ret_ref;
1219 }
1220
1221 static inline struct LDKRouteHintHop CResult_RouteHintHopDecodeErrorZ_get_ok(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
1222 CHECK(owner->result_ok);
1223         return RouteHintHop_clone(&*owner->contents.result);
1224 }
1225 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_get_ok"))) TS_CResult_RouteHintHopDecodeErrorZ_get_ok(uint32_t owner) {
1226         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(owner & ~1);
1227         LDKRouteHintHop ret_var = CResult_RouteHintHopDecodeErrorZ_get_ok(owner_conv);
1228         uint32_t ret_ref = 0;
1229         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1230         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1231         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1232         ret_ref = (uintptr_t)ret_var.inner;
1233         if (ret_var.is_owned) {
1234                 ret_ref |= 1;
1235         }
1236         return ret_ref;
1237 }
1238
1239 static inline struct LDKDecodeError CResult_RouteHintHopDecodeErrorZ_get_err(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
1240 CHECK(!owner->result_ok);
1241         return DecodeError_clone(&*owner->contents.err);
1242 }
1243 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_get_err"))) TS_CResult_RouteHintHopDecodeErrorZ_get_err(uint32_t owner) {
1244         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(owner & ~1);
1245         LDKDecodeError ret_var = CResult_RouteHintHopDecodeErrorZ_get_err(owner_conv);
1246         uint32_t ret_ref = 0;
1247         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1248         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1249         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1250         ret_ref = (uintptr_t)ret_var.inner;
1251         if (ret_var.is_owned) {
1252                 ret_ref |= 1;
1253         }
1254         return ret_ref;
1255 }
1256
1257 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
1258         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
1259         for (size_t i = 0; i < ret.datalen; i++) {
1260                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
1261         }
1262         return ret;
1263 }
1264 static inline struct LDKRoute CResult_RouteLightningErrorZ_get_ok(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
1265 CHECK(owner->result_ok);
1266         return Route_clone(&*owner->contents.result);
1267 }
1268 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_get_ok"))) TS_CResult_RouteLightningErrorZ_get_ok(uint32_t owner) {
1269         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)(owner & ~1);
1270         LDKRoute ret_var = CResult_RouteLightningErrorZ_get_ok(owner_conv);
1271         uint32_t ret_ref = 0;
1272         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1273         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1274         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1275         ret_ref = (uintptr_t)ret_var.inner;
1276         if (ret_var.is_owned) {
1277                 ret_ref |= 1;
1278         }
1279         return ret_ref;
1280 }
1281
1282 static inline struct LDKLightningError CResult_RouteLightningErrorZ_get_err(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
1283 CHECK(!owner->result_ok);
1284         return LightningError_clone(&*owner->contents.err);
1285 }
1286 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_get_err"))) TS_CResult_RouteLightningErrorZ_get_err(uint32_t owner) {
1287         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)(owner & ~1);
1288         LDKLightningError ret_var = CResult_RouteLightningErrorZ_get_err(owner_conv);
1289         uint32_t ret_ref = 0;
1290         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1291         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1292         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1293         ret_ref = (uintptr_t)ret_var.inner;
1294         if (ret_var.is_owned) {
1295                 ret_ref |= 1;
1296         }
1297         return ret_ref;
1298 }
1299
1300 uint32_t __attribute__((export_name("TS_LDKPaymentPurpose_ty_from_ptr"))) TS_LDKPaymentPurpose_ty_from_ptr(uint32_t ptr) {
1301         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
1302         switch(obj->tag) {
1303                 case LDKPaymentPurpose_InvoicePayment: return 0;
1304                 case LDKPaymentPurpose_SpontaneousPayment: return 1;
1305                 default: abort();
1306         }
1307 }
1308 int8_tArray __attribute__((export_name("TS_LDKPaymentPurpose_InvoicePayment_get_payment_preimage"))) TS_LDKPaymentPurpose_InvoicePayment_get_payment_preimage(uint32_t ptr) {
1309         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
1310         assert(obj->tag == LDKPaymentPurpose_InvoicePayment);
1311                         int8_tArray payment_preimage_arr = init_int8_tArray(32, __LINE__);
1312                         memcpy(payment_preimage_arr->elems, obj->invoice_payment.payment_preimage.data, 32);
1313         return payment_preimage_arr;
1314 }
1315 int8_tArray __attribute__((export_name("TS_LDKPaymentPurpose_InvoicePayment_get_payment_secret"))) TS_LDKPaymentPurpose_InvoicePayment_get_payment_secret(uint32_t ptr) {
1316         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
1317         assert(obj->tag == LDKPaymentPurpose_InvoicePayment);
1318                         int8_tArray payment_secret_arr = init_int8_tArray(32, __LINE__);
1319                         memcpy(payment_secret_arr->elems, obj->invoice_payment.payment_secret.data, 32);
1320         return payment_secret_arr;
1321 }
1322 int8_tArray __attribute__((export_name("TS_LDKPaymentPurpose_SpontaneousPayment_get_spontaneous_payment"))) TS_LDKPaymentPurpose_SpontaneousPayment_get_spontaneous_payment(uint32_t ptr) {
1323         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
1324         assert(obj->tag == LDKPaymentPurpose_SpontaneousPayment);
1325                         int8_tArray spontaneous_payment_arr = init_int8_tArray(32, __LINE__);
1326                         memcpy(spontaneous_payment_arr->elems, obj->spontaneous_payment.data, 32);
1327         return spontaneous_payment_arr;
1328 }
1329 static inline struct LDKPaymentPurpose CResult_PaymentPurposeDecodeErrorZ_get_ok(LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR owner){
1330 CHECK(owner->result_ok);
1331         return PaymentPurpose_clone(&*owner->contents.result);
1332 }
1333 uint32_t  __attribute__((export_name("TS_CResult_PaymentPurposeDecodeErrorZ_get_ok"))) TS_CResult_PaymentPurposeDecodeErrorZ_get_ok(uint32_t owner) {
1334         LDKCResult_PaymentPurposeDecodeErrorZ* owner_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)(owner & ~1);
1335         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
1336         *ret_copy = CResult_PaymentPurposeDecodeErrorZ_get_ok(owner_conv);
1337         uint32_t ret_ref = (uintptr_t)ret_copy;
1338         return ret_ref;
1339 }
1340
1341 static inline struct LDKDecodeError CResult_PaymentPurposeDecodeErrorZ_get_err(LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR owner){
1342 CHECK(!owner->result_ok);
1343         return DecodeError_clone(&*owner->contents.err);
1344 }
1345 uint32_t  __attribute__((export_name("TS_CResult_PaymentPurposeDecodeErrorZ_get_err"))) TS_CResult_PaymentPurposeDecodeErrorZ_get_err(uint32_t owner) {
1346         LDKCResult_PaymentPurposeDecodeErrorZ* owner_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)(owner & ~1);
1347         LDKDecodeError ret_var = CResult_PaymentPurposeDecodeErrorZ_get_err(owner_conv);
1348         uint32_t ret_ref = 0;
1349         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1350         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1351         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1352         ret_ref = (uintptr_t)ret_var.inner;
1353         if (ret_var.is_owned) {
1354                 ret_ref |= 1;
1355         }
1356         return ret_ref;
1357 }
1358
1359 uint32_t __attribute__((export_name("TS_LDKClosureReason_ty_from_ptr"))) TS_LDKClosureReason_ty_from_ptr(uint32_t ptr) {
1360         LDKClosureReason *obj = (LDKClosureReason*)(ptr & ~1);
1361         switch(obj->tag) {
1362                 case LDKClosureReason_CounterpartyForceClosed: return 0;
1363                 case LDKClosureReason_HolderForceClosed: return 1;
1364                 case LDKClosureReason_CooperativeClosure: return 2;
1365                 case LDKClosureReason_CommitmentTxConfirmed: return 3;
1366                 case LDKClosureReason_FundingTimedOut: return 4;
1367                 case LDKClosureReason_ProcessingError: return 5;
1368                 case LDKClosureReason_DisconnectedPeer: return 6;
1369                 case LDKClosureReason_OutdatedChannelManager: return 7;
1370                 default: abort();
1371         }
1372 }
1373 jstring __attribute__((export_name("TS_LDKClosureReason_CounterpartyForceClosed_get_peer_msg"))) TS_LDKClosureReason_CounterpartyForceClosed_get_peer_msg(uint32_t ptr) {
1374         LDKClosureReason *obj = (LDKClosureReason*)(ptr & ~1);
1375         assert(obj->tag == LDKClosureReason_CounterpartyForceClosed);
1376                         LDKStr peer_msg_str = obj->counterparty_force_closed.peer_msg;
1377                         jstring peer_msg_conv = str_ref_to_ts(peer_msg_str.chars, peer_msg_str.len);
1378         return peer_msg_conv;
1379 }
1380 jstring __attribute__((export_name("TS_LDKClosureReason_ProcessingError_get_err"))) TS_LDKClosureReason_ProcessingError_get_err(uint32_t ptr) {
1381         LDKClosureReason *obj = (LDKClosureReason*)(ptr & ~1);
1382         assert(obj->tag == LDKClosureReason_ProcessingError);
1383                         LDKStr err_str = obj->processing_error.err;
1384                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
1385         return err_conv;
1386 }
1387 uint32_t __attribute__((export_name("TS_LDKCOption_ClosureReasonZ_ty_from_ptr"))) TS_LDKCOption_ClosureReasonZ_ty_from_ptr(uint32_t ptr) {
1388         LDKCOption_ClosureReasonZ *obj = (LDKCOption_ClosureReasonZ*)(ptr & ~1);
1389         switch(obj->tag) {
1390                 case LDKCOption_ClosureReasonZ_Some: return 0;
1391                 case LDKCOption_ClosureReasonZ_None: return 1;
1392                 default: abort();
1393         }
1394 }
1395 uint32_t __attribute__((export_name("TS_LDKCOption_ClosureReasonZ_Some_get_some"))) TS_LDKCOption_ClosureReasonZ_Some_get_some(uint32_t ptr) {
1396         LDKCOption_ClosureReasonZ *obj = (LDKCOption_ClosureReasonZ*)(ptr & ~1);
1397         assert(obj->tag == LDKCOption_ClosureReasonZ_Some);
1398                         uint32_t some_ref = ((uintptr_t)&obj->some) | 1;
1399         return some_ref;
1400 }
1401 static inline struct LDKCOption_ClosureReasonZ CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
1402 CHECK(owner->result_ok);
1403         return COption_ClosureReasonZ_clone(&*owner->contents.result);
1404 }
1405 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_get_ok"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(uint32_t owner) {
1406         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(owner & ~1);
1407         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
1408         *ret_copy = CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(owner_conv);
1409         uint32_t ret_ref = (uintptr_t)ret_copy;
1410         return ret_ref;
1411 }
1412
1413 static inline struct LDKDecodeError CResult_COption_ClosureReasonZDecodeErrorZ_get_err(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
1414 CHECK(!owner->result_ok);
1415         return DecodeError_clone(&*owner->contents.err);
1416 }
1417 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_get_err"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_get_err(uint32_t owner) {
1418         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(owner & ~1);
1419         LDKDecodeError ret_var = CResult_COption_ClosureReasonZDecodeErrorZ_get_err(owner_conv);
1420         uint32_t ret_ref = 0;
1421         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1422         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1423         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1424         ret_ref = (uintptr_t)ret_var.inner;
1425         if (ret_var.is_owned) {
1426                 ret_ref |= 1;
1427         }
1428         return ret_ref;
1429 }
1430
1431 uint32_t __attribute__((export_name("TS_LDKHTLCDestination_ty_from_ptr"))) TS_LDKHTLCDestination_ty_from_ptr(uint32_t ptr) {
1432         LDKHTLCDestination *obj = (LDKHTLCDestination*)(ptr & ~1);
1433         switch(obj->tag) {
1434                 case LDKHTLCDestination_NextHopChannel: return 0;
1435                 case LDKHTLCDestination_UnknownNextHop: return 1;
1436                 case LDKHTLCDestination_FailedPayment: return 2;
1437                 default: abort();
1438         }
1439 }
1440 int8_tArray __attribute__((export_name("TS_LDKHTLCDestination_NextHopChannel_get_node_id"))) TS_LDKHTLCDestination_NextHopChannel_get_node_id(uint32_t ptr) {
1441         LDKHTLCDestination *obj = (LDKHTLCDestination*)(ptr & ~1);
1442         assert(obj->tag == LDKHTLCDestination_NextHopChannel);
1443                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
1444                         memcpy(node_id_arr->elems, obj->next_hop_channel.node_id.compressed_form, 33);
1445         return node_id_arr;
1446 }
1447 int8_tArray __attribute__((export_name("TS_LDKHTLCDestination_NextHopChannel_get_channel_id"))) TS_LDKHTLCDestination_NextHopChannel_get_channel_id(uint32_t ptr) {
1448         LDKHTLCDestination *obj = (LDKHTLCDestination*)(ptr & ~1);
1449         assert(obj->tag == LDKHTLCDestination_NextHopChannel);
1450                         int8_tArray channel_id_arr = init_int8_tArray(32, __LINE__);
1451                         memcpy(channel_id_arr->elems, obj->next_hop_channel.channel_id.data, 32);
1452         return channel_id_arr;
1453 }
1454 int64_t __attribute__((export_name("TS_LDKHTLCDestination_UnknownNextHop_get_requested_forward_scid"))) TS_LDKHTLCDestination_UnknownNextHop_get_requested_forward_scid(uint32_t ptr) {
1455         LDKHTLCDestination *obj = (LDKHTLCDestination*)(ptr & ~1);
1456         assert(obj->tag == LDKHTLCDestination_UnknownNextHop);
1457                         int64_t requested_forward_scid_conv = obj->unknown_next_hop.requested_forward_scid;
1458         return requested_forward_scid_conv;
1459 }
1460 int8_tArray __attribute__((export_name("TS_LDKHTLCDestination_FailedPayment_get_payment_hash"))) TS_LDKHTLCDestination_FailedPayment_get_payment_hash(uint32_t ptr) {
1461         LDKHTLCDestination *obj = (LDKHTLCDestination*)(ptr & ~1);
1462         assert(obj->tag == LDKHTLCDestination_FailedPayment);
1463                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1464                         memcpy(payment_hash_arr->elems, obj->failed_payment.payment_hash.data, 32);
1465         return payment_hash_arr;
1466 }
1467 uint32_t __attribute__((export_name("TS_LDKCOption_HTLCDestinationZ_ty_from_ptr"))) TS_LDKCOption_HTLCDestinationZ_ty_from_ptr(uint32_t ptr) {
1468         LDKCOption_HTLCDestinationZ *obj = (LDKCOption_HTLCDestinationZ*)(ptr & ~1);
1469         switch(obj->tag) {
1470                 case LDKCOption_HTLCDestinationZ_Some: return 0;
1471                 case LDKCOption_HTLCDestinationZ_None: return 1;
1472                 default: abort();
1473         }
1474 }
1475 uint32_t __attribute__((export_name("TS_LDKCOption_HTLCDestinationZ_Some_get_some"))) TS_LDKCOption_HTLCDestinationZ_Some_get_some(uint32_t ptr) {
1476         LDKCOption_HTLCDestinationZ *obj = (LDKCOption_HTLCDestinationZ*)(ptr & ~1);
1477         assert(obj->tag == LDKCOption_HTLCDestinationZ_Some);
1478                         uint32_t some_ref = ((uintptr_t)&obj->some) | 1;
1479         return some_ref;
1480 }
1481 static inline struct LDKCOption_HTLCDestinationZ CResult_COption_HTLCDestinationZDecodeErrorZ_get_ok(LDKCResult_COption_HTLCDestinationZDecodeErrorZ *NONNULL_PTR owner){
1482 CHECK(owner->result_ok);
1483         return COption_HTLCDestinationZ_clone(&*owner->contents.result);
1484 }
1485 uint32_t  __attribute__((export_name("TS_CResult_COption_HTLCDestinationZDecodeErrorZ_get_ok"))) TS_CResult_COption_HTLCDestinationZDecodeErrorZ_get_ok(uint32_t owner) {
1486         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* owner_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)(owner & ~1);
1487         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
1488         *ret_copy = CResult_COption_HTLCDestinationZDecodeErrorZ_get_ok(owner_conv);
1489         uint32_t ret_ref = (uintptr_t)ret_copy;
1490         return ret_ref;
1491 }
1492
1493 static inline struct LDKDecodeError CResult_COption_HTLCDestinationZDecodeErrorZ_get_err(LDKCResult_COption_HTLCDestinationZDecodeErrorZ *NONNULL_PTR owner){
1494 CHECK(!owner->result_ok);
1495         return DecodeError_clone(&*owner->contents.err);
1496 }
1497 uint32_t  __attribute__((export_name("TS_CResult_COption_HTLCDestinationZDecodeErrorZ_get_err"))) TS_CResult_COption_HTLCDestinationZDecodeErrorZ_get_err(uint32_t owner) {
1498         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* owner_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)(owner & ~1);
1499         LDKDecodeError ret_var = CResult_COption_HTLCDestinationZDecodeErrorZ_get_err(owner_conv);
1500         uint32_t ret_ref = 0;
1501         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1502         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1503         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1504         ret_ref = (uintptr_t)ret_var.inner;
1505         if (ret_var.is_owned) {
1506                 ret_ref |= 1;
1507         }
1508         return ret_ref;
1509 }
1510
1511 uint32_t __attribute__((export_name("TS_LDKNetworkUpdate_ty_from_ptr"))) TS_LDKNetworkUpdate_ty_from_ptr(uint32_t ptr) {
1512         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1513         switch(obj->tag) {
1514                 case LDKNetworkUpdate_ChannelUpdateMessage: return 0;
1515                 case LDKNetworkUpdate_ChannelFailure: return 1;
1516                 case LDKNetworkUpdate_NodeFailure: return 2;
1517                 default: abort();
1518         }
1519 }
1520 uint32_t __attribute__((export_name("TS_LDKNetworkUpdate_ChannelUpdateMessage_get_msg"))) TS_LDKNetworkUpdate_ChannelUpdateMessage_get_msg(uint32_t ptr) {
1521         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1522         assert(obj->tag == LDKNetworkUpdate_ChannelUpdateMessage);
1523                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
1524                         uint32_t msg_ref = 0;
1525                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1526                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1527                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1528                         msg_ref = (uintptr_t)msg_var.inner & ~1;
1529         return msg_ref;
1530 }
1531 int64_t __attribute__((export_name("TS_LDKNetworkUpdate_ChannelFailure_get_short_channel_id"))) TS_LDKNetworkUpdate_ChannelFailure_get_short_channel_id(uint32_t ptr) {
1532         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1533         assert(obj->tag == LDKNetworkUpdate_ChannelFailure);
1534                         int64_t short_channel_id_conv = obj->channel_failure.short_channel_id;
1535         return short_channel_id_conv;
1536 }
1537 jboolean __attribute__((export_name("TS_LDKNetworkUpdate_ChannelFailure_get_is_permanent"))) TS_LDKNetworkUpdate_ChannelFailure_get_is_permanent(uint32_t ptr) {
1538         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1539         assert(obj->tag == LDKNetworkUpdate_ChannelFailure);
1540                         jboolean is_permanent_conv = obj->channel_failure.is_permanent;
1541         return is_permanent_conv;
1542 }
1543 int8_tArray __attribute__((export_name("TS_LDKNetworkUpdate_NodeFailure_get_node_id"))) TS_LDKNetworkUpdate_NodeFailure_get_node_id(uint32_t ptr) {
1544         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1545         assert(obj->tag == LDKNetworkUpdate_NodeFailure);
1546                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
1547                         memcpy(node_id_arr->elems, obj->node_failure.node_id.compressed_form, 33);
1548         return node_id_arr;
1549 }
1550 jboolean __attribute__((export_name("TS_LDKNetworkUpdate_NodeFailure_get_is_permanent"))) TS_LDKNetworkUpdate_NodeFailure_get_is_permanent(uint32_t ptr) {
1551         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1552         assert(obj->tag == LDKNetworkUpdate_NodeFailure);
1553                         jboolean is_permanent_conv = obj->node_failure.is_permanent;
1554         return is_permanent_conv;
1555 }
1556 uint32_t __attribute__((export_name("TS_LDKCOption_NetworkUpdateZ_ty_from_ptr"))) TS_LDKCOption_NetworkUpdateZ_ty_from_ptr(uint32_t ptr) {
1557         LDKCOption_NetworkUpdateZ *obj = (LDKCOption_NetworkUpdateZ*)(ptr & ~1);
1558         switch(obj->tag) {
1559                 case LDKCOption_NetworkUpdateZ_Some: return 0;
1560                 case LDKCOption_NetworkUpdateZ_None: return 1;
1561                 default: abort();
1562         }
1563 }
1564 uint32_t __attribute__((export_name("TS_LDKCOption_NetworkUpdateZ_Some_get_some"))) TS_LDKCOption_NetworkUpdateZ_Some_get_some(uint32_t ptr) {
1565         LDKCOption_NetworkUpdateZ *obj = (LDKCOption_NetworkUpdateZ*)(ptr & ~1);
1566         assert(obj->tag == LDKCOption_NetworkUpdateZ_Some);
1567                         uint32_t some_ref = ((uintptr_t)&obj->some) | 1;
1568         return some_ref;
1569 }
1570 uint32_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_ty_from_ptr"))) TS_LDKSpendableOutputDescriptor_ty_from_ptr(uint32_t ptr) {
1571         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1572         switch(obj->tag) {
1573                 case LDKSpendableOutputDescriptor_StaticOutput: return 0;
1574                 case LDKSpendableOutputDescriptor_DelayedPaymentOutput: return 1;
1575                 case LDKSpendableOutputDescriptor_StaticPaymentOutput: return 2;
1576                 default: abort();
1577         }
1578 }
1579 uint32_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_StaticOutput_get_outpoint"))) TS_LDKSpendableOutputDescriptor_StaticOutput_get_outpoint(uint32_t ptr) {
1580         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1581         assert(obj->tag == LDKSpendableOutputDescriptor_StaticOutput);
1582                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
1583                         uint32_t outpoint_ref = 0;
1584                         CHECK((((uintptr_t)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1585                         CHECK((((uintptr_t)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1586                         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_var);
1587                         outpoint_ref = (uintptr_t)outpoint_var.inner & ~1;
1588         return outpoint_ref;
1589 }
1590 uint32_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_StaticOutput_get_output"))) TS_LDKSpendableOutputDescriptor_StaticOutput_get_output(uint32_t ptr) {
1591         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1592         assert(obj->tag == LDKSpendableOutputDescriptor_StaticOutput);
1593                         uint32_t output_ref = ((uintptr_t)&obj->static_output.output) | 1;
1594         return (uint32_t)output_ref;
1595 }
1596 uint32_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_DelayedPaymentOutput_get_delayed_payment_output"))) TS_LDKSpendableOutputDescriptor_DelayedPaymentOutput_get_delayed_payment_output(uint32_t ptr) {
1597         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1598         assert(obj->tag == LDKSpendableOutputDescriptor_DelayedPaymentOutput);
1599                         LDKDelayedPaymentOutputDescriptor delayed_payment_output_var = obj->delayed_payment_output;
1600                         uint32_t delayed_payment_output_ref = 0;
1601                         CHECK((((uintptr_t)delayed_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1602                         CHECK((((uintptr_t)&delayed_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1603                         CHECK_INNER_FIELD_ACCESS_OR_NULL(delayed_payment_output_var);
1604                         delayed_payment_output_ref = (uintptr_t)delayed_payment_output_var.inner & ~1;
1605         return delayed_payment_output_ref;
1606 }
1607 uint32_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_StaticPaymentOutput_get_static_payment_output"))) TS_LDKSpendableOutputDescriptor_StaticPaymentOutput_get_static_payment_output(uint32_t ptr) {
1608         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1609         assert(obj->tag == LDKSpendableOutputDescriptor_StaticPaymentOutput);
1610                         LDKStaticPaymentOutputDescriptor static_payment_output_var = obj->static_payment_output;
1611                         uint32_t static_payment_output_ref = 0;
1612                         CHECK((((uintptr_t)static_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1613                         CHECK((((uintptr_t)&static_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1614                         CHECK_INNER_FIELD_ACCESS_OR_NULL(static_payment_output_var);
1615                         static_payment_output_ref = (uintptr_t)static_payment_output_var.inner & ~1;
1616         return static_payment_output_ref;
1617 }
1618 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
1619         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
1620         for (size_t i = 0; i < ret.datalen; i++) {
1621                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
1622         }
1623         return ret;
1624 }
1625 uint32_t __attribute__((export_name("TS_LDKEvent_ty_from_ptr"))) TS_LDKEvent_ty_from_ptr(uint32_t ptr) {
1626         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1627         switch(obj->tag) {
1628                 case LDKEvent_FundingGenerationReady: return 0;
1629                 case LDKEvent_PaymentReceived: return 1;
1630                 case LDKEvent_PaymentClaimed: return 2;
1631                 case LDKEvent_PaymentSent: return 3;
1632                 case LDKEvent_PaymentFailed: return 4;
1633                 case LDKEvent_PaymentPathSuccessful: return 5;
1634                 case LDKEvent_PaymentPathFailed: return 6;
1635                 case LDKEvent_ProbeSuccessful: return 7;
1636                 case LDKEvent_ProbeFailed: return 8;
1637                 case LDKEvent_PendingHTLCsForwardable: return 9;
1638                 case LDKEvent_SpendableOutputs: return 10;
1639                 case LDKEvent_PaymentForwarded: return 11;
1640                 case LDKEvent_ChannelClosed: return 12;
1641                 case LDKEvent_DiscardFunding: return 13;
1642                 case LDKEvent_OpenChannelRequest: return 14;
1643                 case LDKEvent_HTLCHandlingFailed: return 15;
1644                 default: abort();
1645         }
1646 }
1647 int8_tArray __attribute__((export_name("TS_LDKEvent_FundingGenerationReady_get_temporary_channel_id"))) TS_LDKEvent_FundingGenerationReady_get_temporary_channel_id(uint32_t ptr) {
1648         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1649         assert(obj->tag == LDKEvent_FundingGenerationReady);
1650                         int8_tArray temporary_channel_id_arr = init_int8_tArray(32, __LINE__);
1651                         memcpy(temporary_channel_id_arr->elems, obj->funding_generation_ready.temporary_channel_id.data, 32);
1652         return temporary_channel_id_arr;
1653 }
1654 int8_tArray __attribute__((export_name("TS_LDKEvent_FundingGenerationReady_get_counterparty_node_id"))) TS_LDKEvent_FundingGenerationReady_get_counterparty_node_id(uint32_t ptr) {
1655         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1656         assert(obj->tag == LDKEvent_FundingGenerationReady);
1657                         int8_tArray counterparty_node_id_arr = init_int8_tArray(33, __LINE__);
1658                         memcpy(counterparty_node_id_arr->elems, obj->funding_generation_ready.counterparty_node_id.compressed_form, 33);
1659         return counterparty_node_id_arr;
1660 }
1661 int64_t __attribute__((export_name("TS_LDKEvent_FundingGenerationReady_get_channel_value_satoshis"))) TS_LDKEvent_FundingGenerationReady_get_channel_value_satoshis(uint32_t ptr) {
1662         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1663         assert(obj->tag == LDKEvent_FundingGenerationReady);
1664                         int64_t channel_value_satoshis_conv = obj->funding_generation_ready.channel_value_satoshis;
1665         return channel_value_satoshis_conv;
1666 }
1667 int8_tArray __attribute__((export_name("TS_LDKEvent_FundingGenerationReady_get_output_script"))) TS_LDKEvent_FundingGenerationReady_get_output_script(uint32_t ptr) {
1668         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1669         assert(obj->tag == LDKEvent_FundingGenerationReady);
1670                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
1671                         int8_tArray output_script_arr = init_int8_tArray(output_script_var.datalen, __LINE__);
1672                         memcpy(output_script_arr->elems, output_script_var.data, output_script_var.datalen);
1673         return output_script_arr;
1674 }
1675 int64_t __attribute__((export_name("TS_LDKEvent_FundingGenerationReady_get_user_channel_id"))) TS_LDKEvent_FundingGenerationReady_get_user_channel_id(uint32_t ptr) {
1676         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1677         assert(obj->tag == LDKEvent_FundingGenerationReady);
1678                         int64_t user_channel_id_conv = obj->funding_generation_ready.user_channel_id;
1679         return user_channel_id_conv;
1680 }
1681 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentReceived_get_payment_hash"))) TS_LDKEvent_PaymentReceived_get_payment_hash(uint32_t ptr) {
1682         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1683         assert(obj->tag == LDKEvent_PaymentReceived);
1684                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1685                         memcpy(payment_hash_arr->elems, obj->payment_received.payment_hash.data, 32);
1686         return payment_hash_arr;
1687 }
1688 int64_t __attribute__((export_name("TS_LDKEvent_PaymentReceived_get_amount_msat"))) TS_LDKEvent_PaymentReceived_get_amount_msat(uint32_t ptr) {
1689         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1690         assert(obj->tag == LDKEvent_PaymentReceived);
1691                         int64_t amount_msat_conv = obj->payment_received.amount_msat;
1692         return amount_msat_conv;
1693 }
1694 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentReceived_get_purpose"))) TS_LDKEvent_PaymentReceived_get_purpose(uint32_t ptr) {
1695         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1696         assert(obj->tag == LDKEvent_PaymentReceived);
1697                         uint32_t purpose_ref = ((uintptr_t)&obj->payment_received.purpose) | 1;
1698         return purpose_ref;
1699 }
1700 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentClaimed_get_payment_hash"))) TS_LDKEvent_PaymentClaimed_get_payment_hash(uint32_t ptr) {
1701         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1702         assert(obj->tag == LDKEvent_PaymentClaimed);
1703                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1704                         memcpy(payment_hash_arr->elems, obj->payment_claimed.payment_hash.data, 32);
1705         return payment_hash_arr;
1706 }
1707 int64_t __attribute__((export_name("TS_LDKEvent_PaymentClaimed_get_amount_msat"))) TS_LDKEvent_PaymentClaimed_get_amount_msat(uint32_t ptr) {
1708         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1709         assert(obj->tag == LDKEvent_PaymentClaimed);
1710                         int64_t amount_msat_conv = obj->payment_claimed.amount_msat;
1711         return amount_msat_conv;
1712 }
1713 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentClaimed_get_purpose"))) TS_LDKEvent_PaymentClaimed_get_purpose(uint32_t ptr) {
1714         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1715         assert(obj->tag == LDKEvent_PaymentClaimed);
1716                         uint32_t purpose_ref = ((uintptr_t)&obj->payment_claimed.purpose) | 1;
1717         return purpose_ref;
1718 }
1719 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentSent_get_payment_id"))) TS_LDKEvent_PaymentSent_get_payment_id(uint32_t ptr) {
1720         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1721         assert(obj->tag == LDKEvent_PaymentSent);
1722                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
1723                         memcpy(payment_id_arr->elems, obj->payment_sent.payment_id.data, 32);
1724         return payment_id_arr;
1725 }
1726 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentSent_get_payment_preimage"))) TS_LDKEvent_PaymentSent_get_payment_preimage(uint32_t ptr) {
1727         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1728         assert(obj->tag == LDKEvent_PaymentSent);
1729                         int8_tArray payment_preimage_arr = init_int8_tArray(32, __LINE__);
1730                         memcpy(payment_preimage_arr->elems, obj->payment_sent.payment_preimage.data, 32);
1731         return payment_preimage_arr;
1732 }
1733 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentSent_get_payment_hash"))) TS_LDKEvent_PaymentSent_get_payment_hash(uint32_t ptr) {
1734         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1735         assert(obj->tag == LDKEvent_PaymentSent);
1736                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1737                         memcpy(payment_hash_arr->elems, obj->payment_sent.payment_hash.data, 32);
1738         return payment_hash_arr;
1739 }
1740 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentSent_get_fee_paid_msat"))) TS_LDKEvent_PaymentSent_get_fee_paid_msat(uint32_t ptr) {
1741         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1742         assert(obj->tag == LDKEvent_PaymentSent);
1743                         uint32_t fee_paid_msat_ref = ((uintptr_t)&obj->payment_sent.fee_paid_msat) | 1;
1744         return fee_paid_msat_ref;
1745 }
1746 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentFailed_get_payment_id"))) TS_LDKEvent_PaymentFailed_get_payment_id(uint32_t ptr) {
1747         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1748         assert(obj->tag == LDKEvent_PaymentFailed);
1749                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
1750                         memcpy(payment_id_arr->elems, obj->payment_failed.payment_id.data, 32);
1751         return payment_id_arr;
1752 }
1753 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentFailed_get_payment_hash"))) TS_LDKEvent_PaymentFailed_get_payment_hash(uint32_t ptr) {
1754         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1755         assert(obj->tag == LDKEvent_PaymentFailed);
1756                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1757                         memcpy(payment_hash_arr->elems, obj->payment_failed.payment_hash.data, 32);
1758         return payment_hash_arr;
1759 }
1760 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathSuccessful_get_payment_id"))) TS_LDKEvent_PaymentPathSuccessful_get_payment_id(uint32_t ptr) {
1761         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1762         assert(obj->tag == LDKEvent_PaymentPathSuccessful);
1763                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
1764                         memcpy(payment_id_arr->elems, obj->payment_path_successful.payment_id.data, 32);
1765         return payment_id_arr;
1766 }
1767 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathSuccessful_get_payment_hash"))) TS_LDKEvent_PaymentPathSuccessful_get_payment_hash(uint32_t ptr) {
1768         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1769         assert(obj->tag == LDKEvent_PaymentPathSuccessful);
1770                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1771                         memcpy(payment_hash_arr->elems, obj->payment_path_successful.payment_hash.data, 32);
1772         return payment_hash_arr;
1773 }
1774 uint32_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathSuccessful_get_path"))) TS_LDKEvent_PaymentPathSuccessful_get_path(uint32_t ptr) {
1775         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1776         assert(obj->tag == LDKEvent_PaymentPathSuccessful);
1777                         LDKCVec_RouteHopZ path_var = obj->payment_path_successful.path;
1778                         uint32_tArray path_arr = NULL;
1779                         path_arr = init_uint32_tArray(path_var.datalen, __LINE__);
1780                         uint32_t *path_arr_ptr = (uint32_t*)(((uint8_t*)path_arr) + 8);
1781                         for (size_t k = 0; k < path_var.datalen; k++) {
1782                                 LDKRouteHop path_conv_10_var = path_var.data[k];
1783                                 uint32_t path_conv_10_ref = 0;
1784                                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1785                                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1786                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
1787                                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner & ~1;
1788                                 path_arr_ptr[k] = path_conv_10_ref;
1789                         }
1790                         
1791         return path_arr;
1792 }
1793 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_payment_id"))) TS_LDKEvent_PaymentPathFailed_get_payment_id(uint32_t ptr) {
1794         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1795         assert(obj->tag == LDKEvent_PaymentPathFailed);
1796                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
1797                         memcpy(payment_id_arr->elems, obj->payment_path_failed.payment_id.data, 32);
1798         return payment_id_arr;
1799 }
1800 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_payment_hash"))) TS_LDKEvent_PaymentPathFailed_get_payment_hash(uint32_t ptr) {
1801         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1802         assert(obj->tag == LDKEvent_PaymentPathFailed);
1803                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1804                         memcpy(payment_hash_arr->elems, obj->payment_path_failed.payment_hash.data, 32);
1805         return payment_hash_arr;
1806 }
1807 jboolean __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_rejected_by_dest"))) TS_LDKEvent_PaymentPathFailed_get_rejected_by_dest(uint32_t ptr) {
1808         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1809         assert(obj->tag == LDKEvent_PaymentPathFailed);
1810                         jboolean rejected_by_dest_conv = obj->payment_path_failed.rejected_by_dest;
1811         return rejected_by_dest_conv;
1812 }
1813 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_network_update"))) TS_LDKEvent_PaymentPathFailed_get_network_update(uint32_t ptr) {
1814         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1815         assert(obj->tag == LDKEvent_PaymentPathFailed);
1816                         uint32_t network_update_ref = ((uintptr_t)&obj->payment_path_failed.network_update) | 1;
1817         return network_update_ref;
1818 }
1819 jboolean __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_all_paths_failed"))) TS_LDKEvent_PaymentPathFailed_get_all_paths_failed(uint32_t ptr) {
1820         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1821         assert(obj->tag == LDKEvent_PaymentPathFailed);
1822                         jboolean all_paths_failed_conv = obj->payment_path_failed.all_paths_failed;
1823         return all_paths_failed_conv;
1824 }
1825 uint32_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_path"))) TS_LDKEvent_PaymentPathFailed_get_path(uint32_t ptr) {
1826         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1827         assert(obj->tag == LDKEvent_PaymentPathFailed);
1828                         LDKCVec_RouteHopZ path_var = obj->payment_path_failed.path;
1829                         uint32_tArray path_arr = NULL;
1830                         path_arr = init_uint32_tArray(path_var.datalen, __LINE__);
1831                         uint32_t *path_arr_ptr = (uint32_t*)(((uint8_t*)path_arr) + 8);
1832                         for (size_t k = 0; k < path_var.datalen; k++) {
1833                                 LDKRouteHop path_conv_10_var = path_var.data[k];
1834                                 uint32_t path_conv_10_ref = 0;
1835                                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1836                                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1837                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
1838                                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner & ~1;
1839                                 path_arr_ptr[k] = path_conv_10_ref;
1840                         }
1841                         
1842         return path_arr;
1843 }
1844 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_short_channel_id"))) TS_LDKEvent_PaymentPathFailed_get_short_channel_id(uint32_t ptr) {
1845         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1846         assert(obj->tag == LDKEvent_PaymentPathFailed);
1847                         uint32_t short_channel_id_ref = ((uintptr_t)&obj->payment_path_failed.short_channel_id) | 1;
1848         return short_channel_id_ref;
1849 }
1850 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_retry"))) TS_LDKEvent_PaymentPathFailed_get_retry(uint32_t ptr) {
1851         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1852         assert(obj->tag == LDKEvent_PaymentPathFailed);
1853                         LDKRouteParameters retry_var = obj->payment_path_failed.retry;
1854                         uint32_t retry_ref = 0;
1855                         if ((uintptr_t)retry_var.inner > 4096) {
1856                                 CHECK((((uintptr_t)retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1857                                 CHECK((((uintptr_t)&retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1858                         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_var);
1859                                 retry_ref = (uintptr_t)retry_var.inner & ~1;
1860                         }
1861         return retry_ref;
1862 }
1863 int8_tArray __attribute__((export_name("TS_LDKEvent_ProbeSuccessful_get_payment_id"))) TS_LDKEvent_ProbeSuccessful_get_payment_id(uint32_t ptr) {
1864         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1865         assert(obj->tag == LDKEvent_ProbeSuccessful);
1866                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
1867                         memcpy(payment_id_arr->elems, obj->probe_successful.payment_id.data, 32);
1868         return payment_id_arr;
1869 }
1870 int8_tArray __attribute__((export_name("TS_LDKEvent_ProbeSuccessful_get_payment_hash"))) TS_LDKEvent_ProbeSuccessful_get_payment_hash(uint32_t ptr) {
1871         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1872         assert(obj->tag == LDKEvent_ProbeSuccessful);
1873                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1874                         memcpy(payment_hash_arr->elems, obj->probe_successful.payment_hash.data, 32);
1875         return payment_hash_arr;
1876 }
1877 uint32_tArray __attribute__((export_name("TS_LDKEvent_ProbeSuccessful_get_path"))) TS_LDKEvent_ProbeSuccessful_get_path(uint32_t ptr) {
1878         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1879         assert(obj->tag == LDKEvent_ProbeSuccessful);
1880                         LDKCVec_RouteHopZ path_var = obj->probe_successful.path;
1881                         uint32_tArray path_arr = NULL;
1882                         path_arr = init_uint32_tArray(path_var.datalen, __LINE__);
1883                         uint32_t *path_arr_ptr = (uint32_t*)(((uint8_t*)path_arr) + 8);
1884                         for (size_t k = 0; k < path_var.datalen; k++) {
1885                                 LDKRouteHop path_conv_10_var = path_var.data[k];
1886                                 uint32_t path_conv_10_ref = 0;
1887                                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1888                                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1889                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
1890                                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner & ~1;
1891                                 path_arr_ptr[k] = path_conv_10_ref;
1892                         }
1893                         
1894         return path_arr;
1895 }
1896 int8_tArray __attribute__((export_name("TS_LDKEvent_ProbeFailed_get_payment_id"))) TS_LDKEvent_ProbeFailed_get_payment_id(uint32_t ptr) {
1897         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1898         assert(obj->tag == LDKEvent_ProbeFailed);
1899                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
1900                         memcpy(payment_id_arr->elems, obj->probe_failed.payment_id.data, 32);
1901         return payment_id_arr;
1902 }
1903 int8_tArray __attribute__((export_name("TS_LDKEvent_ProbeFailed_get_payment_hash"))) TS_LDKEvent_ProbeFailed_get_payment_hash(uint32_t ptr) {
1904         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1905         assert(obj->tag == LDKEvent_ProbeFailed);
1906                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1907                         memcpy(payment_hash_arr->elems, obj->probe_failed.payment_hash.data, 32);
1908         return payment_hash_arr;
1909 }
1910 uint32_tArray __attribute__((export_name("TS_LDKEvent_ProbeFailed_get_path"))) TS_LDKEvent_ProbeFailed_get_path(uint32_t ptr) {
1911         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1912         assert(obj->tag == LDKEvent_ProbeFailed);
1913                         LDKCVec_RouteHopZ path_var = obj->probe_failed.path;
1914                         uint32_tArray path_arr = NULL;
1915                         path_arr = init_uint32_tArray(path_var.datalen, __LINE__);
1916                         uint32_t *path_arr_ptr = (uint32_t*)(((uint8_t*)path_arr) + 8);
1917                         for (size_t k = 0; k < path_var.datalen; k++) {
1918                                 LDKRouteHop path_conv_10_var = path_var.data[k];
1919                                 uint32_t path_conv_10_ref = 0;
1920                                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1921                                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1922                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
1923                                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner & ~1;
1924                                 path_arr_ptr[k] = path_conv_10_ref;
1925                         }
1926                         
1927         return path_arr;
1928 }
1929 uint32_t __attribute__((export_name("TS_LDKEvent_ProbeFailed_get_short_channel_id"))) TS_LDKEvent_ProbeFailed_get_short_channel_id(uint32_t ptr) {
1930         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1931         assert(obj->tag == LDKEvent_ProbeFailed);
1932                         uint32_t short_channel_id_ref = ((uintptr_t)&obj->probe_failed.short_channel_id) | 1;
1933         return short_channel_id_ref;
1934 }
1935 int64_t __attribute__((export_name("TS_LDKEvent_PendingHTLCsForwardable_get_time_forwardable"))) TS_LDKEvent_PendingHTLCsForwardable_get_time_forwardable(uint32_t ptr) {
1936         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1937         assert(obj->tag == LDKEvent_PendingHTLCsForwardable);
1938                         int64_t time_forwardable_conv = obj->pending_htl_cs_forwardable.time_forwardable;
1939         return time_forwardable_conv;
1940 }
1941 uint32_tArray __attribute__((export_name("TS_LDKEvent_SpendableOutputs_get_outputs"))) TS_LDKEvent_SpendableOutputs_get_outputs(uint32_t ptr) {
1942         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1943         assert(obj->tag == LDKEvent_SpendableOutputs);
1944                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
1945                         uint32_tArray outputs_arr = NULL;
1946                         outputs_arr = init_uint32_tArray(outputs_var.datalen, __LINE__);
1947                         uint32_t *outputs_arr_ptr = (uint32_t*)(((uint8_t*)outputs_arr) + 8);
1948                         for (size_t b = 0; b < outputs_var.datalen; b++) {
1949                                 uint32_t outputs_conv_27_ref = ((uintptr_t)&outputs_var.data[b]) | 1;
1950                                 outputs_arr_ptr[b] = outputs_conv_27_ref;
1951                         }
1952                         
1953         return outputs_arr;
1954 }
1955 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentForwarded_get_prev_channel_id"))) TS_LDKEvent_PaymentForwarded_get_prev_channel_id(uint32_t ptr) {
1956         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1957         assert(obj->tag == LDKEvent_PaymentForwarded);
1958                         int8_tArray prev_channel_id_arr = init_int8_tArray(32, __LINE__);
1959                         memcpy(prev_channel_id_arr->elems, obj->payment_forwarded.prev_channel_id.data, 32);
1960         return prev_channel_id_arr;
1961 }
1962 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentForwarded_get_next_channel_id"))) TS_LDKEvent_PaymentForwarded_get_next_channel_id(uint32_t ptr) {
1963         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1964         assert(obj->tag == LDKEvent_PaymentForwarded);
1965                         int8_tArray next_channel_id_arr = init_int8_tArray(32, __LINE__);
1966                         memcpy(next_channel_id_arr->elems, obj->payment_forwarded.next_channel_id.data, 32);
1967         return next_channel_id_arr;
1968 }
1969 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentForwarded_get_fee_earned_msat"))) TS_LDKEvent_PaymentForwarded_get_fee_earned_msat(uint32_t ptr) {
1970         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1971         assert(obj->tag == LDKEvent_PaymentForwarded);
1972                         uint32_t fee_earned_msat_ref = ((uintptr_t)&obj->payment_forwarded.fee_earned_msat) | 1;
1973         return fee_earned_msat_ref;
1974 }
1975 jboolean __attribute__((export_name("TS_LDKEvent_PaymentForwarded_get_claim_from_onchain_tx"))) TS_LDKEvent_PaymentForwarded_get_claim_from_onchain_tx(uint32_t ptr) {
1976         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1977         assert(obj->tag == LDKEvent_PaymentForwarded);
1978                         jboolean claim_from_onchain_tx_conv = obj->payment_forwarded.claim_from_onchain_tx;
1979         return claim_from_onchain_tx_conv;
1980 }
1981 int8_tArray __attribute__((export_name("TS_LDKEvent_ChannelClosed_get_channel_id"))) TS_LDKEvent_ChannelClosed_get_channel_id(uint32_t ptr) {
1982         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1983         assert(obj->tag == LDKEvent_ChannelClosed);
1984                         int8_tArray channel_id_arr = init_int8_tArray(32, __LINE__);
1985                         memcpy(channel_id_arr->elems, obj->channel_closed.channel_id.data, 32);
1986         return channel_id_arr;
1987 }
1988 int64_t __attribute__((export_name("TS_LDKEvent_ChannelClosed_get_user_channel_id"))) TS_LDKEvent_ChannelClosed_get_user_channel_id(uint32_t ptr) {
1989         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1990         assert(obj->tag == LDKEvent_ChannelClosed);
1991                         int64_t user_channel_id_conv = obj->channel_closed.user_channel_id;
1992         return user_channel_id_conv;
1993 }
1994 uint32_t __attribute__((export_name("TS_LDKEvent_ChannelClosed_get_reason"))) TS_LDKEvent_ChannelClosed_get_reason(uint32_t ptr) {
1995         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1996         assert(obj->tag == LDKEvent_ChannelClosed);
1997                         uint32_t reason_ref = ((uintptr_t)&obj->channel_closed.reason) | 1;
1998         return reason_ref;
1999 }
2000 int8_tArray __attribute__((export_name("TS_LDKEvent_DiscardFunding_get_channel_id"))) TS_LDKEvent_DiscardFunding_get_channel_id(uint32_t ptr) {
2001         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
2002         assert(obj->tag == LDKEvent_DiscardFunding);
2003                         int8_tArray channel_id_arr = init_int8_tArray(32, __LINE__);
2004                         memcpy(channel_id_arr->elems, obj->discard_funding.channel_id.data, 32);
2005         return channel_id_arr;
2006 }
2007 int8_tArray __attribute__((export_name("TS_LDKEvent_DiscardFunding_get_transaction"))) TS_LDKEvent_DiscardFunding_get_transaction(uint32_t ptr) {
2008         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
2009         assert(obj->tag == LDKEvent_DiscardFunding);
2010                         LDKTransaction transaction_var = obj->discard_funding.transaction;
2011                         int8_tArray transaction_arr = init_int8_tArray(transaction_var.datalen, __LINE__);
2012                         memcpy(transaction_arr->elems, transaction_var.data, transaction_var.datalen);
2013         return transaction_arr;
2014 }
2015 int8_tArray __attribute__((export_name("TS_LDKEvent_OpenChannelRequest_get_temporary_channel_id"))) TS_LDKEvent_OpenChannelRequest_get_temporary_channel_id(uint32_t ptr) {
2016         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
2017         assert(obj->tag == LDKEvent_OpenChannelRequest);
2018                         int8_tArray temporary_channel_id_arr = init_int8_tArray(32, __LINE__);
2019                         memcpy(temporary_channel_id_arr->elems, obj->open_channel_request.temporary_channel_id.data, 32);
2020         return temporary_channel_id_arr;
2021 }
2022 int8_tArray __attribute__((export_name("TS_LDKEvent_OpenChannelRequest_get_counterparty_node_id"))) TS_LDKEvent_OpenChannelRequest_get_counterparty_node_id(uint32_t ptr) {
2023         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
2024         assert(obj->tag == LDKEvent_OpenChannelRequest);
2025                         int8_tArray counterparty_node_id_arr = init_int8_tArray(33, __LINE__);
2026                         memcpy(counterparty_node_id_arr->elems, obj->open_channel_request.counterparty_node_id.compressed_form, 33);
2027         return counterparty_node_id_arr;
2028 }
2029 int64_t __attribute__((export_name("TS_LDKEvent_OpenChannelRequest_get_funding_satoshis"))) TS_LDKEvent_OpenChannelRequest_get_funding_satoshis(uint32_t ptr) {
2030         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
2031         assert(obj->tag == LDKEvent_OpenChannelRequest);
2032                         int64_t funding_satoshis_conv = obj->open_channel_request.funding_satoshis;
2033         return funding_satoshis_conv;
2034 }
2035 int64_t __attribute__((export_name("TS_LDKEvent_OpenChannelRequest_get_push_msat"))) TS_LDKEvent_OpenChannelRequest_get_push_msat(uint32_t ptr) {
2036         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
2037         assert(obj->tag == LDKEvent_OpenChannelRequest);
2038                         int64_t push_msat_conv = obj->open_channel_request.push_msat;
2039         return push_msat_conv;
2040 }
2041 uint32_t __attribute__((export_name("TS_LDKEvent_OpenChannelRequest_get_channel_type"))) TS_LDKEvent_OpenChannelRequest_get_channel_type(uint32_t ptr) {
2042         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
2043         assert(obj->tag == LDKEvent_OpenChannelRequest);
2044                         LDKChannelTypeFeatures channel_type_var = obj->open_channel_request.channel_type;
2045                         uint32_t channel_type_ref = 0;
2046                         CHECK((((uintptr_t)channel_type_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2047                         CHECK((((uintptr_t)&channel_type_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2048                         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_var);
2049                         channel_type_ref = (uintptr_t)channel_type_var.inner & ~1;
2050         return channel_type_ref;
2051 }
2052 int8_tArray __attribute__((export_name("TS_LDKEvent_HTLCHandlingFailed_get_prev_channel_id"))) TS_LDKEvent_HTLCHandlingFailed_get_prev_channel_id(uint32_t ptr) {
2053         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
2054         assert(obj->tag == LDKEvent_HTLCHandlingFailed);
2055                         int8_tArray prev_channel_id_arr = init_int8_tArray(32, __LINE__);
2056                         memcpy(prev_channel_id_arr->elems, obj->htlc_handling_failed.prev_channel_id.data, 32);
2057         return prev_channel_id_arr;
2058 }
2059 uint32_t __attribute__((export_name("TS_LDKEvent_HTLCHandlingFailed_get_failed_next_destination"))) TS_LDKEvent_HTLCHandlingFailed_get_failed_next_destination(uint32_t ptr) {
2060         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
2061         assert(obj->tag == LDKEvent_HTLCHandlingFailed);
2062                         uint32_t failed_next_destination_ref = ((uintptr_t)&obj->htlc_handling_failed.failed_next_destination) | 1;
2063         return failed_next_destination_ref;
2064 }
2065 uint32_t __attribute__((export_name("TS_LDKCOption_EventZ_ty_from_ptr"))) TS_LDKCOption_EventZ_ty_from_ptr(uint32_t ptr) {
2066         LDKCOption_EventZ *obj = (LDKCOption_EventZ*)(ptr & ~1);
2067         switch(obj->tag) {
2068                 case LDKCOption_EventZ_Some: return 0;
2069                 case LDKCOption_EventZ_None: return 1;
2070                 default: abort();
2071         }
2072 }
2073 uint32_t __attribute__((export_name("TS_LDKCOption_EventZ_Some_get_some"))) TS_LDKCOption_EventZ_Some_get_some(uint32_t ptr) {
2074         LDKCOption_EventZ *obj = (LDKCOption_EventZ*)(ptr & ~1);
2075         assert(obj->tag == LDKCOption_EventZ_Some);
2076                         uint32_t some_ref = ((uintptr_t)&obj->some) | 1;
2077         return some_ref;
2078 }
2079 static inline struct LDKCOption_EventZ CResult_COption_EventZDecodeErrorZ_get_ok(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
2080 CHECK(owner->result_ok);
2081         return COption_EventZ_clone(&*owner->contents.result);
2082 }
2083 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_get_ok"))) TS_CResult_COption_EventZDecodeErrorZ_get_ok(uint32_t owner) {
2084         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(owner & ~1);
2085         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
2086         *ret_copy = CResult_COption_EventZDecodeErrorZ_get_ok(owner_conv);
2087         uint32_t ret_ref = (uintptr_t)ret_copy;
2088         return ret_ref;
2089 }
2090
2091 static inline struct LDKDecodeError CResult_COption_EventZDecodeErrorZ_get_err(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
2092 CHECK(!owner->result_ok);
2093         return DecodeError_clone(&*owner->contents.err);
2094 }
2095 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_get_err"))) TS_CResult_COption_EventZDecodeErrorZ_get_err(uint32_t owner) {
2096         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(owner & ~1);
2097         LDKDecodeError ret_var = CResult_COption_EventZDecodeErrorZ_get_err(owner_conv);
2098         uint32_t ret_ref = 0;
2099         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2100         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2101         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2102         ret_ref = (uintptr_t)ret_var.inner;
2103         if (ret_var.is_owned) {
2104                 ret_ref |= 1;
2105         }
2106         return ret_ref;
2107 }
2108
2109 uint32_t __attribute__((export_name("TS_LDKErrorAction_ty_from_ptr"))) TS_LDKErrorAction_ty_from_ptr(uint32_t ptr) {
2110         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
2111         switch(obj->tag) {
2112                 case LDKErrorAction_DisconnectPeer: return 0;
2113                 case LDKErrorAction_IgnoreError: return 1;
2114                 case LDKErrorAction_IgnoreAndLog: return 2;
2115                 case LDKErrorAction_IgnoreDuplicateGossip: return 3;
2116                 case LDKErrorAction_SendErrorMessage: return 4;
2117                 case LDKErrorAction_SendWarningMessage: return 5;
2118                 default: abort();
2119         }
2120 }
2121 uint32_t __attribute__((export_name("TS_LDKErrorAction_DisconnectPeer_get_msg"))) TS_LDKErrorAction_DisconnectPeer_get_msg(uint32_t ptr) {
2122         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
2123         assert(obj->tag == LDKErrorAction_DisconnectPeer);
2124                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
2125                         uint32_t msg_ref = 0;
2126                         if ((uintptr_t)msg_var.inner > 4096) {
2127                                 CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2128                                 CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2129                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2130                                 msg_ref = (uintptr_t)msg_var.inner & ~1;
2131                         }
2132         return msg_ref;
2133 }
2134 uint32_t __attribute__((export_name("TS_LDKErrorAction_IgnoreAndLog_get_ignore_and_log"))) TS_LDKErrorAction_IgnoreAndLog_get_ignore_and_log(uint32_t ptr) {
2135         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
2136         assert(obj->tag == LDKErrorAction_IgnoreAndLog);
2137                         uint32_t ignore_and_log_conv = LDKLevel_to_js(obj->ignore_and_log);
2138         return ignore_and_log_conv;
2139 }
2140 uint32_t __attribute__((export_name("TS_LDKErrorAction_SendErrorMessage_get_msg"))) TS_LDKErrorAction_SendErrorMessage_get_msg(uint32_t ptr) {
2141         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
2142         assert(obj->tag == LDKErrorAction_SendErrorMessage);
2143                         LDKErrorMessage msg_var = obj->send_error_message.msg;
2144                         uint32_t msg_ref = 0;
2145                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2146                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2147                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2148                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2149         return msg_ref;
2150 }
2151 uint32_t __attribute__((export_name("TS_LDKErrorAction_SendWarningMessage_get_msg"))) TS_LDKErrorAction_SendWarningMessage_get_msg(uint32_t ptr) {
2152         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
2153         assert(obj->tag == LDKErrorAction_SendWarningMessage);
2154                         LDKWarningMessage msg_var = obj->send_warning_message.msg;
2155                         uint32_t msg_ref = 0;
2156                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2157                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2158                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2159                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2160         return msg_ref;
2161 }
2162 uint32_t __attribute__((export_name("TS_LDKErrorAction_SendWarningMessage_get_log_level"))) TS_LDKErrorAction_SendWarningMessage_get_log_level(uint32_t ptr) {
2163         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
2164         assert(obj->tag == LDKErrorAction_SendWarningMessage);
2165                         uint32_t log_level_conv = LDKLevel_to_js(obj->send_warning_message.log_level);
2166         return log_level_conv;
2167 }
2168 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_ty_from_ptr"))) TS_LDKMessageSendEvent_ty_from_ptr(uint32_t ptr) {
2169         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2170         switch(obj->tag) {
2171                 case LDKMessageSendEvent_SendAcceptChannel: return 0;
2172                 case LDKMessageSendEvent_SendOpenChannel: return 1;
2173                 case LDKMessageSendEvent_SendFundingCreated: return 2;
2174                 case LDKMessageSendEvent_SendFundingSigned: return 3;
2175                 case LDKMessageSendEvent_SendChannelReady: return 4;
2176                 case LDKMessageSendEvent_SendAnnouncementSignatures: return 5;
2177                 case LDKMessageSendEvent_UpdateHTLCs: return 6;
2178                 case LDKMessageSendEvent_SendRevokeAndACK: return 7;
2179                 case LDKMessageSendEvent_SendClosingSigned: return 8;
2180                 case LDKMessageSendEvent_SendShutdown: return 9;
2181                 case LDKMessageSendEvent_SendChannelReestablish: return 10;
2182                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: return 11;
2183                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: return 12;
2184                 case LDKMessageSendEvent_BroadcastChannelUpdate: return 13;
2185                 case LDKMessageSendEvent_SendChannelUpdate: return 14;
2186                 case LDKMessageSendEvent_HandleError: return 15;
2187                 case LDKMessageSendEvent_SendChannelRangeQuery: return 16;
2188                 case LDKMessageSendEvent_SendShortIdsQuery: return 17;
2189                 case LDKMessageSendEvent_SendReplyChannelRange: return 18;
2190                 case LDKMessageSendEvent_SendGossipTimestampFilter: return 19;
2191                 default: abort();
2192         }
2193 }
2194 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendAcceptChannel_get_node_id"))) TS_LDKMessageSendEvent_SendAcceptChannel_get_node_id(uint32_t ptr) {
2195         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2196         assert(obj->tag == LDKMessageSendEvent_SendAcceptChannel);
2197                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2198                         memcpy(node_id_arr->elems, obj->send_accept_channel.node_id.compressed_form, 33);
2199         return node_id_arr;
2200 }
2201 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendAcceptChannel_get_msg"))) TS_LDKMessageSendEvent_SendAcceptChannel_get_msg(uint32_t ptr) {
2202         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2203         assert(obj->tag == LDKMessageSendEvent_SendAcceptChannel);
2204                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
2205                         uint32_t msg_ref = 0;
2206                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2207                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2208                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2209                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2210         return msg_ref;
2211 }
2212 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendOpenChannel_get_node_id"))) TS_LDKMessageSendEvent_SendOpenChannel_get_node_id(uint32_t ptr) {
2213         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2214         assert(obj->tag == LDKMessageSendEvent_SendOpenChannel);
2215                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2216                         memcpy(node_id_arr->elems, obj->send_open_channel.node_id.compressed_form, 33);
2217         return node_id_arr;
2218 }
2219 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendOpenChannel_get_msg"))) TS_LDKMessageSendEvent_SendOpenChannel_get_msg(uint32_t ptr) {
2220         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2221         assert(obj->tag == LDKMessageSendEvent_SendOpenChannel);
2222                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
2223                         uint32_t msg_ref = 0;
2224                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2225                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2226                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2227                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2228         return msg_ref;
2229 }
2230 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingCreated_get_node_id"))) TS_LDKMessageSendEvent_SendFundingCreated_get_node_id(uint32_t ptr) {
2231         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2232         assert(obj->tag == LDKMessageSendEvent_SendFundingCreated);
2233                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2234                         memcpy(node_id_arr->elems, obj->send_funding_created.node_id.compressed_form, 33);
2235         return node_id_arr;
2236 }
2237 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingCreated_get_msg"))) TS_LDKMessageSendEvent_SendFundingCreated_get_msg(uint32_t ptr) {
2238         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2239         assert(obj->tag == LDKMessageSendEvent_SendFundingCreated);
2240                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
2241                         uint32_t msg_ref = 0;
2242                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2243                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2244                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2245                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2246         return msg_ref;
2247 }
2248 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingSigned_get_node_id"))) TS_LDKMessageSendEvent_SendFundingSigned_get_node_id(uint32_t ptr) {
2249         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2250         assert(obj->tag == LDKMessageSendEvent_SendFundingSigned);
2251                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2252                         memcpy(node_id_arr->elems, obj->send_funding_signed.node_id.compressed_form, 33);
2253         return node_id_arr;
2254 }
2255 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingSigned_get_msg"))) TS_LDKMessageSendEvent_SendFundingSigned_get_msg(uint32_t ptr) {
2256         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2257         assert(obj->tag == LDKMessageSendEvent_SendFundingSigned);
2258                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
2259                         uint32_t msg_ref = 0;
2260                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2261                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2262                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2263                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2264         return msg_ref;
2265 }
2266 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelReady_get_node_id"))) TS_LDKMessageSendEvent_SendChannelReady_get_node_id(uint32_t ptr) {
2267         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2268         assert(obj->tag == LDKMessageSendEvent_SendChannelReady);
2269                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2270                         memcpy(node_id_arr->elems, obj->send_channel_ready.node_id.compressed_form, 33);
2271         return node_id_arr;
2272 }
2273 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelReady_get_msg"))) TS_LDKMessageSendEvent_SendChannelReady_get_msg(uint32_t ptr) {
2274         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2275         assert(obj->tag == LDKMessageSendEvent_SendChannelReady);
2276                         LDKChannelReady msg_var = obj->send_channel_ready.msg;
2277                         uint32_t msg_ref = 0;
2278                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2279                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2280                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2281                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2282         return msg_ref;
2283 }
2284 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendAnnouncementSignatures_get_node_id"))) TS_LDKMessageSendEvent_SendAnnouncementSignatures_get_node_id(uint32_t ptr) {
2285         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2286         assert(obj->tag == LDKMessageSendEvent_SendAnnouncementSignatures);
2287                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2288                         memcpy(node_id_arr->elems, obj->send_announcement_signatures.node_id.compressed_form, 33);
2289         return node_id_arr;
2290 }
2291 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendAnnouncementSignatures_get_msg"))) TS_LDKMessageSendEvent_SendAnnouncementSignatures_get_msg(uint32_t ptr) {
2292         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2293         assert(obj->tag == LDKMessageSendEvent_SendAnnouncementSignatures);
2294                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
2295                         uint32_t msg_ref = 0;
2296                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2297                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2298                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2299                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2300         return msg_ref;
2301 }
2302 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_UpdateHTLCs_get_node_id"))) TS_LDKMessageSendEvent_UpdateHTLCs_get_node_id(uint32_t ptr) {
2303         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2304         assert(obj->tag == LDKMessageSendEvent_UpdateHTLCs);
2305                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2306                         memcpy(node_id_arr->elems, obj->update_htl_cs.node_id.compressed_form, 33);
2307         return node_id_arr;
2308 }
2309 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_UpdateHTLCs_get_updates"))) TS_LDKMessageSendEvent_UpdateHTLCs_get_updates(uint32_t ptr) {
2310         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2311         assert(obj->tag == LDKMessageSendEvent_UpdateHTLCs);
2312                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
2313                         uint32_t updates_ref = 0;
2314                         CHECK((((uintptr_t)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2315                         CHECK((((uintptr_t)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2316                         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_var);
2317                         updates_ref = (uintptr_t)updates_var.inner & ~1;
2318         return updates_ref;
2319 }
2320 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendRevokeAndACK_get_node_id"))) TS_LDKMessageSendEvent_SendRevokeAndACK_get_node_id(uint32_t ptr) {
2321         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2322         assert(obj->tag == LDKMessageSendEvent_SendRevokeAndACK);
2323                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2324                         memcpy(node_id_arr->elems, obj->send_revoke_and_ack.node_id.compressed_form, 33);
2325         return node_id_arr;
2326 }
2327 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendRevokeAndACK_get_msg"))) TS_LDKMessageSendEvent_SendRevokeAndACK_get_msg(uint32_t ptr) {
2328         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2329         assert(obj->tag == LDKMessageSendEvent_SendRevokeAndACK);
2330                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
2331                         uint32_t msg_ref = 0;
2332                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2333                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2334                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2335                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2336         return msg_ref;
2337 }
2338 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendClosingSigned_get_node_id"))) TS_LDKMessageSendEvent_SendClosingSigned_get_node_id(uint32_t ptr) {
2339         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2340         assert(obj->tag == LDKMessageSendEvent_SendClosingSigned);
2341                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2342                         memcpy(node_id_arr->elems, obj->send_closing_signed.node_id.compressed_form, 33);
2343         return node_id_arr;
2344 }
2345 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendClosingSigned_get_msg"))) TS_LDKMessageSendEvent_SendClosingSigned_get_msg(uint32_t ptr) {
2346         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2347         assert(obj->tag == LDKMessageSendEvent_SendClosingSigned);
2348                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
2349                         uint32_t msg_ref = 0;
2350                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2351                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2352                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2353                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2354         return msg_ref;
2355 }
2356 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendShutdown_get_node_id"))) TS_LDKMessageSendEvent_SendShutdown_get_node_id(uint32_t ptr) {
2357         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2358         assert(obj->tag == LDKMessageSendEvent_SendShutdown);
2359                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2360                         memcpy(node_id_arr->elems, obj->send_shutdown.node_id.compressed_form, 33);
2361         return node_id_arr;
2362 }
2363 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendShutdown_get_msg"))) TS_LDKMessageSendEvent_SendShutdown_get_msg(uint32_t ptr) {
2364         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2365         assert(obj->tag == LDKMessageSendEvent_SendShutdown);
2366                         LDKShutdown msg_var = obj->send_shutdown.msg;
2367                         uint32_t msg_ref = 0;
2368                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2369                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2370                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2371                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2372         return msg_ref;
2373 }
2374 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelReestablish_get_node_id"))) TS_LDKMessageSendEvent_SendChannelReestablish_get_node_id(uint32_t ptr) {
2375         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2376         assert(obj->tag == LDKMessageSendEvent_SendChannelReestablish);
2377                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2378                         memcpy(node_id_arr->elems, obj->send_channel_reestablish.node_id.compressed_form, 33);
2379         return node_id_arr;
2380 }
2381 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelReestablish_get_msg"))) TS_LDKMessageSendEvent_SendChannelReestablish_get_msg(uint32_t ptr) {
2382         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2383         assert(obj->tag == LDKMessageSendEvent_SendChannelReestablish);
2384                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
2385                         uint32_t msg_ref = 0;
2386                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2387                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2388                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2389                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2390         return msg_ref;
2391 }
2392 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_BroadcastChannelAnnouncement_get_msg"))) TS_LDKMessageSendEvent_BroadcastChannelAnnouncement_get_msg(uint32_t ptr) {
2393         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2394         assert(obj->tag == LDKMessageSendEvent_BroadcastChannelAnnouncement);
2395                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
2396                         uint32_t msg_ref = 0;
2397                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2398                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2399                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2400                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2401         return msg_ref;
2402 }
2403 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_BroadcastChannelAnnouncement_get_update_msg"))) TS_LDKMessageSendEvent_BroadcastChannelAnnouncement_get_update_msg(uint32_t ptr) {
2404         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2405         assert(obj->tag == LDKMessageSendEvent_BroadcastChannelAnnouncement);
2406                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
2407                         uint32_t update_msg_ref = 0;
2408                         CHECK((((uintptr_t)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2409                         CHECK((((uintptr_t)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2410                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_var);
2411                         update_msg_ref = (uintptr_t)update_msg_var.inner & ~1;
2412         return update_msg_ref;
2413 }
2414 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_BroadcastNodeAnnouncement_get_msg"))) TS_LDKMessageSendEvent_BroadcastNodeAnnouncement_get_msg(uint32_t ptr) {
2415         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2416         assert(obj->tag == LDKMessageSendEvent_BroadcastNodeAnnouncement);
2417                         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
2418                         uint32_t msg_ref = 0;
2419                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2420                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2421                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2422                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2423         return msg_ref;
2424 }
2425 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_BroadcastChannelUpdate_get_msg"))) TS_LDKMessageSendEvent_BroadcastChannelUpdate_get_msg(uint32_t ptr) {
2426         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2427         assert(obj->tag == LDKMessageSendEvent_BroadcastChannelUpdate);
2428                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
2429                         uint32_t msg_ref = 0;
2430                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2431                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2432                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2433                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2434         return msg_ref;
2435 }
2436 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelUpdate_get_node_id"))) TS_LDKMessageSendEvent_SendChannelUpdate_get_node_id(uint32_t ptr) {
2437         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2438         assert(obj->tag == LDKMessageSendEvent_SendChannelUpdate);
2439                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2440                         memcpy(node_id_arr->elems, obj->send_channel_update.node_id.compressed_form, 33);
2441         return node_id_arr;
2442 }
2443 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelUpdate_get_msg"))) TS_LDKMessageSendEvent_SendChannelUpdate_get_msg(uint32_t ptr) {
2444         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2445         assert(obj->tag == LDKMessageSendEvent_SendChannelUpdate);
2446                         LDKChannelUpdate msg_var = obj->send_channel_update.msg;
2447                         uint32_t msg_ref = 0;
2448                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2449                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2450                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2451                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2452         return msg_ref;
2453 }
2454 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_HandleError_get_node_id"))) TS_LDKMessageSendEvent_HandleError_get_node_id(uint32_t ptr) {
2455         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2456         assert(obj->tag == LDKMessageSendEvent_HandleError);
2457                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2458                         memcpy(node_id_arr->elems, obj->handle_error.node_id.compressed_form, 33);
2459         return node_id_arr;
2460 }
2461 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_HandleError_get_action"))) TS_LDKMessageSendEvent_HandleError_get_action(uint32_t ptr) {
2462         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2463         assert(obj->tag == LDKMessageSendEvent_HandleError);
2464                         uint32_t action_ref = ((uintptr_t)&obj->handle_error.action) | 1;
2465         return action_ref;
2466 }
2467 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelRangeQuery_get_node_id"))) TS_LDKMessageSendEvent_SendChannelRangeQuery_get_node_id(uint32_t ptr) {
2468         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2469         assert(obj->tag == LDKMessageSendEvent_SendChannelRangeQuery);
2470                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2471                         memcpy(node_id_arr->elems, obj->send_channel_range_query.node_id.compressed_form, 33);
2472         return node_id_arr;
2473 }
2474 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelRangeQuery_get_msg"))) TS_LDKMessageSendEvent_SendChannelRangeQuery_get_msg(uint32_t ptr) {
2475         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2476         assert(obj->tag == LDKMessageSendEvent_SendChannelRangeQuery);
2477                         LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
2478                         uint32_t msg_ref = 0;
2479                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2480                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2481                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2482                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2483         return msg_ref;
2484 }
2485 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendShortIdsQuery_get_node_id"))) TS_LDKMessageSendEvent_SendShortIdsQuery_get_node_id(uint32_t ptr) {
2486         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2487         assert(obj->tag == LDKMessageSendEvent_SendShortIdsQuery);
2488                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2489                         memcpy(node_id_arr->elems, obj->send_short_ids_query.node_id.compressed_form, 33);
2490         return node_id_arr;
2491 }
2492 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendShortIdsQuery_get_msg"))) TS_LDKMessageSendEvent_SendShortIdsQuery_get_msg(uint32_t ptr) {
2493         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2494         assert(obj->tag == LDKMessageSendEvent_SendShortIdsQuery);
2495                         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
2496                         uint32_t msg_ref = 0;
2497                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2498                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2499                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2500                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2501         return msg_ref;
2502 }
2503 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendReplyChannelRange_get_node_id"))) TS_LDKMessageSendEvent_SendReplyChannelRange_get_node_id(uint32_t ptr) {
2504         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2505         assert(obj->tag == LDKMessageSendEvent_SendReplyChannelRange);
2506                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2507                         memcpy(node_id_arr->elems, obj->send_reply_channel_range.node_id.compressed_form, 33);
2508         return node_id_arr;
2509 }
2510 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendReplyChannelRange_get_msg"))) TS_LDKMessageSendEvent_SendReplyChannelRange_get_msg(uint32_t ptr) {
2511         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2512         assert(obj->tag == LDKMessageSendEvent_SendReplyChannelRange);
2513                         LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
2514                         uint32_t msg_ref = 0;
2515                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2516                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2517                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2518                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2519         return msg_ref;
2520 }
2521 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendGossipTimestampFilter_get_node_id"))) TS_LDKMessageSendEvent_SendGossipTimestampFilter_get_node_id(uint32_t ptr) {
2522         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2523         assert(obj->tag == LDKMessageSendEvent_SendGossipTimestampFilter);
2524                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2525                         memcpy(node_id_arr->elems, obj->send_gossip_timestamp_filter.node_id.compressed_form, 33);
2526         return node_id_arr;
2527 }
2528 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendGossipTimestampFilter_get_msg"))) TS_LDKMessageSendEvent_SendGossipTimestampFilter_get_msg(uint32_t ptr) {
2529         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2530         assert(obj->tag == LDKMessageSendEvent_SendGossipTimestampFilter);
2531                         LDKGossipTimestampFilter msg_var = obj->send_gossip_timestamp_filter.msg;
2532                         uint32_t msg_ref = 0;
2533                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2534                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2535                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2536                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2537         return msg_ref;
2538 }
2539 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
2540         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
2541         for (size_t i = 0; i < ret.datalen; i++) {
2542                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
2543         }
2544         return ret;
2545 }
2546 static inline struct LDKTxOut CResult_TxOutAccessErrorZ_get_ok(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR owner){
2547 CHECK(owner->result_ok);
2548         return TxOut_clone(&*owner->contents.result);
2549 }
2550 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_get_ok"))) TS_CResult_TxOutAccessErrorZ_get_ok(uint32_t owner) {
2551         LDKCResult_TxOutAccessErrorZ* owner_conv = (LDKCResult_TxOutAccessErrorZ*)(owner & ~1);
2552         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
2553         *ret_ref = CResult_TxOutAccessErrorZ_get_ok(owner_conv);
2554         return (uint32_t)ret_ref;
2555 }
2556
2557 static inline enum LDKAccessError CResult_TxOutAccessErrorZ_get_err(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR owner){
2558 CHECK(!owner->result_ok);
2559         return AccessError_clone(&*owner->contents.err);
2560 }
2561 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_get_err"))) TS_CResult_TxOutAccessErrorZ_get_err(uint32_t owner) {
2562         LDKCResult_TxOutAccessErrorZ* owner_conv = (LDKCResult_TxOutAccessErrorZ*)(owner & ~1);
2563         uint32_t ret_conv = LDKAccessError_to_js(CResult_TxOutAccessErrorZ_get_err(owner_conv));
2564         return ret_conv;
2565 }
2566
2567 static inline uintptr_t C2Tuple_usizeTransactionZ_get_a(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
2568         return owner->a;
2569 }
2570 uint32_t  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_get_a"))) TS_C2Tuple_usizeTransactionZ_get_a(uint32_t owner) {
2571         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)(owner & ~1);
2572         uint32_t ret_conv = C2Tuple_usizeTransactionZ_get_a(owner_conv);
2573         return ret_conv;
2574 }
2575
2576 static inline struct LDKTransaction C2Tuple_usizeTransactionZ_get_b(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
2577         return owner->b;
2578 }
2579 int8_tArray  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_get_b"))) TS_C2Tuple_usizeTransactionZ_get_b(uint32_t owner) {
2580         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)(owner & ~1);
2581         LDKTransaction ret_var = C2Tuple_usizeTransactionZ_get_b(owner_conv);
2582         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
2583         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
2584         return ret_arr;
2585 }
2586
2587 static inline LDKCVec_C2Tuple_usizeTransactionZZ CVec_C2Tuple_usizeTransactionZZ_clone(const LDKCVec_C2Tuple_usizeTransactionZZ *orig) {
2588         LDKCVec_C2Tuple_usizeTransactionZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * orig->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ clone bytes"), .datalen = orig->datalen };
2589         for (size_t i = 0; i < ret.datalen; i++) {
2590                 ret.data[i] = C2Tuple_usizeTransactionZ_clone(&orig->data[i]);
2591         }
2592         return ret;
2593 }
2594 static inline LDKCVec_TxidZ CVec_TxidZ_clone(const LDKCVec_TxidZ *orig) {
2595         LDKCVec_TxidZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_TxidZ clone bytes"), .datalen = orig->datalen };
2596         for (size_t i = 0; i < ret.datalen; i++) {
2597                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
2598         }
2599         return ret;
2600 }
2601 static inline void CResult_NoneChannelMonitorUpdateErrZ_get_ok(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR owner){
2602 CHECK(owner->result_ok);
2603         return *owner->contents.result;
2604 }
2605 void  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_get_ok"))) TS_CResult_NoneChannelMonitorUpdateErrZ_get_ok(uint32_t owner) {
2606         LDKCResult_NoneChannelMonitorUpdateErrZ* owner_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(owner & ~1);
2607         CResult_NoneChannelMonitorUpdateErrZ_get_ok(owner_conv);
2608 }
2609
2610 static inline enum LDKChannelMonitorUpdateErr CResult_NoneChannelMonitorUpdateErrZ_get_err(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR owner){
2611 CHECK(!owner->result_ok);
2612         return ChannelMonitorUpdateErr_clone(&*owner->contents.err);
2613 }
2614 uint32_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_get_err"))) TS_CResult_NoneChannelMonitorUpdateErrZ_get_err(uint32_t owner) {
2615         LDKCResult_NoneChannelMonitorUpdateErrZ* owner_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(owner & ~1);
2616         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(CResult_NoneChannelMonitorUpdateErrZ_get_err(owner_conv));
2617         return ret_conv;
2618 }
2619
2620 uint32_t __attribute__((export_name("TS_LDKMonitorEvent_ty_from_ptr"))) TS_LDKMonitorEvent_ty_from_ptr(uint32_t ptr) {
2621         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
2622         switch(obj->tag) {
2623                 case LDKMonitorEvent_HTLCEvent: return 0;
2624                 case LDKMonitorEvent_CommitmentTxConfirmed: return 1;
2625                 case LDKMonitorEvent_UpdateCompleted: return 2;
2626                 case LDKMonitorEvent_UpdateFailed: return 3;
2627                 default: abort();
2628         }
2629 }
2630 uint32_t __attribute__((export_name("TS_LDKMonitorEvent_HTLCEvent_get_htlc_event"))) TS_LDKMonitorEvent_HTLCEvent_get_htlc_event(uint32_t ptr) {
2631         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
2632         assert(obj->tag == LDKMonitorEvent_HTLCEvent);
2633                         LDKHTLCUpdate htlc_event_var = obj->htlc_event;
2634                         uint32_t htlc_event_ref = 0;
2635                         CHECK((((uintptr_t)htlc_event_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2636                         CHECK((((uintptr_t)&htlc_event_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2637                         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_event_var);
2638                         htlc_event_ref = (uintptr_t)htlc_event_var.inner & ~1;
2639         return htlc_event_ref;
2640 }
2641 uint32_t __attribute__((export_name("TS_LDKMonitorEvent_CommitmentTxConfirmed_get_commitment_tx_confirmed"))) TS_LDKMonitorEvent_CommitmentTxConfirmed_get_commitment_tx_confirmed(uint32_t ptr) {
2642         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
2643         assert(obj->tag == LDKMonitorEvent_CommitmentTxConfirmed);
2644                         LDKOutPoint commitment_tx_confirmed_var = obj->commitment_tx_confirmed;
2645                         uint32_t commitment_tx_confirmed_ref = 0;
2646                         CHECK((((uintptr_t)commitment_tx_confirmed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2647                         CHECK((((uintptr_t)&commitment_tx_confirmed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2648                         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_confirmed_var);
2649                         commitment_tx_confirmed_ref = (uintptr_t)commitment_tx_confirmed_var.inner & ~1;
2650         return commitment_tx_confirmed_ref;
2651 }
2652 uint32_t __attribute__((export_name("TS_LDKMonitorEvent_UpdateCompleted_get_funding_txo"))) TS_LDKMonitorEvent_UpdateCompleted_get_funding_txo(uint32_t ptr) {
2653         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
2654         assert(obj->tag == LDKMonitorEvent_UpdateCompleted);
2655                         LDKOutPoint funding_txo_var = obj->update_completed.funding_txo;
2656                         uint32_t funding_txo_ref = 0;
2657                         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2658                         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2659                         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
2660                         funding_txo_ref = (uintptr_t)funding_txo_var.inner & ~1;
2661         return funding_txo_ref;
2662 }
2663 int64_t __attribute__((export_name("TS_LDKMonitorEvent_UpdateCompleted_get_monitor_update_id"))) TS_LDKMonitorEvent_UpdateCompleted_get_monitor_update_id(uint32_t ptr) {
2664         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
2665         assert(obj->tag == LDKMonitorEvent_UpdateCompleted);
2666                         int64_t monitor_update_id_conv = obj->update_completed.monitor_update_id;
2667         return monitor_update_id_conv;
2668 }
2669 uint32_t __attribute__((export_name("TS_LDKMonitorEvent_UpdateFailed_get_update_failed"))) TS_LDKMonitorEvent_UpdateFailed_get_update_failed(uint32_t ptr) {
2670         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
2671         assert(obj->tag == LDKMonitorEvent_UpdateFailed);
2672                         LDKOutPoint update_failed_var = obj->update_failed;
2673                         uint32_t update_failed_ref = 0;
2674                         CHECK((((uintptr_t)update_failed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2675                         CHECK((((uintptr_t)&update_failed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2676                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_failed_var);
2677                         update_failed_ref = (uintptr_t)update_failed_var.inner & ~1;
2678         return update_failed_ref;
2679 }
2680 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
2681         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
2682         for (size_t i = 0; i < ret.datalen; i++) {
2683                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
2684         }
2685         return ret;
2686 }
2687 static inline struct LDKOutPoint C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_a(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *NONNULL_PTR owner){
2688         return OutPoint_clone(&owner->a);
2689 }
2690 uint32_t  __attribute__((export_name("TS_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_a"))) TS_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_a(uint32_t owner) {
2691         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* owner_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(owner & ~1);
2692         LDKOutPoint ret_var = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_a(owner_conv);
2693         uint32_t ret_ref = 0;
2694         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2695         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2696         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2697         ret_ref = (uintptr_t)ret_var.inner;
2698         if (ret_var.is_owned) {
2699                 ret_ref |= 1;
2700         }
2701         return ret_ref;
2702 }
2703
2704 static inline struct LDKCVec_MonitorEventZ C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_b(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *NONNULL_PTR owner){
2705         return CVec_MonitorEventZ_clone(&owner->b);
2706 }
2707 uint32_tArray  __attribute__((export_name("TS_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_b"))) TS_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_b(uint32_t owner) {
2708         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* owner_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(owner & ~1);
2709         LDKCVec_MonitorEventZ ret_var = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_b(owner_conv);
2710         uint32_tArray ret_arr = NULL;
2711         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
2712         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 8);
2713         for (size_t o = 0; o < ret_var.datalen; o++) {
2714                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
2715                 *ret_conv_14_copy = ret_var.data[o];
2716                 uint32_t ret_conv_14_ref = (uintptr_t)ret_conv_14_copy;
2717                 ret_arr_ptr[o] = ret_conv_14_ref;
2718         }
2719         
2720         FREE(ret_var.data);
2721         return ret_arr;
2722 }
2723
2724 static inline struct LDKPublicKey C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_c(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *NONNULL_PTR owner){
2725         return owner->c;
2726 }
2727 int8_tArray  __attribute__((export_name("TS_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_c"))) TS_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_c(uint32_t owner) {
2728         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* owner_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(owner & ~1);
2729         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
2730         memcpy(ret_arr->elems, C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_c(owner_conv).compressed_form, 33);
2731         return ret_arr;
2732 }
2733
2734 static inline LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ_clone(const LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ *orig) {
2735         LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ) * orig->datalen, "LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ clone bytes"), .datalen = orig->datalen };
2736         for (size_t i = 0; i < ret.datalen; i++) {
2737                 ret.data[i] = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone(&orig->data[i]);
2738         }
2739         return ret;
2740 }
2741 uint32_t __attribute__((export_name("TS_LDKCOption_C2Tuple_usizeTransactionZZ_ty_from_ptr"))) TS_LDKCOption_C2Tuple_usizeTransactionZZ_ty_from_ptr(uint32_t ptr) {
2742         LDKCOption_C2Tuple_usizeTransactionZZ *obj = (LDKCOption_C2Tuple_usizeTransactionZZ*)(ptr & ~1);
2743         switch(obj->tag) {
2744                 case LDKCOption_C2Tuple_usizeTransactionZZ_Some: return 0;
2745                 case LDKCOption_C2Tuple_usizeTransactionZZ_None: return 1;
2746                 default: abort();
2747         }
2748 }
2749 uint32_t __attribute__((export_name("TS_LDKCOption_C2Tuple_usizeTransactionZZ_Some_get_some"))) TS_LDKCOption_C2Tuple_usizeTransactionZZ_Some_get_some(uint32_t ptr) {
2750         LDKCOption_C2Tuple_usizeTransactionZZ *obj = (LDKCOption_C2Tuple_usizeTransactionZZ*)(ptr & ~1);
2751         assert(obj->tag == LDKCOption_C2Tuple_usizeTransactionZZ_Some);
2752                         LDKC2Tuple_usizeTransactionZ* some_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
2753                         *some_conv = obj->some;
2754                         *some_conv = C2Tuple_usizeTransactionZ_clone(some_conv);
2755         return ((uint32_t)some_conv);
2756 }
2757 static inline struct LDKFixedPenaltyScorer CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR owner){
2758 CHECK(owner->result_ok);
2759         return FixedPenaltyScorer_clone(&*owner->contents.result);
2760 }
2761 uint32_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_get_ok"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(uint32_t owner) {
2762         LDKCResult_FixedPenaltyScorerDecodeErrorZ* owner_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(owner & ~1);
2763         LDKFixedPenaltyScorer ret_var = CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(owner_conv);
2764         uint32_t ret_ref = 0;
2765         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2766         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2767         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2768         ret_ref = (uintptr_t)ret_var.inner;
2769         if (ret_var.is_owned) {
2770                 ret_ref |= 1;
2771         }
2772         return ret_ref;
2773 }
2774
2775 static inline struct LDKDecodeError CResult_FixedPenaltyScorerDecodeErrorZ_get_err(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR owner){
2776 CHECK(!owner->result_ok);
2777         return DecodeError_clone(&*owner->contents.err);
2778 }
2779 uint32_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_get_err"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_get_err(uint32_t owner) {
2780         LDKCResult_FixedPenaltyScorerDecodeErrorZ* owner_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(owner & ~1);
2781         LDKDecodeError ret_var = CResult_FixedPenaltyScorerDecodeErrorZ_get_err(owner_conv);
2782         uint32_t ret_ref = 0;
2783         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2784         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2785         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2786         ret_ref = (uintptr_t)ret_var.inner;
2787         if (ret_var.is_owned) {
2788                 ret_ref |= 1;
2789         }
2790         return ret_ref;
2791 }
2792
2793 static inline uint64_t C2Tuple_u64u64Z_get_a(LDKC2Tuple_u64u64Z *NONNULL_PTR owner){
2794         return owner->a;
2795 }
2796 int64_t  __attribute__((export_name("TS_C2Tuple_u64u64Z_get_a"))) TS_C2Tuple_u64u64Z_get_a(uint32_t owner) {
2797         LDKC2Tuple_u64u64Z* owner_conv = (LDKC2Tuple_u64u64Z*)(owner & ~1);
2798         int64_t ret_conv = C2Tuple_u64u64Z_get_a(owner_conv);
2799         return ret_conv;
2800 }
2801
2802 static inline uint64_t C2Tuple_u64u64Z_get_b(LDKC2Tuple_u64u64Z *NONNULL_PTR owner){
2803         return owner->b;
2804 }
2805 int64_t  __attribute__((export_name("TS_C2Tuple_u64u64Z_get_b"))) TS_C2Tuple_u64u64Z_get_b(uint32_t owner) {
2806         LDKC2Tuple_u64u64Z* owner_conv = (LDKC2Tuple_u64u64Z*)(owner & ~1);
2807         int64_t ret_conv = C2Tuple_u64u64Z_get_b(owner_conv);
2808         return ret_conv;
2809 }
2810
2811 uint32_t __attribute__((export_name("TS_LDKCOption_C2Tuple_u64u64ZZ_ty_from_ptr"))) TS_LDKCOption_C2Tuple_u64u64ZZ_ty_from_ptr(uint32_t ptr) {
2812         LDKCOption_C2Tuple_u64u64ZZ *obj = (LDKCOption_C2Tuple_u64u64ZZ*)(ptr & ~1);
2813         switch(obj->tag) {
2814                 case LDKCOption_C2Tuple_u64u64ZZ_Some: return 0;
2815                 case LDKCOption_C2Tuple_u64u64ZZ_None: return 1;
2816                 default: abort();
2817         }
2818 }
2819 uint32_t __attribute__((export_name("TS_LDKCOption_C2Tuple_u64u64ZZ_Some_get_some"))) TS_LDKCOption_C2Tuple_u64u64ZZ_Some_get_some(uint32_t ptr) {
2820         LDKCOption_C2Tuple_u64u64ZZ *obj = (LDKCOption_C2Tuple_u64u64ZZ*)(ptr & ~1);
2821         assert(obj->tag == LDKCOption_C2Tuple_u64u64ZZ_Some);
2822                         LDKC2Tuple_u64u64Z* some_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
2823                         *some_conv = obj->some;
2824                         *some_conv = C2Tuple_u64u64Z_clone(some_conv);
2825         return ((uint32_t)some_conv);
2826 }
2827 static inline LDKCVec_NodeIdZ CVec_NodeIdZ_clone(const LDKCVec_NodeIdZ *orig) {
2828         LDKCVec_NodeIdZ ret = { .data = MALLOC(sizeof(LDKNodeId) * orig->datalen, "LDKCVec_NodeIdZ clone bytes"), .datalen = orig->datalen };
2829         for (size_t i = 0; i < ret.datalen; i++) {
2830                 ret.data[i] = NodeId_clone(&orig->data[i]);
2831         }
2832         return ret;
2833 }
2834 typedef struct LDKLogger_JCalls {
2835         atomic_size_t refcnt;
2836         uint32_t instance_ptr;
2837 } LDKLogger_JCalls;
2838 static void LDKLogger_JCalls_free(void* this_arg) {
2839         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
2840         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2841                 FREE(j_calls);
2842         }
2843 }
2844 void log_LDKLogger_jcall(const void* this_arg, const LDKRecord * record) {
2845         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
2846         LDKRecord record_var = *record;
2847         uint32_t record_ref = 0;
2848         record_var = Record_clone(&record_var);
2849         CHECK((((uintptr_t)record_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2850         CHECK((((uintptr_t)&record_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2851         CHECK_INNER_FIELD_ACCESS_OR_NULL(record_var);
2852         record_ref = (uintptr_t)record_var.inner;
2853         if (record_var.is_owned) {
2854                 record_ref |= 1;
2855         }
2856         js_invoke_function_uuuuuu(j_calls->instance_ptr, 0, (uint32_t)record_ref, 0, 0, 0, 0, 0);
2857 }
2858 static void LDKLogger_JCalls_cloned(LDKLogger* new_obj) {
2859         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) new_obj->this_arg;
2860         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2861 }
2862 static inline LDKLogger LDKLogger_init (JSValue o) {
2863         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
2864         atomic_init(&calls->refcnt, 1);
2865         calls->instance_ptr = o;
2866
2867         LDKLogger ret = {
2868                 .this_arg = (void*) calls,
2869                 .log = log_LDKLogger_jcall,
2870                 .free = LDKLogger_JCalls_free,
2871         };
2872         return ret;
2873 }
2874 long  __attribute__((export_name("TS_LDKLogger_new"))) TS_LDKLogger_new(JSValue o) {
2875         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
2876         *res_ptr = LDKLogger_init(o);
2877         return (long)res_ptr;
2878 }
2879 static inline struct LDKProbabilisticScorer *CResult_ProbabilisticScorerDecodeErrorZ_get_ok(LDKCResult_ProbabilisticScorerDecodeErrorZ *NONNULL_PTR owner){
2880 CHECK(owner->result_ok);
2881         return &*owner->contents.result;
2882 }
2883 uint32_t  __attribute__((export_name("TS_CResult_ProbabilisticScorerDecodeErrorZ_get_ok"))) TS_CResult_ProbabilisticScorerDecodeErrorZ_get_ok(uint32_t owner) {
2884         LDKCResult_ProbabilisticScorerDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)(owner & ~1);
2885         LDKProbabilisticScorer ret_var = *CResult_ProbabilisticScorerDecodeErrorZ_get_ok(owner_conv);
2886         uint32_t ret_ref = 0;
2887         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2888         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2889         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2890         ret_ref = (uintptr_t)ret_var.inner & ~1;
2891         return ret_ref;
2892 }
2893
2894 static inline struct LDKDecodeError CResult_ProbabilisticScorerDecodeErrorZ_get_err(LDKCResult_ProbabilisticScorerDecodeErrorZ *NONNULL_PTR owner){
2895 CHECK(!owner->result_ok);
2896         return DecodeError_clone(&*owner->contents.err);
2897 }
2898 uint32_t  __attribute__((export_name("TS_CResult_ProbabilisticScorerDecodeErrorZ_get_err"))) TS_CResult_ProbabilisticScorerDecodeErrorZ_get_err(uint32_t owner) {
2899         LDKCResult_ProbabilisticScorerDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)(owner & ~1);
2900         LDKDecodeError ret_var = CResult_ProbabilisticScorerDecodeErrorZ_get_err(owner_conv);
2901         uint32_t ret_ref = 0;
2902         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2903         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2904         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2905         ret_ref = (uintptr_t)ret_var.inner;
2906         if (ret_var.is_owned) {
2907                 ret_ref |= 1;
2908         }
2909         return ret_ref;
2910 }
2911
2912 static inline struct LDKInitFeatures CResult_InitFeaturesDecodeErrorZ_get_ok(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
2913 CHECK(owner->result_ok);
2914         return InitFeatures_clone(&*owner->contents.result);
2915 }
2916 uint32_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_get_ok"))) TS_CResult_InitFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
2917         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(owner & ~1);
2918         LDKInitFeatures ret_var = CResult_InitFeaturesDecodeErrorZ_get_ok(owner_conv);
2919         uint32_t ret_ref = 0;
2920         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2921         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2922         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2923         ret_ref = (uintptr_t)ret_var.inner;
2924         if (ret_var.is_owned) {
2925                 ret_ref |= 1;
2926         }
2927         return ret_ref;
2928 }
2929
2930 static inline struct LDKDecodeError CResult_InitFeaturesDecodeErrorZ_get_err(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
2931 CHECK(!owner->result_ok);
2932         return DecodeError_clone(&*owner->contents.err);
2933 }
2934 uint32_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_get_err"))) TS_CResult_InitFeaturesDecodeErrorZ_get_err(uint32_t owner) {
2935         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(owner & ~1);
2936         LDKDecodeError ret_var = CResult_InitFeaturesDecodeErrorZ_get_err(owner_conv);
2937         uint32_t ret_ref = 0;
2938         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2939         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2940         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2941         ret_ref = (uintptr_t)ret_var.inner;
2942         if (ret_var.is_owned) {
2943                 ret_ref |= 1;
2944         }
2945         return ret_ref;
2946 }
2947
2948 static inline struct LDKChannelFeatures CResult_ChannelFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
2949 CHECK(owner->result_ok);
2950         return ChannelFeatures_clone(&*owner->contents.result);
2951 }
2952 uint32_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_get_ok"))) TS_CResult_ChannelFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
2953         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(owner & ~1);
2954         LDKChannelFeatures ret_var = CResult_ChannelFeaturesDecodeErrorZ_get_ok(owner_conv);
2955         uint32_t ret_ref = 0;
2956         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2957         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2958         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2959         ret_ref = (uintptr_t)ret_var.inner;
2960         if (ret_var.is_owned) {
2961                 ret_ref |= 1;
2962         }
2963         return ret_ref;
2964 }
2965
2966 static inline struct LDKDecodeError CResult_ChannelFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
2967 CHECK(!owner->result_ok);
2968         return DecodeError_clone(&*owner->contents.err);
2969 }
2970 uint32_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_get_err"))) TS_CResult_ChannelFeaturesDecodeErrorZ_get_err(uint32_t owner) {
2971         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(owner & ~1);
2972         LDKDecodeError ret_var = CResult_ChannelFeaturesDecodeErrorZ_get_err(owner_conv);
2973         uint32_t ret_ref = 0;
2974         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2975         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2976         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2977         ret_ref = (uintptr_t)ret_var.inner;
2978         if (ret_var.is_owned) {
2979                 ret_ref |= 1;
2980         }
2981         return ret_ref;
2982 }
2983
2984 static inline struct LDKNodeFeatures CResult_NodeFeaturesDecodeErrorZ_get_ok(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
2985 CHECK(owner->result_ok);
2986         return NodeFeatures_clone(&*owner->contents.result);
2987 }
2988 uint32_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_get_ok"))) TS_CResult_NodeFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
2989         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(owner & ~1);
2990         LDKNodeFeatures ret_var = CResult_NodeFeaturesDecodeErrorZ_get_ok(owner_conv);
2991         uint32_t ret_ref = 0;
2992         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2993         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2994         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2995         ret_ref = (uintptr_t)ret_var.inner;
2996         if (ret_var.is_owned) {
2997                 ret_ref |= 1;
2998         }
2999         return ret_ref;
3000 }
3001
3002 static inline struct LDKDecodeError CResult_NodeFeaturesDecodeErrorZ_get_err(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
3003 CHECK(!owner->result_ok);
3004         return DecodeError_clone(&*owner->contents.err);
3005 }
3006 uint32_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_get_err"))) TS_CResult_NodeFeaturesDecodeErrorZ_get_err(uint32_t owner) {
3007         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(owner & ~1);
3008         LDKDecodeError ret_var = CResult_NodeFeaturesDecodeErrorZ_get_err(owner_conv);
3009         uint32_t ret_ref = 0;
3010         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3011         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3012         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3013         ret_ref = (uintptr_t)ret_var.inner;
3014         if (ret_var.is_owned) {
3015                 ret_ref |= 1;
3016         }
3017         return ret_ref;
3018 }
3019
3020 static inline struct LDKInvoiceFeatures CResult_InvoiceFeaturesDecodeErrorZ_get_ok(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
3021 CHECK(owner->result_ok);
3022         return InvoiceFeatures_clone(&*owner->contents.result);
3023 }
3024 uint32_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_get_ok"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
3025         LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(owner & ~1);
3026         LDKInvoiceFeatures ret_var = CResult_InvoiceFeaturesDecodeErrorZ_get_ok(owner_conv);
3027         uint32_t ret_ref = 0;
3028         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3029         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3030         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3031         ret_ref = (uintptr_t)ret_var.inner;
3032         if (ret_var.is_owned) {
3033                 ret_ref |= 1;
3034         }
3035         return ret_ref;
3036 }
3037
3038 static inline struct LDKDecodeError CResult_InvoiceFeaturesDecodeErrorZ_get_err(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
3039 CHECK(!owner->result_ok);
3040         return DecodeError_clone(&*owner->contents.err);
3041 }
3042 uint32_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_get_err"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_get_err(uint32_t owner) {
3043         LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(owner & ~1);
3044         LDKDecodeError ret_var = CResult_InvoiceFeaturesDecodeErrorZ_get_err(owner_conv);
3045         uint32_t ret_ref = 0;
3046         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3047         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3048         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3049         ret_ref = (uintptr_t)ret_var.inner;
3050         if (ret_var.is_owned) {
3051                 ret_ref |= 1;
3052         }
3053         return ret_ref;
3054 }
3055
3056 static inline struct LDKChannelTypeFeatures CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
3057 CHECK(owner->result_ok);
3058         return ChannelTypeFeatures_clone(&*owner->contents.result);
3059 }
3060 uint32_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
3061         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(owner & ~1);
3062         LDKChannelTypeFeatures ret_var = CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(owner_conv);
3063         uint32_t ret_ref = 0;
3064         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3065         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3066         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3067         ret_ref = (uintptr_t)ret_var.inner;
3068         if (ret_var.is_owned) {
3069                 ret_ref |= 1;
3070         }
3071         return ret_ref;
3072 }
3073
3074 static inline struct LDKDecodeError CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
3075 CHECK(!owner->result_ok);
3076         return DecodeError_clone(&*owner->contents.err);
3077 }
3078 uint32_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_get_err"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(uint32_t owner) {
3079         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(owner & ~1);
3080         LDKDecodeError ret_var = CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(owner_conv);
3081         uint32_t ret_ref = 0;
3082         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3083         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3084         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3085         ret_ref = (uintptr_t)ret_var.inner;
3086         if (ret_var.is_owned) {
3087                 ret_ref |= 1;
3088         }
3089         return ret_ref;
3090 }
3091
3092 static inline struct LDKNodeId CResult_NodeIdDecodeErrorZ_get_ok(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
3093 CHECK(owner->result_ok);
3094         return NodeId_clone(&*owner->contents.result);
3095 }
3096 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_get_ok"))) TS_CResult_NodeIdDecodeErrorZ_get_ok(uint32_t owner) {
3097         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)(owner & ~1);
3098         LDKNodeId ret_var = CResult_NodeIdDecodeErrorZ_get_ok(owner_conv);
3099         uint32_t ret_ref = 0;
3100         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3101         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3102         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3103         ret_ref = (uintptr_t)ret_var.inner;
3104         if (ret_var.is_owned) {
3105                 ret_ref |= 1;
3106         }
3107         return ret_ref;
3108 }
3109
3110 static inline struct LDKDecodeError CResult_NodeIdDecodeErrorZ_get_err(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
3111 CHECK(!owner->result_ok);
3112         return DecodeError_clone(&*owner->contents.err);
3113 }
3114 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_get_err"))) TS_CResult_NodeIdDecodeErrorZ_get_err(uint32_t owner) {
3115         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)(owner & ~1);
3116         LDKDecodeError ret_var = CResult_NodeIdDecodeErrorZ_get_err(owner_conv);
3117         uint32_t ret_ref = 0;
3118         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3119         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3120         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3121         ret_ref = (uintptr_t)ret_var.inner;
3122         if (ret_var.is_owned) {
3123                 ret_ref |= 1;
3124         }
3125         return ret_ref;
3126 }
3127
3128 static inline struct LDKCOption_NetworkUpdateZ CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
3129 CHECK(owner->result_ok);
3130         return COption_NetworkUpdateZ_clone(&*owner->contents.result);
3131 }
3132 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(uint32_t owner) {
3133         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(owner & ~1);
3134         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
3135         *ret_copy = CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(owner_conv);
3136         uint32_t ret_ref = (uintptr_t)ret_copy;
3137         return ret_ref;
3138 }
3139
3140 static inline struct LDKDecodeError CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
3141 CHECK(!owner->result_ok);
3142         return DecodeError_clone(&*owner->contents.err);
3143 }
3144 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_get_err"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(uint32_t owner) {
3145         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(owner & ~1);
3146         LDKDecodeError ret_var = CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(owner_conv);
3147         uint32_t ret_ref = 0;
3148         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3149         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3150         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3151         ret_ref = (uintptr_t)ret_var.inner;
3152         if (ret_var.is_owned) {
3153                 ret_ref |= 1;
3154         }
3155         return ret_ref;
3156 }
3157
3158 typedef struct LDKAccess_JCalls {
3159         atomic_size_t refcnt;
3160         uint32_t instance_ptr;
3161 } LDKAccess_JCalls;
3162 static void LDKAccess_JCalls_free(void* this_arg) {
3163         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
3164         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3165                 FREE(j_calls);
3166         }
3167 }
3168 LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
3169         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
3170         int8_tArray genesis_hash_arr = init_int8_tArray(32, __LINE__);
3171         memcpy(genesis_hash_arr->elems, *genesis_hash, 32);
3172         int64_t short_channel_id_conv = short_channel_id;
3173         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);
3174         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3175         CHECK_ACCESS(ret_ptr);
3176         LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(ret_ptr);
3177         FREE((void*)ret);
3178         return ret_conv;
3179 }
3180 static void LDKAccess_JCalls_cloned(LDKAccess* new_obj) {
3181         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) new_obj->this_arg;
3182         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3183 }
3184 static inline LDKAccess LDKAccess_init (JSValue o) {
3185         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
3186         atomic_init(&calls->refcnt, 1);
3187         calls->instance_ptr = o;
3188
3189         LDKAccess ret = {
3190                 .this_arg = (void*) calls,
3191                 .get_utxo = get_utxo_LDKAccess_jcall,
3192                 .free = LDKAccess_JCalls_free,
3193         };
3194         return ret;
3195 }
3196 long  __attribute__((export_name("TS_LDKAccess_new"))) TS_LDKAccess_new(JSValue o) {
3197         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
3198         *res_ptr = LDKAccess_init(o);
3199         return (long)res_ptr;
3200 }
3201 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) {
3202         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3203         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3204         LDKAccess* this_arg_conv = (LDKAccess*)this_arg_ptr;
3205         unsigned char genesis_hash_arr[32];
3206         CHECK(genesis_hash->arr_len == 32);
3207         memcpy(genesis_hash_arr, genesis_hash->elems, 32); FREE(genesis_hash);
3208         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
3209         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
3210         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
3211         return (uint32_t)ret_conv;
3212 }
3213
3214 uint32_t __attribute__((export_name("TS_LDKCOption_AccessZ_ty_from_ptr"))) TS_LDKCOption_AccessZ_ty_from_ptr(uint32_t ptr) {
3215         LDKCOption_AccessZ *obj = (LDKCOption_AccessZ*)(ptr & ~1);
3216         switch(obj->tag) {
3217                 case LDKCOption_AccessZ_Some: return 0;
3218                 case LDKCOption_AccessZ_None: return 1;
3219                 default: abort();
3220         }
3221 }
3222 uint32_t __attribute__((export_name("TS_LDKCOption_AccessZ_Some_get_some"))) TS_LDKCOption_AccessZ_Some_get_some(uint32_t ptr) {
3223         LDKCOption_AccessZ *obj = (LDKCOption_AccessZ*)(ptr & ~1);
3224         assert(obj->tag == LDKCOption_AccessZ_Some);
3225                         LDKAccess* some_ret = MALLOC(sizeof(LDKAccess), "LDKAccess");
3226                         *some_ret = obj->some;
3227                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
3228                         if ((*some_ret).free == LDKAccess_JCalls_free) {
3229                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
3230                                 LDKAccess_JCalls_cloned(&(*some_ret));
3231                         }
3232         return (uint32_t)some_ret;
3233 }
3234 static inline bool CResult_boolLightningErrorZ_get_ok(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
3235 CHECK(owner->result_ok);
3236         return *owner->contents.result;
3237 }
3238 jboolean  __attribute__((export_name("TS_CResult_boolLightningErrorZ_get_ok"))) TS_CResult_boolLightningErrorZ_get_ok(uint32_t owner) {
3239         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)(owner & ~1);
3240         jboolean ret_conv = CResult_boolLightningErrorZ_get_ok(owner_conv);
3241         return ret_conv;
3242 }
3243
3244 static inline struct LDKLightningError CResult_boolLightningErrorZ_get_err(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
3245 CHECK(!owner->result_ok);
3246         return LightningError_clone(&*owner->contents.err);
3247 }
3248 uint32_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_get_err"))) TS_CResult_boolLightningErrorZ_get_err(uint32_t owner) {
3249         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)(owner & ~1);
3250         LDKLightningError ret_var = CResult_boolLightningErrorZ_get_err(owner_conv);
3251         uint32_t ret_ref = 0;
3252         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3253         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3254         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3255         ret_ref = (uintptr_t)ret_var.inner;
3256         if (ret_var.is_owned) {
3257                 ret_ref |= 1;
3258         }
3259         return ret_ref;
3260 }
3261
3262 static inline struct LDKChannelAnnouncement C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
3263         return ChannelAnnouncement_clone(&owner->a);
3264 }
3265 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(uint32_t owner) {
3266         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
3267         LDKChannelAnnouncement ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(owner_conv);
3268         uint32_t ret_ref = 0;
3269         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3270         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3271         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3272         ret_ref = (uintptr_t)ret_var.inner;
3273         if (ret_var.is_owned) {
3274                 ret_ref |= 1;
3275         }
3276         return ret_ref;
3277 }
3278
3279 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
3280         return ChannelUpdate_clone(&owner->b);
3281 }
3282 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(uint32_t owner) {
3283         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
3284         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(owner_conv);
3285         uint32_t ret_ref = 0;
3286         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3287         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3288         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3289         ret_ref = (uintptr_t)ret_var.inner;
3290         if (ret_var.is_owned) {
3291                 ret_ref |= 1;
3292         }
3293         return ret_ref;
3294 }
3295
3296 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
3297         return ChannelUpdate_clone(&owner->c);
3298 }
3299 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(uint32_t owner) {
3300         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
3301         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(owner_conv);
3302         uint32_t ret_ref = 0;
3303         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3304         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3305         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3306         ret_ref = (uintptr_t)ret_var.inner;
3307         if (ret_var.is_owned) {
3308                 ret_ref |= 1;
3309         }
3310         return ret_ref;
3311 }
3312
3313 static inline LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *orig) {
3314         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * orig->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ clone bytes"), .datalen = orig->datalen };
3315         for (size_t i = 0; i < ret.datalen; i++) {
3316                 ret.data[i] = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(&orig->data[i]);
3317         }
3318         return ret;
3319 }
3320 static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCVec_NodeAnnouncementZ *orig) {
3321         LDKCVec_NodeAnnouncementZ ret = { .data = MALLOC(sizeof(LDKNodeAnnouncement) * orig->datalen, "LDKCVec_NodeAnnouncementZ clone bytes"), .datalen = orig->datalen };
3322         for (size_t i = 0; i < ret.datalen; i++) {
3323                 ret.data[i] = NodeAnnouncement_clone(&orig->data[i]);
3324         }
3325         return ret;
3326 }
3327 static inline void CResult_NoneLightningErrorZ_get_ok(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
3328 CHECK(owner->result_ok);
3329         return *owner->contents.result;
3330 }
3331 void  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_get_ok"))) TS_CResult_NoneLightningErrorZ_get_ok(uint32_t owner) {
3332         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)(owner & ~1);
3333         CResult_NoneLightningErrorZ_get_ok(owner_conv);
3334 }
3335
3336 static inline struct LDKLightningError CResult_NoneLightningErrorZ_get_err(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
3337 CHECK(!owner->result_ok);
3338         return LightningError_clone(&*owner->contents.err);
3339 }
3340 uint32_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_get_err"))) TS_CResult_NoneLightningErrorZ_get_err(uint32_t owner) {
3341         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)(owner & ~1);
3342         LDKLightningError ret_var = CResult_NoneLightningErrorZ_get_err(owner_conv);
3343         uint32_t ret_ref = 0;
3344         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3345         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3346         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3347         ret_ref = (uintptr_t)ret_var.inner;
3348         if (ret_var.is_owned) {
3349                 ret_ref |= 1;
3350         }
3351         return ret_ref;
3352 }
3353
3354 static inline struct LDKChannelUpdateInfo CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR owner){
3355 CHECK(owner->result_ok);
3356         return ChannelUpdateInfo_clone(&*owner->contents.result);
3357 }
3358 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_get_ok"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(uint32_t owner) {
3359         LDKCResult_ChannelUpdateInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(owner & ~1);
3360         LDKChannelUpdateInfo ret_var = CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(owner_conv);
3361         uint32_t ret_ref = 0;
3362         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3363         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3364         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3365         ret_ref = (uintptr_t)ret_var.inner;
3366         if (ret_var.is_owned) {
3367                 ret_ref |= 1;
3368         }
3369         return ret_ref;
3370 }
3371
3372 static inline struct LDKDecodeError CResult_ChannelUpdateInfoDecodeErrorZ_get_err(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR owner){
3373 CHECK(!owner->result_ok);
3374         return DecodeError_clone(&*owner->contents.err);
3375 }
3376 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_get_err"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_get_err(uint32_t owner) {
3377         LDKCResult_ChannelUpdateInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(owner & ~1);
3378         LDKDecodeError ret_var = CResult_ChannelUpdateInfoDecodeErrorZ_get_err(owner_conv);
3379         uint32_t ret_ref = 0;
3380         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3381         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3382         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3383         ret_ref = (uintptr_t)ret_var.inner;
3384         if (ret_var.is_owned) {
3385                 ret_ref |= 1;
3386         }
3387         return ret_ref;
3388 }
3389
3390 static inline struct LDKChannelInfo CResult_ChannelInfoDecodeErrorZ_get_ok(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
3391 CHECK(owner->result_ok);
3392         return ChannelInfo_clone(&*owner->contents.result);
3393 }
3394 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_get_ok"))) TS_CResult_ChannelInfoDecodeErrorZ_get_ok(uint32_t owner) {
3395         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(owner & ~1);
3396         LDKChannelInfo ret_var = CResult_ChannelInfoDecodeErrorZ_get_ok(owner_conv);
3397         uint32_t ret_ref = 0;
3398         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3399         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3400         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3401         ret_ref = (uintptr_t)ret_var.inner;
3402         if (ret_var.is_owned) {
3403                 ret_ref |= 1;
3404         }
3405         return ret_ref;
3406 }
3407
3408 static inline struct LDKDecodeError CResult_ChannelInfoDecodeErrorZ_get_err(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
3409 CHECK(!owner->result_ok);
3410         return DecodeError_clone(&*owner->contents.err);
3411 }
3412 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_get_err"))) TS_CResult_ChannelInfoDecodeErrorZ_get_err(uint32_t owner) {
3413         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(owner & ~1);
3414         LDKDecodeError ret_var = CResult_ChannelInfoDecodeErrorZ_get_err(owner_conv);
3415         uint32_t ret_ref = 0;
3416         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3417         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3418         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3419         ret_ref = (uintptr_t)ret_var.inner;
3420         if (ret_var.is_owned) {
3421                 ret_ref |= 1;
3422         }
3423         return ret_ref;
3424 }
3425
3426 static inline struct LDKRoutingFees CResult_RoutingFeesDecodeErrorZ_get_ok(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
3427 CHECK(owner->result_ok);
3428         return RoutingFees_clone(&*owner->contents.result);
3429 }
3430 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_get_ok"))) TS_CResult_RoutingFeesDecodeErrorZ_get_ok(uint32_t owner) {
3431         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(owner & ~1);
3432         LDKRoutingFees ret_var = CResult_RoutingFeesDecodeErrorZ_get_ok(owner_conv);
3433         uint32_t ret_ref = 0;
3434         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3435         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3436         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3437         ret_ref = (uintptr_t)ret_var.inner;
3438         if (ret_var.is_owned) {
3439                 ret_ref |= 1;
3440         }
3441         return ret_ref;
3442 }
3443
3444 static inline struct LDKDecodeError CResult_RoutingFeesDecodeErrorZ_get_err(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
3445 CHECK(!owner->result_ok);
3446         return DecodeError_clone(&*owner->contents.err);
3447 }
3448 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_get_err"))) TS_CResult_RoutingFeesDecodeErrorZ_get_err(uint32_t owner) {
3449         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(owner & ~1);
3450         LDKDecodeError ret_var = CResult_RoutingFeesDecodeErrorZ_get_err(owner_conv);
3451         uint32_t ret_ref = 0;
3452         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3453         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3454         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3455         ret_ref = (uintptr_t)ret_var.inner;
3456         if (ret_var.is_owned) {
3457                 ret_ref |= 1;
3458         }
3459         return ret_ref;
3460 }
3461
3462 uint32_t __attribute__((export_name("TS_LDKNetAddress_ty_from_ptr"))) TS_LDKNetAddress_ty_from_ptr(uint32_t ptr) {
3463         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3464         switch(obj->tag) {
3465                 case LDKNetAddress_IPv4: return 0;
3466                 case LDKNetAddress_IPv6: return 1;
3467                 case LDKNetAddress_OnionV2: return 2;
3468                 case LDKNetAddress_OnionV3: return 3;
3469                 case LDKNetAddress_Hostname: return 4;
3470                 default: abort();
3471         }
3472 }
3473 int8_tArray __attribute__((export_name("TS_LDKNetAddress_IPv4_get_addr"))) TS_LDKNetAddress_IPv4_get_addr(uint32_t ptr) {
3474         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3475         assert(obj->tag == LDKNetAddress_IPv4);
3476                         int8_tArray addr_arr = init_int8_tArray(4, __LINE__);
3477                         memcpy(addr_arr->elems, obj->i_pv4.addr.data, 4);
3478         return addr_arr;
3479 }
3480 int16_t __attribute__((export_name("TS_LDKNetAddress_IPv4_get_port"))) TS_LDKNetAddress_IPv4_get_port(uint32_t ptr) {
3481         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3482         assert(obj->tag == LDKNetAddress_IPv4);
3483                         int16_t port_conv = obj->i_pv4.port;
3484         return port_conv;
3485 }
3486 int8_tArray __attribute__((export_name("TS_LDKNetAddress_IPv6_get_addr"))) TS_LDKNetAddress_IPv6_get_addr(uint32_t ptr) {
3487         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3488         assert(obj->tag == LDKNetAddress_IPv6);
3489                         int8_tArray addr_arr = init_int8_tArray(16, __LINE__);
3490                         memcpy(addr_arr->elems, obj->i_pv6.addr.data, 16);
3491         return addr_arr;
3492 }
3493 int16_t __attribute__((export_name("TS_LDKNetAddress_IPv6_get_port"))) TS_LDKNetAddress_IPv6_get_port(uint32_t ptr) {
3494         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3495         assert(obj->tag == LDKNetAddress_IPv6);
3496                         int16_t port_conv = obj->i_pv6.port;
3497         return port_conv;
3498 }
3499 int8_tArray __attribute__((export_name("TS_LDKNetAddress_OnionV2_get_onion_v2"))) TS_LDKNetAddress_OnionV2_get_onion_v2(uint32_t ptr) {
3500         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3501         assert(obj->tag == LDKNetAddress_OnionV2);
3502                         int8_tArray onion_v2_arr = init_int8_tArray(12, __LINE__);
3503                         memcpy(onion_v2_arr->elems, obj->onion_v2.data, 12);
3504         return onion_v2_arr;
3505 }
3506 int8_tArray __attribute__((export_name("TS_LDKNetAddress_OnionV3_get_ed25519_pubkey"))) TS_LDKNetAddress_OnionV3_get_ed25519_pubkey(uint32_t ptr) {
3507         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3508         assert(obj->tag == LDKNetAddress_OnionV3);
3509                         int8_tArray ed25519_pubkey_arr = init_int8_tArray(32, __LINE__);
3510                         memcpy(ed25519_pubkey_arr->elems, obj->onion_v3.ed25519_pubkey.data, 32);
3511         return ed25519_pubkey_arr;
3512 }
3513 int16_t __attribute__((export_name("TS_LDKNetAddress_OnionV3_get_checksum"))) TS_LDKNetAddress_OnionV3_get_checksum(uint32_t ptr) {
3514         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3515         assert(obj->tag == LDKNetAddress_OnionV3);
3516                         int16_t checksum_conv = obj->onion_v3.checksum;
3517         return checksum_conv;
3518 }
3519 int8_t __attribute__((export_name("TS_LDKNetAddress_OnionV3_get_version"))) TS_LDKNetAddress_OnionV3_get_version(uint32_t ptr) {
3520         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3521         assert(obj->tag == LDKNetAddress_OnionV3);
3522                         int8_t version_conv = obj->onion_v3.version;
3523         return version_conv;
3524 }
3525 int16_t __attribute__((export_name("TS_LDKNetAddress_OnionV3_get_port"))) TS_LDKNetAddress_OnionV3_get_port(uint32_t ptr) {
3526         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3527         assert(obj->tag == LDKNetAddress_OnionV3);
3528                         int16_t port_conv = obj->onion_v3.port;
3529         return port_conv;
3530 }
3531 uint32_t __attribute__((export_name("TS_LDKNetAddress_Hostname_get_hostname"))) TS_LDKNetAddress_Hostname_get_hostname(uint32_t ptr) {
3532         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3533         assert(obj->tag == LDKNetAddress_Hostname);
3534                         LDKHostname hostname_var = obj->hostname.hostname;
3535                         uint32_t hostname_ref = 0;
3536                         CHECK((((uintptr_t)hostname_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3537                         CHECK((((uintptr_t)&hostname_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3538                         CHECK_INNER_FIELD_ACCESS_OR_NULL(hostname_var);
3539                         hostname_ref = (uintptr_t)hostname_var.inner & ~1;
3540         return hostname_ref;
3541 }
3542 int16_t __attribute__((export_name("TS_LDKNetAddress_Hostname_get_port"))) TS_LDKNetAddress_Hostname_get_port(uint32_t ptr) {
3543         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3544         assert(obj->tag == LDKNetAddress_Hostname);
3545                         int16_t port_conv = obj->hostname.port;
3546         return port_conv;
3547 }
3548 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
3549         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
3550         for (size_t i = 0; i < ret.datalen; i++) {
3551                 ret.data[i] = NetAddress_clone(&orig->data[i]);
3552         }
3553         return ret;
3554 }
3555 static inline struct LDKNodeAnnouncementInfo CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
3556 CHECK(owner->result_ok);
3557         return NodeAnnouncementInfo_clone(&*owner->contents.result);
3558 }
3559 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(uint32_t owner) {
3560         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(owner & ~1);
3561         LDKNodeAnnouncementInfo ret_var = CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(owner_conv);
3562         uint32_t ret_ref = 0;
3563         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3564         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3565         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3566         ret_ref = (uintptr_t)ret_var.inner;
3567         if (ret_var.is_owned) {
3568                 ret_ref |= 1;
3569         }
3570         return ret_ref;
3571 }
3572
3573 static inline struct LDKDecodeError CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
3574 CHECK(!owner->result_ok);
3575         return DecodeError_clone(&*owner->contents.err);
3576 }
3577 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_get_err"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(uint32_t owner) {
3578         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(owner & ~1);
3579         LDKDecodeError ret_var = CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(owner_conv);
3580         uint32_t ret_ref = 0;
3581         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3582         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3583         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3584         ret_ref = (uintptr_t)ret_var.inner;
3585         if (ret_var.is_owned) {
3586                 ret_ref |= 1;
3587         }
3588         return ret_ref;
3589 }
3590
3591 static inline struct LDKNodeAlias CResult_NodeAliasDecodeErrorZ_get_ok(LDKCResult_NodeAliasDecodeErrorZ *NONNULL_PTR owner){
3592 CHECK(owner->result_ok);
3593         return NodeAlias_clone(&*owner->contents.result);
3594 }
3595 uint32_t  __attribute__((export_name("TS_CResult_NodeAliasDecodeErrorZ_get_ok"))) TS_CResult_NodeAliasDecodeErrorZ_get_ok(uint32_t owner) {
3596         LDKCResult_NodeAliasDecodeErrorZ* owner_conv = (LDKCResult_NodeAliasDecodeErrorZ*)(owner & ~1);
3597         LDKNodeAlias ret_var = CResult_NodeAliasDecodeErrorZ_get_ok(owner_conv);
3598         uint32_t ret_ref = 0;
3599         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3600         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3601         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3602         ret_ref = (uintptr_t)ret_var.inner;
3603         if (ret_var.is_owned) {
3604                 ret_ref |= 1;
3605         }
3606         return ret_ref;
3607 }
3608
3609 static inline struct LDKDecodeError CResult_NodeAliasDecodeErrorZ_get_err(LDKCResult_NodeAliasDecodeErrorZ *NONNULL_PTR owner){
3610 CHECK(!owner->result_ok);
3611         return DecodeError_clone(&*owner->contents.err);
3612 }
3613 uint32_t  __attribute__((export_name("TS_CResult_NodeAliasDecodeErrorZ_get_err"))) TS_CResult_NodeAliasDecodeErrorZ_get_err(uint32_t owner) {
3614         LDKCResult_NodeAliasDecodeErrorZ* owner_conv = (LDKCResult_NodeAliasDecodeErrorZ*)(owner & ~1);
3615         LDKDecodeError ret_var = CResult_NodeAliasDecodeErrorZ_get_err(owner_conv);
3616         uint32_t ret_ref = 0;
3617         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3618         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3619         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3620         ret_ref = (uintptr_t)ret_var.inner;
3621         if (ret_var.is_owned) {
3622                 ret_ref |= 1;
3623         }
3624         return ret_ref;
3625 }
3626
3627 static inline struct LDKNodeInfo CResult_NodeInfoDecodeErrorZ_get_ok(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
3628 CHECK(owner->result_ok);
3629         return NodeInfo_clone(&*owner->contents.result);
3630 }
3631 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_get_ok"))) TS_CResult_NodeInfoDecodeErrorZ_get_ok(uint32_t owner) {
3632         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(owner & ~1);
3633         LDKNodeInfo ret_var = CResult_NodeInfoDecodeErrorZ_get_ok(owner_conv);
3634         uint32_t ret_ref = 0;
3635         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3636         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3637         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3638         ret_ref = (uintptr_t)ret_var.inner;
3639         if (ret_var.is_owned) {
3640                 ret_ref |= 1;
3641         }
3642         return ret_ref;
3643 }
3644
3645 static inline struct LDKDecodeError CResult_NodeInfoDecodeErrorZ_get_err(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
3646 CHECK(!owner->result_ok);
3647         return DecodeError_clone(&*owner->contents.err);
3648 }
3649 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_get_err"))) TS_CResult_NodeInfoDecodeErrorZ_get_err(uint32_t owner) {
3650         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(owner & ~1);
3651         LDKDecodeError ret_var = CResult_NodeInfoDecodeErrorZ_get_err(owner_conv);
3652         uint32_t ret_ref = 0;
3653         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3654         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3655         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3656         ret_ref = (uintptr_t)ret_var.inner;
3657         if (ret_var.is_owned) {
3658                 ret_ref |= 1;
3659         }
3660         return ret_ref;
3661 }
3662
3663 static inline struct LDKNetworkGraph *CResult_NetworkGraphDecodeErrorZ_get_ok(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
3664 CHECK(owner->result_ok);
3665         return &*owner->contents.result;
3666 }
3667 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_get_ok"))) TS_CResult_NetworkGraphDecodeErrorZ_get_ok(uint32_t owner) {
3668         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(owner & ~1);
3669         LDKNetworkGraph ret_var = *CResult_NetworkGraphDecodeErrorZ_get_ok(owner_conv);
3670         uint32_t ret_ref = 0;
3671         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3672         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3673         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3674         ret_ref = (uintptr_t)ret_var.inner & ~1;
3675         return ret_ref;
3676 }
3677
3678 static inline struct LDKDecodeError CResult_NetworkGraphDecodeErrorZ_get_err(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
3679 CHECK(!owner->result_ok);
3680         return DecodeError_clone(&*owner->contents.err);
3681 }
3682 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_get_err"))) TS_CResult_NetworkGraphDecodeErrorZ_get_err(uint32_t owner) {
3683         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(owner & ~1);
3684         LDKDecodeError ret_var = CResult_NetworkGraphDecodeErrorZ_get_err(owner_conv);
3685         uint32_t ret_ref = 0;
3686         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3687         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3688         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3689         ret_ref = (uintptr_t)ret_var.inner;
3690         if (ret_var.is_owned) {
3691                 ret_ref |= 1;
3692         }
3693         return ret_ref;
3694 }
3695
3696 uint32_t __attribute__((export_name("TS_LDKCOption_CVec_NetAddressZZ_ty_from_ptr"))) TS_LDKCOption_CVec_NetAddressZZ_ty_from_ptr(uint32_t ptr) {
3697         LDKCOption_CVec_NetAddressZZ *obj = (LDKCOption_CVec_NetAddressZZ*)(ptr & ~1);
3698         switch(obj->tag) {
3699                 case LDKCOption_CVec_NetAddressZZ_Some: return 0;
3700                 case LDKCOption_CVec_NetAddressZZ_None: return 1;
3701                 default: abort();
3702         }
3703 }
3704 uint32_tArray __attribute__((export_name("TS_LDKCOption_CVec_NetAddressZZ_Some_get_some"))) TS_LDKCOption_CVec_NetAddressZZ_Some_get_some(uint32_t ptr) {
3705         LDKCOption_CVec_NetAddressZZ *obj = (LDKCOption_CVec_NetAddressZZ*)(ptr & ~1);
3706         assert(obj->tag == LDKCOption_CVec_NetAddressZZ_Some);
3707                         LDKCVec_NetAddressZ some_var = obj->some;
3708                         uint32_tArray some_arr = NULL;
3709                         some_arr = init_uint32_tArray(some_var.datalen, __LINE__);
3710                         uint32_t *some_arr_ptr = (uint32_t*)(((uint8_t*)some_arr) + 8);
3711                         for (size_t m = 0; m < some_var.datalen; m++) {
3712                                 uint32_t some_conv_12_ref = ((uintptr_t)&some_var.data[m]) | 1;
3713                                 some_arr_ptr[m] = some_conv_12_ref;
3714                         }
3715                         
3716         return some_arr;
3717 }
3718 static inline struct LDKDelayedPaymentOutputDescriptor CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3719 CHECK(owner->result_ok);
3720         return DelayedPaymentOutputDescriptor_clone(&*owner->contents.result);
3721 }
3722 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(uint32_t owner) {
3723         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
3724         LDKDelayedPaymentOutputDescriptor ret_var = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
3725         uint32_t ret_ref = 0;
3726         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3727         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3728         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3729         ret_ref = (uintptr_t)ret_var.inner;
3730         if (ret_var.is_owned) {
3731                 ret_ref |= 1;
3732         }
3733         return ret_ref;
3734 }
3735
3736 static inline struct LDKDecodeError CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3737 CHECK(!owner->result_ok);
3738         return DecodeError_clone(&*owner->contents.err);
3739 }
3740 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(uint32_t owner) {
3741         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
3742         LDKDecodeError ret_var = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
3743         uint32_t ret_ref = 0;
3744         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3745         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3746         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3747         ret_ref = (uintptr_t)ret_var.inner;
3748         if (ret_var.is_owned) {
3749                 ret_ref |= 1;
3750         }
3751         return ret_ref;
3752 }
3753
3754 static inline struct LDKStaticPaymentOutputDescriptor CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3755 CHECK(owner->result_ok);
3756         return StaticPaymentOutputDescriptor_clone(&*owner->contents.result);
3757 }
3758 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(uint32_t owner) {
3759         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
3760         LDKStaticPaymentOutputDescriptor ret_var = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
3761         uint32_t ret_ref = 0;
3762         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3763         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3764         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3765         ret_ref = (uintptr_t)ret_var.inner;
3766         if (ret_var.is_owned) {
3767                 ret_ref |= 1;
3768         }
3769         return ret_ref;
3770 }
3771
3772 static inline struct LDKDecodeError CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3773 CHECK(!owner->result_ok);
3774         return DecodeError_clone(&*owner->contents.err);
3775 }
3776 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(uint32_t owner) {
3777         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
3778         LDKDecodeError ret_var = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
3779         uint32_t ret_ref = 0;
3780         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3781         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3782         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3783         ret_ref = (uintptr_t)ret_var.inner;
3784         if (ret_var.is_owned) {
3785                 ret_ref |= 1;
3786         }
3787         return ret_ref;
3788 }
3789
3790 static inline struct LDKSpendableOutputDescriptor CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3791 CHECK(owner->result_ok);
3792         return SpendableOutputDescriptor_clone(&*owner->contents.result);
3793 }
3794 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(uint32_t owner) {
3795         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(owner & ~1);
3796         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
3797         *ret_copy = CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
3798         uint32_t ret_ref = (uintptr_t)ret_copy;
3799         return ret_ref;
3800 }
3801
3802 static inline struct LDKDecodeError CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3803 CHECK(!owner->result_ok);
3804         return DecodeError_clone(&*owner->contents.err);
3805 }
3806 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_get_err"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(uint32_t owner) {
3807         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(owner & ~1);
3808         LDKDecodeError ret_var = CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(owner_conv);
3809         uint32_t ret_ref = 0;
3810         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3811         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3812         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3813         ret_ref = (uintptr_t)ret_var.inner;
3814         if (ret_var.is_owned) {
3815                 ret_ref |= 1;
3816         }
3817         return ret_ref;
3818 }
3819
3820 static inline LDKCVec_PaymentPreimageZ CVec_PaymentPreimageZ_clone(const LDKCVec_PaymentPreimageZ *orig) {
3821         LDKCVec_PaymentPreimageZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_PaymentPreimageZ clone bytes"), .datalen = orig->datalen };
3822         for (size_t i = 0; i < ret.datalen; i++) {
3823                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
3824         }
3825         return ret;
3826 }
3827 static inline struct LDKSignature C2Tuple_SignatureCVec_SignatureZZ_get_a(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
3828         return owner->a;
3829 }
3830 int8_tArray  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_get_a"))) TS_C2Tuple_SignatureCVec_SignatureZZ_get_a(uint32_t owner) {
3831         LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(owner & ~1);
3832         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
3833         memcpy(ret_arr->elems, C2Tuple_SignatureCVec_SignatureZZ_get_a(owner_conv).compact_form, 64);
3834         return ret_arr;
3835 }
3836
3837 static inline struct LDKCVec_SignatureZ C2Tuple_SignatureCVec_SignatureZZ_get_b(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
3838         return owner->b;
3839 }
3840 ptrArray  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_get_b"))) TS_C2Tuple_SignatureCVec_SignatureZZ_get_b(uint32_t owner) {
3841         LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(owner & ~1);
3842         LDKCVec_SignatureZ ret_var = C2Tuple_SignatureCVec_SignatureZZ_get_b(owner_conv);
3843         ptrArray ret_arr = NULL;
3844         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
3845         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 8);
3846         for (size_t m = 0; m < ret_var.datalen; m++) {
3847                 int8_tArray ret_conv_12_arr = init_int8_tArray(64, __LINE__);
3848                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].compact_form, 64);
3849                 ret_arr_ptr[m] = ret_conv_12_arr;
3850         }
3851         
3852         return ret_arr;
3853 }
3854
3855 static inline struct LDKC2Tuple_SignatureCVec_SignatureZZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
3856 CHECK(owner->result_ok);
3857         return C2Tuple_SignatureCVec_SignatureZZ_clone(&*owner->contents.result);
3858 }
3859 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(uint32_t owner) {
3860         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(owner & ~1);
3861         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
3862         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(owner_conv);
3863         return ((uint32_t)ret_conv);
3864 }
3865
3866 static inline void CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
3867 CHECK(!owner->result_ok);
3868         return *owner->contents.err;
3869 }
3870 void  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(uint32_t owner) {
3871         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(owner & ~1);
3872         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(owner_conv);
3873 }
3874
3875 static inline struct LDKSignature CResult_SignatureNoneZ_get_ok(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
3876 CHECK(owner->result_ok);
3877         return *owner->contents.result;
3878 }
3879 int8_tArray  __attribute__((export_name("TS_CResult_SignatureNoneZ_get_ok"))) TS_CResult_SignatureNoneZ_get_ok(uint32_t owner) {
3880         LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)(owner & ~1);
3881         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
3882         memcpy(ret_arr->elems, CResult_SignatureNoneZ_get_ok(owner_conv).compact_form, 64);
3883         return ret_arr;
3884 }
3885
3886 static inline void CResult_SignatureNoneZ_get_err(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
3887 CHECK(!owner->result_ok);
3888         return *owner->contents.err;
3889 }
3890 void  __attribute__((export_name("TS_CResult_SignatureNoneZ_get_err"))) TS_CResult_SignatureNoneZ_get_err(uint32_t owner) {
3891         LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)(owner & ~1);
3892         CResult_SignatureNoneZ_get_err(owner_conv);
3893 }
3894
3895 static inline struct LDKSignature C2Tuple_SignatureSignatureZ_get_a(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR owner){
3896         return owner->a;
3897 }
3898 int8_tArray  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_get_a"))) TS_C2Tuple_SignatureSignatureZ_get_a(uint32_t owner) {
3899         LDKC2Tuple_SignatureSignatureZ* owner_conv = (LDKC2Tuple_SignatureSignatureZ*)(owner & ~1);
3900         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
3901         memcpy(ret_arr->elems, C2Tuple_SignatureSignatureZ_get_a(owner_conv).compact_form, 64);
3902         return ret_arr;
3903 }
3904
3905 static inline struct LDKSignature C2Tuple_SignatureSignatureZ_get_b(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR owner){
3906         return owner->b;
3907 }
3908 int8_tArray  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_get_b"))) TS_C2Tuple_SignatureSignatureZ_get_b(uint32_t owner) {
3909         LDKC2Tuple_SignatureSignatureZ* owner_conv = (LDKC2Tuple_SignatureSignatureZ*)(owner & ~1);
3910         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
3911         memcpy(ret_arr->elems, C2Tuple_SignatureSignatureZ_get_b(owner_conv).compact_form, 64);
3912         return ret_arr;
3913 }
3914
3915 static inline struct LDKC2Tuple_SignatureSignatureZ CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR owner){
3916 CHECK(owner->result_ok);
3917         return C2Tuple_SignatureSignatureZ_clone(&*owner->contents.result);
3918 }
3919 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(uint32_t owner) {
3920         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(owner & ~1);
3921         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
3922         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(owner_conv);
3923         return ((uint32_t)ret_conv);
3924 }
3925
3926 static inline void CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR owner){
3927 CHECK(!owner->result_ok);
3928         return *owner->contents.err;
3929 }
3930 void  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_get_err"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(uint32_t owner) {
3931         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(owner & ~1);
3932         CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(owner_conv);
3933 }
3934
3935 static inline struct LDKSecretKey CResult_SecretKeyNoneZ_get_ok(LDKCResult_SecretKeyNoneZ *NONNULL_PTR owner){
3936 CHECK(owner->result_ok);
3937         return *owner->contents.result;
3938 }
3939 int8_tArray  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_get_ok"))) TS_CResult_SecretKeyNoneZ_get_ok(uint32_t owner) {
3940         LDKCResult_SecretKeyNoneZ* owner_conv = (LDKCResult_SecretKeyNoneZ*)(owner & ~1);
3941         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
3942         memcpy(ret_arr->elems, CResult_SecretKeyNoneZ_get_ok(owner_conv).bytes, 32);
3943         return ret_arr;
3944 }
3945
3946 static inline void CResult_SecretKeyNoneZ_get_err(LDKCResult_SecretKeyNoneZ *NONNULL_PTR owner){
3947 CHECK(!owner->result_ok);
3948         return *owner->contents.err;
3949 }
3950 void  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_get_err"))) TS_CResult_SecretKeyNoneZ_get_err(uint32_t owner) {
3951         LDKCResult_SecretKeyNoneZ* owner_conv = (LDKCResult_SecretKeyNoneZ*)(owner & ~1);
3952         CResult_SecretKeyNoneZ_get_err(owner_conv);
3953 }
3954
3955 typedef struct LDKBaseSign_JCalls {
3956         atomic_size_t refcnt;
3957         uint32_t instance_ptr;
3958 } LDKBaseSign_JCalls;
3959 static void LDKBaseSign_JCalls_free(void* this_arg) {
3960         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3961         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3962                 FREE(j_calls);
3963         }
3964 }
3965 LDKPublicKey get_per_commitment_point_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
3966         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3967         int64_t idx_conv = idx;
3968         int8_tArray ret = (int8_tArray)js_invoke_function_buuuuu(j_calls->instance_ptr, 2, (uint32_t)idx_conv, 0, 0, 0, 0, 0);
3969         LDKPublicKey ret_ref;
3970         CHECK(ret->arr_len == 33);
3971         memcpy(ret_ref.compressed_form, ret->elems, 33); FREE(ret);
3972         return ret_ref;
3973 }
3974 LDKThirtyTwoBytes release_commitment_secret_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
3975         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3976         int64_t idx_conv = idx;
3977         int8_tArray ret = (int8_tArray)js_invoke_function_buuuuu(j_calls->instance_ptr, 3, (uint32_t)idx_conv, 0, 0, 0, 0, 0);
3978         LDKThirtyTwoBytes ret_ref;
3979         CHECK(ret->arr_len == 32);
3980         memcpy(ret_ref.data, ret->elems, 32); FREE(ret);
3981         return ret_ref;
3982 }
3983 LDKCResult_NoneNoneZ validate_holder_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * holder_tx, LDKCVec_PaymentPreimageZ preimages) {
3984         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3985         LDKHolderCommitmentTransaction holder_tx_var = *holder_tx;
3986         uint32_t holder_tx_ref = 0;
3987         holder_tx_var = HolderCommitmentTransaction_clone(&holder_tx_var);
3988         CHECK((((uintptr_t)holder_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3989         CHECK((((uintptr_t)&holder_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3990         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_var);
3991         holder_tx_ref = (uintptr_t)holder_tx_var.inner;
3992         if (holder_tx_var.is_owned) {
3993                 holder_tx_ref |= 1;
3994         }
3995         LDKCVec_PaymentPreimageZ preimages_var = preimages;
3996         ptrArray preimages_arr = NULL;
3997         preimages_arr = init_ptrArray(preimages_var.datalen, __LINE__);
3998         int8_tArray *preimages_arr_ptr = (int8_tArray*)(((uint8_t*)preimages_arr) + 8);
3999         for (size_t m = 0; m < preimages_var.datalen; m++) {
4000                 int8_tArray preimages_conv_12_arr = init_int8_tArray(32, __LINE__);
4001                 memcpy(preimages_conv_12_arr->elems, preimages_var.data[m].data, 32);
4002                 preimages_arr_ptr[m] = preimages_conv_12_arr;
4003         }
4004         
4005         FREE(preimages_var.data);
4006         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);
4007         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4008         CHECK_ACCESS(ret_ptr);
4009         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
4010         FREE((void*)ret);
4011         return ret_conv;
4012 }
4013 LDKThirtyTwoBytes channel_keys_id_LDKBaseSign_jcall(const void* this_arg) {
4014         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4015         int8_tArray ret = (int8_tArray)js_invoke_function_uuuuuu(j_calls->instance_ptr, 5, 0, 0, 0, 0, 0, 0);
4016         LDKThirtyTwoBytes ret_ref;
4017         CHECK(ret->arr_len == 32);
4018         memcpy(ret_ref.data, ret->elems, 32); FREE(ret);
4019         return ret_ref;
4020 }
4021 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx, LDKCVec_PaymentPreimageZ preimages) {
4022         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4023         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
4024         uint32_t commitment_tx_ref = 0;
4025         commitment_tx_var = CommitmentTransaction_clone(&commitment_tx_var);
4026         CHECK((((uintptr_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4027         CHECK((((uintptr_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4028         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
4029         commitment_tx_ref = (uintptr_t)commitment_tx_var.inner;
4030         if (commitment_tx_var.is_owned) {
4031                 commitment_tx_ref |= 1;
4032         }
4033         LDKCVec_PaymentPreimageZ preimages_var = preimages;
4034         ptrArray preimages_arr = NULL;
4035         preimages_arr = init_ptrArray(preimages_var.datalen, __LINE__);
4036         int8_tArray *preimages_arr_ptr = (int8_tArray*)(((uint8_t*)preimages_arr) + 8);
4037         for (size_t m = 0; m < preimages_var.datalen; m++) {
4038                 int8_tArray preimages_conv_12_arr = init_int8_tArray(32, __LINE__);
4039                 memcpy(preimages_conv_12_arr->elems, preimages_var.data[m].data, 32);
4040                 preimages_arr_ptr[m] = preimages_conv_12_arr;
4041         }
4042         
4043         FREE(preimages_var.data);
4044         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);
4045         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4046         CHECK_ACCESS(ret_ptr);
4047         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
4048         FREE((void*)ret);
4049         return ret_conv;
4050 }
4051 LDKCResult_NoneNoneZ validate_counterparty_revocation_LDKBaseSign_jcall(const void* this_arg, uint64_t idx, const uint8_t (* secret)[32]) {
4052         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4053         int64_t idx_conv = idx;
4054         int8_tArray secret_arr = init_int8_tArray(32, __LINE__);
4055         memcpy(secret_arr->elems, *secret, 32);
4056         uint32_t ret = js_invoke_function_buuuuu(j_calls->instance_ptr, 7, (uint32_t)idx_conv, (uint32_t)secret_arr, 0, 0, 0, 0);
4057         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4058         CHECK_ACCESS(ret_ptr);
4059         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
4060         FREE((void*)ret);
4061         return ret_conv;
4062 }
4063 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
4064         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4065         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
4066         uint32_t commitment_tx_ref = 0;
4067         commitment_tx_var = HolderCommitmentTransaction_clone(&commitment_tx_var);
4068         CHECK((((uintptr_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4069         CHECK((((uintptr_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4070         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
4071         commitment_tx_ref = (uintptr_t)commitment_tx_var.inner;
4072         if (commitment_tx_var.is_owned) {
4073                 commitment_tx_ref |= 1;
4074         }
4075         uint32_t ret = js_invoke_function_uuuuuu(j_calls->instance_ptr, 8, (uint32_t)commitment_tx_ref, 0, 0, 0, 0, 0);
4076         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4077         CHECK_ACCESS(ret_ptr);
4078         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
4079         FREE((void*)ret);
4080         return ret_conv;
4081 }
4082 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]) {
4083         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4084         LDKTransaction justice_tx_var = justice_tx;
4085         int8_tArray justice_tx_arr = init_int8_tArray(justice_tx_var.datalen, __LINE__);
4086         memcpy(justice_tx_arr->elems, justice_tx_var.data, justice_tx_var.datalen);
4087         Transaction_free(justice_tx_var);
4088         uint32_t input_conv = input;
4089         int64_t amount_conv = amount;
4090         int8_tArray per_commitment_key_arr = init_int8_tArray(32, __LINE__);
4091         memcpy(per_commitment_key_arr->elems, *per_commitment_key, 32);
4092         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);
4093         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4094         CHECK_ACCESS(ret_ptr);
4095         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
4096         FREE((void*)ret);
4097         return ret_conv;
4098 }
4099 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) {
4100         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4101         LDKTransaction justice_tx_var = justice_tx;
4102         int8_tArray justice_tx_arr = init_int8_tArray(justice_tx_var.datalen, __LINE__);
4103         memcpy(justice_tx_arr->elems, justice_tx_var.data, justice_tx_var.datalen);
4104         Transaction_free(justice_tx_var);
4105         uint32_t input_conv = input;
4106         int64_t amount_conv = amount;
4107         int8_tArray per_commitment_key_arr = init_int8_tArray(32, __LINE__);
4108         memcpy(per_commitment_key_arr->elems, *per_commitment_key, 32);
4109         LDKHTLCOutputInCommitment htlc_var = *htlc;
4110         uint32_t htlc_ref = 0;
4111         htlc_var = HTLCOutputInCommitment_clone(&htlc_var);
4112         CHECK((((uintptr_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4113         CHECK((((uintptr_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4114         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
4115         htlc_ref = (uintptr_t)htlc_var.inner;
4116         if (htlc_var.is_owned) {
4117                 htlc_ref |= 1;
4118         }
4119         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);
4120         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4121         CHECK_ACCESS(ret_ptr);
4122         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
4123         FREE((void*)ret);
4124         return ret_conv;
4125 }
4126 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) {
4127         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4128         LDKTransaction htlc_tx_var = htlc_tx;
4129         int8_tArray htlc_tx_arr = init_int8_tArray(htlc_tx_var.datalen, __LINE__);
4130         memcpy(htlc_tx_arr->elems, htlc_tx_var.data, htlc_tx_var.datalen);
4131         Transaction_free(htlc_tx_var);
4132         uint32_t input_conv = input;
4133         int64_t amount_conv = amount;
4134         int8_tArray per_commitment_point_arr = init_int8_tArray(33, __LINE__);
4135         memcpy(per_commitment_point_arr->elems, per_commitment_point.compressed_form, 33);
4136         LDKHTLCOutputInCommitment htlc_var = *htlc;
4137         uint32_t htlc_ref = 0;
4138         htlc_var = HTLCOutputInCommitment_clone(&htlc_var);
4139         CHECK((((uintptr_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4140         CHECK((((uintptr_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4141         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
4142         htlc_ref = (uintptr_t)htlc_var.inner;
4143         if (htlc_var.is_owned) {
4144                 htlc_ref |= 1;
4145         }
4146         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);
4147         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4148         CHECK_ACCESS(ret_ptr);
4149         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
4150         FREE((void*)ret);
4151         return ret_conv;
4152 }
4153 LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* this_arg, const LDKClosingTransaction * closing_tx) {
4154         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4155         LDKClosingTransaction closing_tx_var = *closing_tx;
4156         uint32_t closing_tx_ref = 0;
4157         closing_tx_var = ClosingTransaction_clone(&closing_tx_var);
4158         CHECK((((uintptr_t)closing_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4159         CHECK((((uintptr_t)&closing_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4160         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_var);
4161         closing_tx_ref = (uintptr_t)closing_tx_var.inner;
4162         if (closing_tx_var.is_owned) {
4163                 closing_tx_ref |= 1;
4164         }
4165         uint32_t ret = js_invoke_function_uuuuuu(j_calls->instance_ptr, 12, (uint32_t)closing_tx_ref, 0, 0, 0, 0, 0);
4166         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4167         CHECK_ACCESS(ret_ptr);
4168         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
4169         FREE((void*)ret);
4170         return ret_conv;
4171 }
4172 LDKCResult_C2Tuple_SignatureSignatureZNoneZ sign_channel_announcement_LDKBaseSign_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
4173         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4174         LDKUnsignedChannelAnnouncement msg_var = *msg;
4175         uint32_t msg_ref = 0;
4176         msg_var = UnsignedChannelAnnouncement_clone(&msg_var);
4177         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4178         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4179         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4180         msg_ref = (uintptr_t)msg_var.inner;
4181         if (msg_var.is_owned) {
4182                 msg_ref |= 1;
4183         }
4184         uint32_t ret = js_invoke_function_uuuuuu(j_calls->instance_ptr, 13, (uint32_t)msg_ref, 0, 0, 0, 0, 0);
4185         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4186         CHECK_ACCESS(ret_ptr);
4187         LDKCResult_C2Tuple_SignatureSignatureZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(ret_ptr);
4188         FREE((void*)ret);
4189         return ret_conv;
4190 }
4191 void ready_channel_LDKBaseSign_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
4192         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4193         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
4194         uint32_t channel_parameters_ref = 0;
4195         channel_parameters_var = ChannelTransactionParameters_clone(&channel_parameters_var);
4196         CHECK((((uintptr_t)channel_parameters_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4197         CHECK((((uintptr_t)&channel_parameters_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4198         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_var);
4199         channel_parameters_ref = (uintptr_t)channel_parameters_var.inner;
4200         if (channel_parameters_var.is_owned) {
4201                 channel_parameters_ref |= 1;
4202         }
4203         js_invoke_function_uuuuuu(j_calls->instance_ptr, 14, (uint32_t)channel_parameters_ref, 0, 0, 0, 0, 0);
4204 }
4205 static void LDKBaseSign_JCalls_cloned(LDKBaseSign* new_obj) {
4206         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) new_obj->this_arg;
4207         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4208 }
4209 static inline LDKBaseSign LDKBaseSign_init (JSValue o, uint32_t pubkeys) {
4210         LDKBaseSign_JCalls *calls = MALLOC(sizeof(LDKBaseSign_JCalls), "LDKBaseSign_JCalls");
4211         atomic_init(&calls->refcnt, 1);
4212         calls->instance_ptr = o;
4213
4214         LDKChannelPublicKeys pubkeys_conv;
4215         pubkeys_conv.inner = (void*)(pubkeys & (~1));
4216         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
4217         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
4218
4219         LDKBaseSign ret = {
4220                 .this_arg = (void*) calls,
4221                 .get_per_commitment_point = get_per_commitment_point_LDKBaseSign_jcall,
4222                 .release_commitment_secret = release_commitment_secret_LDKBaseSign_jcall,
4223                 .validate_holder_commitment = validate_holder_commitment_LDKBaseSign_jcall,
4224                 .channel_keys_id = channel_keys_id_LDKBaseSign_jcall,
4225                 .sign_counterparty_commitment = sign_counterparty_commitment_LDKBaseSign_jcall,
4226                 .validate_counterparty_revocation = validate_counterparty_revocation_LDKBaseSign_jcall,
4227                 .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_LDKBaseSign_jcall,
4228                 .sign_justice_revoked_output = sign_justice_revoked_output_LDKBaseSign_jcall,
4229                 .sign_justice_revoked_htlc = sign_justice_revoked_htlc_LDKBaseSign_jcall,
4230                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_LDKBaseSign_jcall,
4231                 .sign_closing_transaction = sign_closing_transaction_LDKBaseSign_jcall,
4232                 .sign_channel_announcement = sign_channel_announcement_LDKBaseSign_jcall,
4233                 .ready_channel = ready_channel_LDKBaseSign_jcall,
4234                 .free = LDKBaseSign_JCalls_free,
4235                 .pubkeys = pubkeys_conv,
4236                 .set_pubkeys = NULL,
4237         };
4238         return ret;
4239 }
4240 long  __attribute__((export_name("TS_LDKBaseSign_new"))) TS_LDKBaseSign_new(JSValue o, uint32_t pubkeys) {
4241         LDKBaseSign *res_ptr = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
4242         *res_ptr = LDKBaseSign_init(o, pubkeys);
4243         return (long)res_ptr;
4244 }
4245 int8_tArray  __attribute__((export_name("TS_BaseSign_get_per_commitment_point"))) TS_BaseSign_get_per_commitment_point(uint32_t this_arg, int64_t idx) {
4246         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4247         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4248         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4249         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
4250         memcpy(ret_arr->elems, (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form, 33);
4251         return ret_arr;
4252 }
4253
4254 int8_tArray  __attribute__((export_name("TS_BaseSign_release_commitment_secret"))) TS_BaseSign_release_commitment_secret(uint32_t this_arg, int64_t idx) {
4255         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4256         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4257         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4258         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4259         memcpy(ret_arr->elems, (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data, 32);
4260         return ret_arr;
4261 }
4262
4263 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) {
4264         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4265         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4266         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4267         LDKHolderCommitmentTransaction holder_tx_conv;
4268         holder_tx_conv.inner = (void*)(holder_tx & (~1));
4269         holder_tx_conv.is_owned = false;
4270         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_conv);
4271         LDKCVec_PaymentPreimageZ preimages_constr;
4272         preimages_constr.datalen = preimages->arr_len;
4273         if (preimages_constr.datalen > 0)
4274                 preimages_constr.data = MALLOC(preimages_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
4275         else
4276                 preimages_constr.data = NULL;
4277         int8_tArray* preimages_vals = (void*) preimages->elems;
4278         for (size_t m = 0; m < preimages_constr.datalen; m++) {
4279                 int8_tArray preimages_conv_12 = preimages_vals[m];
4280                 LDKThirtyTwoBytes preimages_conv_12_ref;
4281                 CHECK(preimages_conv_12->arr_len == 32);
4282                 memcpy(preimages_conv_12_ref.data, preimages_conv_12->elems, 32); FREE(preimages_conv_12);
4283                 preimages_constr.data[m] = preimages_conv_12_ref;
4284         }
4285         FREE(preimages);
4286         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
4287         *ret_conv = (this_arg_conv->validate_holder_commitment)(this_arg_conv->this_arg, &holder_tx_conv, preimages_constr);
4288         return (uint32_t)ret_conv;
4289 }
4290
4291 int8_tArray  __attribute__((export_name("TS_BaseSign_channel_keys_id"))) TS_BaseSign_channel_keys_id(uint32_t this_arg) {
4292         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4293         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4294         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4295         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4296         memcpy(ret_arr->elems, (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data, 32);
4297         return ret_arr;
4298 }
4299
4300 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) {
4301         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4302         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4303         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4304         LDKCommitmentTransaction commitment_tx_conv;
4305         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
4306         commitment_tx_conv.is_owned = false;
4307         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
4308         LDKCVec_PaymentPreimageZ preimages_constr;
4309         preimages_constr.datalen = preimages->arr_len;
4310         if (preimages_constr.datalen > 0)
4311                 preimages_constr.data = MALLOC(preimages_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
4312         else
4313                 preimages_constr.data = NULL;
4314         int8_tArray* preimages_vals = (void*) preimages->elems;
4315         for (size_t m = 0; m < preimages_constr.datalen; m++) {
4316                 int8_tArray preimages_conv_12 = preimages_vals[m];
4317                 LDKThirtyTwoBytes preimages_conv_12_ref;
4318                 CHECK(preimages_conv_12->arr_len == 32);
4319                 memcpy(preimages_conv_12_ref.data, preimages_conv_12->elems, 32); FREE(preimages_conv_12);
4320                 preimages_constr.data[m] = preimages_conv_12_ref;
4321         }
4322         FREE(preimages);
4323         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
4324         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv, preimages_constr);
4325         return (uint32_t)ret_conv;
4326 }
4327
4328 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) {
4329         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4330         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4331         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4332         unsigned char secret_arr[32];
4333         CHECK(secret->arr_len == 32);
4334         memcpy(secret_arr, secret->elems, 32); FREE(secret);
4335         unsigned char (*secret_ref)[32] = &secret_arr;
4336         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
4337         *ret_conv = (this_arg_conv->validate_counterparty_revocation)(this_arg_conv->this_arg, idx, secret_ref);
4338         return (uint32_t)ret_conv;
4339 }
4340
4341 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) {
4342         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4343         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4344         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4345         LDKHolderCommitmentTransaction commitment_tx_conv;
4346         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
4347         commitment_tx_conv.is_owned = false;
4348         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
4349         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
4350         *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
4351         return (uint32_t)ret_conv;
4352 }
4353
4354 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) {
4355         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4356         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4357         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4358         LDKTransaction justice_tx_ref;
4359         justice_tx_ref.datalen = justice_tx->arr_len;
4360         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
4361         memcpy(justice_tx_ref.data, justice_tx->elems, justice_tx_ref.datalen); FREE(justice_tx);
4362         justice_tx_ref.data_is_owned = true;
4363         unsigned char per_commitment_key_arr[32];
4364         CHECK(per_commitment_key->arr_len == 32);
4365         memcpy(per_commitment_key_arr, per_commitment_key->elems, 32); FREE(per_commitment_key);
4366         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
4367         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
4368         *ret_conv = (this_arg_conv->sign_justice_revoked_output)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref);
4369         return (uint32_t)ret_conv;
4370 }
4371
4372 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) {
4373         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4374         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4375         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4376         LDKTransaction justice_tx_ref;
4377         justice_tx_ref.datalen = justice_tx->arr_len;
4378         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
4379         memcpy(justice_tx_ref.data, justice_tx->elems, justice_tx_ref.datalen); FREE(justice_tx);
4380         justice_tx_ref.data_is_owned = true;
4381         unsigned char per_commitment_key_arr[32];
4382         CHECK(per_commitment_key->arr_len == 32);
4383         memcpy(per_commitment_key_arr, per_commitment_key->elems, 32); FREE(per_commitment_key);
4384         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
4385         LDKHTLCOutputInCommitment htlc_conv;
4386         htlc_conv.inner = (void*)(htlc & (~1));
4387         htlc_conv.is_owned = false;
4388         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
4389         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
4390         *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);
4391         return (uint32_t)ret_conv;
4392 }
4393
4394 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) {
4395         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4396         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4397         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4398         LDKTransaction htlc_tx_ref;
4399         htlc_tx_ref.datalen = htlc_tx->arr_len;
4400         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
4401         memcpy(htlc_tx_ref.data, htlc_tx->elems, htlc_tx_ref.datalen); FREE(htlc_tx);
4402         htlc_tx_ref.data_is_owned = true;
4403         LDKPublicKey per_commitment_point_ref;
4404         CHECK(per_commitment_point->arr_len == 33);
4405         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
4406         LDKHTLCOutputInCommitment htlc_conv;
4407         htlc_conv.inner = (void*)(htlc & (~1));
4408         htlc_conv.is_owned = false;
4409         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
4410         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
4411         *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);
4412         return (uint32_t)ret_conv;
4413 }
4414
4415 uint32_t  __attribute__((export_name("TS_BaseSign_sign_closing_transaction"))) TS_BaseSign_sign_closing_transaction(uint32_t this_arg, uint32_t closing_tx) {
4416         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4417         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4418         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4419         LDKClosingTransaction closing_tx_conv;
4420         closing_tx_conv.inner = (void*)(closing_tx & (~1));
4421         closing_tx_conv.is_owned = false;
4422         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_conv);
4423         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
4424         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, &closing_tx_conv);
4425         return (uint32_t)ret_conv;
4426 }
4427
4428 uint32_t  __attribute__((export_name("TS_BaseSign_sign_channel_announcement"))) TS_BaseSign_sign_channel_announcement(uint32_t this_arg, uint32_t msg) {
4429         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4430         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4431         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4432         LDKUnsignedChannelAnnouncement msg_conv;
4433         msg_conv.inner = (void*)(msg & (~1));
4434         msg_conv.is_owned = false;
4435         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
4436         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
4437         *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
4438         return (uint32_t)ret_conv;
4439 }
4440
4441 void  __attribute__((export_name("TS_BaseSign_ready_channel"))) TS_BaseSign_ready_channel(uint32_t this_arg, uint32_t channel_parameters) {
4442         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4443         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4444         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4445         LDKChannelTransactionParameters channel_parameters_conv;
4446         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
4447         channel_parameters_conv.is_owned = false;
4448         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
4449         (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
4450 }
4451
4452 LDKChannelPublicKeys LDKBaseSign_set_get_pubkeys(LDKBaseSign* this_arg) {
4453         if (this_arg->set_pubkeys != NULL)
4454                 this_arg->set_pubkeys(this_arg);
4455         return this_arg->pubkeys;
4456 }
4457 uint32_t  __attribute__((export_name("TS_BaseSign_get_pubkeys"))) TS_BaseSign_get_pubkeys(uint32_t this_arg) {
4458         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4459         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4460         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4461         LDKChannelPublicKeys ret_var = LDKBaseSign_set_get_pubkeys(this_arg_conv);
4462         uint32_t ret_ref = 0;
4463         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4464         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4465         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4466         ret_ref = (uintptr_t)ret_var.inner;
4467         if (ret_var.is_owned) {
4468                 ret_ref |= 1;
4469         }
4470         return ret_ref;
4471 }
4472
4473 typedef struct LDKSign_JCalls {
4474         atomic_size_t refcnt;
4475         uint32_t instance_ptr;
4476         LDKBaseSign_JCalls* BaseSign;
4477 } LDKSign_JCalls;
4478 static void LDKSign_JCalls_free(void* this_arg) {
4479         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
4480         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4481                 FREE(j_calls);
4482         }
4483 }
4484 LDKCVec_u8Z write_LDKSign_jcall(const void* this_arg) {
4485         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
4486         int8_tArray ret = (int8_tArray)js_invoke_function_uuuuuu(j_calls->instance_ptr, 15, 0, 0, 0, 0, 0, 0);
4487         LDKCVec_u8Z ret_ref;
4488         ret_ref.datalen = ret->arr_len;
4489         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
4490         memcpy(ret_ref.data, ret->elems, ret_ref.datalen); FREE(ret);
4491         return ret_ref;
4492 }
4493 static void LDKSign_JCalls_cloned(LDKSign* new_obj) {
4494         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) new_obj->this_arg;
4495         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4496         atomic_fetch_add_explicit(&j_calls->BaseSign->refcnt, 1, memory_order_release);
4497 }
4498 static inline LDKSign LDKSign_init (JSValue o, JSValue BaseSign, uint32_t pubkeys) {
4499         LDKSign_JCalls *calls = MALLOC(sizeof(LDKSign_JCalls), "LDKSign_JCalls");
4500         atomic_init(&calls->refcnt, 1);
4501         calls->instance_ptr = o;
4502
4503         LDKChannelPublicKeys pubkeys_conv;
4504         pubkeys_conv.inner = (void*)(pubkeys & (~1));
4505         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
4506         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
4507
4508         LDKSign ret = {
4509                 .this_arg = (void*) calls,
4510                 .write = write_LDKSign_jcall,
4511                 .cloned = LDKSign_JCalls_cloned,
4512                 .free = LDKSign_JCalls_free,
4513                 .BaseSign = LDKBaseSign_init(BaseSign, pubkeys),
4514         };
4515         calls->BaseSign = ret.BaseSign.this_arg;
4516         return ret;
4517 }
4518 long  __attribute__((export_name("TS_LDKSign_new"))) TS_LDKSign_new(JSValue o, JSValue BaseSign, uint32_t pubkeys) {
4519         LDKSign *res_ptr = MALLOC(sizeof(LDKSign), "LDKSign");
4520         *res_ptr = LDKSign_init(o, BaseSign, pubkeys);
4521         return (long)res_ptr;
4522 }
4523 int8_tArray  __attribute__((export_name("TS_Sign_write"))) TS_Sign_write(uint32_t this_arg) {
4524         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4525         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4526         LDKSign* this_arg_conv = (LDKSign*)this_arg_ptr;
4527         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
4528         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
4529         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
4530         CVec_u8Z_free(ret_var);
4531         return ret_arr;
4532 }
4533
4534 static inline struct LDKSign CResult_SignDecodeErrorZ_get_ok(LDKCResult_SignDecodeErrorZ *NONNULL_PTR owner){
4535 CHECK(owner->result_ok);
4536         return Sign_clone(&*owner->contents.result);
4537 }
4538 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_get_ok"))) TS_CResult_SignDecodeErrorZ_get_ok(uint32_t owner) {
4539         LDKCResult_SignDecodeErrorZ* owner_conv = (LDKCResult_SignDecodeErrorZ*)(owner & ~1);
4540         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
4541         *ret_ret = CResult_SignDecodeErrorZ_get_ok(owner_conv);
4542         return (uint32_t)ret_ret;
4543 }
4544
4545 static inline struct LDKDecodeError CResult_SignDecodeErrorZ_get_err(LDKCResult_SignDecodeErrorZ *NONNULL_PTR owner){
4546 CHECK(!owner->result_ok);
4547         return DecodeError_clone(&*owner->contents.err);
4548 }
4549 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_get_err"))) TS_CResult_SignDecodeErrorZ_get_err(uint32_t owner) {
4550         LDKCResult_SignDecodeErrorZ* owner_conv = (LDKCResult_SignDecodeErrorZ*)(owner & ~1);
4551         LDKDecodeError ret_var = CResult_SignDecodeErrorZ_get_err(owner_conv);
4552         uint32_t ret_ref = 0;
4553         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4554         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4555         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4556         ret_ref = (uintptr_t)ret_var.inner;
4557         if (ret_var.is_owned) {
4558                 ret_ref |= 1;
4559         }
4560         return ret_ref;
4561 }
4562
4563 static inline struct LDKRecoverableSignature CResult_RecoverableSignatureNoneZ_get_ok(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
4564 CHECK(owner->result_ok);
4565         return *owner->contents.result;
4566 }
4567 int8_tArray  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_get_ok"))) TS_CResult_RecoverableSignatureNoneZ_get_ok(uint32_t owner) {
4568         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)(owner & ~1);
4569         int8_tArray ret_arr = init_int8_tArray(68, __LINE__);
4570         memcpy(ret_arr->elems, CResult_RecoverableSignatureNoneZ_get_ok(owner_conv).serialized_form, 68);
4571         return ret_arr;
4572 }
4573
4574 static inline void CResult_RecoverableSignatureNoneZ_get_err(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
4575 CHECK(!owner->result_ok);
4576         return *owner->contents.err;
4577 }
4578 void  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_get_err"))) TS_CResult_RecoverableSignatureNoneZ_get_err(uint32_t owner) {
4579         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)(owner & ~1);
4580         CResult_RecoverableSignatureNoneZ_get_err(owner_conv);
4581 }
4582
4583 static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
4584         LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
4585         for (size_t i = 0; i < ret.datalen; i++) {
4586                 ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
4587         }
4588         return ret;
4589 }
4590 static inline struct LDKCVec_CVec_u8ZZ CResult_CVec_CVec_u8ZZNoneZ_get_ok(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
4591 CHECK(owner->result_ok);
4592         return CVec_CVec_u8ZZ_clone(&*owner->contents.result);
4593 }
4594 ptrArray  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_get_ok"))) TS_CResult_CVec_CVec_u8ZZNoneZ_get_ok(uint32_t owner) {
4595         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(owner & ~1);
4596         LDKCVec_CVec_u8ZZ ret_var = CResult_CVec_CVec_u8ZZNoneZ_get_ok(owner_conv);
4597         ptrArray ret_arr = NULL;
4598         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
4599         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 8);
4600         for (size_t m = 0; m < ret_var.datalen; m++) {
4601                 LDKCVec_u8Z ret_conv_12_var = ret_var.data[m];
4602                 int8_tArray ret_conv_12_arr = init_int8_tArray(ret_conv_12_var.datalen, __LINE__);
4603                 memcpy(ret_conv_12_arr->elems, ret_conv_12_var.data, ret_conv_12_var.datalen);
4604                 CVec_u8Z_free(ret_conv_12_var);
4605                 ret_arr_ptr[m] = ret_conv_12_arr;
4606         }
4607         
4608         FREE(ret_var.data);
4609         return ret_arr;
4610 }
4611
4612 static inline void CResult_CVec_CVec_u8ZZNoneZ_get_err(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
4613 CHECK(!owner->result_ok);
4614         return *owner->contents.err;
4615 }
4616 void  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_get_err"))) TS_CResult_CVec_CVec_u8ZZNoneZ_get_err(uint32_t owner) {
4617         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(owner & ~1);
4618         CResult_CVec_CVec_u8ZZNoneZ_get_err(owner_conv);
4619 }
4620
4621 static inline struct LDKInMemorySigner CResult_InMemorySignerDecodeErrorZ_get_ok(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
4622 CHECK(owner->result_ok);
4623         return InMemorySigner_clone(&*owner->contents.result);
4624 }
4625 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_get_ok"))) TS_CResult_InMemorySignerDecodeErrorZ_get_ok(uint32_t owner) {
4626         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(owner & ~1);
4627         LDKInMemorySigner ret_var = CResult_InMemorySignerDecodeErrorZ_get_ok(owner_conv);
4628         uint32_t ret_ref = 0;
4629         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4630         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4631         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4632         ret_ref = (uintptr_t)ret_var.inner;
4633         if (ret_var.is_owned) {
4634                 ret_ref |= 1;
4635         }
4636         return ret_ref;
4637 }
4638
4639 static inline struct LDKDecodeError CResult_InMemorySignerDecodeErrorZ_get_err(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
4640 CHECK(!owner->result_ok);
4641         return DecodeError_clone(&*owner->contents.err);
4642 }
4643 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_get_err"))) TS_CResult_InMemorySignerDecodeErrorZ_get_err(uint32_t owner) {
4644         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(owner & ~1);
4645         LDKDecodeError ret_var = CResult_InMemorySignerDecodeErrorZ_get_err(owner_conv);
4646         uint32_t ret_ref = 0;
4647         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4648         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4649         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4650         ret_ref = (uintptr_t)ret_var.inner;
4651         if (ret_var.is_owned) {
4652                 ret_ref |= 1;
4653         }
4654         return ret_ref;
4655 }
4656
4657 static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
4658         LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
4659         for (size_t i = 0; i < ret.datalen; i++) {
4660                 ret.data[i] = TxOut_clone(&orig->data[i]);
4661         }
4662         return ret;
4663 }
4664 static inline struct LDKTransaction CResult_TransactionNoneZ_get_ok(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
4665 CHECK(owner->result_ok);
4666         return *owner->contents.result;
4667 }
4668 int8_tArray  __attribute__((export_name("TS_CResult_TransactionNoneZ_get_ok"))) TS_CResult_TransactionNoneZ_get_ok(uint32_t owner) {
4669         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)(owner & ~1);
4670         LDKTransaction ret_var = CResult_TransactionNoneZ_get_ok(owner_conv);
4671         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
4672         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
4673         return ret_arr;
4674 }
4675
4676 static inline void CResult_TransactionNoneZ_get_err(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
4677 CHECK(!owner->result_ok);
4678         return *owner->contents.err;
4679 }
4680 void  __attribute__((export_name("TS_CResult_TransactionNoneZ_get_err"))) TS_CResult_TransactionNoneZ_get_err(uint32_t owner) {
4681         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)(owner & ~1);
4682         CResult_TransactionNoneZ_get_err(owner_conv);
4683 }
4684
4685 uint32_t __attribute__((export_name("TS_LDKCOption_u16Z_ty_from_ptr"))) TS_LDKCOption_u16Z_ty_from_ptr(uint32_t ptr) {
4686         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)(ptr & ~1);
4687         switch(obj->tag) {
4688                 case LDKCOption_u16Z_Some: return 0;
4689                 case LDKCOption_u16Z_None: return 1;
4690                 default: abort();
4691         }
4692 }
4693 int16_t __attribute__((export_name("TS_LDKCOption_u16Z_Some_get_some"))) TS_LDKCOption_u16Z_Some_get_some(uint32_t ptr) {
4694         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)(ptr & ~1);
4695         assert(obj->tag == LDKCOption_u16Z_Some);
4696                         int16_t some_conv = obj->some;
4697         return some_conv;
4698 }
4699 uint32_t __attribute__((export_name("TS_LDKAPIError_ty_from_ptr"))) TS_LDKAPIError_ty_from_ptr(uint32_t ptr) {
4700         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
4701         switch(obj->tag) {
4702                 case LDKAPIError_APIMisuseError: return 0;
4703                 case LDKAPIError_FeeRateTooHigh: return 1;
4704                 case LDKAPIError_RouteError: return 2;
4705                 case LDKAPIError_ChannelUnavailable: return 3;
4706                 case LDKAPIError_MonitorUpdateFailed: return 4;
4707                 case LDKAPIError_IncompatibleShutdownScript: return 5;
4708                 default: abort();
4709         }
4710 }
4711 jstring __attribute__((export_name("TS_LDKAPIError_APIMisuseError_get_err"))) TS_LDKAPIError_APIMisuseError_get_err(uint32_t ptr) {
4712         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
4713         assert(obj->tag == LDKAPIError_APIMisuseError);
4714                         LDKStr err_str = obj->api_misuse_error.err;
4715                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
4716         return err_conv;
4717 }
4718 jstring __attribute__((export_name("TS_LDKAPIError_FeeRateTooHigh_get_err"))) TS_LDKAPIError_FeeRateTooHigh_get_err(uint32_t ptr) {
4719         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
4720         assert(obj->tag == LDKAPIError_FeeRateTooHigh);
4721                         LDKStr err_str = obj->fee_rate_too_high.err;
4722                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
4723         return err_conv;
4724 }
4725 int32_t __attribute__((export_name("TS_LDKAPIError_FeeRateTooHigh_get_feerate"))) TS_LDKAPIError_FeeRateTooHigh_get_feerate(uint32_t ptr) {
4726         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
4727         assert(obj->tag == LDKAPIError_FeeRateTooHigh);
4728                         int32_t feerate_conv = obj->fee_rate_too_high.feerate;
4729         return feerate_conv;
4730 }
4731 jstring __attribute__((export_name("TS_LDKAPIError_RouteError_get_err"))) TS_LDKAPIError_RouteError_get_err(uint32_t ptr) {
4732         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
4733         assert(obj->tag == LDKAPIError_RouteError);
4734                         LDKStr err_str = obj->route_error.err;
4735                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
4736         return err_conv;
4737 }
4738 jstring __attribute__((export_name("TS_LDKAPIError_ChannelUnavailable_get_err"))) TS_LDKAPIError_ChannelUnavailable_get_err(uint32_t ptr) {
4739         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
4740         assert(obj->tag == LDKAPIError_ChannelUnavailable);
4741                         LDKStr err_str = obj->channel_unavailable.err;
4742                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
4743         return err_conv;
4744 }
4745 uint32_t __attribute__((export_name("TS_LDKAPIError_IncompatibleShutdownScript_get_script"))) TS_LDKAPIError_IncompatibleShutdownScript_get_script(uint32_t ptr) {
4746         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
4747         assert(obj->tag == LDKAPIError_IncompatibleShutdownScript);
4748                         LDKShutdownScript script_var = obj->incompatible_shutdown_script.script;
4749                         uint32_t script_ref = 0;
4750                         CHECK((((uintptr_t)script_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4751                         CHECK((((uintptr_t)&script_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4752                         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_var);
4753                         script_ref = (uintptr_t)script_var.inner & ~1;
4754         return script_ref;
4755 }
4756 static inline void CResult_NoneAPIErrorZ_get_ok(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
4757 CHECK(owner->result_ok);
4758         return *owner->contents.result;
4759 }
4760 void  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_get_ok"))) TS_CResult_NoneAPIErrorZ_get_ok(uint32_t owner) {
4761         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)(owner & ~1);
4762         CResult_NoneAPIErrorZ_get_ok(owner_conv);
4763 }
4764
4765 static inline struct LDKAPIError CResult_NoneAPIErrorZ_get_err(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
4766 CHECK(!owner->result_ok);
4767         return APIError_clone(&*owner->contents.err);
4768 }
4769 uint32_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_get_err"))) TS_CResult_NoneAPIErrorZ_get_err(uint32_t owner) {
4770         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)(owner & ~1);
4771         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
4772         *ret_copy = CResult_NoneAPIErrorZ_get_err(owner_conv);
4773         uint32_t ret_ref = (uintptr_t)ret_copy;
4774         return ret_ref;
4775 }
4776
4777 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
4778         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
4779         for (size_t i = 0; i < ret.datalen; i++) {
4780                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
4781         }
4782         return ret;
4783 }
4784 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
4785         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
4786         for (size_t i = 0; i < ret.datalen; i++) {
4787                 ret.data[i] = APIError_clone(&orig->data[i]);
4788         }
4789         return ret;
4790 }
4791 static inline struct LDKThirtyTwoBytes CResult__u832APIErrorZ_get_ok(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
4792 CHECK(owner->result_ok);
4793         return ThirtyTwoBytes_clone(&*owner->contents.result);
4794 }
4795 int8_tArray  __attribute__((export_name("TS_CResult__u832APIErrorZ_get_ok"))) TS_CResult__u832APIErrorZ_get_ok(uint32_t owner) {
4796         LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)(owner & ~1);
4797         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4798         memcpy(ret_arr->elems, CResult__u832APIErrorZ_get_ok(owner_conv).data, 32);
4799         return ret_arr;
4800 }
4801
4802 static inline struct LDKAPIError CResult__u832APIErrorZ_get_err(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
4803 CHECK(!owner->result_ok);
4804         return APIError_clone(&*owner->contents.err);
4805 }
4806 uint32_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_get_err"))) TS_CResult__u832APIErrorZ_get_err(uint32_t owner) {
4807         LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)(owner & ~1);
4808         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
4809         *ret_copy = CResult__u832APIErrorZ_get_err(owner_conv);
4810         uint32_t ret_ref = (uintptr_t)ret_copy;
4811         return ret_ref;
4812 }
4813
4814 uint32_t __attribute__((export_name("TS_LDKPaymentSendFailure_ty_from_ptr"))) TS_LDKPaymentSendFailure_ty_from_ptr(uint32_t ptr) {
4815         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
4816         switch(obj->tag) {
4817                 case LDKPaymentSendFailure_ParameterError: return 0;
4818                 case LDKPaymentSendFailure_PathParameterError: return 1;
4819                 case LDKPaymentSendFailure_AllFailedRetrySafe: return 2;
4820                 case LDKPaymentSendFailure_PartialFailure: return 3;
4821                 default: abort();
4822         }
4823 }
4824 uint32_t __attribute__((export_name("TS_LDKPaymentSendFailure_ParameterError_get_parameter_error"))) TS_LDKPaymentSendFailure_ParameterError_get_parameter_error(uint32_t ptr) {
4825         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
4826         assert(obj->tag == LDKPaymentSendFailure_ParameterError);
4827                         uint32_t parameter_error_ref = ((uintptr_t)&obj->parameter_error) | 1;
4828         return parameter_error_ref;
4829 }
4830 uint32_tArray __attribute__((export_name("TS_LDKPaymentSendFailure_PathParameterError_get_path_parameter_error"))) TS_LDKPaymentSendFailure_PathParameterError_get_path_parameter_error(uint32_t ptr) {
4831         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
4832         assert(obj->tag == LDKPaymentSendFailure_PathParameterError);
4833                         LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
4834                         uint32_tArray path_parameter_error_arr = NULL;
4835                         path_parameter_error_arr = init_uint32_tArray(path_parameter_error_var.datalen, __LINE__);
4836                         uint32_t *path_parameter_error_arr_ptr = (uint32_t*)(((uint8_t*)path_parameter_error_arr) + 8);
4837                         for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
4838                                 LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
4839                                 *path_parameter_error_conv_22_conv = path_parameter_error_var.data[w];
4840                                 *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
4841                                 path_parameter_error_arr_ptr[w] = (uint32_t)path_parameter_error_conv_22_conv;
4842                         }
4843                         
4844         return path_parameter_error_arr;
4845 }
4846 uint32_tArray __attribute__((export_name("TS_LDKPaymentSendFailure_AllFailedRetrySafe_get_all_failed_retry_safe"))) TS_LDKPaymentSendFailure_AllFailedRetrySafe_get_all_failed_retry_safe(uint32_t ptr) {
4847         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
4848         assert(obj->tag == LDKPaymentSendFailure_AllFailedRetrySafe);
4849                         LDKCVec_APIErrorZ all_failed_retry_safe_var = obj->all_failed_retry_safe;
4850                         uint32_tArray all_failed_retry_safe_arr = NULL;
4851                         all_failed_retry_safe_arr = init_uint32_tArray(all_failed_retry_safe_var.datalen, __LINE__);
4852                         uint32_t *all_failed_retry_safe_arr_ptr = (uint32_t*)(((uint8_t*)all_failed_retry_safe_arr) + 8);
4853                         for (size_t k = 0; k < all_failed_retry_safe_var.datalen; k++) {
4854                                 uint32_t all_failed_retry_safe_conv_10_ref = ((uintptr_t)&all_failed_retry_safe_var.data[k]) | 1;
4855                                 all_failed_retry_safe_arr_ptr[k] = all_failed_retry_safe_conv_10_ref;
4856                         }
4857                         
4858         return all_failed_retry_safe_arr;
4859 }
4860 uint32_tArray __attribute__((export_name("TS_LDKPaymentSendFailure_PartialFailure_get_results"))) TS_LDKPaymentSendFailure_PartialFailure_get_results(uint32_t ptr) {
4861         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
4862         assert(obj->tag == LDKPaymentSendFailure_PartialFailure);
4863                         LDKCVec_CResult_NoneAPIErrorZZ results_var = obj->partial_failure.results;
4864                         uint32_tArray results_arr = NULL;
4865                         results_arr = init_uint32_tArray(results_var.datalen, __LINE__);
4866                         uint32_t *results_arr_ptr = (uint32_t*)(((uint8_t*)results_arr) + 8);
4867                         for (size_t w = 0; w < results_var.datalen; w++) {
4868                                 LDKCResult_NoneAPIErrorZ* results_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
4869                                 *results_conv_22_conv = results_var.data[w];
4870                                 *results_conv_22_conv = CResult_NoneAPIErrorZ_clone(results_conv_22_conv);
4871                                 results_arr_ptr[w] = (uint32_t)results_conv_22_conv;
4872                         }
4873                         
4874         return results_arr;
4875 }
4876 uint32_t __attribute__((export_name("TS_LDKPaymentSendFailure_PartialFailure_get_failed_paths_retry"))) TS_LDKPaymentSendFailure_PartialFailure_get_failed_paths_retry(uint32_t ptr) {
4877         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
4878         assert(obj->tag == LDKPaymentSendFailure_PartialFailure);
4879                         LDKRouteParameters failed_paths_retry_var = obj->partial_failure.failed_paths_retry;
4880                         uint32_t failed_paths_retry_ref = 0;
4881                         if ((uintptr_t)failed_paths_retry_var.inner > 4096) {
4882                                 CHECK((((uintptr_t)failed_paths_retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4883                                 CHECK((((uintptr_t)&failed_paths_retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4884                         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_var);
4885                                 failed_paths_retry_ref = (uintptr_t)failed_paths_retry_var.inner & ~1;
4886                         }
4887         return failed_paths_retry_ref;
4888 }
4889 int8_tArray __attribute__((export_name("TS_LDKPaymentSendFailure_PartialFailure_get_payment_id"))) TS_LDKPaymentSendFailure_PartialFailure_get_payment_id(uint32_t ptr) {
4890         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
4891         assert(obj->tag == LDKPaymentSendFailure_PartialFailure);
4892                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
4893                         memcpy(payment_id_arr->elems, obj->partial_failure.payment_id.data, 32);
4894         return payment_id_arr;
4895 }
4896 static inline struct LDKThirtyTwoBytes CResult_PaymentIdPaymentSendFailureZ_get_ok(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR owner){
4897 CHECK(owner->result_ok);
4898         return ThirtyTwoBytes_clone(&*owner->contents.result);
4899 }
4900 int8_tArray  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_get_ok"))) TS_CResult_PaymentIdPaymentSendFailureZ_get_ok(uint32_t owner) {
4901         LDKCResult_PaymentIdPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(owner & ~1);
4902         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4903         memcpy(ret_arr->elems, CResult_PaymentIdPaymentSendFailureZ_get_ok(owner_conv).data, 32);
4904         return ret_arr;
4905 }
4906
4907 static inline struct LDKPaymentSendFailure CResult_PaymentIdPaymentSendFailureZ_get_err(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR owner){
4908 CHECK(!owner->result_ok);
4909         return PaymentSendFailure_clone(&*owner->contents.err);
4910 }
4911 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_get_err"))) TS_CResult_PaymentIdPaymentSendFailureZ_get_err(uint32_t owner) {
4912         LDKCResult_PaymentIdPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(owner & ~1);
4913         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
4914         *ret_copy = CResult_PaymentIdPaymentSendFailureZ_get_err(owner_conv);
4915         uint32_t ret_ref = (uintptr_t)ret_copy;
4916         return ret_ref;
4917 }
4918
4919 static inline void CResult_NonePaymentSendFailureZ_get_ok(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
4920 CHECK(owner->result_ok);
4921         return *owner->contents.result;
4922 }
4923 void  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_get_ok"))) TS_CResult_NonePaymentSendFailureZ_get_ok(uint32_t owner) {
4924         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)(owner & ~1);
4925         CResult_NonePaymentSendFailureZ_get_ok(owner_conv);
4926 }
4927
4928 static inline struct LDKPaymentSendFailure CResult_NonePaymentSendFailureZ_get_err(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
4929 CHECK(!owner->result_ok);
4930         return PaymentSendFailure_clone(&*owner->contents.err);
4931 }
4932 uint32_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_get_err"))) TS_CResult_NonePaymentSendFailureZ_get_err(uint32_t owner) {
4933         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)(owner & ~1);
4934         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
4935         *ret_copy = CResult_NonePaymentSendFailureZ_get_err(owner_conv);
4936         uint32_t ret_ref = (uintptr_t)ret_copy;
4937         return ret_ref;
4938 }
4939
4940 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_a(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
4941         return ThirtyTwoBytes_clone(&owner->a);
4942 }
4943 int8_tArray  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_get_a"))) TS_C2Tuple_PaymentHashPaymentIdZ_get_a(uint32_t owner) {
4944         LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(owner & ~1);
4945         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4946         memcpy(ret_arr->elems, C2Tuple_PaymentHashPaymentIdZ_get_a(owner_conv).data, 32);
4947         return ret_arr;
4948 }
4949
4950 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_b(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
4951         return ThirtyTwoBytes_clone(&owner->b);
4952 }
4953 int8_tArray  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_get_b"))) TS_C2Tuple_PaymentHashPaymentIdZ_get_b(uint32_t owner) {
4954         LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(owner & ~1);
4955         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4956         memcpy(ret_arr->elems, C2Tuple_PaymentHashPaymentIdZ_get_b(owner_conv).data, 32);
4957         return ret_arr;
4958 }
4959
4960 static inline struct LDKC2Tuple_PaymentHashPaymentIdZ CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
4961 CHECK(owner->result_ok);
4962         return C2Tuple_PaymentHashPaymentIdZ_clone(&*owner->contents.result);
4963 }
4964 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(uint32_t owner) {
4965         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(owner & ~1);
4966         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
4967         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(owner_conv);
4968         return ((uint32_t)ret_conv);
4969 }
4970
4971 static inline struct LDKPaymentSendFailure CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
4972 CHECK(!owner->result_ok);
4973         return PaymentSendFailure_clone(&*owner->contents.err);
4974 }
4975 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(uint32_t owner) {
4976         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(owner & ~1);
4977         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
4978         *ret_copy = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(owner_conv);
4979         uint32_t ret_ref = (uintptr_t)ret_copy;
4980         return ret_ref;
4981 }
4982
4983 static inline LDKCVec_ThirtyTwoBytesZ CVec_ThirtyTwoBytesZ_clone(const LDKCVec_ThirtyTwoBytesZ *orig) {
4984         LDKCVec_ThirtyTwoBytesZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_ThirtyTwoBytesZ clone bytes"), .datalen = orig->datalen };
4985         for (size_t i = 0; i < ret.datalen; i++) {
4986                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
4987         }
4988         return ret;
4989 }
4990 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_a(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
4991         return ThirtyTwoBytes_clone(&owner->a);
4992 }
4993 int8_tArray  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_get_a"))) TS_C2Tuple_PaymentHashPaymentSecretZ_get_a(uint32_t owner) {
4994         LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(owner & ~1);
4995         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4996         memcpy(ret_arr->elems, C2Tuple_PaymentHashPaymentSecretZ_get_a(owner_conv).data, 32);
4997         return ret_arr;
4998 }
4999
5000 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_b(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
5001         return ThirtyTwoBytes_clone(&owner->b);
5002 }
5003 int8_tArray  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_get_b"))) TS_C2Tuple_PaymentHashPaymentSecretZ_get_b(uint32_t owner) {
5004         LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(owner & ~1);
5005         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5006         memcpy(ret_arr->elems, C2Tuple_PaymentHashPaymentSecretZ_get_b(owner_conv).data, 32);
5007         return ret_arr;
5008 }
5009
5010 static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
5011 CHECK(owner->result_ok);
5012         return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
5013 }
5014 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(uint32_t owner) {
5015         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(owner & ~1);
5016         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
5017         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(owner_conv);
5018         return ((uint32_t)ret_conv);
5019 }
5020
5021 static inline void CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
5022 CHECK(!owner->result_ok);
5023         return *owner->contents.err;
5024 }
5025 void  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(uint32_t owner) {
5026         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(owner & ~1);
5027         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(owner_conv);
5028 }
5029
5030 static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
5031 CHECK(owner->result_ok);
5032         return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
5033 }
5034 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(uint32_t owner) {
5035         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(owner & ~1);
5036         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
5037         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(owner_conv);
5038         return ((uint32_t)ret_conv);
5039 }
5040
5041 static inline struct LDKAPIError CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
5042 CHECK(!owner->result_ok);
5043         return APIError_clone(&*owner->contents.err);
5044 }
5045 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(uint32_t owner) {
5046         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(owner & ~1);
5047         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
5048         *ret_copy = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(owner_conv);
5049         uint32_t ret_ref = (uintptr_t)ret_copy;
5050         return ret_ref;
5051 }
5052
5053 static inline struct LDKThirtyTwoBytes CResult_PaymentSecretNoneZ_get_ok(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
5054 CHECK(owner->result_ok);
5055         return ThirtyTwoBytes_clone(&*owner->contents.result);
5056 }
5057 int8_tArray  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_get_ok"))) TS_CResult_PaymentSecretNoneZ_get_ok(uint32_t owner) {
5058         LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)(owner & ~1);
5059         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5060         memcpy(ret_arr->elems, CResult_PaymentSecretNoneZ_get_ok(owner_conv).data, 32);
5061         return ret_arr;
5062 }
5063
5064 static inline void CResult_PaymentSecretNoneZ_get_err(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
5065 CHECK(!owner->result_ok);
5066         return *owner->contents.err;
5067 }
5068 void  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_get_err"))) TS_CResult_PaymentSecretNoneZ_get_err(uint32_t owner) {
5069         LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)(owner & ~1);
5070         CResult_PaymentSecretNoneZ_get_err(owner_conv);
5071 }
5072
5073 static inline struct LDKThirtyTwoBytes CResult_PaymentSecretAPIErrorZ_get_ok(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
5074 CHECK(owner->result_ok);
5075         return ThirtyTwoBytes_clone(&*owner->contents.result);
5076 }
5077 int8_tArray  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_get_ok"))) TS_CResult_PaymentSecretAPIErrorZ_get_ok(uint32_t owner) {
5078         LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(owner & ~1);
5079         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5080         memcpy(ret_arr->elems, CResult_PaymentSecretAPIErrorZ_get_ok(owner_conv).data, 32);
5081         return ret_arr;
5082 }
5083
5084 static inline struct LDKAPIError CResult_PaymentSecretAPIErrorZ_get_err(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
5085 CHECK(!owner->result_ok);
5086         return APIError_clone(&*owner->contents.err);
5087 }
5088 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_get_err"))) TS_CResult_PaymentSecretAPIErrorZ_get_err(uint32_t owner) {
5089         LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(owner & ~1);
5090         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
5091         *ret_copy = CResult_PaymentSecretAPIErrorZ_get_err(owner_conv);
5092         uint32_t ret_ref = (uintptr_t)ret_copy;
5093         return ret_ref;
5094 }
5095
5096 static inline struct LDKThirtyTwoBytes CResult_PaymentPreimageAPIErrorZ_get_ok(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
5097 CHECK(owner->result_ok);
5098         return ThirtyTwoBytes_clone(&*owner->contents.result);
5099 }
5100 int8_tArray  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_get_ok"))) TS_CResult_PaymentPreimageAPIErrorZ_get_ok(uint32_t owner) {
5101         LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(owner & ~1);
5102         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5103         memcpy(ret_arr->elems, CResult_PaymentPreimageAPIErrorZ_get_ok(owner_conv).data, 32);
5104         return ret_arr;
5105 }
5106
5107 static inline struct LDKAPIError CResult_PaymentPreimageAPIErrorZ_get_err(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
5108 CHECK(!owner->result_ok);
5109         return APIError_clone(&*owner->contents.err);
5110 }
5111 uint32_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_get_err"))) TS_CResult_PaymentPreimageAPIErrorZ_get_err(uint32_t owner) {
5112         LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(owner & ~1);
5113         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
5114         *ret_copy = CResult_PaymentPreimageAPIErrorZ_get_err(owner_conv);
5115         uint32_t ret_ref = (uintptr_t)ret_copy;
5116         return ret_ref;
5117 }
5118
5119 static inline struct LDKCounterpartyForwardingInfo CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR owner){
5120 CHECK(owner->result_ok);
5121         return CounterpartyForwardingInfo_clone(&*owner->contents.result);
5122 }
5123 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(uint32_t owner) {
5124         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(owner & ~1);
5125         LDKCounterpartyForwardingInfo ret_var = CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(owner_conv);
5126         uint32_t ret_ref = 0;
5127         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5128         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5129         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5130         ret_ref = (uintptr_t)ret_var.inner;
5131         if (ret_var.is_owned) {
5132                 ret_ref |= 1;
5133         }
5134         return ret_ref;
5135 }
5136
5137 static inline struct LDKDecodeError CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR owner){
5138 CHECK(!owner->result_ok);
5139         return DecodeError_clone(&*owner->contents.err);
5140 }
5141 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(uint32_t owner) {
5142         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(owner & ~1);
5143         LDKDecodeError ret_var = CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(owner_conv);
5144         uint32_t ret_ref = 0;
5145         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5146         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5147         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5148         ret_ref = (uintptr_t)ret_var.inner;
5149         if (ret_var.is_owned) {
5150                 ret_ref |= 1;
5151         }
5152         return ret_ref;
5153 }
5154
5155 static inline struct LDKChannelCounterparty CResult_ChannelCounterpartyDecodeErrorZ_get_ok(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR owner){
5156 CHECK(owner->result_ok);
5157         return ChannelCounterparty_clone(&*owner->contents.result);
5158 }
5159 uint32_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_get_ok"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_get_ok(uint32_t owner) {
5160         LDKCResult_ChannelCounterpartyDecodeErrorZ* owner_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(owner & ~1);
5161         LDKChannelCounterparty ret_var = CResult_ChannelCounterpartyDecodeErrorZ_get_ok(owner_conv);
5162         uint32_t ret_ref = 0;
5163         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5164         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5165         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5166         ret_ref = (uintptr_t)ret_var.inner;
5167         if (ret_var.is_owned) {
5168                 ret_ref |= 1;
5169         }
5170         return ret_ref;
5171 }
5172
5173 static inline struct LDKDecodeError CResult_ChannelCounterpartyDecodeErrorZ_get_err(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR owner){
5174 CHECK(!owner->result_ok);
5175         return DecodeError_clone(&*owner->contents.err);
5176 }
5177 uint32_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_get_err"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_get_err(uint32_t owner) {
5178         LDKCResult_ChannelCounterpartyDecodeErrorZ* owner_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(owner & ~1);
5179         LDKDecodeError ret_var = CResult_ChannelCounterpartyDecodeErrorZ_get_err(owner_conv);
5180         uint32_t ret_ref = 0;
5181         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5182         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5183         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5184         ret_ref = (uintptr_t)ret_var.inner;
5185         if (ret_var.is_owned) {
5186                 ret_ref |= 1;
5187         }
5188         return ret_ref;
5189 }
5190
5191 static inline struct LDKChannelDetails CResult_ChannelDetailsDecodeErrorZ_get_ok(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR owner){
5192 CHECK(owner->result_ok);
5193         return ChannelDetails_clone(&*owner->contents.result);
5194 }
5195 uint32_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_get_ok"))) TS_CResult_ChannelDetailsDecodeErrorZ_get_ok(uint32_t owner) {
5196         LDKCResult_ChannelDetailsDecodeErrorZ* owner_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(owner & ~1);
5197         LDKChannelDetails ret_var = CResult_ChannelDetailsDecodeErrorZ_get_ok(owner_conv);
5198         uint32_t ret_ref = 0;
5199         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5200         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5201         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5202         ret_ref = (uintptr_t)ret_var.inner;
5203         if (ret_var.is_owned) {
5204                 ret_ref |= 1;
5205         }
5206         return ret_ref;
5207 }
5208
5209 static inline struct LDKDecodeError CResult_ChannelDetailsDecodeErrorZ_get_err(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR owner){
5210 CHECK(!owner->result_ok);
5211         return DecodeError_clone(&*owner->contents.err);
5212 }
5213 uint32_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_get_err"))) TS_CResult_ChannelDetailsDecodeErrorZ_get_err(uint32_t owner) {
5214         LDKCResult_ChannelDetailsDecodeErrorZ* owner_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(owner & ~1);
5215         LDKDecodeError ret_var = CResult_ChannelDetailsDecodeErrorZ_get_err(owner_conv);
5216         uint32_t ret_ref = 0;
5217         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5218         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5219         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5220         ret_ref = (uintptr_t)ret_var.inner;
5221         if (ret_var.is_owned) {
5222                 ret_ref |= 1;
5223         }
5224         return ret_ref;
5225 }
5226
5227 static inline struct LDKPhantomRouteHints CResult_PhantomRouteHintsDecodeErrorZ_get_ok(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR owner){
5228 CHECK(owner->result_ok);
5229         return PhantomRouteHints_clone(&*owner->contents.result);
5230 }
5231 uint32_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_get_ok"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_get_ok(uint32_t owner) {
5232         LDKCResult_PhantomRouteHintsDecodeErrorZ* owner_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(owner & ~1);
5233         LDKPhantomRouteHints ret_var = CResult_PhantomRouteHintsDecodeErrorZ_get_ok(owner_conv);
5234         uint32_t ret_ref = 0;
5235         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5236         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5237         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5238         ret_ref = (uintptr_t)ret_var.inner;
5239         if (ret_var.is_owned) {
5240                 ret_ref |= 1;
5241         }
5242         return ret_ref;
5243 }
5244
5245 static inline struct LDKDecodeError CResult_PhantomRouteHintsDecodeErrorZ_get_err(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR owner){
5246 CHECK(!owner->result_ok);
5247         return DecodeError_clone(&*owner->contents.err);
5248 }
5249 uint32_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_get_err"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_get_err(uint32_t owner) {
5250         LDKCResult_PhantomRouteHintsDecodeErrorZ* owner_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(owner & ~1);
5251         LDKDecodeError ret_var = CResult_PhantomRouteHintsDecodeErrorZ_get_err(owner_conv);
5252         uint32_t ret_ref = 0;
5253         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5254         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5255         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5256         ret_ref = (uintptr_t)ret_var.inner;
5257         if (ret_var.is_owned) {
5258                 ret_ref |= 1;
5259         }
5260         return ret_ref;
5261 }
5262
5263 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
5264         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
5265         for (size_t i = 0; i < ret.datalen; i++) {
5266                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
5267         }
5268         return ret;
5269 }
5270 typedef struct LDKWatch_JCalls {
5271         atomic_size_t refcnt;
5272         uint32_t instance_ptr;
5273 } LDKWatch_JCalls;
5274 static void LDKWatch_JCalls_free(void* this_arg) {
5275         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
5276         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5277                 FREE(j_calls);
5278         }
5279 }
5280 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
5281         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
5282         LDKOutPoint funding_txo_var = funding_txo;
5283         uint32_t funding_txo_ref = 0;
5284         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5285         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5286         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
5287         funding_txo_ref = (uintptr_t)funding_txo_var.inner;
5288         if (funding_txo_var.is_owned) {
5289                 funding_txo_ref |= 1;
5290         }
5291         LDKChannelMonitor monitor_var = monitor;
5292         uint32_t monitor_ref = 0;
5293         CHECK((((uintptr_t)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5294         CHECK((((uintptr_t)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5295         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_var);
5296         monitor_ref = (uintptr_t)monitor_var.inner;
5297         if (monitor_var.is_owned) {
5298                 monitor_ref |= 1;
5299         }
5300         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);
5301         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5302         CHECK_ACCESS(ret_ptr);
5303         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
5304         FREE((void*)ret);
5305         return ret_conv;
5306 }
5307 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
5308         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
5309         LDKOutPoint funding_txo_var = funding_txo;
5310         uint32_t funding_txo_ref = 0;
5311         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5312         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5313         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
5314         funding_txo_ref = (uintptr_t)funding_txo_var.inner;
5315         if (funding_txo_var.is_owned) {
5316                 funding_txo_ref |= 1;
5317         }
5318         LDKChannelMonitorUpdate update_var = update;
5319         uint32_t update_ref = 0;
5320         CHECK((((uintptr_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5321         CHECK((((uintptr_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5322         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
5323         update_ref = (uintptr_t)update_var.inner;
5324         if (update_var.is_owned) {
5325                 update_ref |= 1;
5326         }
5327         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);
5328         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5329         CHECK_ACCESS(ret_ptr);
5330         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
5331         FREE((void*)ret);
5332         return ret_conv;
5333 }
5334 LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ release_pending_monitor_events_LDKWatch_jcall(const void* this_arg) {
5335         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
5336         uint32_tArray ret = (uint32_tArray)js_invoke_function_uuuuuu(j_calls->instance_ptr, 18, 0, 0, 0, 0, 0, 0);
5337         LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ ret_constr;
5338         ret_constr.datalen = ret->arr_len;
5339         if (ret_constr.datalen > 0)
5340                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ Elements");
5341         else
5342                 ret_constr.data = NULL;
5343         uint32_t* ret_vals = ret->elems;
5344         for (size_t x = 0; x < ret_constr.datalen; x++) {
5345                 uint32_t ret_conv_49 = ret_vals[x];
5346                 void* ret_conv_49_ptr = (void*)(((uintptr_t)ret_conv_49) & ~1);
5347                 CHECK_ACCESS(ret_conv_49_ptr);
5348                 LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ ret_conv_49_conv = *(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(ret_conv_49_ptr);
5349                 FREE((void*)ret_conv_49);
5350                 ret_constr.data[x] = ret_conv_49_conv;
5351         }
5352         FREE(ret);
5353         return ret_constr;
5354 }
5355 static void LDKWatch_JCalls_cloned(LDKWatch* new_obj) {
5356         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) new_obj->this_arg;
5357         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5358 }
5359 static inline LDKWatch LDKWatch_init (JSValue o) {
5360         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
5361         atomic_init(&calls->refcnt, 1);
5362         calls->instance_ptr = o;
5363
5364         LDKWatch ret = {
5365                 .this_arg = (void*) calls,
5366                 .watch_channel = watch_channel_LDKWatch_jcall,
5367                 .update_channel = update_channel_LDKWatch_jcall,
5368                 .release_pending_monitor_events = release_pending_monitor_events_LDKWatch_jcall,
5369                 .free = LDKWatch_JCalls_free,
5370         };
5371         return ret;
5372 }
5373 long  __attribute__((export_name("TS_LDKWatch_new"))) TS_LDKWatch_new(JSValue o) {
5374         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
5375         *res_ptr = LDKWatch_init(o);
5376         return (long)res_ptr;
5377 }
5378 uint32_t  __attribute__((export_name("TS_Watch_watch_channel"))) TS_Watch_watch_channel(uint32_t this_arg, uint32_t funding_txo, uint32_t monitor) {
5379         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5380         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5381         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
5382         LDKOutPoint funding_txo_conv;
5383         funding_txo_conv.inner = (void*)(funding_txo & (~1));
5384         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
5385         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
5386         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
5387         LDKChannelMonitor monitor_conv;
5388         monitor_conv.inner = (void*)(monitor & (~1));
5389         monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
5390         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_conv);
5391         monitor_conv = ChannelMonitor_clone(&monitor_conv);
5392         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
5393         *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
5394         return (uint32_t)ret_conv;
5395 }
5396
5397 uint32_t  __attribute__((export_name("TS_Watch_update_channel"))) TS_Watch_update_channel(uint32_t this_arg, uint32_t funding_txo, uint32_t update) {
5398         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5399         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5400         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
5401         LDKOutPoint funding_txo_conv;
5402         funding_txo_conv.inner = (void*)(funding_txo & (~1));
5403         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
5404         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
5405         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
5406         LDKChannelMonitorUpdate update_conv;
5407         update_conv.inner = (void*)(update & (~1));
5408         update_conv.is_owned = (update & 1) || (update == 0);
5409         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
5410         update_conv = ChannelMonitorUpdate_clone(&update_conv);
5411         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
5412         *ret_conv = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
5413         return (uint32_t)ret_conv;
5414 }
5415
5416 uint32_tArray  __attribute__((export_name("TS_Watch_release_pending_monitor_events"))) TS_Watch_release_pending_monitor_events(uint32_t this_arg) {
5417         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5418         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5419         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
5420         LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
5421         uint32_tArray ret_arr = NULL;
5422         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
5423         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 8);
5424         for (size_t x = 0; x < ret_var.datalen; x++) {
5425                 LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* ret_conv_49_conv = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ");
5426                 *ret_conv_49_conv = ret_var.data[x];
5427                 ret_arr_ptr[x] = ((uint32_t)ret_conv_49_conv);
5428         }
5429         
5430         FREE(ret_var.data);
5431         return ret_arr;
5432 }
5433
5434 typedef struct LDKBroadcasterInterface_JCalls {
5435         atomic_size_t refcnt;
5436         uint32_t instance_ptr;
5437 } LDKBroadcasterInterface_JCalls;
5438 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
5439         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
5440         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5441                 FREE(j_calls);
5442         }
5443 }
5444 void broadcast_transaction_LDKBroadcasterInterface_jcall(const void* this_arg, LDKTransaction tx) {
5445         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
5446         LDKTransaction tx_var = tx;
5447         int8_tArray tx_arr = init_int8_tArray(tx_var.datalen, __LINE__);
5448         memcpy(tx_arr->elems, tx_var.data, tx_var.datalen);
5449         Transaction_free(tx_var);
5450         js_invoke_function_uuuuuu(j_calls->instance_ptr, 19, (uint32_t)tx_arr, 0, 0, 0, 0, 0);
5451 }
5452 static void LDKBroadcasterInterface_JCalls_cloned(LDKBroadcasterInterface* new_obj) {
5453         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) new_obj->this_arg;
5454         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5455 }
5456 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (JSValue o) {
5457         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
5458         atomic_init(&calls->refcnt, 1);
5459         calls->instance_ptr = o;
5460
5461         LDKBroadcasterInterface ret = {
5462                 .this_arg = (void*) calls,
5463                 .broadcast_transaction = broadcast_transaction_LDKBroadcasterInterface_jcall,
5464                 .free = LDKBroadcasterInterface_JCalls_free,
5465         };
5466         return ret;
5467 }
5468 long  __attribute__((export_name("TS_LDKBroadcasterInterface_new"))) TS_LDKBroadcasterInterface_new(JSValue o) {
5469         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
5470         *res_ptr = LDKBroadcasterInterface_init(o);
5471         return (long)res_ptr;
5472 }
5473 void  __attribute__((export_name("TS_BroadcasterInterface_broadcast_transaction"))) TS_BroadcasterInterface_broadcast_transaction(uint32_t this_arg, int8_tArray tx) {
5474         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5475         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5476         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)this_arg_ptr;
5477         LDKTransaction tx_ref;
5478         tx_ref.datalen = tx->arr_len;
5479         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
5480         memcpy(tx_ref.data, tx->elems, tx_ref.datalen); FREE(tx);
5481         tx_ref.data_is_owned = true;
5482         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
5483 }
5484
5485 typedef struct LDKKeysInterface_JCalls {
5486         atomic_size_t refcnt;
5487         uint32_t instance_ptr;
5488 } LDKKeysInterface_JCalls;
5489 static void LDKKeysInterface_JCalls_free(void* this_arg) {
5490         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5491         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5492                 FREE(j_calls);
5493         }
5494 }
5495 LDKCResult_SecretKeyNoneZ get_node_secret_LDKKeysInterface_jcall(const void* this_arg, LDKRecipient recipient) {
5496         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5497         uint32_t recipient_conv = LDKRecipient_to_js(recipient);
5498         uint32_t ret = js_invoke_function_uuuuuu(j_calls->instance_ptr, 20, (uint32_t)recipient_conv, 0, 0, 0, 0, 0);
5499         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5500         CHECK_ACCESS(ret_ptr);
5501         LDKCResult_SecretKeyNoneZ ret_conv = *(LDKCResult_SecretKeyNoneZ*)(ret_ptr);
5502         FREE((void*)ret);
5503         return ret_conv;
5504 }
5505 LDKCVec_u8Z get_destination_script_LDKKeysInterface_jcall(const void* this_arg) {
5506         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5507         int8_tArray ret = (int8_tArray)js_invoke_function_uuuuuu(j_calls->instance_ptr, 21, 0, 0, 0, 0, 0, 0);
5508         LDKCVec_u8Z ret_ref;
5509         ret_ref.datalen = ret->arr_len;
5510         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
5511         memcpy(ret_ref.data, ret->elems, ret_ref.datalen); FREE(ret);
5512         return ret_ref;
5513 }
5514 LDKShutdownScript get_shutdown_scriptpubkey_LDKKeysInterface_jcall(const void* this_arg) {
5515         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5516         uint32_t ret = js_invoke_function_uuuuuu(j_calls->instance_ptr, 22, 0, 0, 0, 0, 0, 0);
5517         LDKShutdownScript ret_conv;
5518         ret_conv.inner = (void*)(ret & (~1));
5519         ret_conv.is_owned = (ret & 1) || (ret == 0);
5520         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
5521         return ret_conv;
5522 }
5523 LDKSign get_channel_signer_LDKKeysInterface_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
5524         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5525         jboolean inbound_conv = inbound;
5526         int64_t channel_value_satoshis_conv = channel_value_satoshis;
5527         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);
5528         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5529         CHECK_ACCESS(ret_ptr);
5530         LDKSign ret_conv = *(LDKSign*)(ret_ptr);
5531         FREE((void*)ret);
5532         return ret_conv;
5533 }
5534 LDKThirtyTwoBytes get_secure_random_bytes_LDKKeysInterface_jcall(const void* this_arg) {
5535         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5536         int8_tArray ret = (int8_tArray)js_invoke_function_uuuuuu(j_calls->instance_ptr, 24, 0, 0, 0, 0, 0, 0);
5537         LDKThirtyTwoBytes ret_ref;
5538         CHECK(ret->arr_len == 32);
5539         memcpy(ret_ref.data, ret->elems, 32); FREE(ret);
5540         return ret_ref;
5541 }
5542 LDKCResult_SignDecodeErrorZ read_chan_signer_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice reader) {
5543         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5544         LDKu8slice reader_var = reader;
5545         int8_tArray reader_arr = init_int8_tArray(reader_var.datalen, __LINE__);
5546         memcpy(reader_arr->elems, reader_var.data, reader_var.datalen);
5547         uint32_t ret = js_invoke_function_uuuuuu(j_calls->instance_ptr, 25, (uint32_t)reader_arr, 0, 0, 0, 0, 0);
5548         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5549         CHECK_ACCESS(ret_ptr);
5550         LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(ret_ptr);
5551         FREE((void*)ret);
5552         return ret_conv;
5553 }
5554 LDKCResult_RecoverableSignatureNoneZ sign_invoice_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice hrp_bytes, LDKCVec_u5Z invoice_data, LDKRecipient receipient) {
5555         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5556         LDKu8slice hrp_bytes_var = hrp_bytes;
5557         int8_tArray hrp_bytes_arr = init_int8_tArray(hrp_bytes_var.datalen, __LINE__);
5558         memcpy(hrp_bytes_arr->elems, hrp_bytes_var.data, hrp_bytes_var.datalen);
5559         LDKCVec_u5Z invoice_data_var = invoice_data;
5560         ptrArray invoice_data_arr = NULL;
5561         invoice_data_arr = init_ptrArray(invoice_data_var.datalen, __LINE__);
5562         int8_t *invoice_data_arr_ptr = (int8_t*)(((uint8_t*)invoice_data_arr) + 8);
5563         for (size_t h = 0; h < invoice_data_var.datalen; h++) {
5564                 uint8_t invoice_data_conv_7_val = invoice_data_var.data[h]._0;
5565                 invoice_data_arr_ptr[h] = invoice_data_conv_7_val;
5566         }
5567         
5568         FREE(invoice_data_var.data);
5569         uint32_t receipient_conv = LDKRecipient_to_js(receipient);
5570         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);
5571         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5572         CHECK_ACCESS(ret_ptr);
5573         LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(ret_ptr);
5574         FREE((void*)ret);
5575         return ret_conv;
5576 }
5577 LDKThirtyTwoBytes get_inbound_payment_key_material_LDKKeysInterface_jcall(const void* this_arg) {
5578         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5579         int8_tArray ret = (int8_tArray)js_invoke_function_uuuuuu(j_calls->instance_ptr, 27, 0, 0, 0, 0, 0, 0);
5580         LDKThirtyTwoBytes ret_ref;
5581         CHECK(ret->arr_len == 32);
5582         memcpy(ret_ref.data, ret->elems, 32); FREE(ret);
5583         return ret_ref;
5584 }
5585 static void LDKKeysInterface_JCalls_cloned(LDKKeysInterface* new_obj) {
5586         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) new_obj->this_arg;
5587         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5588 }
5589 static inline LDKKeysInterface LDKKeysInterface_init (JSValue o) {
5590         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
5591         atomic_init(&calls->refcnt, 1);
5592         calls->instance_ptr = o;
5593
5594         LDKKeysInterface ret = {
5595                 .this_arg = (void*) calls,
5596                 .get_node_secret = get_node_secret_LDKKeysInterface_jcall,
5597                 .get_destination_script = get_destination_script_LDKKeysInterface_jcall,
5598                 .get_shutdown_scriptpubkey = get_shutdown_scriptpubkey_LDKKeysInterface_jcall,
5599                 .get_channel_signer = get_channel_signer_LDKKeysInterface_jcall,
5600                 .get_secure_random_bytes = get_secure_random_bytes_LDKKeysInterface_jcall,
5601                 .read_chan_signer = read_chan_signer_LDKKeysInterface_jcall,
5602                 .sign_invoice = sign_invoice_LDKKeysInterface_jcall,
5603                 .get_inbound_payment_key_material = get_inbound_payment_key_material_LDKKeysInterface_jcall,
5604                 .free = LDKKeysInterface_JCalls_free,
5605         };
5606         return ret;
5607 }
5608 long  __attribute__((export_name("TS_LDKKeysInterface_new"))) TS_LDKKeysInterface_new(JSValue o) {
5609         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
5610         *res_ptr = LDKKeysInterface_init(o);
5611         return (long)res_ptr;
5612 }
5613 uint32_t  __attribute__((export_name("TS_KeysInterface_get_node_secret"))) TS_KeysInterface_get_node_secret(uint32_t this_arg, uint32_t recipient) {
5614         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5615         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5616         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
5617         LDKRecipient recipient_conv = LDKRecipient_from_js(recipient);
5618         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
5619         *ret_conv = (this_arg_conv->get_node_secret)(this_arg_conv->this_arg, recipient_conv);
5620         return (uint32_t)ret_conv;
5621 }
5622
5623 int8_tArray  __attribute__((export_name("TS_KeysInterface_get_destination_script"))) TS_KeysInterface_get_destination_script(uint32_t this_arg) {
5624         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5625         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5626         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
5627         LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
5628         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
5629         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
5630         CVec_u8Z_free(ret_var);
5631         return ret_arr;
5632 }
5633
5634 uint32_t  __attribute__((export_name("TS_KeysInterface_get_shutdown_scriptpubkey"))) TS_KeysInterface_get_shutdown_scriptpubkey(uint32_t this_arg) {
5635         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5636         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5637         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
5638         LDKShutdownScript ret_var = (this_arg_conv->get_shutdown_scriptpubkey)(this_arg_conv->this_arg);
5639         uint32_t ret_ref = 0;
5640         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5641         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5642         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5643         ret_ref = (uintptr_t)ret_var.inner;
5644         if (ret_var.is_owned) {
5645                 ret_ref |= 1;
5646         }
5647         return ret_ref;
5648 }
5649
5650 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) {
5651         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5652         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5653         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
5654         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
5655         *ret_ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
5656         return (uint32_t)ret_ret;
5657 }
5658
5659 int8_tArray  __attribute__((export_name("TS_KeysInterface_get_secure_random_bytes"))) TS_KeysInterface_get_secure_random_bytes(uint32_t this_arg) {
5660         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5661         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5662         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
5663         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5664         memcpy(ret_arr->elems, (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data, 32);
5665         return ret_arr;
5666 }
5667
5668 uint32_t  __attribute__((export_name("TS_KeysInterface_read_chan_signer"))) TS_KeysInterface_read_chan_signer(uint32_t this_arg, int8_tArray reader) {
5669         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5670         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5671         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
5672         LDKu8slice reader_ref;
5673         reader_ref.datalen = reader->arr_len;
5674         reader_ref.data = reader->elems;
5675         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
5676         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
5677         FREE(reader);
5678         return (uint32_t)ret_conv;
5679 }
5680
5681 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) {
5682         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5683         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5684         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
5685         LDKu8slice hrp_bytes_ref;
5686         hrp_bytes_ref.datalen = hrp_bytes->arr_len;
5687         hrp_bytes_ref.data = hrp_bytes->elems;
5688         LDKCVec_u5Z invoice_data_constr;
5689         invoice_data_constr.datalen = invoice_data->arr_len;
5690         if (invoice_data_constr.datalen > 0)
5691                 invoice_data_constr.data = MALLOC(invoice_data_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
5692         else
5693                 invoice_data_constr.data = NULL;
5694         int8_t* invoice_data_vals = (void*) invoice_data->elems;
5695         for (size_t h = 0; h < invoice_data_constr.datalen; h++) {
5696                 int8_t invoice_data_conv_7 = invoice_data_vals[h];
5697                 
5698                 invoice_data_constr.data[h] = (LDKu5){ ._0 = invoice_data_conv_7 };
5699         }
5700         FREE(invoice_data);
5701         LDKRecipient receipient_conv = LDKRecipient_from_js(receipient);
5702         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
5703         *ret_conv = (this_arg_conv->sign_invoice)(this_arg_conv->this_arg, hrp_bytes_ref, invoice_data_constr, receipient_conv);
5704         FREE(hrp_bytes);
5705         return (uint32_t)ret_conv;
5706 }
5707
5708 int8_tArray  __attribute__((export_name("TS_KeysInterface_get_inbound_payment_key_material"))) TS_KeysInterface_get_inbound_payment_key_material(uint32_t this_arg) {
5709         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5710         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5711         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
5712         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5713         memcpy(ret_arr->elems, (this_arg_conv->get_inbound_payment_key_material)(this_arg_conv->this_arg).data, 32);
5714         return ret_arr;
5715 }
5716
5717 typedef struct LDKFeeEstimator_JCalls {
5718         atomic_size_t refcnt;
5719         uint32_t instance_ptr;
5720 } LDKFeeEstimator_JCalls;
5721 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
5722         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
5723         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5724                 FREE(j_calls);
5725         }
5726 }
5727 uint32_t get_est_sat_per_1000_weight_LDKFeeEstimator_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
5728         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
5729         uint32_t confirmation_target_conv = LDKConfirmationTarget_to_js(confirmation_target);
5730         return js_invoke_function_uuuuuu(j_calls->instance_ptr, 28, (uint32_t)confirmation_target_conv, 0, 0, 0, 0, 0);
5731 }
5732 static void LDKFeeEstimator_JCalls_cloned(LDKFeeEstimator* new_obj) {
5733         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) new_obj->this_arg;
5734         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5735 }
5736 static inline LDKFeeEstimator LDKFeeEstimator_init (JSValue o) {
5737         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
5738         atomic_init(&calls->refcnt, 1);
5739         calls->instance_ptr = o;
5740
5741         LDKFeeEstimator ret = {
5742                 .this_arg = (void*) calls,
5743                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_LDKFeeEstimator_jcall,
5744                 .free = LDKFeeEstimator_JCalls_free,
5745         };
5746         return ret;
5747 }
5748 long  __attribute__((export_name("TS_LDKFeeEstimator_new"))) TS_LDKFeeEstimator_new(JSValue o) {
5749         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
5750         *res_ptr = LDKFeeEstimator_init(o);
5751         return (long)res_ptr;
5752 }
5753 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) {
5754         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5755         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5756         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)this_arg_ptr;
5757         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_js(confirmation_target);
5758         int32_t ret_conv = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
5759         return ret_conv;
5760 }
5761
5762 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelManagerZ_get_a(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
5763         return ThirtyTwoBytes_clone(&owner->a);
5764 }
5765 int8_tArray  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_get_a"))) TS_C2Tuple_BlockHashChannelManagerZ_get_a(uint32_t owner) {
5766         LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(owner & ~1);
5767         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5768         memcpy(ret_arr->elems, C2Tuple_BlockHashChannelManagerZ_get_a(owner_conv).data, 32);
5769         return ret_arr;
5770 }
5771
5772 static inline struct LDKChannelManager *C2Tuple_BlockHashChannelManagerZ_get_b(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
5773         return &owner->b;
5774 }
5775 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_get_b"))) TS_C2Tuple_BlockHashChannelManagerZ_get_b(uint32_t owner) {
5776         LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(owner & ~1);
5777         LDKChannelManager ret_var = *C2Tuple_BlockHashChannelManagerZ_get_b(owner_conv);
5778         uint32_t ret_ref = 0;
5779         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5780         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5781         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5782         ret_ref = (uintptr_t)ret_var.inner & ~1;
5783         return ret_ref;
5784 }
5785
5786 static inline struct LDKC2Tuple_BlockHashChannelManagerZ *CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
5787 CHECK(owner->result_ok);
5788         return &*owner->contents.result;
5789 }
5790 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(uint32_t owner) {
5791         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(owner & ~1);
5792         uint32_t ret_ret = (uintptr_t)CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(owner_conv) | 1;
5793         return ret_ret;
5794 }
5795
5796 static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
5797 CHECK(!owner->result_ok);
5798         return DecodeError_clone(&*owner->contents.err);
5799 }
5800 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(uint32_t owner) {
5801         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(owner & ~1);
5802         LDKDecodeError ret_var = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(owner_conv);
5803         uint32_t ret_ref = 0;
5804         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5805         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5806         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5807         ret_ref = (uintptr_t)ret_var.inner;
5808         if (ret_var.is_owned) {
5809                 ret_ref |= 1;
5810         }
5811         return ret_ref;
5812 }
5813
5814 static inline struct LDKChannelConfig CResult_ChannelConfigDecodeErrorZ_get_ok(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
5815 CHECK(owner->result_ok);
5816         return ChannelConfig_clone(&*owner->contents.result);
5817 }
5818 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_get_ok"))) TS_CResult_ChannelConfigDecodeErrorZ_get_ok(uint32_t owner) {
5819         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(owner & ~1);
5820         LDKChannelConfig ret_var = CResult_ChannelConfigDecodeErrorZ_get_ok(owner_conv);
5821         uint32_t ret_ref = 0;
5822         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5823         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5824         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5825         ret_ref = (uintptr_t)ret_var.inner;
5826         if (ret_var.is_owned) {
5827                 ret_ref |= 1;
5828         }
5829         return ret_ref;
5830 }
5831
5832 static inline struct LDKDecodeError CResult_ChannelConfigDecodeErrorZ_get_err(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
5833 CHECK(!owner->result_ok);
5834         return DecodeError_clone(&*owner->contents.err);
5835 }
5836 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_get_err"))) TS_CResult_ChannelConfigDecodeErrorZ_get_err(uint32_t owner) {
5837         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(owner & ~1);
5838         LDKDecodeError ret_var = CResult_ChannelConfigDecodeErrorZ_get_err(owner_conv);
5839         uint32_t ret_ref = 0;
5840         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5841         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5842         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5843         ret_ref = (uintptr_t)ret_var.inner;
5844         if (ret_var.is_owned) {
5845                 ret_ref |= 1;
5846         }
5847         return ret_ref;
5848 }
5849
5850 static inline struct LDKOutPoint CResult_OutPointDecodeErrorZ_get_ok(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
5851 CHECK(owner->result_ok);
5852         return OutPoint_clone(&*owner->contents.result);
5853 }
5854 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_get_ok"))) TS_CResult_OutPointDecodeErrorZ_get_ok(uint32_t owner) {
5855         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)(owner & ~1);
5856         LDKOutPoint ret_var = CResult_OutPointDecodeErrorZ_get_ok(owner_conv);
5857         uint32_t ret_ref = 0;
5858         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5859         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5860         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5861         ret_ref = (uintptr_t)ret_var.inner;
5862         if (ret_var.is_owned) {
5863                 ret_ref |= 1;
5864         }
5865         return ret_ref;
5866 }
5867
5868 static inline struct LDKDecodeError CResult_OutPointDecodeErrorZ_get_err(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
5869 CHECK(!owner->result_ok);
5870         return DecodeError_clone(&*owner->contents.err);
5871 }
5872 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_get_err"))) TS_CResult_OutPointDecodeErrorZ_get_err(uint32_t owner) {
5873         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)(owner & ~1);
5874         LDKDecodeError ret_var = CResult_OutPointDecodeErrorZ_get_err(owner_conv);
5875         uint32_t ret_ref = 0;
5876         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5877         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5878         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5879         ret_ref = (uintptr_t)ret_var.inner;
5880         if (ret_var.is_owned) {
5881                 ret_ref |= 1;
5882         }
5883         return ret_ref;
5884 }
5885
5886 typedef struct LDKType_JCalls {
5887         atomic_size_t refcnt;
5888         uint32_t instance_ptr;
5889 } LDKType_JCalls;
5890 static void LDKType_JCalls_free(void* this_arg) {
5891         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
5892         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5893                 FREE(j_calls);
5894         }
5895 }
5896 uint16_t type_id_LDKType_jcall(const void* this_arg) {
5897         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
5898         return js_invoke_function_uuuuuu(j_calls->instance_ptr, 29, 0, 0, 0, 0, 0, 0);
5899 }
5900 LDKStr debug_str_LDKType_jcall(const void* this_arg) {
5901         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
5902         jstring ret = (jstring)js_invoke_function_uuuuuu(j_calls->instance_ptr, 30, 0, 0, 0, 0, 0, 0);
5903         LDKStr ret_conv = str_ref_to_owned_c(ret);
5904         return ret_conv;
5905 }
5906 LDKCVec_u8Z write_LDKType_jcall(const void* this_arg) {
5907         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
5908         int8_tArray ret = (int8_tArray)js_invoke_function_uuuuuu(j_calls->instance_ptr, 31, 0, 0, 0, 0, 0, 0);
5909         LDKCVec_u8Z ret_ref;
5910         ret_ref.datalen = ret->arr_len;
5911         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
5912         memcpy(ret_ref.data, ret->elems, ret_ref.datalen); FREE(ret);
5913         return ret_ref;
5914 }
5915 static void LDKType_JCalls_cloned(LDKType* new_obj) {
5916         LDKType_JCalls *j_calls = (LDKType_JCalls*) new_obj->this_arg;
5917         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5918 }
5919 static inline LDKType LDKType_init (JSValue o) {
5920         LDKType_JCalls *calls = MALLOC(sizeof(LDKType_JCalls), "LDKType_JCalls");
5921         atomic_init(&calls->refcnt, 1);
5922         calls->instance_ptr = o;
5923
5924         LDKType ret = {
5925                 .this_arg = (void*) calls,
5926                 .type_id = type_id_LDKType_jcall,
5927                 .debug_str = debug_str_LDKType_jcall,
5928                 .write = write_LDKType_jcall,
5929                 .cloned = LDKType_JCalls_cloned,
5930                 .free = LDKType_JCalls_free,
5931         };
5932         return ret;
5933 }
5934 long  __attribute__((export_name("TS_LDKType_new"))) TS_LDKType_new(JSValue o) {
5935         LDKType *res_ptr = MALLOC(sizeof(LDKType), "LDKType");
5936         *res_ptr = LDKType_init(o);
5937         return (long)res_ptr;
5938 }
5939 int16_t  __attribute__((export_name("TS_Type_type_id"))) TS_Type_type_id(uint32_t this_arg) {
5940         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5941         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5942         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
5943         int16_t ret_conv = (this_arg_conv->type_id)(this_arg_conv->this_arg);
5944         return ret_conv;
5945 }
5946
5947 jstring  __attribute__((export_name("TS_Type_debug_str"))) TS_Type_debug_str(uint32_t this_arg) {
5948         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5949         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5950         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
5951         LDKStr ret_str = (this_arg_conv->debug_str)(this_arg_conv->this_arg);
5952         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
5953         Str_free(ret_str);
5954         return ret_conv;
5955 }
5956
5957 int8_tArray  __attribute__((export_name("TS_Type_write"))) TS_Type_write(uint32_t this_arg) {
5958         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5959         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5960         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
5961         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
5962         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
5963         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
5964         CVec_u8Z_free(ret_var);
5965         return ret_arr;
5966 }
5967
5968 uint32_t __attribute__((export_name("TS_LDKCOption_TypeZ_ty_from_ptr"))) TS_LDKCOption_TypeZ_ty_from_ptr(uint32_t ptr) {
5969         LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)(ptr & ~1);
5970         switch(obj->tag) {
5971                 case LDKCOption_TypeZ_Some: return 0;
5972                 case LDKCOption_TypeZ_None: return 1;
5973                 default: abort();
5974         }
5975 }
5976 uint32_t __attribute__((export_name("TS_LDKCOption_TypeZ_Some_get_some"))) TS_LDKCOption_TypeZ_Some_get_some(uint32_t ptr) {
5977         LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)(ptr & ~1);
5978         assert(obj->tag == LDKCOption_TypeZ_Some);
5979                         LDKType* some_ret = MALLOC(sizeof(LDKType), "LDKType");
5980                         *some_ret = Type_clone(&obj->some);
5981         return (uint32_t)some_ret;
5982 }
5983 static inline struct LDKCOption_TypeZ CResult_COption_TypeZDecodeErrorZ_get_ok(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
5984 CHECK(owner->result_ok);
5985         return COption_TypeZ_clone(&*owner->contents.result);
5986 }
5987 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_get_ok"))) TS_CResult_COption_TypeZDecodeErrorZ_get_ok(uint32_t owner) {
5988         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(owner & ~1);
5989         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
5990         *ret_copy = CResult_COption_TypeZDecodeErrorZ_get_ok(owner_conv);
5991         uint32_t ret_ref = (uintptr_t)ret_copy;
5992         return ret_ref;
5993 }
5994
5995 static inline struct LDKDecodeError CResult_COption_TypeZDecodeErrorZ_get_err(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
5996 CHECK(!owner->result_ok);
5997         return DecodeError_clone(&*owner->contents.err);
5998 }
5999 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_get_err"))) TS_CResult_COption_TypeZDecodeErrorZ_get_err(uint32_t owner) {
6000         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(owner & ~1);
6001         LDKDecodeError ret_var = CResult_COption_TypeZDecodeErrorZ_get_err(owner_conv);
6002         uint32_t ret_ref = 0;
6003         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6004         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6005         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6006         ret_ref = (uintptr_t)ret_var.inner;
6007         if (ret_var.is_owned) {
6008                 ret_ref |= 1;
6009         }
6010         return ret_ref;
6011 }
6012
6013 uint32_t __attribute__((export_name("TS_LDKPaymentError_ty_from_ptr"))) TS_LDKPaymentError_ty_from_ptr(uint32_t ptr) {
6014         LDKPaymentError *obj = (LDKPaymentError*)(ptr & ~1);
6015         switch(obj->tag) {
6016                 case LDKPaymentError_Invoice: return 0;
6017                 case LDKPaymentError_Routing: return 1;
6018                 case LDKPaymentError_Sending: return 2;
6019                 default: abort();
6020         }
6021 }
6022 jstring __attribute__((export_name("TS_LDKPaymentError_Invoice_get_invoice"))) TS_LDKPaymentError_Invoice_get_invoice(uint32_t ptr) {
6023         LDKPaymentError *obj = (LDKPaymentError*)(ptr & ~1);
6024         assert(obj->tag == LDKPaymentError_Invoice);
6025                         LDKStr invoice_str = obj->invoice;
6026                         jstring invoice_conv = str_ref_to_ts(invoice_str.chars, invoice_str.len);
6027         return invoice_conv;
6028 }
6029 uint32_t __attribute__((export_name("TS_LDKPaymentError_Routing_get_routing"))) TS_LDKPaymentError_Routing_get_routing(uint32_t ptr) {
6030         LDKPaymentError *obj = (LDKPaymentError*)(ptr & ~1);
6031         assert(obj->tag == LDKPaymentError_Routing);
6032                         LDKLightningError routing_var = obj->routing;
6033                         uint32_t routing_ref = 0;
6034                         CHECK((((uintptr_t)routing_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6035                         CHECK((((uintptr_t)&routing_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6036                         CHECK_INNER_FIELD_ACCESS_OR_NULL(routing_var);
6037                         routing_ref = (uintptr_t)routing_var.inner & ~1;
6038         return routing_ref;
6039 }
6040 uint32_t __attribute__((export_name("TS_LDKPaymentError_Sending_get_sending"))) TS_LDKPaymentError_Sending_get_sending(uint32_t ptr) {
6041         LDKPaymentError *obj = (LDKPaymentError*)(ptr & ~1);
6042         assert(obj->tag == LDKPaymentError_Sending);
6043                         uint32_t sending_ref = ((uintptr_t)&obj->sending) | 1;
6044         return sending_ref;
6045 }
6046 static inline struct LDKThirtyTwoBytes CResult_PaymentIdPaymentErrorZ_get_ok(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR owner){
6047 CHECK(owner->result_ok);
6048         return ThirtyTwoBytes_clone(&*owner->contents.result);
6049 }
6050 int8_tArray  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_get_ok"))) TS_CResult_PaymentIdPaymentErrorZ_get_ok(uint32_t owner) {
6051         LDKCResult_PaymentIdPaymentErrorZ* owner_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(owner & ~1);
6052         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
6053         memcpy(ret_arr->elems, CResult_PaymentIdPaymentErrorZ_get_ok(owner_conv).data, 32);
6054         return ret_arr;
6055 }
6056
6057 static inline struct LDKPaymentError CResult_PaymentIdPaymentErrorZ_get_err(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR owner){
6058 CHECK(!owner->result_ok);
6059         return PaymentError_clone(&*owner->contents.err);
6060 }
6061 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_get_err"))) TS_CResult_PaymentIdPaymentErrorZ_get_err(uint32_t owner) {
6062         LDKCResult_PaymentIdPaymentErrorZ* owner_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(owner & ~1);
6063         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
6064         *ret_copy = CResult_PaymentIdPaymentErrorZ_get_err(owner_conv);
6065         uint32_t ret_ref = (uintptr_t)ret_copy;
6066         return ret_ref;
6067 }
6068
6069 uint32_t __attribute__((export_name("TS_LDKParseError_ty_from_ptr"))) TS_LDKParseError_ty_from_ptr(uint32_t ptr) {
6070         LDKParseError *obj = (LDKParseError*)(ptr & ~1);
6071         switch(obj->tag) {
6072                 case LDKParseError_Bech32Error: return 0;
6073                 case LDKParseError_ParseAmountError: return 1;
6074                 case LDKParseError_MalformedSignature: return 2;
6075                 case LDKParseError_BadPrefix: return 3;
6076                 case LDKParseError_UnknownCurrency: return 4;
6077                 case LDKParseError_UnknownSiPrefix: return 5;
6078                 case LDKParseError_MalformedHRP: return 6;
6079                 case LDKParseError_TooShortDataPart: return 7;
6080                 case LDKParseError_UnexpectedEndOfTaggedFields: return 8;
6081                 case LDKParseError_DescriptionDecodeError: return 9;
6082                 case LDKParseError_PaddingError: return 10;
6083                 case LDKParseError_IntegerOverflowError: return 11;
6084                 case LDKParseError_InvalidSegWitProgramLength: return 12;
6085                 case LDKParseError_InvalidPubKeyHashLength: return 13;
6086                 case LDKParseError_InvalidScriptHashLength: return 14;
6087                 case LDKParseError_InvalidRecoveryId: return 15;
6088                 case LDKParseError_InvalidSliceLength: return 16;
6089                 case LDKParseError_Skip: return 17;
6090                 default: abort();
6091         }
6092 }
6093 uint32_t __attribute__((export_name("TS_LDKParseError_Bech32Error_get_bech32_error"))) TS_LDKParseError_Bech32Error_get_bech32_error(uint32_t ptr) {
6094         LDKParseError *obj = (LDKParseError*)(ptr & ~1);
6095         assert(obj->tag == LDKParseError_Bech32Error);
6096                         uint32_t bech32_error_ref = ((uintptr_t)&obj->bech32_error) | 1;
6097         return bech32_error_ref;
6098 }
6099 int32_t __attribute__((export_name("TS_LDKParseError_ParseAmountError_get_parse_amount_error"))) TS_LDKParseError_ParseAmountError_get_parse_amount_error(uint32_t ptr) {
6100         LDKParseError *obj = (LDKParseError*)(ptr & ~1);
6101         assert(obj->tag == LDKParseError_ParseAmountError);
6102                         /*obj->parse_amount_error*/
6103         return 0;
6104 }
6105 uint32_t __attribute__((export_name("TS_LDKParseError_MalformedSignature_get_malformed_signature"))) TS_LDKParseError_MalformedSignature_get_malformed_signature(uint32_t ptr) {
6106         LDKParseError *obj = (LDKParseError*)(ptr & ~1);
6107         assert(obj->tag == LDKParseError_MalformedSignature);
6108                         uint32_t malformed_signature_conv = LDKSecp256k1Error_to_js(obj->malformed_signature);
6109         return malformed_signature_conv;
6110 }
6111 int32_t __attribute__((export_name("TS_LDKParseError_DescriptionDecodeError_get_description_decode_error"))) TS_LDKParseError_DescriptionDecodeError_get_description_decode_error(uint32_t ptr) {
6112         LDKParseError *obj = (LDKParseError*)(ptr & ~1);
6113         assert(obj->tag == LDKParseError_DescriptionDecodeError);
6114                         /*obj->description_decode_error*/
6115         return 0;
6116 }
6117 jstring __attribute__((export_name("TS_LDKParseError_InvalidSliceLength_get_invalid_slice_length"))) TS_LDKParseError_InvalidSliceLength_get_invalid_slice_length(uint32_t ptr) {
6118         LDKParseError *obj = (LDKParseError*)(ptr & ~1);
6119         assert(obj->tag == LDKParseError_InvalidSliceLength);
6120                         LDKStr invalid_slice_length_str = obj->invalid_slice_length;
6121                         jstring invalid_slice_length_conv = str_ref_to_ts(invalid_slice_length_str.chars, invalid_slice_length_str.len);
6122         return invalid_slice_length_conv;
6123 }
6124 static inline enum LDKSiPrefix CResult_SiPrefixParseErrorZ_get_ok(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR owner){
6125 CHECK(owner->result_ok);
6126         return SiPrefix_clone(&*owner->contents.result);
6127 }
6128 uint32_t  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_get_ok"))) TS_CResult_SiPrefixParseErrorZ_get_ok(uint32_t owner) {
6129         LDKCResult_SiPrefixParseErrorZ* owner_conv = (LDKCResult_SiPrefixParseErrorZ*)(owner & ~1);
6130         uint32_t ret_conv = LDKSiPrefix_to_js(CResult_SiPrefixParseErrorZ_get_ok(owner_conv));
6131         return ret_conv;
6132 }
6133
6134 static inline struct LDKParseError CResult_SiPrefixParseErrorZ_get_err(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR owner){
6135 CHECK(!owner->result_ok);
6136         return ParseError_clone(&*owner->contents.err);
6137 }
6138 uint32_t  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_get_err"))) TS_CResult_SiPrefixParseErrorZ_get_err(uint32_t owner) {
6139         LDKCResult_SiPrefixParseErrorZ* owner_conv = (LDKCResult_SiPrefixParseErrorZ*)(owner & ~1);
6140         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
6141         *ret_copy = CResult_SiPrefixParseErrorZ_get_err(owner_conv);
6142         uint32_t ret_ref = (uintptr_t)ret_copy;
6143         return ret_ref;
6144 }
6145
6146 uint32_t __attribute__((export_name("TS_LDKParseOrSemanticError_ty_from_ptr"))) TS_LDKParseOrSemanticError_ty_from_ptr(uint32_t ptr) {
6147         LDKParseOrSemanticError *obj = (LDKParseOrSemanticError*)(ptr & ~1);
6148         switch(obj->tag) {
6149                 case LDKParseOrSemanticError_ParseError: return 0;
6150                 case LDKParseOrSemanticError_SemanticError: return 1;
6151                 default: abort();
6152         }
6153 }
6154 uint32_t __attribute__((export_name("TS_LDKParseOrSemanticError_ParseError_get_parse_error"))) TS_LDKParseOrSemanticError_ParseError_get_parse_error(uint32_t ptr) {
6155         LDKParseOrSemanticError *obj = (LDKParseOrSemanticError*)(ptr & ~1);
6156         assert(obj->tag == LDKParseOrSemanticError_ParseError);
6157                         uint32_t parse_error_ref = ((uintptr_t)&obj->parse_error) | 1;
6158         return parse_error_ref;
6159 }
6160 uint32_t __attribute__((export_name("TS_LDKParseOrSemanticError_SemanticError_get_semantic_error"))) TS_LDKParseOrSemanticError_SemanticError_get_semantic_error(uint32_t ptr) {
6161         LDKParseOrSemanticError *obj = (LDKParseOrSemanticError*)(ptr & ~1);
6162         assert(obj->tag == LDKParseOrSemanticError_SemanticError);
6163                         uint32_t semantic_error_conv = LDKSemanticError_to_js(obj->semantic_error);
6164         return semantic_error_conv;
6165 }
6166 static inline struct LDKInvoice CResult_InvoiceParseOrSemanticErrorZ_get_ok(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR owner){
6167 CHECK(owner->result_ok);
6168         return Invoice_clone(&*owner->contents.result);
6169 }
6170 uint32_t  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_get_ok"))) TS_CResult_InvoiceParseOrSemanticErrorZ_get_ok(uint32_t owner) {
6171         LDKCResult_InvoiceParseOrSemanticErrorZ* owner_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(owner & ~1);
6172         LDKInvoice ret_var = CResult_InvoiceParseOrSemanticErrorZ_get_ok(owner_conv);
6173         uint32_t ret_ref = 0;
6174         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6175         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6176         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6177         ret_ref = (uintptr_t)ret_var.inner;
6178         if (ret_var.is_owned) {
6179                 ret_ref |= 1;
6180         }
6181         return ret_ref;
6182 }
6183
6184 static inline struct LDKParseOrSemanticError CResult_InvoiceParseOrSemanticErrorZ_get_err(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR owner){
6185 CHECK(!owner->result_ok);
6186         return ParseOrSemanticError_clone(&*owner->contents.err);
6187 }
6188 uint32_t  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_get_err"))) TS_CResult_InvoiceParseOrSemanticErrorZ_get_err(uint32_t owner) {
6189         LDKCResult_InvoiceParseOrSemanticErrorZ* owner_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(owner & ~1);
6190         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
6191         *ret_copy = CResult_InvoiceParseOrSemanticErrorZ_get_err(owner_conv);
6192         uint32_t ret_ref = (uintptr_t)ret_copy;
6193         return ret_ref;
6194 }
6195
6196 static inline struct LDKSignedRawInvoice CResult_SignedRawInvoiceParseErrorZ_get_ok(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR owner){
6197 CHECK(owner->result_ok);
6198         return SignedRawInvoice_clone(&*owner->contents.result);
6199 }
6200 uint32_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_get_ok"))) TS_CResult_SignedRawInvoiceParseErrorZ_get_ok(uint32_t owner) {
6201         LDKCResult_SignedRawInvoiceParseErrorZ* owner_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(owner & ~1);
6202         LDKSignedRawInvoice ret_var = CResult_SignedRawInvoiceParseErrorZ_get_ok(owner_conv);
6203         uint32_t ret_ref = 0;
6204         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6205         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6206         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6207         ret_ref = (uintptr_t)ret_var.inner;
6208         if (ret_var.is_owned) {
6209                 ret_ref |= 1;
6210         }
6211         return ret_ref;
6212 }
6213
6214 static inline struct LDKParseError CResult_SignedRawInvoiceParseErrorZ_get_err(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR owner){
6215 CHECK(!owner->result_ok);
6216         return ParseError_clone(&*owner->contents.err);
6217 }
6218 uint32_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_get_err"))) TS_CResult_SignedRawInvoiceParseErrorZ_get_err(uint32_t owner) {
6219         LDKCResult_SignedRawInvoiceParseErrorZ* owner_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(owner & ~1);
6220         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
6221         *ret_copy = CResult_SignedRawInvoiceParseErrorZ_get_err(owner_conv);
6222         uint32_t ret_ref = (uintptr_t)ret_copy;
6223         return ret_ref;
6224 }
6225
6226 static inline struct LDKRawInvoice C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
6227         return RawInvoice_clone(&owner->a);
6228 }
6229 uint32_t  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(uint32_t owner) {
6230         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
6231         LDKRawInvoice ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(owner_conv);
6232         uint32_t ret_ref = 0;
6233         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6234         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6235         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6236         ret_ref = (uintptr_t)ret_var.inner;
6237         if (ret_var.is_owned) {
6238                 ret_ref |= 1;
6239         }
6240         return ret_ref;
6241 }
6242
6243 static inline struct LDKThirtyTwoBytes C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
6244         return ThirtyTwoBytes_clone(&owner->b);
6245 }
6246 int8_tArray  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(uint32_t owner) {
6247         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
6248         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
6249         memcpy(ret_arr->elems, C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(owner_conv).data, 32);
6250         return ret_arr;
6251 }
6252
6253 static inline struct LDKInvoiceSignature C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
6254         return InvoiceSignature_clone(&owner->c);
6255 }
6256 uint32_t  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(uint32_t owner) {
6257         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
6258         LDKInvoiceSignature ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(owner_conv);
6259         uint32_t ret_ref = 0;
6260         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6261         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6262         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6263         ret_ref = (uintptr_t)ret_var.inner;
6264         if (ret_var.is_owned) {
6265                 ret_ref |= 1;
6266         }
6267         return ret_ref;
6268 }
6269
6270 static inline struct LDKPayeePubKey CResult_PayeePubKeyErrorZ_get_ok(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR owner){
6271 CHECK(owner->result_ok);
6272         return PayeePubKey_clone(&*owner->contents.result);
6273 }
6274 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_get_ok"))) TS_CResult_PayeePubKeyErrorZ_get_ok(uint32_t owner) {
6275         LDKCResult_PayeePubKeyErrorZ* owner_conv = (LDKCResult_PayeePubKeyErrorZ*)(owner & ~1);
6276         LDKPayeePubKey ret_var = CResult_PayeePubKeyErrorZ_get_ok(owner_conv);
6277         uint32_t ret_ref = 0;
6278         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6279         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6280         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6281         ret_ref = (uintptr_t)ret_var.inner;
6282         if (ret_var.is_owned) {
6283                 ret_ref |= 1;
6284         }
6285         return ret_ref;
6286 }
6287
6288 static inline enum LDKSecp256k1Error CResult_PayeePubKeyErrorZ_get_err(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR owner){
6289 CHECK(!owner->result_ok);
6290         return *owner->contents.err;
6291 }
6292 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_get_err"))) TS_CResult_PayeePubKeyErrorZ_get_err(uint32_t owner) {
6293         LDKCResult_PayeePubKeyErrorZ* owner_conv = (LDKCResult_PayeePubKeyErrorZ*)(owner & ~1);
6294         uint32_t ret_conv = LDKSecp256k1Error_to_js(CResult_PayeePubKeyErrorZ_get_err(owner_conv));
6295         return ret_conv;
6296 }
6297
6298 static inline LDKCVec_PrivateRouteZ CVec_PrivateRouteZ_clone(const LDKCVec_PrivateRouteZ *orig) {
6299         LDKCVec_PrivateRouteZ ret = { .data = MALLOC(sizeof(LDKPrivateRoute) * orig->datalen, "LDKCVec_PrivateRouteZ clone bytes"), .datalen = orig->datalen };
6300         for (size_t i = 0; i < ret.datalen; i++) {
6301                 ret.data[i] = PrivateRoute_clone(&orig->data[i]);
6302         }
6303         return ret;
6304 }
6305 static inline struct LDKPositiveTimestamp CResult_PositiveTimestampCreationErrorZ_get_ok(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR owner){
6306 CHECK(owner->result_ok);
6307         return PositiveTimestamp_clone(&*owner->contents.result);
6308 }
6309 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_get_ok"))) TS_CResult_PositiveTimestampCreationErrorZ_get_ok(uint32_t owner) {
6310         LDKCResult_PositiveTimestampCreationErrorZ* owner_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(owner & ~1);
6311         LDKPositiveTimestamp ret_var = CResult_PositiveTimestampCreationErrorZ_get_ok(owner_conv);
6312         uint32_t ret_ref = 0;
6313         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6314         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6315         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6316         ret_ref = (uintptr_t)ret_var.inner;
6317         if (ret_var.is_owned) {
6318                 ret_ref |= 1;
6319         }
6320         return ret_ref;
6321 }
6322
6323 static inline enum LDKCreationError CResult_PositiveTimestampCreationErrorZ_get_err(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR owner){
6324 CHECK(!owner->result_ok);
6325         return CreationError_clone(&*owner->contents.err);
6326 }
6327 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_get_err"))) TS_CResult_PositiveTimestampCreationErrorZ_get_err(uint32_t owner) {
6328         LDKCResult_PositiveTimestampCreationErrorZ* owner_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(owner & ~1);
6329         uint32_t ret_conv = LDKCreationError_to_js(CResult_PositiveTimestampCreationErrorZ_get_err(owner_conv));
6330         return ret_conv;
6331 }
6332
6333 static inline void CResult_NoneSemanticErrorZ_get_ok(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR owner){
6334 CHECK(owner->result_ok);
6335         return *owner->contents.result;
6336 }
6337 void  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_get_ok"))) TS_CResult_NoneSemanticErrorZ_get_ok(uint32_t owner) {
6338         LDKCResult_NoneSemanticErrorZ* owner_conv = (LDKCResult_NoneSemanticErrorZ*)(owner & ~1);
6339         CResult_NoneSemanticErrorZ_get_ok(owner_conv);
6340 }
6341
6342 static inline enum LDKSemanticError CResult_NoneSemanticErrorZ_get_err(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR owner){
6343 CHECK(!owner->result_ok);
6344         return SemanticError_clone(&*owner->contents.err);
6345 }
6346 uint32_t  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_get_err"))) TS_CResult_NoneSemanticErrorZ_get_err(uint32_t owner) {
6347         LDKCResult_NoneSemanticErrorZ* owner_conv = (LDKCResult_NoneSemanticErrorZ*)(owner & ~1);
6348         uint32_t ret_conv = LDKSemanticError_to_js(CResult_NoneSemanticErrorZ_get_err(owner_conv));
6349         return ret_conv;
6350 }
6351
6352 static inline struct LDKInvoice CResult_InvoiceSemanticErrorZ_get_ok(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR owner){
6353 CHECK(owner->result_ok);
6354         return Invoice_clone(&*owner->contents.result);
6355 }
6356 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_get_ok"))) TS_CResult_InvoiceSemanticErrorZ_get_ok(uint32_t owner) {
6357         LDKCResult_InvoiceSemanticErrorZ* owner_conv = (LDKCResult_InvoiceSemanticErrorZ*)(owner & ~1);
6358         LDKInvoice ret_var = CResult_InvoiceSemanticErrorZ_get_ok(owner_conv);
6359         uint32_t ret_ref = 0;
6360         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6361         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6362         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6363         ret_ref = (uintptr_t)ret_var.inner;
6364         if (ret_var.is_owned) {
6365                 ret_ref |= 1;
6366         }
6367         return ret_ref;
6368 }
6369
6370 static inline enum LDKSemanticError CResult_InvoiceSemanticErrorZ_get_err(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR owner){
6371 CHECK(!owner->result_ok);
6372         return SemanticError_clone(&*owner->contents.err);
6373 }
6374 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_get_err"))) TS_CResult_InvoiceSemanticErrorZ_get_err(uint32_t owner) {
6375         LDKCResult_InvoiceSemanticErrorZ* owner_conv = (LDKCResult_InvoiceSemanticErrorZ*)(owner & ~1);
6376         uint32_t ret_conv = LDKSemanticError_to_js(CResult_InvoiceSemanticErrorZ_get_err(owner_conv));
6377         return ret_conv;
6378 }
6379
6380 static inline struct LDKDescription CResult_DescriptionCreationErrorZ_get_ok(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR owner){
6381 CHECK(owner->result_ok);
6382         return Description_clone(&*owner->contents.result);
6383 }
6384 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_get_ok"))) TS_CResult_DescriptionCreationErrorZ_get_ok(uint32_t owner) {
6385         LDKCResult_DescriptionCreationErrorZ* owner_conv = (LDKCResult_DescriptionCreationErrorZ*)(owner & ~1);
6386         LDKDescription ret_var = CResult_DescriptionCreationErrorZ_get_ok(owner_conv);
6387         uint32_t ret_ref = 0;
6388         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6389         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6390         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6391         ret_ref = (uintptr_t)ret_var.inner;
6392         if (ret_var.is_owned) {
6393                 ret_ref |= 1;
6394         }
6395         return ret_ref;
6396 }
6397
6398 static inline enum LDKCreationError CResult_DescriptionCreationErrorZ_get_err(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR owner){
6399 CHECK(!owner->result_ok);
6400         return CreationError_clone(&*owner->contents.err);
6401 }
6402 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_get_err"))) TS_CResult_DescriptionCreationErrorZ_get_err(uint32_t owner) {
6403         LDKCResult_DescriptionCreationErrorZ* owner_conv = (LDKCResult_DescriptionCreationErrorZ*)(owner & ~1);
6404         uint32_t ret_conv = LDKCreationError_to_js(CResult_DescriptionCreationErrorZ_get_err(owner_conv));
6405         return ret_conv;
6406 }
6407
6408 static inline struct LDKPrivateRoute CResult_PrivateRouteCreationErrorZ_get_ok(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR owner){
6409 CHECK(owner->result_ok);
6410         return PrivateRoute_clone(&*owner->contents.result);
6411 }
6412 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_get_ok"))) TS_CResult_PrivateRouteCreationErrorZ_get_ok(uint32_t owner) {
6413         LDKCResult_PrivateRouteCreationErrorZ* owner_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(owner & ~1);
6414         LDKPrivateRoute ret_var = CResult_PrivateRouteCreationErrorZ_get_ok(owner_conv);
6415         uint32_t ret_ref = 0;
6416         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6417         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6418         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6419         ret_ref = (uintptr_t)ret_var.inner;
6420         if (ret_var.is_owned) {
6421                 ret_ref |= 1;
6422         }
6423         return ret_ref;
6424 }
6425
6426 static inline enum LDKCreationError CResult_PrivateRouteCreationErrorZ_get_err(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR owner){
6427 CHECK(!owner->result_ok);
6428         return CreationError_clone(&*owner->contents.err);
6429 }
6430 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_get_err"))) TS_CResult_PrivateRouteCreationErrorZ_get_err(uint32_t owner) {
6431         LDKCResult_PrivateRouteCreationErrorZ* owner_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(owner & ~1);
6432         uint32_t ret_conv = LDKCreationError_to_js(CResult_PrivateRouteCreationErrorZ_get_err(owner_conv));
6433         return ret_conv;
6434 }
6435
6436 static inline struct LDKStr CResult_StringErrorZ_get_ok(LDKCResult_StringErrorZ *NONNULL_PTR owner){
6437 CHECK(owner->result_ok);
6438         return *owner->contents.result;
6439 }
6440 jstring  __attribute__((export_name("TS_CResult_StringErrorZ_get_ok"))) TS_CResult_StringErrorZ_get_ok(uint32_t owner) {
6441         LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)(owner & ~1);
6442         LDKStr ret_str = CResult_StringErrorZ_get_ok(owner_conv);
6443         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
6444         return ret_conv;
6445 }
6446
6447 static inline enum LDKSecp256k1Error CResult_StringErrorZ_get_err(LDKCResult_StringErrorZ *NONNULL_PTR owner){
6448 CHECK(!owner->result_ok);
6449         return *owner->contents.err;
6450 }
6451 uint32_t  __attribute__((export_name("TS_CResult_StringErrorZ_get_err"))) TS_CResult_StringErrorZ_get_err(uint32_t owner) {
6452         LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)(owner & ~1);
6453         uint32_t ret_conv = LDKSecp256k1Error_to_js(CResult_StringErrorZ_get_err(owner_conv));
6454         return ret_conv;
6455 }
6456
6457 static inline struct LDKChannelMonitorUpdate CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
6458 CHECK(owner->result_ok);
6459         return ChannelMonitorUpdate_clone(&*owner->contents.result);
6460 }
6461 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(uint32_t owner) {
6462         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(owner & ~1);
6463         LDKChannelMonitorUpdate ret_var = CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(owner_conv);
6464         uint32_t ret_ref = 0;
6465         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6466         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6467         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6468         ret_ref = (uintptr_t)ret_var.inner;
6469         if (ret_var.is_owned) {
6470                 ret_ref |= 1;
6471         }
6472         return ret_ref;
6473 }
6474
6475 static inline struct LDKDecodeError CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
6476 CHECK(!owner->result_ok);
6477         return DecodeError_clone(&*owner->contents.err);
6478 }
6479 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_get_err"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(uint32_t owner) {
6480         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(owner & ~1);
6481         LDKDecodeError ret_var = CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(owner_conv);
6482         uint32_t ret_ref = 0;
6483         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6484         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6485         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6486         ret_ref = (uintptr_t)ret_var.inner;
6487         if (ret_var.is_owned) {
6488                 ret_ref |= 1;
6489         }
6490         return ret_ref;
6491 }
6492
6493 uint32_t __attribute__((export_name("TS_LDKCOption_MonitorEventZ_ty_from_ptr"))) TS_LDKCOption_MonitorEventZ_ty_from_ptr(uint32_t ptr) {
6494         LDKCOption_MonitorEventZ *obj = (LDKCOption_MonitorEventZ*)(ptr & ~1);
6495         switch(obj->tag) {
6496                 case LDKCOption_MonitorEventZ_Some: return 0;
6497                 case LDKCOption_MonitorEventZ_None: return 1;
6498                 default: abort();
6499         }
6500 }
6501 uint32_t __attribute__((export_name("TS_LDKCOption_MonitorEventZ_Some_get_some"))) TS_LDKCOption_MonitorEventZ_Some_get_some(uint32_t ptr) {
6502         LDKCOption_MonitorEventZ *obj = (LDKCOption_MonitorEventZ*)(ptr & ~1);
6503         assert(obj->tag == LDKCOption_MonitorEventZ_Some);
6504                         uint32_t some_ref = ((uintptr_t)&obj->some) | 1;
6505         return some_ref;
6506 }
6507 static inline struct LDKCOption_MonitorEventZ CResult_COption_MonitorEventZDecodeErrorZ_get_ok(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
6508 CHECK(owner->result_ok);
6509         return COption_MonitorEventZ_clone(&*owner->contents.result);
6510 }
6511 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_get_ok"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_get_ok(uint32_t owner) {
6512         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(owner & ~1);
6513         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
6514         *ret_copy = CResult_COption_MonitorEventZDecodeErrorZ_get_ok(owner_conv);
6515         uint32_t ret_ref = (uintptr_t)ret_copy;
6516         return ret_ref;
6517 }
6518
6519 static inline struct LDKDecodeError CResult_COption_MonitorEventZDecodeErrorZ_get_err(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
6520 CHECK(!owner->result_ok);
6521         return DecodeError_clone(&*owner->contents.err);
6522 }
6523 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_get_err"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_get_err(uint32_t owner) {
6524         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(owner & ~1);
6525         LDKDecodeError ret_var = CResult_COption_MonitorEventZDecodeErrorZ_get_err(owner_conv);
6526         uint32_t ret_ref = 0;
6527         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6528         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6529         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6530         ret_ref = (uintptr_t)ret_var.inner;
6531         if (ret_var.is_owned) {
6532                 ret_ref |= 1;
6533         }
6534         return ret_ref;
6535 }
6536
6537 static inline struct LDKHTLCUpdate CResult_HTLCUpdateDecodeErrorZ_get_ok(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
6538 CHECK(owner->result_ok);
6539         return HTLCUpdate_clone(&*owner->contents.result);
6540 }
6541 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_get_ok"))) TS_CResult_HTLCUpdateDecodeErrorZ_get_ok(uint32_t owner) {
6542         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(owner & ~1);
6543         LDKHTLCUpdate ret_var = CResult_HTLCUpdateDecodeErrorZ_get_ok(owner_conv);
6544         uint32_t ret_ref = 0;
6545         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6546         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6547         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6548         ret_ref = (uintptr_t)ret_var.inner;
6549         if (ret_var.is_owned) {
6550                 ret_ref |= 1;
6551         }
6552         return ret_ref;
6553 }
6554
6555 static inline struct LDKDecodeError CResult_HTLCUpdateDecodeErrorZ_get_err(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
6556 CHECK(!owner->result_ok);
6557         return DecodeError_clone(&*owner->contents.err);
6558 }
6559 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_get_err"))) TS_CResult_HTLCUpdateDecodeErrorZ_get_err(uint32_t owner) {
6560         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(owner & ~1);
6561         LDKDecodeError ret_var = CResult_HTLCUpdateDecodeErrorZ_get_err(owner_conv);
6562         uint32_t ret_ref = 0;
6563         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6564         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6565         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6566         ret_ref = (uintptr_t)ret_var.inner;
6567         if (ret_var.is_owned) {
6568                 ret_ref |= 1;
6569         }
6570         return ret_ref;
6571 }
6572
6573 static inline struct LDKOutPoint C2Tuple_OutPointScriptZ_get_a(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
6574         return OutPoint_clone(&owner->a);
6575 }
6576 uint32_t  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_get_a"))) TS_C2Tuple_OutPointScriptZ_get_a(uint32_t owner) {
6577         LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)(owner & ~1);
6578         LDKOutPoint ret_var = C2Tuple_OutPointScriptZ_get_a(owner_conv);
6579         uint32_t ret_ref = 0;
6580         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6581         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6582         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6583         ret_ref = (uintptr_t)ret_var.inner;
6584         if (ret_var.is_owned) {
6585                 ret_ref |= 1;
6586         }
6587         return ret_ref;
6588 }
6589
6590 static inline struct LDKCVec_u8Z C2Tuple_OutPointScriptZ_get_b(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
6591         return CVec_u8Z_clone(&owner->b);
6592 }
6593 int8_tArray  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_get_b"))) TS_C2Tuple_OutPointScriptZ_get_b(uint32_t owner) {
6594         LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)(owner & ~1);
6595         LDKCVec_u8Z ret_var = C2Tuple_OutPointScriptZ_get_b(owner_conv);
6596         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
6597         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
6598         CVec_u8Z_free(ret_var);
6599         return ret_arr;
6600 }
6601
6602 static inline uint32_t C2Tuple_u32ScriptZ_get_a(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
6603         return owner->a;
6604 }
6605 int32_t  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_get_a"))) TS_C2Tuple_u32ScriptZ_get_a(uint32_t owner) {
6606         LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)(owner & ~1);
6607         int32_t ret_conv = C2Tuple_u32ScriptZ_get_a(owner_conv);
6608         return ret_conv;
6609 }
6610
6611 static inline struct LDKCVec_u8Z C2Tuple_u32ScriptZ_get_b(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
6612         return CVec_u8Z_clone(&owner->b);
6613 }
6614 int8_tArray  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_get_b"))) TS_C2Tuple_u32ScriptZ_get_b(uint32_t owner) {
6615         LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)(owner & ~1);
6616         LDKCVec_u8Z ret_var = C2Tuple_u32ScriptZ_get_b(owner_conv);
6617         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
6618         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
6619         CVec_u8Z_free(ret_var);
6620         return ret_arr;
6621 }
6622
6623 static inline LDKCVec_C2Tuple_u32ScriptZZ CVec_C2Tuple_u32ScriptZZ_clone(const LDKCVec_C2Tuple_u32ScriptZZ *orig) {
6624         LDKCVec_C2Tuple_u32ScriptZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * orig->datalen, "LDKCVec_C2Tuple_u32ScriptZZ clone bytes"), .datalen = orig->datalen };
6625         for (size_t i = 0; i < ret.datalen; i++) {
6626                 ret.data[i] = C2Tuple_u32ScriptZ_clone(&orig->data[i]);
6627         }
6628         return ret;
6629 }
6630 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
6631         return ThirtyTwoBytes_clone(&owner->a);
6632 }
6633 int8_tArray  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(uint32_t owner) {
6634         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(owner & ~1);
6635         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
6636         memcpy(ret_arr->elems, C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(owner_conv).data, 32);
6637         return ret_arr;
6638 }
6639
6640 static inline struct LDKCVec_C2Tuple_u32ScriptZZ C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
6641         return CVec_C2Tuple_u32ScriptZZ_clone(&owner->b);
6642 }
6643 uint32_tArray  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(uint32_t owner) {
6644         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(owner & ~1);
6645         LDKCVec_C2Tuple_u32ScriptZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(owner_conv);
6646         uint32_tArray ret_arr = NULL;
6647         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
6648         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 8);
6649         for (size_t v = 0; v < ret_var.datalen; v++) {
6650                 LDKC2Tuple_u32ScriptZ* ret_conv_21_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
6651                 *ret_conv_21_conv = ret_var.data[v];
6652                 ret_arr_ptr[v] = ((uint32_t)ret_conv_21_conv);
6653         }
6654         
6655         FREE(ret_var.data);
6656         return ret_arr;
6657 }
6658
6659 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *orig) {
6660         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 };
6661         for (size_t i = 0; i < ret.datalen; i++) {
6662                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(&orig->data[i]);
6663         }
6664         return ret;
6665 }
6666 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
6667         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
6668         for (size_t i = 0; i < ret.datalen; i++) {
6669                 ret.data[i] = Event_clone(&orig->data[i]);
6670         }
6671         return ret;
6672 }
6673 static inline uint32_t C2Tuple_u32TxOutZ_get_a(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
6674         return owner->a;
6675 }
6676 int32_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_get_a"))) TS_C2Tuple_u32TxOutZ_get_a(uint32_t owner) {
6677         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)(owner & ~1);
6678         int32_t ret_conv = C2Tuple_u32TxOutZ_get_a(owner_conv);
6679         return ret_conv;
6680 }
6681
6682 static inline struct LDKTxOut C2Tuple_u32TxOutZ_get_b(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
6683         return TxOut_clone(&owner->b);
6684 }
6685 uint32_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_get_b"))) TS_C2Tuple_u32TxOutZ_get_b(uint32_t owner) {
6686         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)(owner & ~1);
6687         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
6688         *ret_ref = C2Tuple_u32TxOutZ_get_b(owner_conv);
6689         return (uint32_t)ret_ref;
6690 }
6691
6692 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
6693         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
6694         for (size_t i = 0; i < ret.datalen; i++) {
6695                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
6696         }
6697         return ret;
6698 }
6699 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
6700         return ThirtyTwoBytes_clone(&owner->a);
6701 }
6702 int8_tArray  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(uint32_t owner) {
6703         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(owner & ~1);
6704         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
6705         memcpy(ret_arr->elems, C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(owner_conv).data, 32);
6706         return ret_arr;
6707 }
6708
6709 static inline struct LDKCVec_C2Tuple_u32TxOutZZ C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
6710         return CVec_C2Tuple_u32TxOutZZ_clone(&owner->b);
6711 }
6712 uint32_tArray  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(uint32_t owner) {
6713         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(owner & ~1);
6714         LDKCVec_C2Tuple_u32TxOutZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(owner_conv);
6715         uint32_tArray ret_arr = NULL;
6716         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
6717         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 8);
6718         for (size_t u = 0; u < ret_var.datalen; u++) {
6719                 LDKC2Tuple_u32TxOutZ* ret_conv_20_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
6720                 *ret_conv_20_conv = ret_var.data[u];
6721                 ret_arr_ptr[u] = ((uint32_t)ret_conv_20_conv);
6722         }
6723         
6724         FREE(ret_var.data);
6725         return ret_arr;
6726 }
6727
6728 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *orig) {
6729         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 };
6730         for (size_t i = 0; i < ret.datalen; i++) {
6731                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(&orig->data[i]);
6732         }
6733         return ret;
6734 }
6735 uint32_t __attribute__((export_name("TS_LDKBalance_ty_from_ptr"))) TS_LDKBalance_ty_from_ptr(uint32_t ptr) {
6736         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
6737         switch(obj->tag) {
6738                 case LDKBalance_ClaimableOnChannelClose: return 0;
6739                 case LDKBalance_ClaimableAwaitingConfirmations: return 1;
6740                 case LDKBalance_ContentiousClaimable: return 2;
6741                 case LDKBalance_MaybeClaimableHTLCAwaitingTimeout: return 3;
6742                 default: abort();
6743         }
6744 }
6745 int64_t __attribute__((export_name("TS_LDKBalance_ClaimableOnChannelClose_get_claimable_amount_satoshis"))) TS_LDKBalance_ClaimableOnChannelClose_get_claimable_amount_satoshis(uint32_t ptr) {
6746         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
6747         assert(obj->tag == LDKBalance_ClaimableOnChannelClose);
6748                         int64_t claimable_amount_satoshis_conv = obj->claimable_on_channel_close.claimable_amount_satoshis;
6749         return claimable_amount_satoshis_conv;
6750 }
6751 int64_t __attribute__((export_name("TS_LDKBalance_ClaimableAwaitingConfirmations_get_claimable_amount_satoshis"))) TS_LDKBalance_ClaimableAwaitingConfirmations_get_claimable_amount_satoshis(uint32_t ptr) {
6752         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
6753         assert(obj->tag == LDKBalance_ClaimableAwaitingConfirmations);
6754                         int64_t claimable_amount_satoshis_conv = obj->claimable_awaiting_confirmations.claimable_amount_satoshis;
6755         return claimable_amount_satoshis_conv;
6756 }
6757 int32_t __attribute__((export_name("TS_LDKBalance_ClaimableAwaitingConfirmations_get_confirmation_height"))) TS_LDKBalance_ClaimableAwaitingConfirmations_get_confirmation_height(uint32_t ptr) {
6758         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
6759         assert(obj->tag == LDKBalance_ClaimableAwaitingConfirmations);
6760                         int32_t confirmation_height_conv = obj->claimable_awaiting_confirmations.confirmation_height;
6761         return confirmation_height_conv;
6762 }
6763 int64_t __attribute__((export_name("TS_LDKBalance_ContentiousClaimable_get_claimable_amount_satoshis"))) TS_LDKBalance_ContentiousClaimable_get_claimable_amount_satoshis(uint32_t ptr) {
6764         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
6765         assert(obj->tag == LDKBalance_ContentiousClaimable);
6766                         int64_t claimable_amount_satoshis_conv = obj->contentious_claimable.claimable_amount_satoshis;
6767         return claimable_amount_satoshis_conv;
6768 }
6769 int32_t __attribute__((export_name("TS_LDKBalance_ContentiousClaimable_get_timeout_height"))) TS_LDKBalance_ContentiousClaimable_get_timeout_height(uint32_t ptr) {
6770         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
6771         assert(obj->tag == LDKBalance_ContentiousClaimable);
6772                         int32_t timeout_height_conv = obj->contentious_claimable.timeout_height;
6773         return timeout_height_conv;
6774 }
6775 int64_t __attribute__((export_name("TS_LDKBalance_MaybeClaimableHTLCAwaitingTimeout_get_claimable_amount_satoshis"))) TS_LDKBalance_MaybeClaimableHTLCAwaitingTimeout_get_claimable_amount_satoshis(uint32_t ptr) {
6776         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
6777         assert(obj->tag == LDKBalance_MaybeClaimableHTLCAwaitingTimeout);
6778                         int64_t claimable_amount_satoshis_conv = obj->maybe_claimable_htlc_awaiting_timeout.claimable_amount_satoshis;
6779         return claimable_amount_satoshis_conv;
6780 }
6781 int32_t __attribute__((export_name("TS_LDKBalance_MaybeClaimableHTLCAwaitingTimeout_get_claimable_height"))) TS_LDKBalance_MaybeClaimableHTLCAwaitingTimeout_get_claimable_height(uint32_t ptr) {
6782         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
6783         assert(obj->tag == LDKBalance_MaybeClaimableHTLCAwaitingTimeout);
6784                         int32_t claimable_height_conv = obj->maybe_claimable_htlc_awaiting_timeout.claimable_height;
6785         return claimable_height_conv;
6786 }
6787 static inline LDKCVec_BalanceZ CVec_BalanceZ_clone(const LDKCVec_BalanceZ *orig) {
6788         LDKCVec_BalanceZ ret = { .data = MALLOC(sizeof(LDKBalance) * orig->datalen, "LDKCVec_BalanceZ clone bytes"), .datalen = orig->datalen };
6789         for (size_t i = 0; i < ret.datalen; i++) {
6790                 ret.data[i] = Balance_clone(&orig->data[i]);
6791         }
6792         return ret;
6793 }
6794 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelMonitorZ_get_a(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
6795         return ThirtyTwoBytes_clone(&owner->a);
6796 }
6797 int8_tArray  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_get_a"))) TS_C2Tuple_BlockHashChannelMonitorZ_get_a(uint32_t owner) {
6798         LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(owner & ~1);
6799         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
6800         memcpy(ret_arr->elems, C2Tuple_BlockHashChannelMonitorZ_get_a(owner_conv).data, 32);
6801         return ret_arr;
6802 }
6803
6804 static inline struct LDKChannelMonitor C2Tuple_BlockHashChannelMonitorZ_get_b(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
6805         return ChannelMonitor_clone(&owner->b);
6806 }
6807 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_get_b"))) TS_C2Tuple_BlockHashChannelMonitorZ_get_b(uint32_t owner) {
6808         LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(owner & ~1);
6809         LDKChannelMonitor ret_var = C2Tuple_BlockHashChannelMonitorZ_get_b(owner_conv);
6810         uint32_t ret_ref = 0;
6811         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6812         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6813         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6814         ret_ref = (uintptr_t)ret_var.inner;
6815         if (ret_var.is_owned) {
6816                 ret_ref |= 1;
6817         }
6818         return ret_ref;
6819 }
6820
6821 static inline struct LDKC2Tuple_BlockHashChannelMonitorZ CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
6822 CHECK(owner->result_ok);
6823         return C2Tuple_BlockHashChannelMonitorZ_clone(&*owner->contents.result);
6824 }
6825 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(uint32_t owner) {
6826         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(owner & ~1);
6827         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
6828         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(owner_conv);
6829         return ((uint32_t)ret_conv);
6830 }
6831
6832 static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
6833 CHECK(!owner->result_ok);
6834         return DecodeError_clone(&*owner->contents.err);
6835 }
6836 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(uint32_t owner) {
6837         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(owner & ~1);
6838         LDKDecodeError ret_var = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(owner_conv);
6839         uint32_t ret_ref = 0;
6840         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6841         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6842         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6843         ret_ref = (uintptr_t)ret_var.inner;
6844         if (ret_var.is_owned) {
6845                 ret_ref |= 1;
6846         }
6847         return ret_ref;
6848 }
6849
6850 static inline struct LDKPublicKey C2Tuple_PublicKeyTypeZ_get_a(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
6851         return owner->a;
6852 }
6853 int8_tArray  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_get_a"))) TS_C2Tuple_PublicKeyTypeZ_get_a(uint32_t owner) {
6854         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)(owner & ~1);
6855         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
6856         memcpy(ret_arr->elems, C2Tuple_PublicKeyTypeZ_get_a(owner_conv).compressed_form, 33);
6857         return ret_arr;
6858 }
6859
6860 static inline struct LDKType C2Tuple_PublicKeyTypeZ_get_b(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
6861         return Type_clone(&owner->b);
6862 }
6863 uint32_t  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_get_b"))) TS_C2Tuple_PublicKeyTypeZ_get_b(uint32_t owner) {
6864         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)(owner & ~1);
6865         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
6866         *ret_ret = C2Tuple_PublicKeyTypeZ_get_b(owner_conv);
6867         return (uint32_t)ret_ret;
6868 }
6869
6870 static inline LDKCVec_C2Tuple_PublicKeyTypeZZ CVec_C2Tuple_PublicKeyTypeZZ_clone(const LDKCVec_C2Tuple_PublicKeyTypeZZ *orig) {
6871         LDKCVec_C2Tuple_PublicKeyTypeZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ) * orig->datalen, "LDKCVec_C2Tuple_PublicKeyTypeZZ clone bytes"), .datalen = orig->datalen };
6872         for (size_t i = 0; i < ret.datalen; i++) {
6873                 ret.data[i] = C2Tuple_PublicKeyTypeZ_clone(&orig->data[i]);
6874         }
6875         return ret;
6876 }
6877 uint32_t __attribute__((export_name("TS_LDKCOption_NetAddressZ_ty_from_ptr"))) TS_LDKCOption_NetAddressZ_ty_from_ptr(uint32_t ptr) {
6878         LDKCOption_NetAddressZ *obj = (LDKCOption_NetAddressZ*)(ptr & ~1);
6879         switch(obj->tag) {
6880                 case LDKCOption_NetAddressZ_Some: return 0;
6881                 case LDKCOption_NetAddressZ_None: return 1;
6882                 default: abort();
6883         }
6884 }
6885 uint32_t __attribute__((export_name("TS_LDKCOption_NetAddressZ_Some_get_some"))) TS_LDKCOption_NetAddressZ_Some_get_some(uint32_t ptr) {
6886         LDKCOption_NetAddressZ *obj = (LDKCOption_NetAddressZ*)(ptr & ~1);
6887         assert(obj->tag == LDKCOption_NetAddressZ_Some);
6888                         uint32_t some_ref = ((uintptr_t)&obj->some) | 1;
6889         return some_ref;
6890 }
6891 static inline struct LDKCVec_u8Z CResult_CVec_u8ZPeerHandleErrorZ_get_ok(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
6892 CHECK(owner->result_ok);
6893         return CVec_u8Z_clone(&*owner->contents.result);
6894 }
6895 int8_tArray  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_get_ok"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_get_ok(uint32_t owner) {
6896         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(owner & ~1);
6897         LDKCVec_u8Z ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_ok(owner_conv);
6898         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
6899         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
6900         CVec_u8Z_free(ret_var);
6901         return ret_arr;
6902 }
6903
6904 static inline struct LDKPeerHandleError CResult_CVec_u8ZPeerHandleErrorZ_get_err(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
6905 CHECK(!owner->result_ok);
6906         return PeerHandleError_clone(&*owner->contents.err);
6907 }
6908 uint32_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_get_err"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_get_err(uint32_t owner) {
6909         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(owner & ~1);
6910         LDKPeerHandleError ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_err(owner_conv);
6911         uint32_t ret_ref = 0;
6912         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6913         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6914         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6915         ret_ref = (uintptr_t)ret_var.inner;
6916         if (ret_var.is_owned) {
6917                 ret_ref |= 1;
6918         }
6919         return ret_ref;
6920 }
6921
6922 static inline void CResult_NonePeerHandleErrorZ_get_ok(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
6923 CHECK(owner->result_ok);
6924         return *owner->contents.result;
6925 }
6926 void  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_get_ok"))) TS_CResult_NonePeerHandleErrorZ_get_ok(uint32_t owner) {
6927         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)(owner & ~1);
6928         CResult_NonePeerHandleErrorZ_get_ok(owner_conv);
6929 }
6930
6931 static inline struct LDKPeerHandleError CResult_NonePeerHandleErrorZ_get_err(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
6932 CHECK(!owner->result_ok);
6933         return PeerHandleError_clone(&*owner->contents.err);
6934 }
6935 uint32_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_get_err"))) TS_CResult_NonePeerHandleErrorZ_get_err(uint32_t owner) {
6936         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)(owner & ~1);
6937         LDKPeerHandleError ret_var = CResult_NonePeerHandleErrorZ_get_err(owner_conv);
6938         uint32_t ret_ref = 0;
6939         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6940         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6941         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6942         ret_ref = (uintptr_t)ret_var.inner;
6943         if (ret_var.is_owned) {
6944                 ret_ref |= 1;
6945         }
6946         return ret_ref;
6947 }
6948
6949 static inline bool CResult_boolPeerHandleErrorZ_get_ok(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
6950 CHECK(owner->result_ok);
6951         return *owner->contents.result;
6952 }
6953 jboolean  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_get_ok"))) TS_CResult_boolPeerHandleErrorZ_get_ok(uint32_t owner) {
6954         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)(owner & ~1);
6955         jboolean ret_conv = CResult_boolPeerHandleErrorZ_get_ok(owner_conv);
6956         return ret_conv;
6957 }
6958
6959 static inline struct LDKPeerHandleError CResult_boolPeerHandleErrorZ_get_err(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
6960 CHECK(!owner->result_ok);
6961         return PeerHandleError_clone(&*owner->contents.err);
6962 }
6963 uint32_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_get_err"))) TS_CResult_boolPeerHandleErrorZ_get_err(uint32_t owner) {
6964         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)(owner & ~1);
6965         LDKPeerHandleError ret_var = CResult_boolPeerHandleErrorZ_get_err(owner_conv);
6966         uint32_t ret_ref = 0;
6967         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6968         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6969         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6970         ret_ref = (uintptr_t)ret_var.inner;
6971         if (ret_var.is_owned) {
6972                 ret_ref |= 1;
6973         }
6974         return ret_ref;
6975 }
6976
6977 static inline void CResult_NoneErrorZ_get_ok(LDKCResult_NoneErrorZ *NONNULL_PTR owner){
6978 CHECK(owner->result_ok);
6979         return *owner->contents.result;
6980 }
6981 void  __attribute__((export_name("TS_CResult_NoneErrorZ_get_ok"))) TS_CResult_NoneErrorZ_get_ok(uint32_t owner) {
6982         LDKCResult_NoneErrorZ* owner_conv = (LDKCResult_NoneErrorZ*)(owner & ~1);
6983         CResult_NoneErrorZ_get_ok(owner_conv);
6984 }
6985
6986 static inline enum LDKIOError CResult_NoneErrorZ_get_err(LDKCResult_NoneErrorZ *NONNULL_PTR owner){
6987 CHECK(!owner->result_ok);
6988         return *owner->contents.err;
6989 }
6990 uint32_t  __attribute__((export_name("TS_CResult_NoneErrorZ_get_err"))) TS_CResult_NoneErrorZ_get_err(uint32_t owner) {
6991         LDKCResult_NoneErrorZ* owner_conv = (LDKCResult_NoneErrorZ*)(owner & ~1);
6992         uint32_t ret_conv = LDKIOError_to_js(CResult_NoneErrorZ_get_err(owner_conv));
6993         return ret_conv;
6994 }
6995
6996 static inline struct LDKNetAddress CResult_NetAddressDecodeErrorZ_get_ok(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
6997 CHECK(owner->result_ok);
6998         return NetAddress_clone(&*owner->contents.result);
6999 }
7000 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_get_ok"))) TS_CResult_NetAddressDecodeErrorZ_get_ok(uint32_t owner) {
7001         LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)(owner & ~1);
7002         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
7003         *ret_copy = CResult_NetAddressDecodeErrorZ_get_ok(owner_conv);
7004         uint32_t ret_ref = (uintptr_t)ret_copy;
7005         return ret_ref;
7006 }
7007
7008 static inline struct LDKDecodeError CResult_NetAddressDecodeErrorZ_get_err(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
7009 CHECK(!owner->result_ok);
7010         return DecodeError_clone(&*owner->contents.err);
7011 }
7012 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_get_err"))) TS_CResult_NetAddressDecodeErrorZ_get_err(uint32_t owner) {
7013         LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)(owner & ~1);
7014         LDKDecodeError ret_var = CResult_NetAddressDecodeErrorZ_get_err(owner_conv);
7015         uint32_t ret_ref = 0;
7016         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7017         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7018         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7019         ret_ref = (uintptr_t)ret_var.inner;
7020         if (ret_var.is_owned) {
7021                 ret_ref |= 1;
7022         }
7023         return ret_ref;
7024 }
7025
7026 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
7027         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
7028         for (size_t i = 0; i < ret.datalen; i++) {
7029                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
7030         }
7031         return ret;
7032 }
7033 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
7034         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
7035         for (size_t i = 0; i < ret.datalen; i++) {
7036                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
7037         }
7038         return ret;
7039 }
7040 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
7041         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
7042         for (size_t i = 0; i < ret.datalen; i++) {
7043                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
7044         }
7045         return ret;
7046 }
7047 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
7048         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
7049         for (size_t i = 0; i < ret.datalen; i++) {
7050                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
7051         }
7052         return ret;
7053 }
7054 static inline struct LDKAcceptChannel CResult_AcceptChannelDecodeErrorZ_get_ok(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
7055 CHECK(owner->result_ok);
7056         return AcceptChannel_clone(&*owner->contents.result);
7057 }
7058 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_get_ok"))) TS_CResult_AcceptChannelDecodeErrorZ_get_ok(uint32_t owner) {
7059         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(owner & ~1);
7060         LDKAcceptChannel ret_var = CResult_AcceptChannelDecodeErrorZ_get_ok(owner_conv);
7061         uint32_t ret_ref = 0;
7062         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7063         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7064         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7065         ret_ref = (uintptr_t)ret_var.inner;
7066         if (ret_var.is_owned) {
7067                 ret_ref |= 1;
7068         }
7069         return ret_ref;
7070 }
7071
7072 static inline struct LDKDecodeError CResult_AcceptChannelDecodeErrorZ_get_err(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
7073 CHECK(!owner->result_ok);
7074         return DecodeError_clone(&*owner->contents.err);
7075 }
7076 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_get_err"))) TS_CResult_AcceptChannelDecodeErrorZ_get_err(uint32_t owner) {
7077         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(owner & ~1);
7078         LDKDecodeError ret_var = CResult_AcceptChannelDecodeErrorZ_get_err(owner_conv);
7079         uint32_t ret_ref = 0;
7080         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7081         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7082         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7083         ret_ref = (uintptr_t)ret_var.inner;
7084         if (ret_var.is_owned) {
7085                 ret_ref |= 1;
7086         }
7087         return ret_ref;
7088 }
7089
7090 static inline struct LDKAnnouncementSignatures CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
7091 CHECK(owner->result_ok);
7092         return AnnouncementSignatures_clone(&*owner->contents.result);
7093 }
7094 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_get_ok"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(uint32_t owner) {
7095         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(owner & ~1);
7096         LDKAnnouncementSignatures ret_var = CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(owner_conv);
7097         uint32_t ret_ref = 0;
7098         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7099         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7100         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7101         ret_ref = (uintptr_t)ret_var.inner;
7102         if (ret_var.is_owned) {
7103                 ret_ref |= 1;
7104         }
7105         return ret_ref;
7106 }
7107
7108 static inline struct LDKDecodeError CResult_AnnouncementSignaturesDecodeErrorZ_get_err(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
7109 CHECK(!owner->result_ok);
7110         return DecodeError_clone(&*owner->contents.err);
7111 }
7112 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_get_err"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_get_err(uint32_t owner) {
7113         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(owner & ~1);
7114         LDKDecodeError ret_var = CResult_AnnouncementSignaturesDecodeErrorZ_get_err(owner_conv);
7115         uint32_t ret_ref = 0;
7116         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7117         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7118         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7119         ret_ref = (uintptr_t)ret_var.inner;
7120         if (ret_var.is_owned) {
7121                 ret_ref |= 1;
7122         }
7123         return ret_ref;
7124 }
7125
7126 static inline struct LDKChannelReestablish CResult_ChannelReestablishDecodeErrorZ_get_ok(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
7127 CHECK(owner->result_ok);
7128         return ChannelReestablish_clone(&*owner->contents.result);
7129 }
7130 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_get_ok"))) TS_CResult_ChannelReestablishDecodeErrorZ_get_ok(uint32_t owner) {
7131         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(owner & ~1);
7132         LDKChannelReestablish ret_var = CResult_ChannelReestablishDecodeErrorZ_get_ok(owner_conv);
7133         uint32_t ret_ref = 0;
7134         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7135         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7136         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7137         ret_ref = (uintptr_t)ret_var.inner;
7138         if (ret_var.is_owned) {
7139                 ret_ref |= 1;
7140         }
7141         return ret_ref;
7142 }
7143
7144 static inline struct LDKDecodeError CResult_ChannelReestablishDecodeErrorZ_get_err(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
7145 CHECK(!owner->result_ok);
7146         return DecodeError_clone(&*owner->contents.err);
7147 }
7148 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_get_err"))) TS_CResult_ChannelReestablishDecodeErrorZ_get_err(uint32_t owner) {
7149         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(owner & ~1);
7150         LDKDecodeError ret_var = CResult_ChannelReestablishDecodeErrorZ_get_err(owner_conv);
7151         uint32_t ret_ref = 0;
7152         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7153         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7154         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7155         ret_ref = (uintptr_t)ret_var.inner;
7156         if (ret_var.is_owned) {
7157                 ret_ref |= 1;
7158         }
7159         return ret_ref;
7160 }
7161
7162 static inline struct LDKClosingSigned CResult_ClosingSignedDecodeErrorZ_get_ok(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
7163 CHECK(owner->result_ok);
7164         return ClosingSigned_clone(&*owner->contents.result);
7165 }
7166 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_get_ok"))) TS_CResult_ClosingSignedDecodeErrorZ_get_ok(uint32_t owner) {
7167         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(owner & ~1);
7168         LDKClosingSigned ret_var = CResult_ClosingSignedDecodeErrorZ_get_ok(owner_conv);
7169         uint32_t ret_ref = 0;
7170         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7171         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7172         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7173         ret_ref = (uintptr_t)ret_var.inner;
7174         if (ret_var.is_owned) {
7175                 ret_ref |= 1;
7176         }
7177         return ret_ref;
7178 }
7179
7180 static inline struct LDKDecodeError CResult_ClosingSignedDecodeErrorZ_get_err(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
7181 CHECK(!owner->result_ok);
7182         return DecodeError_clone(&*owner->contents.err);
7183 }
7184 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_get_err"))) TS_CResult_ClosingSignedDecodeErrorZ_get_err(uint32_t owner) {
7185         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(owner & ~1);
7186         LDKDecodeError ret_var = CResult_ClosingSignedDecodeErrorZ_get_err(owner_conv);
7187         uint32_t ret_ref = 0;
7188         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7189         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7190         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7191         ret_ref = (uintptr_t)ret_var.inner;
7192         if (ret_var.is_owned) {
7193                 ret_ref |= 1;
7194         }
7195         return ret_ref;
7196 }
7197
7198 static inline struct LDKClosingSignedFeeRange CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
7199 CHECK(owner->result_ok);
7200         return ClosingSignedFeeRange_clone(&*owner->contents.result);
7201 }
7202 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(uint32_t owner) {
7203         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(owner & ~1);
7204         LDKClosingSignedFeeRange ret_var = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(owner_conv);
7205         uint32_t ret_ref = 0;
7206         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7207         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7208         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7209         ret_ref = (uintptr_t)ret_var.inner;
7210         if (ret_var.is_owned) {
7211                 ret_ref |= 1;
7212         }
7213         return ret_ref;
7214 }
7215
7216 static inline struct LDKDecodeError CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
7217 CHECK(!owner->result_ok);
7218         return DecodeError_clone(&*owner->contents.err);
7219 }
7220 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(uint32_t owner) {
7221         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(owner & ~1);
7222         LDKDecodeError ret_var = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(owner_conv);
7223         uint32_t ret_ref = 0;
7224         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7225         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7226         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7227         ret_ref = (uintptr_t)ret_var.inner;
7228         if (ret_var.is_owned) {
7229                 ret_ref |= 1;
7230         }
7231         return ret_ref;
7232 }
7233
7234 static inline struct LDKCommitmentSigned CResult_CommitmentSignedDecodeErrorZ_get_ok(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
7235 CHECK(owner->result_ok);
7236         return CommitmentSigned_clone(&*owner->contents.result);
7237 }
7238 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_get_ok"))) TS_CResult_CommitmentSignedDecodeErrorZ_get_ok(uint32_t owner) {
7239         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(owner & ~1);
7240         LDKCommitmentSigned ret_var = CResult_CommitmentSignedDecodeErrorZ_get_ok(owner_conv);
7241         uint32_t ret_ref = 0;
7242         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7243         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7244         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7245         ret_ref = (uintptr_t)ret_var.inner;
7246         if (ret_var.is_owned) {
7247                 ret_ref |= 1;
7248         }
7249         return ret_ref;
7250 }
7251
7252 static inline struct LDKDecodeError CResult_CommitmentSignedDecodeErrorZ_get_err(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
7253 CHECK(!owner->result_ok);
7254         return DecodeError_clone(&*owner->contents.err);
7255 }
7256 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_get_err"))) TS_CResult_CommitmentSignedDecodeErrorZ_get_err(uint32_t owner) {
7257         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(owner & ~1);
7258         LDKDecodeError ret_var = CResult_CommitmentSignedDecodeErrorZ_get_err(owner_conv);
7259         uint32_t ret_ref = 0;
7260         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7261         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7262         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7263         ret_ref = (uintptr_t)ret_var.inner;
7264         if (ret_var.is_owned) {
7265                 ret_ref |= 1;
7266         }
7267         return ret_ref;
7268 }
7269
7270 static inline struct LDKFundingCreated CResult_FundingCreatedDecodeErrorZ_get_ok(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
7271 CHECK(owner->result_ok);
7272         return FundingCreated_clone(&*owner->contents.result);
7273 }
7274 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_get_ok"))) TS_CResult_FundingCreatedDecodeErrorZ_get_ok(uint32_t owner) {
7275         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(owner & ~1);
7276         LDKFundingCreated ret_var = CResult_FundingCreatedDecodeErrorZ_get_ok(owner_conv);
7277         uint32_t ret_ref = 0;
7278         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7279         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7280         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7281         ret_ref = (uintptr_t)ret_var.inner;
7282         if (ret_var.is_owned) {
7283                 ret_ref |= 1;
7284         }
7285         return ret_ref;
7286 }
7287
7288 static inline struct LDKDecodeError CResult_FundingCreatedDecodeErrorZ_get_err(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
7289 CHECK(!owner->result_ok);
7290         return DecodeError_clone(&*owner->contents.err);
7291 }
7292 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_get_err"))) TS_CResult_FundingCreatedDecodeErrorZ_get_err(uint32_t owner) {
7293         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(owner & ~1);
7294         LDKDecodeError ret_var = CResult_FundingCreatedDecodeErrorZ_get_err(owner_conv);
7295         uint32_t ret_ref = 0;
7296         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7297         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7298         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7299         ret_ref = (uintptr_t)ret_var.inner;
7300         if (ret_var.is_owned) {
7301                 ret_ref |= 1;
7302         }
7303         return ret_ref;
7304 }
7305
7306 static inline struct LDKFundingSigned CResult_FundingSignedDecodeErrorZ_get_ok(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
7307 CHECK(owner->result_ok);
7308         return FundingSigned_clone(&*owner->contents.result);
7309 }
7310 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_get_ok"))) TS_CResult_FundingSignedDecodeErrorZ_get_ok(uint32_t owner) {
7311         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(owner & ~1);
7312         LDKFundingSigned ret_var = CResult_FundingSignedDecodeErrorZ_get_ok(owner_conv);
7313         uint32_t ret_ref = 0;
7314         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7315         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7316         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7317         ret_ref = (uintptr_t)ret_var.inner;
7318         if (ret_var.is_owned) {
7319                 ret_ref |= 1;
7320         }
7321         return ret_ref;
7322 }
7323
7324 static inline struct LDKDecodeError CResult_FundingSignedDecodeErrorZ_get_err(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
7325 CHECK(!owner->result_ok);
7326         return DecodeError_clone(&*owner->contents.err);
7327 }
7328 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_get_err"))) TS_CResult_FundingSignedDecodeErrorZ_get_err(uint32_t owner) {
7329         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(owner & ~1);
7330         LDKDecodeError ret_var = CResult_FundingSignedDecodeErrorZ_get_err(owner_conv);
7331         uint32_t ret_ref = 0;
7332         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7333         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7334         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7335         ret_ref = (uintptr_t)ret_var.inner;
7336         if (ret_var.is_owned) {
7337                 ret_ref |= 1;
7338         }
7339         return ret_ref;
7340 }
7341
7342 static inline struct LDKChannelReady CResult_ChannelReadyDecodeErrorZ_get_ok(LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR owner){
7343 CHECK(owner->result_ok);
7344         return ChannelReady_clone(&*owner->contents.result);
7345 }
7346 uint32_t  __attribute__((export_name("TS_CResult_ChannelReadyDecodeErrorZ_get_ok"))) TS_CResult_ChannelReadyDecodeErrorZ_get_ok(uint32_t owner) {
7347         LDKCResult_ChannelReadyDecodeErrorZ* owner_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)(owner & ~1);
7348         LDKChannelReady ret_var = CResult_ChannelReadyDecodeErrorZ_get_ok(owner_conv);
7349         uint32_t ret_ref = 0;
7350         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7351         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7352         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7353         ret_ref = (uintptr_t)ret_var.inner;
7354         if (ret_var.is_owned) {
7355                 ret_ref |= 1;
7356         }
7357         return ret_ref;
7358 }
7359
7360 static inline struct LDKDecodeError CResult_ChannelReadyDecodeErrorZ_get_err(LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR owner){
7361 CHECK(!owner->result_ok);
7362         return DecodeError_clone(&*owner->contents.err);
7363 }
7364 uint32_t  __attribute__((export_name("TS_CResult_ChannelReadyDecodeErrorZ_get_err"))) TS_CResult_ChannelReadyDecodeErrorZ_get_err(uint32_t owner) {
7365         LDKCResult_ChannelReadyDecodeErrorZ* owner_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)(owner & ~1);
7366         LDKDecodeError ret_var = CResult_ChannelReadyDecodeErrorZ_get_err(owner_conv);
7367         uint32_t ret_ref = 0;
7368         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7369         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7370         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7371         ret_ref = (uintptr_t)ret_var.inner;
7372         if (ret_var.is_owned) {
7373                 ret_ref |= 1;
7374         }
7375         return ret_ref;
7376 }
7377
7378 static inline struct LDKInit CResult_InitDecodeErrorZ_get_ok(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
7379 CHECK(owner->result_ok);
7380         return Init_clone(&*owner->contents.result);
7381 }
7382 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_get_ok"))) TS_CResult_InitDecodeErrorZ_get_ok(uint32_t owner) {
7383         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)(owner & ~1);
7384         LDKInit ret_var = CResult_InitDecodeErrorZ_get_ok(owner_conv);
7385         uint32_t ret_ref = 0;
7386         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7387         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7388         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7389         ret_ref = (uintptr_t)ret_var.inner;
7390         if (ret_var.is_owned) {
7391                 ret_ref |= 1;
7392         }
7393         return ret_ref;
7394 }
7395
7396 static inline struct LDKDecodeError CResult_InitDecodeErrorZ_get_err(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
7397 CHECK(!owner->result_ok);
7398         return DecodeError_clone(&*owner->contents.err);
7399 }
7400 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_get_err"))) TS_CResult_InitDecodeErrorZ_get_err(uint32_t owner) {
7401         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)(owner & ~1);
7402         LDKDecodeError ret_var = CResult_InitDecodeErrorZ_get_err(owner_conv);
7403         uint32_t ret_ref = 0;
7404         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7405         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7406         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7407         ret_ref = (uintptr_t)ret_var.inner;
7408         if (ret_var.is_owned) {
7409                 ret_ref |= 1;
7410         }
7411         return ret_ref;
7412 }
7413
7414 static inline struct LDKOpenChannel CResult_OpenChannelDecodeErrorZ_get_ok(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
7415 CHECK(owner->result_ok);
7416         return OpenChannel_clone(&*owner->contents.result);
7417 }
7418 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_get_ok"))) TS_CResult_OpenChannelDecodeErrorZ_get_ok(uint32_t owner) {
7419         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(owner & ~1);
7420         LDKOpenChannel ret_var = CResult_OpenChannelDecodeErrorZ_get_ok(owner_conv);
7421         uint32_t ret_ref = 0;
7422         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7423         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7424         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7425         ret_ref = (uintptr_t)ret_var.inner;
7426         if (ret_var.is_owned) {
7427                 ret_ref |= 1;
7428         }
7429         return ret_ref;
7430 }
7431
7432 static inline struct LDKDecodeError CResult_OpenChannelDecodeErrorZ_get_err(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
7433 CHECK(!owner->result_ok);
7434         return DecodeError_clone(&*owner->contents.err);
7435 }
7436 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_get_err"))) TS_CResult_OpenChannelDecodeErrorZ_get_err(uint32_t owner) {
7437         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(owner & ~1);
7438         LDKDecodeError ret_var = CResult_OpenChannelDecodeErrorZ_get_err(owner_conv);
7439         uint32_t ret_ref = 0;
7440         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7441         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7442         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7443         ret_ref = (uintptr_t)ret_var.inner;
7444         if (ret_var.is_owned) {
7445                 ret_ref |= 1;
7446         }
7447         return ret_ref;
7448 }
7449
7450 static inline struct LDKRevokeAndACK CResult_RevokeAndACKDecodeErrorZ_get_ok(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
7451 CHECK(owner->result_ok);
7452         return RevokeAndACK_clone(&*owner->contents.result);
7453 }
7454 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_get_ok"))) TS_CResult_RevokeAndACKDecodeErrorZ_get_ok(uint32_t owner) {
7455         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(owner & ~1);
7456         LDKRevokeAndACK ret_var = CResult_RevokeAndACKDecodeErrorZ_get_ok(owner_conv);
7457         uint32_t ret_ref = 0;
7458         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7459         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7460         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7461         ret_ref = (uintptr_t)ret_var.inner;
7462         if (ret_var.is_owned) {
7463                 ret_ref |= 1;
7464         }
7465         return ret_ref;
7466 }
7467
7468 static inline struct LDKDecodeError CResult_RevokeAndACKDecodeErrorZ_get_err(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
7469 CHECK(!owner->result_ok);
7470         return DecodeError_clone(&*owner->contents.err);
7471 }
7472 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_get_err"))) TS_CResult_RevokeAndACKDecodeErrorZ_get_err(uint32_t owner) {
7473         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(owner & ~1);
7474         LDKDecodeError ret_var = CResult_RevokeAndACKDecodeErrorZ_get_err(owner_conv);
7475         uint32_t ret_ref = 0;
7476         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7477         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7478         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7479         ret_ref = (uintptr_t)ret_var.inner;
7480         if (ret_var.is_owned) {
7481                 ret_ref |= 1;
7482         }
7483         return ret_ref;
7484 }
7485
7486 static inline struct LDKShutdown CResult_ShutdownDecodeErrorZ_get_ok(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
7487 CHECK(owner->result_ok);
7488         return Shutdown_clone(&*owner->contents.result);
7489 }
7490 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_get_ok"))) TS_CResult_ShutdownDecodeErrorZ_get_ok(uint32_t owner) {
7491         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)(owner & ~1);
7492         LDKShutdown ret_var = CResult_ShutdownDecodeErrorZ_get_ok(owner_conv);
7493         uint32_t ret_ref = 0;
7494         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7495         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7496         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7497         ret_ref = (uintptr_t)ret_var.inner;
7498         if (ret_var.is_owned) {
7499                 ret_ref |= 1;
7500         }
7501         return ret_ref;
7502 }
7503
7504 static inline struct LDKDecodeError CResult_ShutdownDecodeErrorZ_get_err(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
7505 CHECK(!owner->result_ok);
7506         return DecodeError_clone(&*owner->contents.err);
7507 }
7508 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_get_err"))) TS_CResult_ShutdownDecodeErrorZ_get_err(uint32_t owner) {
7509         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)(owner & ~1);
7510         LDKDecodeError ret_var = CResult_ShutdownDecodeErrorZ_get_err(owner_conv);
7511         uint32_t ret_ref = 0;
7512         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7513         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7514         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7515         ret_ref = (uintptr_t)ret_var.inner;
7516         if (ret_var.is_owned) {
7517                 ret_ref |= 1;
7518         }
7519         return ret_ref;
7520 }
7521
7522 static inline struct LDKUpdateFailHTLC CResult_UpdateFailHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
7523 CHECK(owner->result_ok);
7524         return UpdateFailHTLC_clone(&*owner->contents.result);
7525 }
7526 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_get_ok"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_get_ok(uint32_t owner) {
7527         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(owner & ~1);
7528         LDKUpdateFailHTLC ret_var = CResult_UpdateFailHTLCDecodeErrorZ_get_ok(owner_conv);
7529         uint32_t ret_ref = 0;
7530         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7531         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7532         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7533         ret_ref = (uintptr_t)ret_var.inner;
7534         if (ret_var.is_owned) {
7535                 ret_ref |= 1;
7536         }
7537         return ret_ref;
7538 }
7539
7540 static inline struct LDKDecodeError CResult_UpdateFailHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
7541 CHECK(!owner->result_ok);
7542         return DecodeError_clone(&*owner->contents.err);
7543 }
7544 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_get_err"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_get_err(uint32_t owner) {
7545         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(owner & ~1);
7546         LDKDecodeError ret_var = CResult_UpdateFailHTLCDecodeErrorZ_get_err(owner_conv);
7547         uint32_t ret_ref = 0;
7548         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7549         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7550         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7551         ret_ref = (uintptr_t)ret_var.inner;
7552         if (ret_var.is_owned) {
7553                 ret_ref |= 1;
7554         }
7555         return ret_ref;
7556 }
7557
7558 static inline struct LDKUpdateFailMalformedHTLC CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
7559 CHECK(owner->result_ok);
7560         return UpdateFailMalformedHTLC_clone(&*owner->contents.result);
7561 }
7562 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(uint32_t owner) {
7563         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(owner & ~1);
7564         LDKUpdateFailMalformedHTLC ret_var = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(owner_conv);
7565         uint32_t ret_ref = 0;
7566         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7567         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7568         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7569         ret_ref = (uintptr_t)ret_var.inner;
7570         if (ret_var.is_owned) {
7571                 ret_ref |= 1;
7572         }
7573         return ret_ref;
7574 }
7575
7576 static inline struct LDKDecodeError CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
7577 CHECK(!owner->result_ok);
7578         return DecodeError_clone(&*owner->contents.err);
7579 }
7580 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(uint32_t owner) {
7581         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(owner & ~1);
7582         LDKDecodeError ret_var = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(owner_conv);
7583         uint32_t ret_ref = 0;
7584         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7585         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7586         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7587         ret_ref = (uintptr_t)ret_var.inner;
7588         if (ret_var.is_owned) {
7589                 ret_ref |= 1;
7590         }
7591         return ret_ref;
7592 }
7593
7594 static inline struct LDKUpdateFee CResult_UpdateFeeDecodeErrorZ_get_ok(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
7595 CHECK(owner->result_ok);
7596         return UpdateFee_clone(&*owner->contents.result);
7597 }
7598 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_get_ok"))) TS_CResult_UpdateFeeDecodeErrorZ_get_ok(uint32_t owner) {
7599         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(owner & ~1);
7600         LDKUpdateFee ret_var = CResult_UpdateFeeDecodeErrorZ_get_ok(owner_conv);
7601         uint32_t ret_ref = 0;
7602         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7603         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7604         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7605         ret_ref = (uintptr_t)ret_var.inner;
7606         if (ret_var.is_owned) {
7607                 ret_ref |= 1;
7608         }
7609         return ret_ref;
7610 }
7611
7612 static inline struct LDKDecodeError CResult_UpdateFeeDecodeErrorZ_get_err(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
7613 CHECK(!owner->result_ok);
7614         return DecodeError_clone(&*owner->contents.err);
7615 }
7616 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_get_err"))) TS_CResult_UpdateFeeDecodeErrorZ_get_err(uint32_t owner) {
7617         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(owner & ~1);
7618         LDKDecodeError ret_var = CResult_UpdateFeeDecodeErrorZ_get_err(owner_conv);
7619         uint32_t ret_ref = 0;
7620         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7621         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7622         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7623         ret_ref = (uintptr_t)ret_var.inner;
7624         if (ret_var.is_owned) {
7625                 ret_ref |= 1;
7626         }
7627         return ret_ref;
7628 }
7629
7630 static inline struct LDKUpdateFulfillHTLC CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
7631 CHECK(owner->result_ok);
7632         return UpdateFulfillHTLC_clone(&*owner->contents.result);
7633 }
7634 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(uint32_t owner) {
7635         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(owner & ~1);
7636         LDKUpdateFulfillHTLC ret_var = CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(owner_conv);
7637         uint32_t ret_ref = 0;
7638         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7639         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7640         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7641         ret_ref = (uintptr_t)ret_var.inner;
7642         if (ret_var.is_owned) {
7643                 ret_ref |= 1;
7644         }
7645         return ret_ref;
7646 }
7647
7648 static inline struct LDKDecodeError CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
7649 CHECK(!owner->result_ok);
7650         return DecodeError_clone(&*owner->contents.err);
7651 }
7652 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_get_err"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(uint32_t owner) {
7653         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(owner & ~1);
7654         LDKDecodeError ret_var = CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(owner_conv);
7655         uint32_t ret_ref = 0;
7656         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7657         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7658         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7659         ret_ref = (uintptr_t)ret_var.inner;
7660         if (ret_var.is_owned) {
7661                 ret_ref |= 1;
7662         }
7663         return ret_ref;
7664 }
7665
7666 static inline struct LDKUpdateAddHTLC CResult_UpdateAddHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
7667 CHECK(owner->result_ok);
7668         return UpdateAddHTLC_clone(&*owner->contents.result);
7669 }
7670 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_get_ok"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_get_ok(uint32_t owner) {
7671         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(owner & ~1);
7672         LDKUpdateAddHTLC ret_var = CResult_UpdateAddHTLCDecodeErrorZ_get_ok(owner_conv);
7673         uint32_t ret_ref = 0;
7674         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7675         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7676         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7677         ret_ref = (uintptr_t)ret_var.inner;
7678         if (ret_var.is_owned) {
7679                 ret_ref |= 1;
7680         }
7681         return ret_ref;
7682 }
7683
7684 static inline struct LDKDecodeError CResult_UpdateAddHTLCDecodeErrorZ_get_err(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
7685 CHECK(!owner->result_ok);
7686         return DecodeError_clone(&*owner->contents.err);
7687 }
7688 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_get_err"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_get_err(uint32_t owner) {
7689         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(owner & ~1);
7690         LDKDecodeError ret_var = CResult_UpdateAddHTLCDecodeErrorZ_get_err(owner_conv);
7691         uint32_t ret_ref = 0;
7692         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7693         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7694         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7695         ret_ref = (uintptr_t)ret_var.inner;
7696         if (ret_var.is_owned) {
7697                 ret_ref |= 1;
7698         }
7699         return ret_ref;
7700 }
7701
7702 static inline struct LDKPing CResult_PingDecodeErrorZ_get_ok(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
7703 CHECK(owner->result_ok);
7704         return Ping_clone(&*owner->contents.result);
7705 }
7706 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_get_ok"))) TS_CResult_PingDecodeErrorZ_get_ok(uint32_t owner) {
7707         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)(owner & ~1);
7708         LDKPing ret_var = CResult_PingDecodeErrorZ_get_ok(owner_conv);
7709         uint32_t ret_ref = 0;
7710         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7711         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7712         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7713         ret_ref = (uintptr_t)ret_var.inner;
7714         if (ret_var.is_owned) {
7715                 ret_ref |= 1;
7716         }
7717         return ret_ref;
7718 }
7719
7720 static inline struct LDKDecodeError CResult_PingDecodeErrorZ_get_err(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
7721 CHECK(!owner->result_ok);
7722         return DecodeError_clone(&*owner->contents.err);
7723 }
7724 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_get_err"))) TS_CResult_PingDecodeErrorZ_get_err(uint32_t owner) {
7725         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)(owner & ~1);
7726         LDKDecodeError ret_var = CResult_PingDecodeErrorZ_get_err(owner_conv);
7727         uint32_t ret_ref = 0;
7728         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7729         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7730         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7731         ret_ref = (uintptr_t)ret_var.inner;
7732         if (ret_var.is_owned) {
7733                 ret_ref |= 1;
7734         }
7735         return ret_ref;
7736 }
7737
7738 static inline struct LDKPong CResult_PongDecodeErrorZ_get_ok(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
7739 CHECK(owner->result_ok);
7740         return Pong_clone(&*owner->contents.result);
7741 }
7742 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_get_ok"))) TS_CResult_PongDecodeErrorZ_get_ok(uint32_t owner) {
7743         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)(owner & ~1);
7744         LDKPong ret_var = CResult_PongDecodeErrorZ_get_ok(owner_conv);
7745         uint32_t ret_ref = 0;
7746         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7747         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7748         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7749         ret_ref = (uintptr_t)ret_var.inner;
7750         if (ret_var.is_owned) {
7751                 ret_ref |= 1;
7752         }
7753         return ret_ref;
7754 }
7755
7756 static inline struct LDKDecodeError CResult_PongDecodeErrorZ_get_err(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
7757 CHECK(!owner->result_ok);
7758         return DecodeError_clone(&*owner->contents.err);
7759 }
7760 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_get_err"))) TS_CResult_PongDecodeErrorZ_get_err(uint32_t owner) {
7761         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)(owner & ~1);
7762         LDKDecodeError ret_var = CResult_PongDecodeErrorZ_get_err(owner_conv);
7763         uint32_t ret_ref = 0;
7764         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7765         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7766         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7767         ret_ref = (uintptr_t)ret_var.inner;
7768         if (ret_var.is_owned) {
7769                 ret_ref |= 1;
7770         }
7771         return ret_ref;
7772 }
7773
7774 static inline struct LDKUnsignedChannelAnnouncement CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7775 CHECK(owner->result_ok);
7776         return UnsignedChannelAnnouncement_clone(&*owner->contents.result);
7777 }
7778 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(uint32_t owner) {
7779         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(owner & ~1);
7780         LDKUnsignedChannelAnnouncement ret_var = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
7781         uint32_t ret_ref = 0;
7782         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7783         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7784         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7785         ret_ref = (uintptr_t)ret_var.inner;
7786         if (ret_var.is_owned) {
7787                 ret_ref |= 1;
7788         }
7789         return ret_ref;
7790 }
7791
7792 static inline struct LDKDecodeError CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7793 CHECK(!owner->result_ok);
7794         return DecodeError_clone(&*owner->contents.err);
7795 }
7796 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(uint32_t owner) {
7797         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(owner & ~1);
7798         LDKDecodeError ret_var = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
7799         uint32_t ret_ref = 0;
7800         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7801         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7802         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7803         ret_ref = (uintptr_t)ret_var.inner;
7804         if (ret_var.is_owned) {
7805                 ret_ref |= 1;
7806         }
7807         return ret_ref;
7808 }
7809
7810 static inline struct LDKChannelAnnouncement CResult_ChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7811 CHECK(owner->result_ok);
7812         return ChannelAnnouncement_clone(&*owner->contents.result);
7813 }
7814 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_get_ok"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_get_ok(uint32_t owner) {
7815         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(owner & ~1);
7816         LDKChannelAnnouncement ret_var = CResult_ChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
7817         uint32_t ret_ref = 0;
7818         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7819         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7820         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7821         ret_ref = (uintptr_t)ret_var.inner;
7822         if (ret_var.is_owned) {
7823                 ret_ref |= 1;
7824         }
7825         return ret_ref;
7826 }
7827
7828 static inline struct LDKDecodeError CResult_ChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7829 CHECK(!owner->result_ok);
7830         return DecodeError_clone(&*owner->contents.err);
7831 }
7832 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_get_err"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_get_err(uint32_t owner) {
7833         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(owner & ~1);
7834         LDKDecodeError ret_var = CResult_ChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
7835         uint32_t ret_ref = 0;
7836         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7837         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7838         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7839         ret_ref = (uintptr_t)ret_var.inner;
7840         if (ret_var.is_owned) {
7841                 ret_ref |= 1;
7842         }
7843         return ret_ref;
7844 }
7845
7846 static inline struct LDKUnsignedChannelUpdate CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
7847 CHECK(owner->result_ok);
7848         return UnsignedChannelUpdate_clone(&*owner->contents.result);
7849 }
7850 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(uint32_t owner) {
7851         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(owner & ~1);
7852         LDKUnsignedChannelUpdate ret_var = CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(owner_conv);
7853         uint32_t ret_ref = 0;
7854         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7855         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7856         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7857         ret_ref = (uintptr_t)ret_var.inner;
7858         if (ret_var.is_owned) {
7859                 ret_ref |= 1;
7860         }
7861         return ret_ref;
7862 }
7863
7864 static inline struct LDKDecodeError CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
7865 CHECK(!owner->result_ok);
7866         return DecodeError_clone(&*owner->contents.err);
7867 }
7868 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_get_err"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(uint32_t owner) {
7869         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(owner & ~1);
7870         LDKDecodeError ret_var = CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(owner_conv);
7871         uint32_t ret_ref = 0;
7872         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7873         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7874         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7875         ret_ref = (uintptr_t)ret_var.inner;
7876         if (ret_var.is_owned) {
7877                 ret_ref |= 1;
7878         }
7879         return ret_ref;
7880 }
7881
7882 static inline struct LDKChannelUpdate CResult_ChannelUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
7883 CHECK(owner->result_ok);
7884         return ChannelUpdate_clone(&*owner->contents.result);
7885 }
7886 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_get_ok"))) TS_CResult_ChannelUpdateDecodeErrorZ_get_ok(uint32_t owner) {
7887         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(owner & ~1);
7888         LDKChannelUpdate ret_var = CResult_ChannelUpdateDecodeErrorZ_get_ok(owner_conv);
7889         uint32_t ret_ref = 0;
7890         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7891         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7892         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7893         ret_ref = (uintptr_t)ret_var.inner;
7894         if (ret_var.is_owned) {
7895                 ret_ref |= 1;
7896         }
7897         return ret_ref;
7898 }
7899
7900 static inline struct LDKDecodeError CResult_ChannelUpdateDecodeErrorZ_get_err(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
7901 CHECK(!owner->result_ok);
7902         return DecodeError_clone(&*owner->contents.err);
7903 }
7904 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_get_err"))) TS_CResult_ChannelUpdateDecodeErrorZ_get_err(uint32_t owner) {
7905         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(owner & ~1);
7906         LDKDecodeError ret_var = CResult_ChannelUpdateDecodeErrorZ_get_err(owner_conv);
7907         uint32_t ret_ref = 0;
7908         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7909         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7910         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7911         ret_ref = (uintptr_t)ret_var.inner;
7912         if (ret_var.is_owned) {
7913                 ret_ref |= 1;
7914         }
7915         return ret_ref;
7916 }
7917
7918 static inline struct LDKErrorMessage CResult_ErrorMessageDecodeErrorZ_get_ok(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
7919 CHECK(owner->result_ok);
7920         return ErrorMessage_clone(&*owner->contents.result);
7921 }
7922 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_get_ok"))) TS_CResult_ErrorMessageDecodeErrorZ_get_ok(uint32_t owner) {
7923         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(owner & ~1);
7924         LDKErrorMessage ret_var = CResult_ErrorMessageDecodeErrorZ_get_ok(owner_conv);
7925         uint32_t ret_ref = 0;
7926         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7927         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7928         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7929         ret_ref = (uintptr_t)ret_var.inner;
7930         if (ret_var.is_owned) {
7931                 ret_ref |= 1;
7932         }
7933         return ret_ref;
7934 }
7935
7936 static inline struct LDKDecodeError CResult_ErrorMessageDecodeErrorZ_get_err(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
7937 CHECK(!owner->result_ok);
7938         return DecodeError_clone(&*owner->contents.err);
7939 }
7940 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_get_err"))) TS_CResult_ErrorMessageDecodeErrorZ_get_err(uint32_t owner) {
7941         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(owner & ~1);
7942         LDKDecodeError ret_var = CResult_ErrorMessageDecodeErrorZ_get_err(owner_conv);
7943         uint32_t ret_ref = 0;
7944         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7945         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7946         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7947         ret_ref = (uintptr_t)ret_var.inner;
7948         if (ret_var.is_owned) {
7949                 ret_ref |= 1;
7950         }
7951         return ret_ref;
7952 }
7953
7954 static inline struct LDKWarningMessage CResult_WarningMessageDecodeErrorZ_get_ok(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR owner){
7955 CHECK(owner->result_ok);
7956         return WarningMessage_clone(&*owner->contents.result);
7957 }
7958 uint32_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_get_ok"))) TS_CResult_WarningMessageDecodeErrorZ_get_ok(uint32_t owner) {
7959         LDKCResult_WarningMessageDecodeErrorZ* owner_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(owner & ~1);
7960         LDKWarningMessage ret_var = CResult_WarningMessageDecodeErrorZ_get_ok(owner_conv);
7961         uint32_t ret_ref = 0;
7962         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7963         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7964         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7965         ret_ref = (uintptr_t)ret_var.inner;
7966         if (ret_var.is_owned) {
7967                 ret_ref |= 1;
7968         }
7969         return ret_ref;
7970 }
7971
7972 static inline struct LDKDecodeError CResult_WarningMessageDecodeErrorZ_get_err(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR owner){
7973 CHECK(!owner->result_ok);
7974         return DecodeError_clone(&*owner->contents.err);
7975 }
7976 uint32_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_get_err"))) TS_CResult_WarningMessageDecodeErrorZ_get_err(uint32_t owner) {
7977         LDKCResult_WarningMessageDecodeErrorZ* owner_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(owner & ~1);
7978         LDKDecodeError ret_var = CResult_WarningMessageDecodeErrorZ_get_err(owner_conv);
7979         uint32_t ret_ref = 0;
7980         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7981         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7982         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7983         ret_ref = (uintptr_t)ret_var.inner;
7984         if (ret_var.is_owned) {
7985                 ret_ref |= 1;
7986         }
7987         return ret_ref;
7988 }
7989
7990 static inline struct LDKUnsignedNodeAnnouncement CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7991 CHECK(owner->result_ok);
7992         return UnsignedNodeAnnouncement_clone(&*owner->contents.result);
7993 }
7994 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(uint32_t owner) {
7995         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(owner & ~1);
7996         LDKUnsignedNodeAnnouncement ret_var = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
7997         uint32_t ret_ref = 0;
7998         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7999         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8000         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8001         ret_ref = (uintptr_t)ret_var.inner;
8002         if (ret_var.is_owned) {
8003                 ret_ref |= 1;
8004         }
8005         return ret_ref;
8006 }
8007
8008 static inline struct LDKDecodeError CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
8009 CHECK(!owner->result_ok);
8010         return DecodeError_clone(&*owner->contents.err);
8011 }
8012 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(uint32_t owner) {
8013         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(owner & ~1);
8014         LDKDecodeError ret_var = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(owner_conv);
8015         uint32_t ret_ref = 0;
8016         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8017         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8018         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8019         ret_ref = (uintptr_t)ret_var.inner;
8020         if (ret_var.is_owned) {
8021                 ret_ref |= 1;
8022         }
8023         return ret_ref;
8024 }
8025
8026 static inline struct LDKNodeAnnouncement CResult_NodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
8027 CHECK(owner->result_ok);
8028         return NodeAnnouncement_clone(&*owner->contents.result);
8029 }
8030 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_get_ok"))) TS_CResult_NodeAnnouncementDecodeErrorZ_get_ok(uint32_t owner) {
8031         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(owner & ~1);
8032         LDKNodeAnnouncement ret_var = CResult_NodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
8033         uint32_t ret_ref = 0;
8034         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8035         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8036         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8037         ret_ref = (uintptr_t)ret_var.inner;
8038         if (ret_var.is_owned) {
8039                 ret_ref |= 1;
8040         }
8041         return ret_ref;
8042 }
8043
8044 static inline struct LDKDecodeError CResult_NodeAnnouncementDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
8045 CHECK(!owner->result_ok);
8046         return DecodeError_clone(&*owner->contents.err);
8047 }
8048 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_get_err"))) TS_CResult_NodeAnnouncementDecodeErrorZ_get_err(uint32_t owner) {
8049         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(owner & ~1);
8050         LDKDecodeError ret_var = CResult_NodeAnnouncementDecodeErrorZ_get_err(owner_conv);
8051         uint32_t ret_ref = 0;
8052         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8053         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8054         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8055         ret_ref = (uintptr_t)ret_var.inner;
8056         if (ret_var.is_owned) {
8057                 ret_ref |= 1;
8058         }
8059         return ret_ref;
8060 }
8061
8062 static inline struct LDKQueryShortChannelIds CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
8063 CHECK(owner->result_ok);
8064         return QueryShortChannelIds_clone(&*owner->contents.result);
8065 }
8066 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_get_ok"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(uint32_t owner) {
8067         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(owner & ~1);
8068         LDKQueryShortChannelIds ret_var = CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(owner_conv);
8069         uint32_t ret_ref = 0;
8070         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8071         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8072         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8073         ret_ref = (uintptr_t)ret_var.inner;
8074         if (ret_var.is_owned) {
8075                 ret_ref |= 1;
8076         }
8077         return ret_ref;
8078 }
8079
8080 static inline struct LDKDecodeError CResult_QueryShortChannelIdsDecodeErrorZ_get_err(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
8081 CHECK(!owner->result_ok);
8082         return DecodeError_clone(&*owner->contents.err);
8083 }
8084 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_get_err"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_get_err(uint32_t owner) {
8085         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(owner & ~1);
8086         LDKDecodeError ret_var = CResult_QueryShortChannelIdsDecodeErrorZ_get_err(owner_conv);
8087         uint32_t ret_ref = 0;
8088         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8089         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8090         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8091         ret_ref = (uintptr_t)ret_var.inner;
8092         if (ret_var.is_owned) {
8093                 ret_ref |= 1;
8094         }
8095         return ret_ref;
8096 }
8097
8098 static inline struct LDKReplyShortChannelIdsEnd CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
8099 CHECK(owner->result_ok);
8100         return ReplyShortChannelIdsEnd_clone(&*owner->contents.result);
8101 }
8102 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(uint32_t owner) {
8103         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(owner & ~1);
8104         LDKReplyShortChannelIdsEnd ret_var = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(owner_conv);
8105         uint32_t ret_ref = 0;
8106         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8107         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8108         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8109         ret_ref = (uintptr_t)ret_var.inner;
8110         if (ret_var.is_owned) {
8111                 ret_ref |= 1;
8112         }
8113         return ret_ref;
8114 }
8115
8116 static inline struct LDKDecodeError CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
8117 CHECK(!owner->result_ok);
8118         return DecodeError_clone(&*owner->contents.err);
8119 }
8120 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(uint32_t owner) {
8121         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(owner & ~1);
8122         LDKDecodeError ret_var = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(owner_conv);
8123         uint32_t ret_ref = 0;
8124         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8125         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8126         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8127         ret_ref = (uintptr_t)ret_var.inner;
8128         if (ret_var.is_owned) {
8129                 ret_ref |= 1;
8130         }
8131         return ret_ref;
8132 }
8133
8134 static inline struct LDKQueryChannelRange CResult_QueryChannelRangeDecodeErrorZ_get_ok(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
8135 CHECK(owner->result_ok);
8136         return QueryChannelRange_clone(&*owner->contents.result);
8137 }
8138 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_get_ok"))) TS_CResult_QueryChannelRangeDecodeErrorZ_get_ok(uint32_t owner) {
8139         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(owner & ~1);
8140         LDKQueryChannelRange ret_var = CResult_QueryChannelRangeDecodeErrorZ_get_ok(owner_conv);
8141         uint32_t ret_ref = 0;
8142         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8143         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8144         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8145         ret_ref = (uintptr_t)ret_var.inner;
8146         if (ret_var.is_owned) {
8147                 ret_ref |= 1;
8148         }
8149         return ret_ref;
8150 }
8151
8152 static inline struct LDKDecodeError CResult_QueryChannelRangeDecodeErrorZ_get_err(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
8153 CHECK(!owner->result_ok);
8154         return DecodeError_clone(&*owner->contents.err);
8155 }
8156 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_get_err"))) TS_CResult_QueryChannelRangeDecodeErrorZ_get_err(uint32_t owner) {
8157         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(owner & ~1);
8158         LDKDecodeError ret_var = CResult_QueryChannelRangeDecodeErrorZ_get_err(owner_conv);
8159         uint32_t ret_ref = 0;
8160         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8161         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8162         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8163         ret_ref = (uintptr_t)ret_var.inner;
8164         if (ret_var.is_owned) {
8165                 ret_ref |= 1;
8166         }
8167         return ret_ref;
8168 }
8169
8170 static inline struct LDKReplyChannelRange CResult_ReplyChannelRangeDecodeErrorZ_get_ok(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
8171 CHECK(owner->result_ok);
8172         return ReplyChannelRange_clone(&*owner->contents.result);
8173 }
8174 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_get_ok"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_get_ok(uint32_t owner) {
8175         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(owner & ~1);
8176         LDKReplyChannelRange ret_var = CResult_ReplyChannelRangeDecodeErrorZ_get_ok(owner_conv);
8177         uint32_t ret_ref = 0;
8178         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8179         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8180         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8181         ret_ref = (uintptr_t)ret_var.inner;
8182         if (ret_var.is_owned) {
8183                 ret_ref |= 1;
8184         }
8185         return ret_ref;
8186 }
8187
8188 static inline struct LDKDecodeError CResult_ReplyChannelRangeDecodeErrorZ_get_err(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
8189 CHECK(!owner->result_ok);
8190         return DecodeError_clone(&*owner->contents.err);
8191 }
8192 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_get_err"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_get_err(uint32_t owner) {
8193         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(owner & ~1);
8194         LDKDecodeError ret_var = CResult_ReplyChannelRangeDecodeErrorZ_get_err(owner_conv);
8195         uint32_t ret_ref = 0;
8196         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8197         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8198         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8199         ret_ref = (uintptr_t)ret_var.inner;
8200         if (ret_var.is_owned) {
8201                 ret_ref |= 1;
8202         }
8203         return ret_ref;
8204 }
8205
8206 static inline struct LDKGossipTimestampFilter CResult_GossipTimestampFilterDecodeErrorZ_get_ok(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
8207 CHECK(owner->result_ok);
8208         return GossipTimestampFilter_clone(&*owner->contents.result);
8209 }
8210 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_get_ok"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_get_ok(uint32_t owner) {
8211         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(owner & ~1);
8212         LDKGossipTimestampFilter ret_var = CResult_GossipTimestampFilterDecodeErrorZ_get_ok(owner_conv);
8213         uint32_t ret_ref = 0;
8214         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8215         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8216         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8217         ret_ref = (uintptr_t)ret_var.inner;
8218         if (ret_var.is_owned) {
8219                 ret_ref |= 1;
8220         }
8221         return ret_ref;
8222 }
8223
8224 static inline struct LDKDecodeError CResult_GossipTimestampFilterDecodeErrorZ_get_err(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
8225 CHECK(!owner->result_ok);
8226         return DecodeError_clone(&*owner->contents.err);
8227 }
8228 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_get_err"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_get_err(uint32_t owner) {
8229         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(owner & ~1);
8230         LDKDecodeError ret_var = CResult_GossipTimestampFilterDecodeErrorZ_get_err(owner_conv);
8231         uint32_t ret_ref = 0;
8232         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8233         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8234         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8235         ret_ref = (uintptr_t)ret_var.inner;
8236         if (ret_var.is_owned) {
8237                 ret_ref |= 1;
8238         }
8239         return ret_ref;
8240 }
8241
8242 uint32_t __attribute__((export_name("TS_LDKSignOrCreationError_ty_from_ptr"))) TS_LDKSignOrCreationError_ty_from_ptr(uint32_t ptr) {
8243         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)(ptr & ~1);
8244         switch(obj->tag) {
8245                 case LDKSignOrCreationError_SignError: return 0;
8246                 case LDKSignOrCreationError_CreationError: return 1;
8247                 default: abort();
8248         }
8249 }
8250 uint32_t __attribute__((export_name("TS_LDKSignOrCreationError_CreationError_get_creation_error"))) TS_LDKSignOrCreationError_CreationError_get_creation_error(uint32_t ptr) {
8251         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)(ptr & ~1);
8252         assert(obj->tag == LDKSignOrCreationError_CreationError);
8253                         uint32_t creation_error_conv = LDKCreationError_to_js(obj->creation_error);
8254         return creation_error_conv;
8255 }
8256 static inline struct LDKInvoice CResult_InvoiceSignOrCreationErrorZ_get_ok(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR owner){
8257 CHECK(owner->result_ok);
8258         return Invoice_clone(&*owner->contents.result);
8259 }
8260 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_get_ok"))) TS_CResult_InvoiceSignOrCreationErrorZ_get_ok(uint32_t owner) {
8261         LDKCResult_InvoiceSignOrCreationErrorZ* owner_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(owner & ~1);
8262         LDKInvoice ret_var = CResult_InvoiceSignOrCreationErrorZ_get_ok(owner_conv);
8263         uint32_t ret_ref = 0;
8264         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8265         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8266         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8267         ret_ref = (uintptr_t)ret_var.inner;
8268         if (ret_var.is_owned) {
8269                 ret_ref |= 1;
8270         }
8271         return ret_ref;
8272 }
8273
8274 static inline struct LDKSignOrCreationError CResult_InvoiceSignOrCreationErrorZ_get_err(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR owner){
8275 CHECK(!owner->result_ok);
8276         return SignOrCreationError_clone(&*owner->contents.err);
8277 }
8278 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_get_err"))) TS_CResult_InvoiceSignOrCreationErrorZ_get_err(uint32_t owner) {
8279         LDKCResult_InvoiceSignOrCreationErrorZ* owner_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(owner & ~1);
8280         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
8281         *ret_copy = CResult_InvoiceSignOrCreationErrorZ_get_err(owner_conv);
8282         uint32_t ret_ref = (uintptr_t)ret_copy;
8283         return ret_ref;
8284 }
8285
8286 typedef struct LDKFilter_JCalls {
8287         atomic_size_t refcnt;
8288         uint32_t instance_ptr;
8289 } LDKFilter_JCalls;
8290 static void LDKFilter_JCalls_free(void* this_arg) {
8291         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
8292         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8293                 FREE(j_calls);
8294         }
8295 }
8296 void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
8297         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
8298         int8_tArray txid_arr = init_int8_tArray(32, __LINE__);
8299         memcpy(txid_arr->elems, *txid, 32);
8300         LDKu8slice script_pubkey_var = script_pubkey;
8301         int8_tArray script_pubkey_arr = init_int8_tArray(script_pubkey_var.datalen, __LINE__);
8302         memcpy(script_pubkey_arr->elems, script_pubkey_var.data, script_pubkey_var.datalen);
8303         js_invoke_function_uuuuuu(j_calls->instance_ptr, 32, (uint32_t)txid_arr, (uint32_t)script_pubkey_arr, 0, 0, 0, 0);
8304 }
8305 LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) {
8306         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
8307         LDKWatchedOutput output_var = output;
8308         uint32_t output_ref = 0;
8309         CHECK((((uintptr_t)output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8310         CHECK((((uintptr_t)&output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8311         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_var);
8312         output_ref = (uintptr_t)output_var.inner;
8313         if (output_var.is_owned) {
8314                 output_ref |= 1;
8315         }
8316         uint32_t ret = js_invoke_function_uuuuuu(j_calls->instance_ptr, 33, (uint32_t)output_ref, 0, 0, 0, 0, 0);
8317         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
8318         CHECK_ACCESS(ret_ptr);
8319         LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(ret_ptr);
8320         FREE((void*)ret);
8321         return ret_conv;
8322 }
8323 static void LDKFilter_JCalls_cloned(LDKFilter* new_obj) {
8324         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) new_obj->this_arg;
8325         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8326 }
8327 static inline LDKFilter LDKFilter_init (JSValue o) {
8328         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
8329         atomic_init(&calls->refcnt, 1);
8330         calls->instance_ptr = o;
8331
8332         LDKFilter ret = {
8333                 .this_arg = (void*) calls,
8334                 .register_tx = register_tx_LDKFilter_jcall,
8335                 .register_output = register_output_LDKFilter_jcall,
8336                 .free = LDKFilter_JCalls_free,
8337         };
8338         return ret;
8339 }
8340 long  __attribute__((export_name("TS_LDKFilter_new"))) TS_LDKFilter_new(JSValue o) {
8341         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
8342         *res_ptr = LDKFilter_init(o);
8343         return (long)res_ptr;
8344 }
8345 void  __attribute__((export_name("TS_Filter_register_tx"))) TS_Filter_register_tx(uint32_t this_arg, int8_tArray txid, int8_tArray script_pubkey) {
8346         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8347         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8348         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
8349         unsigned char txid_arr[32];
8350         CHECK(txid->arr_len == 32);
8351         memcpy(txid_arr, txid->elems, 32); FREE(txid);
8352         unsigned char (*txid_ref)[32] = &txid_arr;
8353         LDKu8slice script_pubkey_ref;
8354         script_pubkey_ref.datalen = script_pubkey->arr_len;
8355         script_pubkey_ref.data = script_pubkey->elems;
8356         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
8357         FREE(script_pubkey);
8358 }
8359
8360 uint32_t  __attribute__((export_name("TS_Filter_register_output"))) TS_Filter_register_output(uint32_t this_arg, uint32_t output) {
8361         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8362         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8363         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
8364         LDKWatchedOutput output_conv;
8365         output_conv.inner = (void*)(output & (~1));
8366         output_conv.is_owned = (output & 1) || (output == 0);
8367         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_conv);
8368         output_conv = WatchedOutput_clone(&output_conv);
8369         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
8370         *ret_copy = (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv);
8371         uint32_t ret_ref = (uintptr_t)ret_copy;
8372         return ret_ref;
8373 }
8374
8375 uint32_t __attribute__((export_name("TS_LDKCOption_FilterZ_ty_from_ptr"))) TS_LDKCOption_FilterZ_ty_from_ptr(uint32_t ptr) {
8376         LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)(ptr & ~1);
8377         switch(obj->tag) {
8378                 case LDKCOption_FilterZ_Some: return 0;
8379                 case LDKCOption_FilterZ_None: return 1;
8380                 default: abort();
8381         }
8382 }
8383 uint32_t __attribute__((export_name("TS_LDKCOption_FilterZ_Some_get_some"))) TS_LDKCOption_FilterZ_Some_get_some(uint32_t ptr) {
8384         LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)(ptr & ~1);
8385         assert(obj->tag == LDKCOption_FilterZ_Some);
8386                         LDKFilter* some_ret = MALLOC(sizeof(LDKFilter), "LDKFilter");
8387                         *some_ret = obj->some;
8388                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
8389                         if ((*some_ret).free == LDKFilter_JCalls_free) {
8390                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
8391                                 LDKFilter_JCalls_cloned(&(*some_ret));
8392                         }
8393         return (uint32_t)some_ret;
8394 }
8395 static inline struct LDKLockedChannelMonitor *CResult_LockedChannelMonitorNoneZ_get_ok(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
8396 CHECK(owner->result_ok);
8397         return &*owner->contents.result;
8398 }
8399 uint32_t  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_get_ok"))) TS_CResult_LockedChannelMonitorNoneZ_get_ok(uint32_t owner) {
8400         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(owner & ~1);
8401         LDKLockedChannelMonitor ret_var = *CResult_LockedChannelMonitorNoneZ_get_ok(owner_conv);
8402         uint32_t ret_ref = 0;
8403         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8404         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8405         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8406         ret_ref = (uintptr_t)ret_var.inner & ~1;
8407         return ret_ref;
8408 }
8409
8410 static inline void CResult_LockedChannelMonitorNoneZ_get_err(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
8411 CHECK(!owner->result_ok);
8412         return *owner->contents.err;
8413 }
8414 void  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_get_err"))) TS_CResult_LockedChannelMonitorNoneZ_get_err(uint32_t owner) {
8415         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(owner & ~1);
8416         CResult_LockedChannelMonitorNoneZ_get_err(owner_conv);
8417 }
8418
8419 static inline LDKCVec_OutPointZ CVec_OutPointZ_clone(const LDKCVec_OutPointZ *orig) {
8420         LDKCVec_OutPointZ ret = { .data = MALLOC(sizeof(LDKOutPoint) * orig->datalen, "LDKCVec_OutPointZ clone bytes"), .datalen = orig->datalen };
8421         for (size_t i = 0; i < ret.datalen; i++) {
8422                 ret.data[i] = OutPoint_clone(&orig->data[i]);
8423         }
8424         return ret;
8425 }
8426 typedef struct LDKMessageSendEventsProvider_JCalls {
8427         atomic_size_t refcnt;
8428         uint32_t instance_ptr;
8429 } LDKMessageSendEventsProvider_JCalls;
8430 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
8431         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
8432         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8433                 FREE(j_calls);
8434         }
8435 }
8436 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) {
8437         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
8438         uint32_tArray ret = (uint32_tArray)js_invoke_function_uuuuuu(j_calls->instance_ptr, 34, 0, 0, 0, 0, 0, 0);
8439         LDKCVec_MessageSendEventZ ret_constr;
8440         ret_constr.datalen = ret->arr_len;
8441         if (ret_constr.datalen > 0)
8442                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
8443         else
8444                 ret_constr.data = NULL;
8445         uint32_t* ret_vals = ret->elems;
8446         for (size_t s = 0; s < ret_constr.datalen; s++) {
8447                 uint32_t ret_conv_18 = ret_vals[s];
8448                 void* ret_conv_18_ptr = (void*)(((uintptr_t)ret_conv_18) & ~1);
8449                 CHECK_ACCESS(ret_conv_18_ptr);
8450                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(ret_conv_18_ptr);
8451                 FREE((void*)ret_conv_18);
8452                 ret_constr.data[s] = ret_conv_18_conv;
8453         }
8454         FREE(ret);
8455         return ret_constr;
8456 }
8457 static void LDKMessageSendEventsProvider_JCalls_cloned(LDKMessageSendEventsProvider* new_obj) {
8458         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) new_obj->this_arg;
8459         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8460 }
8461 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (JSValue o) {
8462         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
8463         atomic_init(&calls->refcnt, 1);
8464         calls->instance_ptr = o;
8465
8466         LDKMessageSendEventsProvider ret = {
8467                 .this_arg = (void*) calls,
8468                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall,
8469                 .free = LDKMessageSendEventsProvider_JCalls_free,
8470         };
8471         return ret;
8472 }
8473 long  __attribute__((export_name("TS_LDKMessageSendEventsProvider_new"))) TS_LDKMessageSendEventsProvider_new(JSValue o) {
8474         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
8475         *res_ptr = LDKMessageSendEventsProvider_init(o);
8476         return (long)res_ptr;
8477 }
8478 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) {
8479         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8480         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8481         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)this_arg_ptr;
8482         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
8483         uint32_tArray ret_arr = NULL;
8484         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
8485         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 8);
8486         for (size_t s = 0; s < ret_var.datalen; s++) {
8487                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
8488                 *ret_conv_18_copy = ret_var.data[s];
8489                 uint32_t ret_conv_18_ref = (uintptr_t)ret_conv_18_copy;
8490                 ret_arr_ptr[s] = ret_conv_18_ref;
8491         }
8492         
8493         FREE(ret_var.data);
8494         return ret_arr;
8495 }
8496
8497 typedef struct LDKEventHandler_JCalls {
8498         atomic_size_t refcnt;
8499         uint32_t instance_ptr;
8500 } LDKEventHandler_JCalls;
8501 static void LDKEventHandler_JCalls_free(void* this_arg) {
8502         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
8503         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8504                 FREE(j_calls);
8505         }
8506 }
8507 void handle_event_LDKEventHandler_jcall(const void* this_arg, const LDKEvent * event) {
8508         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
8509         LDKEvent *ret_event = MALLOC(sizeof(LDKEvent), "LDKEvent ret conversion");
8510         *ret_event = Event_clone(event);
8511         js_invoke_function_uuuuuu(j_calls->instance_ptr, 35, (uint32_t)(uint32_t)ret_event, 0, 0, 0, 0, 0);
8512 }
8513 static void LDKEventHandler_JCalls_cloned(LDKEventHandler* new_obj) {
8514         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) new_obj->this_arg;
8515         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8516 }
8517 static inline LDKEventHandler LDKEventHandler_init (JSValue o) {
8518         LDKEventHandler_JCalls *calls = MALLOC(sizeof(LDKEventHandler_JCalls), "LDKEventHandler_JCalls");
8519         atomic_init(&calls->refcnt, 1);
8520         calls->instance_ptr = o;
8521
8522         LDKEventHandler ret = {
8523                 .this_arg = (void*) calls,
8524                 .handle_event = handle_event_LDKEventHandler_jcall,
8525                 .free = LDKEventHandler_JCalls_free,
8526         };
8527         return ret;
8528 }
8529 long  __attribute__((export_name("TS_LDKEventHandler_new"))) TS_LDKEventHandler_new(JSValue o) {
8530         LDKEventHandler *res_ptr = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
8531         *res_ptr = LDKEventHandler_init(o);
8532         return (long)res_ptr;
8533 }
8534 void  __attribute__((export_name("TS_EventHandler_handle_event"))) TS_EventHandler_handle_event(uint32_t this_arg, uint32_t event) {
8535         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8536         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8537         LDKEventHandler* this_arg_conv = (LDKEventHandler*)this_arg_ptr;
8538         LDKEvent* event_conv = (LDKEvent*)event;
8539         (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv);
8540 }
8541
8542 typedef struct LDKEventsProvider_JCalls {
8543         atomic_size_t refcnt;
8544         uint32_t instance_ptr;
8545 } LDKEventsProvider_JCalls;
8546 static void LDKEventsProvider_JCalls_free(void* this_arg) {
8547         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
8548         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8549                 FREE(j_calls);
8550         }
8551 }
8552 void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEventHandler handler) {
8553         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
8554         LDKEventHandler* handler_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
8555         *handler_ret = handler;
8556         js_invoke_function_uuuuuu(j_calls->instance_ptr, 36, (uint32_t)(uint32_t)handler_ret, 0, 0, 0, 0, 0);
8557 }
8558 static void LDKEventsProvider_JCalls_cloned(LDKEventsProvider* new_obj) {
8559         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) new_obj->this_arg;
8560         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8561 }
8562 static inline LDKEventsProvider LDKEventsProvider_init (JSValue o) {
8563         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
8564         atomic_init(&calls->refcnt, 1);
8565         calls->instance_ptr = o;
8566
8567         LDKEventsProvider ret = {
8568                 .this_arg = (void*) calls,
8569                 .process_pending_events = process_pending_events_LDKEventsProvider_jcall,
8570                 .free = LDKEventsProvider_JCalls_free,
8571         };
8572         return ret;
8573 }
8574 long  __attribute__((export_name("TS_LDKEventsProvider_new"))) TS_LDKEventsProvider_new(JSValue o) {
8575         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
8576         *res_ptr = LDKEventsProvider_init(o);
8577         return (long)res_ptr;
8578 }
8579 void  __attribute__((export_name("TS_EventsProvider_process_pending_events"))) TS_EventsProvider_process_pending_events(uint32_t this_arg, uint32_t handler) {
8580         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8581         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8582         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)this_arg_ptr;
8583         void* handler_ptr = (void*)(((uintptr_t)handler) & ~1);
8584         CHECK_ACCESS(handler_ptr);
8585         LDKEventHandler handler_conv = *(LDKEventHandler*)(handler_ptr);
8586         if (handler_conv.free == LDKEventHandler_JCalls_free) {
8587                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
8588                 LDKEventHandler_JCalls_cloned(&handler_conv);
8589         }
8590         (this_arg_conv->process_pending_events)(this_arg_conv->this_arg, handler_conv);
8591 }
8592
8593 typedef struct LDKScore_JCalls {
8594         atomic_size_t refcnt;
8595         uint32_t instance_ptr;
8596 } LDKScore_JCalls;
8597 static void LDKScore_JCalls_free(void* this_arg) {
8598         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
8599         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8600                 FREE(j_calls);
8601         }
8602 }
8603 uint64_t channel_penalty_msat_LDKScore_jcall(const void* this_arg, uint64_t short_channel_id, const LDKNodeId * source, const LDKNodeId * target, LDKChannelUsage usage) {
8604         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
8605         int64_t short_channel_id_conv = short_channel_id;
8606         LDKNodeId source_var = *source;
8607         uint32_t source_ref = 0;
8608         source_var = NodeId_clone(&source_var);
8609         CHECK((((uintptr_t)source_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8610         CHECK((((uintptr_t)&source_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8611         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_var);
8612         source_ref = (uintptr_t)source_var.inner;
8613         if (source_var.is_owned) {
8614                 source_ref |= 1;
8615         }
8616         LDKNodeId target_var = *target;
8617         uint32_t target_ref = 0;
8618         target_var = NodeId_clone(&target_var);
8619         CHECK((((uintptr_t)target_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8620         CHECK((((uintptr_t)&target_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8621         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_var);
8622         target_ref = (uintptr_t)target_var.inner;
8623         if (target_var.is_owned) {
8624                 target_ref |= 1;
8625         }
8626         LDKChannelUsage usage_var = usage;
8627         uint32_t usage_ref = 0;
8628         CHECK((((uintptr_t)usage_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8629         CHECK((((uintptr_t)&usage_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8630         CHECK_INNER_FIELD_ACCESS_OR_NULL(usage_var);
8631         usage_ref = (uintptr_t)usage_var.inner;
8632         if (usage_var.is_owned) {
8633                 usage_ref |= 1;
8634         }
8635         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);
8636 }
8637 void payment_path_failed_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
8638         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
8639         LDKCVec_RouteHopZ path_var = path;
8640         uint32_tArray path_arr = NULL;
8641         path_arr = init_uint32_tArray(path_var.datalen, __LINE__);
8642         uint32_t *path_arr_ptr = (uint32_t*)(((uint8_t*)path_arr) + 8);
8643         for (size_t k = 0; k < path_var.datalen; k++) {
8644                 LDKRouteHop path_conv_10_var = path_var.data[k];
8645                 uint32_t path_conv_10_ref = 0;
8646                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8647                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8648                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
8649                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner;
8650                 if (path_conv_10_var.is_owned) {
8651                         path_conv_10_ref |= 1;
8652                 }
8653                 path_arr_ptr[k] = path_conv_10_ref;
8654         }
8655         
8656         FREE(path_var.data);
8657         int64_t short_channel_id_conv = short_channel_id;
8658         js_invoke_function_ubuuuu(j_calls->instance_ptr, 38, (uint32_t)path_arr, (uint32_t)short_channel_id_conv, 0, 0, 0, 0);
8659 }
8660 void payment_path_successful_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path) {
8661         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
8662         LDKCVec_RouteHopZ path_var = path;
8663         uint32_tArray path_arr = NULL;
8664         path_arr = init_uint32_tArray(path_var.datalen, __LINE__);
8665         uint32_t *path_arr_ptr = (uint32_t*)(((uint8_t*)path_arr) + 8);
8666         for (size_t k = 0; k < path_var.datalen; k++) {
8667                 LDKRouteHop path_conv_10_var = path_var.data[k];
8668                 uint32_t path_conv_10_ref = 0;
8669                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8670                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8671                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
8672                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner;
8673                 if (path_conv_10_var.is_owned) {
8674                         path_conv_10_ref |= 1;
8675                 }
8676                 path_arr_ptr[k] = path_conv_10_ref;
8677         }
8678         
8679         FREE(path_var.data);
8680         js_invoke_function_uuuuuu(j_calls->instance_ptr, 39, (uint32_t)path_arr, 0, 0, 0, 0, 0);
8681 }
8682 void probe_failed_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
8683         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
8684         LDKCVec_RouteHopZ path_var = path;
8685         uint32_tArray path_arr = NULL;
8686         path_arr = init_uint32_tArray(path_var.datalen, __LINE__);
8687         uint32_t *path_arr_ptr = (uint32_t*)(((uint8_t*)path_arr) + 8);
8688         for (size_t k = 0; k < path_var.datalen; k++) {
8689                 LDKRouteHop path_conv_10_var = path_var.data[k];
8690                 uint32_t path_conv_10_ref = 0;
8691                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8692                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8693                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
8694                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner;
8695                 if (path_conv_10_var.is_owned) {
8696                         path_conv_10_ref |= 1;
8697                 }
8698                 path_arr_ptr[k] = path_conv_10_ref;
8699         }
8700         
8701         FREE(path_var.data);
8702         int64_t short_channel_id_conv = short_channel_id;
8703         js_invoke_function_ubuuuu(j_calls->instance_ptr, 40, (uint32_t)path_arr, (uint32_t)short_channel_id_conv, 0, 0, 0, 0);
8704 }
8705 void probe_successful_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path) {
8706         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
8707         LDKCVec_RouteHopZ path_var = path;
8708         uint32_tArray path_arr = NULL;
8709         path_arr = init_uint32_tArray(path_var.datalen, __LINE__);
8710         uint32_t *path_arr_ptr = (uint32_t*)(((uint8_t*)path_arr) + 8);
8711         for (size_t k = 0; k < path_var.datalen; k++) {
8712                 LDKRouteHop path_conv_10_var = path_var.data[k];
8713                 uint32_t path_conv_10_ref = 0;
8714                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8715                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8716                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
8717                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner;
8718                 if (path_conv_10_var.is_owned) {
8719                         path_conv_10_ref |= 1;
8720                 }
8721                 path_arr_ptr[k] = path_conv_10_ref;
8722         }
8723         
8724         FREE(path_var.data);
8725         js_invoke_function_uuuuuu(j_calls->instance_ptr, 41, (uint32_t)path_arr, 0, 0, 0, 0, 0);
8726 }
8727 LDKCVec_u8Z write_LDKScore_jcall(const void* this_arg) {
8728         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
8729         int8_tArray ret = (int8_tArray)js_invoke_function_uuuuuu(j_calls->instance_ptr, 42, 0, 0, 0, 0, 0, 0);
8730         LDKCVec_u8Z ret_ref;
8731         ret_ref.datalen = ret->arr_len;
8732         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
8733         memcpy(ret_ref.data, ret->elems, ret_ref.datalen); FREE(ret);
8734         return ret_ref;
8735 }
8736 static void LDKScore_JCalls_cloned(LDKScore* new_obj) {
8737         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) new_obj->this_arg;
8738         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8739 }
8740 static inline LDKScore LDKScore_init (JSValue o) {
8741         LDKScore_JCalls *calls = MALLOC(sizeof(LDKScore_JCalls), "LDKScore_JCalls");
8742         atomic_init(&calls->refcnt, 1);
8743         calls->instance_ptr = o;
8744
8745         LDKScore ret = {
8746                 .this_arg = (void*) calls,
8747                 .channel_penalty_msat = channel_penalty_msat_LDKScore_jcall,
8748                 .payment_path_failed = payment_path_failed_LDKScore_jcall,
8749                 .payment_path_successful = payment_path_successful_LDKScore_jcall,
8750                 .probe_failed = probe_failed_LDKScore_jcall,
8751                 .probe_successful = probe_successful_LDKScore_jcall,
8752                 .write = write_LDKScore_jcall,
8753                 .free = LDKScore_JCalls_free,
8754         };
8755         return ret;
8756 }
8757 long  __attribute__((export_name("TS_LDKScore_new"))) TS_LDKScore_new(JSValue o) {
8758         LDKScore *res_ptr = MALLOC(sizeof(LDKScore), "LDKScore");
8759         *res_ptr = LDKScore_init(o);
8760         return (long)res_ptr;
8761 }
8762 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) {
8763         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8764         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8765         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
8766         LDKNodeId source_conv;
8767         source_conv.inner = (void*)(source & (~1));
8768         source_conv.is_owned = false;
8769         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_conv);
8770         LDKNodeId target_conv;
8771         target_conv.inner = (void*)(target & (~1));
8772         target_conv.is_owned = false;
8773         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
8774         LDKChannelUsage usage_conv;
8775         usage_conv.inner = (void*)(usage & (~1));
8776         usage_conv.is_owned = (usage & 1) || (usage == 0);
8777         CHECK_INNER_FIELD_ACCESS_OR_NULL(usage_conv);
8778         usage_conv = ChannelUsage_clone(&usage_conv);
8779         int64_t ret_conv = (this_arg_conv->channel_penalty_msat)(this_arg_conv->this_arg, short_channel_id, &source_conv, &target_conv, usage_conv);
8780         return ret_conv;
8781 }
8782
8783 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) {
8784         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8785         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8786         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
8787         LDKCVec_RouteHopZ path_constr;
8788         path_constr.datalen = path->arr_len;
8789         if (path_constr.datalen > 0)
8790                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
8791         else
8792                 path_constr.data = NULL;
8793         uint32_t* path_vals = path->elems;
8794         for (size_t k = 0; k < path_constr.datalen; k++) {
8795                 uint32_t path_conv_10 = path_vals[k];
8796                 LDKRouteHop path_conv_10_conv;
8797                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
8798                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
8799                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
8800                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
8801                 path_constr.data[k] = path_conv_10_conv;
8802         }
8803         FREE(path);
8804         (this_arg_conv->payment_path_failed)(this_arg_conv->this_arg, path_constr, short_channel_id);
8805 }
8806
8807 void  __attribute__((export_name("TS_Score_payment_path_successful"))) TS_Score_payment_path_successful(uint32_t this_arg, uint32_tArray path) {
8808         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8809         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8810         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
8811         LDKCVec_RouteHopZ path_constr;
8812         path_constr.datalen = path->arr_len;
8813         if (path_constr.datalen > 0)
8814                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
8815         else
8816                 path_constr.data = NULL;
8817         uint32_t* path_vals = path->elems;
8818         for (size_t k = 0; k < path_constr.datalen; k++) {
8819                 uint32_t path_conv_10 = path_vals[k];
8820                 LDKRouteHop path_conv_10_conv;
8821                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
8822                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
8823                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
8824                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
8825                 path_constr.data[k] = path_conv_10_conv;
8826         }
8827         FREE(path);
8828         (this_arg_conv->payment_path_successful)(this_arg_conv->this_arg, path_constr);
8829 }
8830
8831 void  __attribute__((export_name("TS_Score_probe_failed"))) TS_Score_probe_failed(uint32_t this_arg, uint32_tArray path, int64_t short_channel_id) {
8832         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8833         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8834         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
8835         LDKCVec_RouteHopZ path_constr;
8836         path_constr.datalen = path->arr_len;
8837         if (path_constr.datalen > 0)
8838                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
8839         else
8840                 path_constr.data = NULL;
8841         uint32_t* path_vals = path->elems;
8842         for (size_t k = 0; k < path_constr.datalen; k++) {
8843                 uint32_t path_conv_10 = path_vals[k];
8844                 LDKRouteHop path_conv_10_conv;
8845                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
8846                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
8847                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
8848                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
8849                 path_constr.data[k] = path_conv_10_conv;
8850         }
8851         FREE(path);
8852         (this_arg_conv->probe_failed)(this_arg_conv->this_arg, path_constr, short_channel_id);
8853 }
8854
8855 void  __attribute__((export_name("TS_Score_probe_successful"))) TS_Score_probe_successful(uint32_t this_arg, uint32_tArray path) {
8856         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8857         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8858         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
8859         LDKCVec_RouteHopZ path_constr;
8860         path_constr.datalen = path->arr_len;
8861         if (path_constr.datalen > 0)
8862                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
8863         else
8864                 path_constr.data = NULL;
8865         uint32_t* path_vals = path->elems;
8866         for (size_t k = 0; k < path_constr.datalen; k++) {
8867                 uint32_t path_conv_10 = path_vals[k];
8868                 LDKRouteHop path_conv_10_conv;
8869                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
8870                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
8871                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
8872                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
8873                 path_constr.data[k] = path_conv_10_conv;
8874         }
8875         FREE(path);
8876         (this_arg_conv->probe_successful)(this_arg_conv->this_arg, path_constr);
8877 }
8878
8879 int8_tArray  __attribute__((export_name("TS_Score_write"))) TS_Score_write(uint32_t this_arg) {
8880         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8881         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8882         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
8883         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
8884         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
8885         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
8886         CVec_u8Z_free(ret_var);
8887         return ret_arr;
8888 }
8889
8890 typedef struct LDKPersister_JCalls {
8891         atomic_size_t refcnt;
8892         uint32_t instance_ptr;
8893 } LDKPersister_JCalls;
8894 static void LDKPersister_JCalls_free(void* this_arg) {
8895         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
8896         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8897                 FREE(j_calls);
8898         }
8899 }
8900 LDKCResult_NoneErrorZ persist_manager_LDKPersister_jcall(const void* this_arg, const LDKChannelManager * channel_manager) {
8901         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
8902         LDKChannelManager channel_manager_var = *channel_manager;
8903         uint32_t channel_manager_ref = 0;
8904         // WARNING: we may need a move here but no clone is available for LDKChannelManager
8905         CHECK((((uintptr_t)channel_manager_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8906         CHECK((((uintptr_t)&channel_manager_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8907         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_var);
8908         channel_manager_ref = (uintptr_t)channel_manager_var.inner;
8909         if (channel_manager_var.is_owned) {
8910                 channel_manager_ref |= 1;
8911         }
8912         uint32_t ret = js_invoke_function_uuuuuu(j_calls->instance_ptr, 43, (uint32_t)channel_manager_ref, 0, 0, 0, 0, 0);
8913         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
8914         CHECK_ACCESS(ret_ptr);
8915         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
8916         FREE((void*)ret);
8917         return ret_conv;
8918 }
8919 LDKCResult_NoneErrorZ persist_graph_LDKPersister_jcall(const void* this_arg, const LDKNetworkGraph * network_graph) {
8920         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
8921         LDKNetworkGraph network_graph_var = *network_graph;
8922         uint32_t network_graph_ref = 0;
8923         // WARNING: we may need a move here but no clone is available for LDKNetworkGraph
8924         CHECK((((uintptr_t)network_graph_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8925         CHECK((((uintptr_t)&network_graph_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8926         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_var);
8927         network_graph_ref = (uintptr_t)network_graph_var.inner;
8928         if (network_graph_var.is_owned) {
8929                 network_graph_ref |= 1;
8930         }
8931         uint32_t ret = js_invoke_function_uuuuuu(j_calls->instance_ptr, 44, (uint32_t)network_graph_ref, 0, 0, 0, 0, 0);
8932         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
8933         CHECK_ACCESS(ret_ptr);
8934         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
8935         FREE((void*)ret);
8936         return ret_conv;
8937 }
8938 LDKCResult_NoneErrorZ persist_scorer_LDKPersister_jcall(const void* this_arg, const LDKMultiThreadedLockableScore * scorer) {
8939         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
8940         LDKMultiThreadedLockableScore scorer_var = *scorer;
8941         uint32_t scorer_ref = 0;
8942         // WARNING: we may need a move here but no clone is available for LDKMultiThreadedLockableScore
8943         CHECK((((uintptr_t)scorer_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8944         CHECK((((uintptr_t)&scorer_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8945         CHECK_INNER_FIELD_ACCESS_OR_NULL(scorer_var);
8946         scorer_ref = (uintptr_t)scorer_var.inner;
8947         if (scorer_var.is_owned) {
8948                 scorer_ref |= 1;
8949         }
8950         uint32_t ret = js_invoke_function_uuuuuu(j_calls->instance_ptr, 45, (uint32_t)scorer_ref, 0, 0, 0, 0, 0);
8951         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
8952         CHECK_ACCESS(ret_ptr);
8953         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
8954         FREE((void*)ret);
8955         return ret_conv;
8956 }
8957 static void LDKPersister_JCalls_cloned(LDKPersister* new_obj) {
8958         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) new_obj->this_arg;
8959         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8960 }
8961 static inline LDKPersister LDKPersister_init (JSValue o) {
8962         LDKPersister_JCalls *calls = MALLOC(sizeof(LDKPersister_JCalls), "LDKPersister_JCalls");
8963         atomic_init(&calls->refcnt, 1);
8964         calls->instance_ptr = o;
8965
8966         LDKPersister ret = {
8967                 .this_arg = (void*) calls,
8968                 .persist_manager = persist_manager_LDKPersister_jcall,
8969                 .persist_graph = persist_graph_LDKPersister_jcall,
8970                 .persist_scorer = persist_scorer_LDKPersister_jcall,
8971                 .free = LDKPersister_JCalls_free,
8972         };
8973         return ret;
8974 }
8975 long  __attribute__((export_name("TS_LDKPersister_new"))) TS_LDKPersister_new(JSValue o) {
8976         LDKPersister *res_ptr = MALLOC(sizeof(LDKPersister), "LDKPersister");
8977         *res_ptr = LDKPersister_init(o);
8978         return (long)res_ptr;
8979 }
8980 uint32_t  __attribute__((export_name("TS_Persister_persist_manager"))) TS_Persister_persist_manager(uint32_t this_arg, uint32_t channel_manager) {
8981         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8982         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8983         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
8984         LDKChannelManager channel_manager_conv;
8985         channel_manager_conv.inner = (void*)(channel_manager & (~1));
8986         channel_manager_conv.is_owned = false;
8987         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_conv);
8988         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
8989         *ret_conv = (this_arg_conv->persist_manager)(this_arg_conv->this_arg, &channel_manager_conv);
8990         return (uint32_t)ret_conv;
8991 }
8992
8993 uint32_t  __attribute__((export_name("TS_Persister_persist_graph"))) TS_Persister_persist_graph(uint32_t this_arg, uint32_t network_graph) {
8994         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8995         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8996         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
8997         LDKNetworkGraph network_graph_conv;
8998         network_graph_conv.inner = (void*)(network_graph & (~1));
8999         network_graph_conv.is_owned = false;
9000         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
9001         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
9002         *ret_conv = (this_arg_conv->persist_graph)(this_arg_conv->this_arg, &network_graph_conv);
9003         return (uint32_t)ret_conv;
9004 }
9005
9006 uint32_t  __attribute__((export_name("TS_Persister_persist_scorer"))) TS_Persister_persist_scorer(uint32_t this_arg, uint32_t scorer) {
9007         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9008         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9009         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
9010         LDKMultiThreadedLockableScore scorer_conv;
9011         scorer_conv.inner = (void*)(scorer & (~1));
9012         scorer_conv.is_owned = false;
9013         CHECK_INNER_FIELD_ACCESS_OR_NULL(scorer_conv);
9014         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
9015         *ret_conv = (this_arg_conv->persist_scorer)(this_arg_conv->this_arg, &scorer_conv);
9016         return (uint32_t)ret_conv;
9017 }
9018
9019 typedef struct LDKListen_JCalls {
9020         atomic_size_t refcnt;
9021         uint32_t instance_ptr;
9022 } LDKListen_JCalls;
9023 static void LDKListen_JCalls_free(void* this_arg) {
9024         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
9025         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9026                 FREE(j_calls);
9027         }
9028 }
9029 void filtered_block_connected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
9030         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
9031         int8_tArray header_arr = init_int8_tArray(80, __LINE__);
9032         memcpy(header_arr->elems, *header, 80);
9033         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
9034         uint32_tArray txdata_arr = NULL;
9035         txdata_arr = init_uint32_tArray(txdata_var.datalen, __LINE__);
9036         uint32_t *txdata_arr_ptr = (uint32_t*)(((uint8_t*)txdata_arr) + 8);
9037         for (size_t c = 0; c < txdata_var.datalen; c++) {
9038                 LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
9039                 *txdata_conv_28_conv = txdata_var.data[c];
9040                 txdata_arr_ptr[c] = ((uint32_t)txdata_conv_28_conv);
9041         }
9042         
9043         FREE(txdata_var.data);
9044         int32_t height_conv = height;
9045         js_invoke_function_uuuuuu(j_calls->instance_ptr, 46, (uint32_t)header_arr, (uint32_t)txdata_arr, (uint32_t)height_conv, 0, 0, 0);
9046 }
9047 void block_connected_LDKListen_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
9048         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
9049         LDKu8slice block_var = block;
9050         int8_tArray block_arr = init_int8_tArray(block_var.datalen, __LINE__);
9051         memcpy(block_arr->elems, block_var.data, block_var.datalen);
9052         int32_t height_conv = height;
9053         js_invoke_function_uuuuuu(j_calls->instance_ptr, 47, (uint32_t)block_arr, (uint32_t)height_conv, 0, 0, 0, 0);
9054 }
9055 void block_disconnected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
9056         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
9057         int8_tArray header_arr = init_int8_tArray(80, __LINE__);
9058         memcpy(header_arr->elems, *header, 80);
9059         int32_t height_conv = height;
9060         js_invoke_function_uuuuuu(j_calls->instance_ptr, 48, (uint32_t)header_arr, (uint32_t)height_conv, 0, 0, 0, 0);
9061 }
9062 static void LDKListen_JCalls_cloned(LDKListen* new_obj) {
9063         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) new_obj->this_arg;
9064         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9065 }
9066 static inline LDKListen LDKListen_init (JSValue o) {
9067         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
9068         atomic_init(&calls->refcnt, 1);
9069         calls->instance_ptr = o;
9070
9071         LDKListen ret = {
9072                 .this_arg = (void*) calls,
9073                 .filtered_block_connected = filtered_block_connected_LDKListen_jcall,
9074                 .block_connected = block_connected_LDKListen_jcall,
9075                 .block_disconnected = block_disconnected_LDKListen_jcall,
9076                 .free = LDKListen_JCalls_free,
9077         };
9078         return ret;
9079 }
9080 long  __attribute__((export_name("TS_LDKListen_new"))) TS_LDKListen_new(JSValue o) {
9081         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
9082         *res_ptr = LDKListen_init(o);
9083         return (long)res_ptr;
9084 }
9085 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) {
9086         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9087         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9088         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
9089         unsigned char header_arr[80];
9090         CHECK(header->arr_len == 80);
9091         memcpy(header_arr, header->elems, 80); FREE(header);
9092         unsigned char (*header_ref)[80] = &header_arr;
9093         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
9094         txdata_constr.datalen = txdata->arr_len;
9095         if (txdata_constr.datalen > 0)
9096                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
9097         else
9098                 txdata_constr.data = NULL;
9099         uint32_t* txdata_vals = txdata->elems;
9100         for (size_t c = 0; c < txdata_constr.datalen; c++) {
9101                 uint32_t txdata_conv_28 = txdata_vals[c];
9102                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
9103                 CHECK_ACCESS(txdata_conv_28_ptr);
9104                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
9105                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
9106                 txdata_constr.data[c] = txdata_conv_28_conv;
9107         }
9108         FREE(txdata);
9109         (this_arg_conv->filtered_block_connected)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
9110 }
9111
9112 void  __attribute__((export_name("TS_Listen_block_connected"))) TS_Listen_block_connected(uint32_t this_arg, int8_tArray block, int32_t height) {
9113         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9114         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9115         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
9116         LDKu8slice block_ref;
9117         block_ref.datalen = block->arr_len;
9118         block_ref.data = block->elems;
9119         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
9120         FREE(block);
9121 }
9122
9123 void  __attribute__((export_name("TS_Listen_block_disconnected"))) TS_Listen_block_disconnected(uint32_t this_arg, int8_tArray header, int32_t height) {
9124         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9125         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9126         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
9127         unsigned char header_arr[80];
9128         CHECK(header->arr_len == 80);
9129         memcpy(header_arr, header->elems, 80); FREE(header);
9130         unsigned char (*header_ref)[80] = &header_arr;
9131         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
9132 }
9133
9134 typedef struct LDKConfirm_JCalls {
9135         atomic_size_t refcnt;
9136         uint32_t instance_ptr;
9137 } LDKConfirm_JCalls;
9138 static void LDKConfirm_JCalls_free(void* this_arg) {
9139         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
9140         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9141                 FREE(j_calls);
9142         }
9143 }
9144 void transactions_confirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
9145         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
9146         int8_tArray header_arr = init_int8_tArray(80, __LINE__);
9147         memcpy(header_arr->elems, *header, 80);
9148         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
9149         uint32_tArray txdata_arr = NULL;
9150         txdata_arr = init_uint32_tArray(txdata_var.datalen, __LINE__);
9151         uint32_t *txdata_arr_ptr = (uint32_t*)(((uint8_t*)txdata_arr) + 8);
9152         for (size_t c = 0; c < txdata_var.datalen; c++) {
9153                 LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
9154                 *txdata_conv_28_conv = txdata_var.data[c];
9155                 txdata_arr_ptr[c] = ((uint32_t)txdata_conv_28_conv);
9156         }
9157         
9158         FREE(txdata_var.data);
9159         int32_t height_conv = height;
9160         js_invoke_function_uuuuuu(j_calls->instance_ptr, 49, (uint32_t)header_arr, (uint32_t)txdata_arr, (uint32_t)height_conv, 0, 0, 0);
9161 }
9162 void transaction_unconfirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* txid)[32]) {
9163         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
9164         int8_tArray txid_arr = init_int8_tArray(32, __LINE__);
9165         memcpy(txid_arr->elems, *txid, 32);
9166         js_invoke_function_uuuuuu(j_calls->instance_ptr, 50, (uint32_t)txid_arr, 0, 0, 0, 0, 0);
9167 }
9168 void best_block_updated_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
9169         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
9170         int8_tArray header_arr = init_int8_tArray(80, __LINE__);
9171         memcpy(header_arr->elems, *header, 80);
9172         int32_t height_conv = height;
9173         js_invoke_function_uuuuuu(j_calls->instance_ptr, 51, (uint32_t)header_arr, (uint32_t)height_conv, 0, 0, 0, 0);
9174 }
9175 LDKCVec_TxidZ get_relevant_txids_LDKConfirm_jcall(const void* this_arg) {
9176         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
9177         ptrArray ret = (ptrArray)js_invoke_function_uuuuuu(j_calls->instance_ptr, 52, 0, 0, 0, 0, 0, 0);
9178         LDKCVec_TxidZ ret_constr;
9179         ret_constr.datalen = ret->arr_len;
9180         if (ret_constr.datalen > 0)
9181                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
9182         else
9183                 ret_constr.data = NULL;
9184         int8_tArray* ret_vals = (void*) ret->elems;
9185         for (size_t m = 0; m < ret_constr.datalen; m++) {
9186                 int8_tArray ret_conv_12 = ret_vals[m];
9187                 LDKThirtyTwoBytes ret_conv_12_ref;
9188                 CHECK(ret_conv_12->arr_len == 32);
9189                 memcpy(ret_conv_12_ref.data, ret_conv_12->elems, 32); FREE(ret_conv_12);
9190                 ret_constr.data[m] = ret_conv_12_ref;
9191         }
9192         FREE(ret);
9193         return ret_constr;
9194 }
9195 static void LDKConfirm_JCalls_cloned(LDKConfirm* new_obj) {
9196         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) new_obj->this_arg;
9197         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9198 }
9199 static inline LDKConfirm LDKConfirm_init (JSValue o) {
9200         LDKConfirm_JCalls *calls = MALLOC(sizeof(LDKConfirm_JCalls), "LDKConfirm_JCalls");
9201         atomic_init(&calls->refcnt, 1);
9202         calls->instance_ptr = o;
9203
9204         LDKConfirm ret = {
9205                 .this_arg = (void*) calls,
9206                 .transactions_confirmed = transactions_confirmed_LDKConfirm_jcall,
9207                 .transaction_unconfirmed = transaction_unconfirmed_LDKConfirm_jcall,
9208                 .best_block_updated = best_block_updated_LDKConfirm_jcall,
9209                 .get_relevant_txids = get_relevant_txids_LDKConfirm_jcall,
9210                 .free = LDKConfirm_JCalls_free,
9211         };
9212         return ret;
9213 }
9214 long  __attribute__((export_name("TS_LDKConfirm_new"))) TS_LDKConfirm_new(JSValue o) {
9215         LDKConfirm *res_ptr = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
9216         *res_ptr = LDKConfirm_init(o);
9217         return (long)res_ptr;
9218 }
9219 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) {
9220         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9221         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9222         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
9223         unsigned char header_arr[80];
9224         CHECK(header->arr_len == 80);
9225         memcpy(header_arr, header->elems, 80); FREE(header);
9226         unsigned char (*header_ref)[80] = &header_arr;
9227         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
9228         txdata_constr.datalen = txdata->arr_len;
9229         if (txdata_constr.datalen > 0)
9230                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
9231         else
9232                 txdata_constr.data = NULL;
9233         uint32_t* txdata_vals = txdata->elems;
9234         for (size_t c = 0; c < txdata_constr.datalen; c++) {
9235                 uint32_t txdata_conv_28 = txdata_vals[c];
9236                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
9237                 CHECK_ACCESS(txdata_conv_28_ptr);
9238                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
9239                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
9240                 txdata_constr.data[c] = txdata_conv_28_conv;
9241         }
9242         FREE(txdata);
9243         (this_arg_conv->transactions_confirmed)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
9244 }
9245
9246 void  __attribute__((export_name("TS_Confirm_transaction_unconfirmed"))) TS_Confirm_transaction_unconfirmed(uint32_t this_arg, int8_tArray txid) {
9247         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9248         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9249         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
9250         unsigned char txid_arr[32];
9251         CHECK(txid->arr_len == 32);
9252         memcpy(txid_arr, txid->elems, 32); FREE(txid);
9253         unsigned char (*txid_ref)[32] = &txid_arr;
9254         (this_arg_conv->transaction_unconfirmed)(this_arg_conv->this_arg, txid_ref);
9255 }
9256
9257 void  __attribute__((export_name("TS_Confirm_best_block_updated"))) TS_Confirm_best_block_updated(uint32_t this_arg, int8_tArray header, int32_t height) {
9258         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9259         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9260         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
9261         unsigned char header_arr[80];
9262         CHECK(header->arr_len == 80);
9263         memcpy(header_arr, header->elems, 80); FREE(header);
9264         unsigned char (*header_ref)[80] = &header_arr;
9265         (this_arg_conv->best_block_updated)(this_arg_conv->this_arg, header_ref, height);
9266 }
9267
9268 ptrArray  __attribute__((export_name("TS_Confirm_get_relevant_txids"))) TS_Confirm_get_relevant_txids(uint32_t this_arg) {
9269         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9270         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9271         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
9272         LDKCVec_TxidZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg);
9273         ptrArray ret_arr = NULL;
9274         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
9275         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 8);
9276         for (size_t m = 0; m < ret_var.datalen; m++) {
9277                 int8_tArray ret_conv_12_arr = init_int8_tArray(32, __LINE__);
9278                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].data, 32);
9279                 ret_arr_ptr[m] = ret_conv_12_arr;
9280         }
9281         
9282         FREE(ret_var.data);
9283         return ret_arr;
9284 }
9285
9286 typedef struct LDKPersist_JCalls {
9287         atomic_size_t refcnt;
9288         uint32_t instance_ptr;
9289 } LDKPersist_JCalls;
9290 static void LDKPersist_JCalls_free(void* this_arg) {
9291         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
9292         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9293                 FREE(j_calls);
9294         }
9295 }
9296 LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
9297         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
9298         LDKOutPoint channel_id_var = channel_id;
9299         uint32_t channel_id_ref = 0;
9300         CHECK((((uintptr_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9301         CHECK((((uintptr_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9302         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
9303         channel_id_ref = (uintptr_t)channel_id_var.inner;
9304         if (channel_id_var.is_owned) {
9305                 channel_id_ref |= 1;
9306         }
9307         LDKChannelMonitor data_var = *data;
9308         uint32_t data_ref = 0;
9309         data_var = ChannelMonitor_clone(&data_var);
9310         CHECK((((uintptr_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9311         CHECK((((uintptr_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9312         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
9313         data_ref = (uintptr_t)data_var.inner;
9314         if (data_var.is_owned) {
9315                 data_ref |= 1;
9316         }
9317         LDKMonitorUpdateId update_id_var = update_id;
9318         uint32_t update_id_ref = 0;
9319         CHECK((((uintptr_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9320         CHECK((((uintptr_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9321         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
9322         update_id_ref = (uintptr_t)update_id_var.inner;
9323         if (update_id_var.is_owned) {
9324                 update_id_ref |= 1;
9325         }
9326         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);
9327         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9328         CHECK_ACCESS(ret_ptr);
9329         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
9330         FREE((void*)ret);
9331         return ret_conv;
9332 }
9333 LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
9334         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
9335         LDKOutPoint channel_id_var = channel_id;
9336         uint32_t channel_id_ref = 0;
9337         CHECK((((uintptr_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9338         CHECK((((uintptr_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9339         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
9340         channel_id_ref = (uintptr_t)channel_id_var.inner;
9341         if (channel_id_var.is_owned) {
9342                 channel_id_ref |= 1;
9343         }
9344         LDKChannelMonitorUpdate update_var = *update;
9345         uint32_t update_ref = 0;
9346         if ((uintptr_t)update_var.inner > 4096) {
9347                 update_var = ChannelMonitorUpdate_clone(&update_var);
9348                 CHECK((((uintptr_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9349                 CHECK((((uintptr_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9350         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
9351                 update_ref = (uintptr_t)update_var.inner;
9352                 if (update_var.is_owned) {
9353                         update_ref |= 1;
9354                 }
9355         }
9356         LDKChannelMonitor data_var = *data;
9357         uint32_t data_ref = 0;
9358         data_var = ChannelMonitor_clone(&data_var);
9359         CHECK((((uintptr_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9360         CHECK((((uintptr_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9361         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
9362         data_ref = (uintptr_t)data_var.inner;
9363         if (data_var.is_owned) {
9364                 data_ref |= 1;
9365         }
9366         LDKMonitorUpdateId update_id_var = update_id;
9367         uint32_t update_id_ref = 0;
9368         CHECK((((uintptr_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9369         CHECK((((uintptr_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9370         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
9371         update_id_ref = (uintptr_t)update_id_var.inner;
9372         if (update_id_var.is_owned) {
9373                 update_id_ref |= 1;
9374         }
9375         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);
9376         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9377         CHECK_ACCESS(ret_ptr);
9378         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
9379         FREE((void*)ret);
9380         return ret_conv;
9381 }
9382 static void LDKPersist_JCalls_cloned(LDKPersist* new_obj) {
9383         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) new_obj->this_arg;
9384         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9385 }
9386 static inline LDKPersist LDKPersist_init (JSValue o) {
9387         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
9388         atomic_init(&calls->refcnt, 1);
9389         calls->instance_ptr = o;
9390
9391         LDKPersist ret = {
9392                 .this_arg = (void*) calls,
9393                 .persist_new_channel = persist_new_channel_LDKPersist_jcall,
9394                 .update_persisted_channel = update_persisted_channel_LDKPersist_jcall,
9395                 .free = LDKPersist_JCalls_free,
9396         };
9397         return ret;
9398 }
9399 long  __attribute__((export_name("TS_LDKPersist_new"))) TS_LDKPersist_new(JSValue o) {
9400         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
9401         *res_ptr = LDKPersist_init(o);
9402         return (long)res_ptr;
9403 }
9404 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) {
9405         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9406         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9407         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
9408         LDKOutPoint channel_id_conv;
9409         channel_id_conv.inner = (void*)(channel_id & (~1));
9410         channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
9411         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
9412         channel_id_conv = OutPoint_clone(&channel_id_conv);
9413         LDKChannelMonitor data_conv;
9414         data_conv.inner = (void*)(data & (~1));
9415         data_conv.is_owned = false;
9416         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
9417         LDKMonitorUpdateId update_id_conv;
9418         update_id_conv.inner = (void*)(update_id & (~1));
9419         update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
9420         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
9421         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
9422         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
9423         *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, channel_id_conv, &data_conv, update_id_conv);
9424         return (uint32_t)ret_conv;
9425 }
9426
9427 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) {
9428         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9429         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9430         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
9431         LDKOutPoint channel_id_conv;
9432         channel_id_conv.inner = (void*)(channel_id & (~1));
9433         channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
9434         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
9435         channel_id_conv = OutPoint_clone(&channel_id_conv);
9436         LDKChannelMonitorUpdate update_conv;
9437         update_conv.inner = (void*)(update & (~1));
9438         update_conv.is_owned = false;
9439         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
9440         LDKChannelMonitor data_conv;
9441         data_conv.inner = (void*)(data & (~1));
9442         data_conv.is_owned = false;
9443         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
9444         LDKMonitorUpdateId update_id_conv;
9445         update_id_conv.inner = (void*)(update_id & (~1));
9446         update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
9447         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
9448         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
9449         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
9450         *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, channel_id_conv, &update_conv, &data_conv, update_id_conv);
9451         return (uint32_t)ret_conv;
9452 }
9453
9454 typedef struct LDKChannelMessageHandler_JCalls {
9455         atomic_size_t refcnt;
9456         uint32_t instance_ptr;
9457         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
9458 } LDKChannelMessageHandler_JCalls;
9459 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
9460         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9461         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9462                 FREE(j_calls);
9463         }
9464 }
9465 void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
9466         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9467         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9468         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9469         LDKInitFeatures their_features_var = their_features;
9470         uint32_t their_features_ref = 0;
9471         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9472         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9473         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
9474         their_features_ref = (uintptr_t)their_features_var.inner;
9475         if (their_features_var.is_owned) {
9476                 their_features_ref |= 1;
9477         }
9478         LDKOpenChannel msg_var = *msg;
9479         uint32_t msg_ref = 0;
9480         msg_var = OpenChannel_clone(&msg_var);
9481         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9482         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9483         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9484         msg_ref = (uintptr_t)msg_var.inner;
9485         if (msg_var.is_owned) {
9486                 msg_ref |= 1;
9487         }
9488         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);
9489 }
9490 void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
9491         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9492         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9493         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9494         LDKInitFeatures their_features_var = their_features;
9495         uint32_t their_features_ref = 0;
9496         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9497         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9498         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
9499         their_features_ref = (uintptr_t)their_features_var.inner;
9500         if (their_features_var.is_owned) {
9501                 their_features_ref |= 1;
9502         }
9503         LDKAcceptChannel msg_var = *msg;
9504         uint32_t msg_ref = 0;
9505         msg_var = AcceptChannel_clone(&msg_var);
9506         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9507         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9508         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9509         msg_ref = (uintptr_t)msg_var.inner;
9510         if (msg_var.is_owned) {
9511                 msg_ref |= 1;
9512         }
9513         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);
9514 }
9515 void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
9516         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9517         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9518         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9519         LDKFundingCreated msg_var = *msg;
9520         uint32_t msg_ref = 0;
9521         msg_var = FundingCreated_clone(&msg_var);
9522         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9523         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9524         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9525         msg_ref = (uintptr_t)msg_var.inner;
9526         if (msg_var.is_owned) {
9527                 msg_ref |= 1;
9528         }
9529         js_invoke_function_uuuuuu(j_calls->instance_ptr, 57, (uint32_t)their_node_id_arr, (uint32_t)msg_ref, 0, 0, 0, 0);
9530 }
9531 void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
9532         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9533         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9534         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9535         LDKFundingSigned msg_var = *msg;
9536         uint32_t msg_ref = 0;
9537         msg_var = FundingSigned_clone(&msg_var);
9538         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9539         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9540         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9541         msg_ref = (uintptr_t)msg_var.inner;
9542         if (msg_var.is_owned) {
9543                 msg_ref |= 1;
9544         }
9545         js_invoke_function_uuuuuu(j_calls->instance_ptr, 58, (uint32_t)their_node_id_arr, (uint32_t)msg_ref, 0, 0, 0, 0);
9546 }
9547 void handle_channel_ready_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReady * msg) {
9548         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9549         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9550         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9551         LDKChannelReady msg_var = *msg;
9552         uint32_t msg_ref = 0;
9553         msg_var = ChannelReady_clone(&msg_var);
9554         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9555         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9556         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9557         msg_ref = (uintptr_t)msg_var.inner;
9558         if (msg_var.is_owned) {
9559                 msg_ref |= 1;
9560         }
9561         js_invoke_function_uuuuuu(j_calls->instance_ptr, 59, (uint32_t)their_node_id_arr, (uint32_t)msg_ref, 0, 0, 0, 0);
9562 }
9563 void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInitFeatures * their_features, const LDKShutdown * msg) {
9564         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9565         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9566         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9567         LDKInitFeatures their_features_var = *their_features;
9568         uint32_t their_features_ref = 0;
9569         their_features_var = InitFeatures_clone(&their_features_var);
9570         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9571         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9572         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
9573         their_features_ref = (uintptr_t)their_features_var.inner;
9574         if (their_features_var.is_owned) {
9575                 their_features_ref |= 1;
9576         }
9577         LDKShutdown msg_var = *msg;
9578         uint32_t msg_ref = 0;
9579         msg_var = Shutdown_clone(&msg_var);
9580         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9581         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9582         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9583         msg_ref = (uintptr_t)msg_var.inner;
9584         if (msg_var.is_owned) {
9585                 msg_ref |= 1;
9586         }
9587         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);
9588 }
9589 void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
9590         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9591         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9592         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9593         LDKClosingSigned msg_var = *msg;
9594         uint32_t msg_ref = 0;
9595         msg_var = ClosingSigned_clone(&msg_var);
9596         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9597         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9598         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9599         msg_ref = (uintptr_t)msg_var.inner;
9600         if (msg_var.is_owned) {
9601                 msg_ref |= 1;
9602         }
9603         js_invoke_function_uuuuuu(j_calls->instance_ptr, 61, (uint32_t)their_node_id_arr, (uint32_t)msg_ref, 0, 0, 0, 0);
9604 }
9605 void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
9606         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9607         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9608         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9609         LDKUpdateAddHTLC msg_var = *msg;
9610         uint32_t msg_ref = 0;
9611         msg_var = UpdateAddHTLC_clone(&msg_var);
9612         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9613         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9614         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9615         msg_ref = (uintptr_t)msg_var.inner;
9616         if (msg_var.is_owned) {
9617                 msg_ref |= 1;
9618         }
9619         js_invoke_function_uuuuuu(j_calls->instance_ptr, 62, (uint32_t)their_node_id_arr, (uint32_t)msg_ref, 0, 0, 0, 0);
9620 }
9621 void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
9622         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9623         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9624         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9625         LDKUpdateFulfillHTLC msg_var = *msg;
9626         uint32_t msg_ref = 0;
9627         msg_var = UpdateFulfillHTLC_clone(&msg_var);
9628         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9629         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9630         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9631         msg_ref = (uintptr_t)msg_var.inner;
9632         if (msg_var.is_owned) {
9633                 msg_ref |= 1;
9634         }
9635         js_invoke_function_uuuuuu(j_calls->instance_ptr, 63, (uint32_t)their_node_id_arr, (uint32_t)msg_ref, 0, 0, 0, 0);
9636 }
9637 void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
9638         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9639         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9640         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9641         LDKUpdateFailHTLC msg_var = *msg;
9642         uint32_t msg_ref = 0;
9643         msg_var = UpdateFailHTLC_clone(&msg_var);
9644         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9645         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9646         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9647         msg_ref = (uintptr_t)msg_var.inner;
9648         if (msg_var.is_owned) {
9649                 msg_ref |= 1;
9650         }
9651         js_invoke_function_uuuuuu(j_calls->instance_ptr, 64, (uint32_t)their_node_id_arr, (uint32_t)msg_ref, 0, 0, 0, 0);
9652 }
9653 void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
9654         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9655         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9656         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9657         LDKUpdateFailMalformedHTLC msg_var = *msg;
9658         uint32_t msg_ref = 0;
9659         msg_var = UpdateFailMalformedHTLC_clone(&msg_var);
9660         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9661         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9662         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9663         msg_ref = (uintptr_t)msg_var.inner;
9664         if (msg_var.is_owned) {
9665                 msg_ref |= 1;
9666         }
9667         js_invoke_function_uuuuuu(j_calls->instance_ptr, 65, (uint32_t)their_node_id_arr, (uint32_t)msg_ref, 0, 0, 0, 0);
9668 }
9669 void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
9670         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9671         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9672         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9673         LDKCommitmentSigned msg_var = *msg;
9674         uint32_t msg_ref = 0;
9675         msg_var = CommitmentSigned_clone(&msg_var);
9676         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9677         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9678         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9679         msg_ref = (uintptr_t)msg_var.inner;
9680         if (msg_var.is_owned) {
9681                 msg_ref |= 1;
9682         }
9683         js_invoke_function_uuuuuu(j_calls->instance_ptr, 66, (uint32_t)their_node_id_arr, (uint32_t)msg_ref, 0, 0, 0, 0);
9684 }
9685 void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
9686         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9687         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9688         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9689         LDKRevokeAndACK msg_var = *msg;
9690         uint32_t msg_ref = 0;
9691         msg_var = RevokeAndACK_clone(&msg_var);
9692         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9693         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9694         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9695         msg_ref = (uintptr_t)msg_var.inner;
9696         if (msg_var.is_owned) {
9697                 msg_ref |= 1;
9698         }
9699         js_invoke_function_uuuuuu(j_calls->instance_ptr, 67, (uint32_t)their_node_id_arr, (uint32_t)msg_ref, 0, 0, 0, 0);
9700 }
9701 void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
9702         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9703         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9704         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9705         LDKUpdateFee msg_var = *msg;
9706         uint32_t msg_ref = 0;
9707         msg_var = UpdateFee_clone(&msg_var);
9708         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9709         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9710         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9711         msg_ref = (uintptr_t)msg_var.inner;
9712         if (msg_var.is_owned) {
9713                 msg_ref |= 1;
9714         }
9715         js_invoke_function_uuuuuu(j_calls->instance_ptr, 68, (uint32_t)their_node_id_arr, (uint32_t)msg_ref, 0, 0, 0, 0);
9716 }
9717 void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
9718         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9719         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9720         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9721         LDKAnnouncementSignatures msg_var = *msg;
9722         uint32_t msg_ref = 0;
9723         msg_var = AnnouncementSignatures_clone(&msg_var);
9724         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9725         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9726         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9727         msg_ref = (uintptr_t)msg_var.inner;
9728         if (msg_var.is_owned) {
9729                 msg_ref |= 1;
9730         }
9731         js_invoke_function_uuuuuu(j_calls->instance_ptr, 69, (uint32_t)their_node_id_arr, (uint32_t)msg_ref, 0, 0, 0, 0);
9732 }
9733 void peer_disconnected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
9734         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9735         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9736         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9737         jboolean no_connection_possible_conv = no_connection_possible;
9738         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);
9739 }
9740 void peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
9741         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9742         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9743         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9744         LDKInit msg_var = *msg;
9745         uint32_t msg_ref = 0;
9746         msg_var = Init_clone(&msg_var);
9747         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9748         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9749         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9750         msg_ref = (uintptr_t)msg_var.inner;
9751         if (msg_var.is_owned) {
9752                 msg_ref |= 1;
9753         }
9754         js_invoke_function_uuuuuu(j_calls->instance_ptr, 71, (uint32_t)their_node_id_arr, (uint32_t)msg_ref, 0, 0, 0, 0);
9755 }
9756 void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
9757         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9758         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9759         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9760         LDKChannelReestablish msg_var = *msg;
9761         uint32_t msg_ref = 0;
9762         msg_var = ChannelReestablish_clone(&msg_var);
9763         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9764         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9765         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9766         msg_ref = (uintptr_t)msg_var.inner;
9767         if (msg_var.is_owned) {
9768                 msg_ref |= 1;
9769         }
9770         js_invoke_function_uuuuuu(j_calls->instance_ptr, 72, (uint32_t)their_node_id_arr, (uint32_t)msg_ref, 0, 0, 0, 0);
9771 }
9772 void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelUpdate * msg) {
9773         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9774         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9775         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9776         LDKChannelUpdate msg_var = *msg;
9777         uint32_t msg_ref = 0;
9778         msg_var = ChannelUpdate_clone(&msg_var);
9779         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9780         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9781         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9782         msg_ref = (uintptr_t)msg_var.inner;
9783         if (msg_var.is_owned) {
9784                 msg_ref |= 1;
9785         }
9786         js_invoke_function_uuuuuu(j_calls->instance_ptr, 73, (uint32_t)their_node_id_arr, (uint32_t)msg_ref, 0, 0, 0, 0);
9787 }
9788 void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
9789         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9790         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9791         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9792         LDKErrorMessage msg_var = *msg;
9793         uint32_t msg_ref = 0;
9794         msg_var = ErrorMessage_clone(&msg_var);
9795         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9796         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9797         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9798         msg_ref = (uintptr_t)msg_var.inner;
9799         if (msg_var.is_owned) {
9800                 msg_ref |= 1;
9801         }
9802         js_invoke_function_uuuuuu(j_calls->instance_ptr, 74, (uint32_t)their_node_id_arr, (uint32_t)msg_ref, 0, 0, 0, 0);
9803 }
9804 static void LDKChannelMessageHandler_JCalls_cloned(LDKChannelMessageHandler* new_obj) {
9805         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) new_obj->this_arg;
9806         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9807         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
9808 }
9809 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (JSValue o, JSValue MessageSendEventsProvider) {
9810         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
9811         atomic_init(&calls->refcnt, 1);
9812         calls->instance_ptr = o;
9813
9814         LDKChannelMessageHandler ret = {
9815                 .this_arg = (void*) calls,
9816                 .handle_open_channel = handle_open_channel_LDKChannelMessageHandler_jcall,
9817                 .handle_accept_channel = handle_accept_channel_LDKChannelMessageHandler_jcall,
9818                 .handle_funding_created = handle_funding_created_LDKChannelMessageHandler_jcall,
9819                 .handle_funding_signed = handle_funding_signed_LDKChannelMessageHandler_jcall,
9820                 .handle_channel_ready = handle_channel_ready_LDKChannelMessageHandler_jcall,
9821                 .handle_shutdown = handle_shutdown_LDKChannelMessageHandler_jcall,
9822                 .handle_closing_signed = handle_closing_signed_LDKChannelMessageHandler_jcall,
9823                 .handle_update_add_htlc = handle_update_add_htlc_LDKChannelMessageHandler_jcall,
9824                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall,
9825                 .handle_update_fail_htlc = handle_update_fail_htlc_LDKChannelMessageHandler_jcall,
9826                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall,
9827                 .handle_commitment_signed = handle_commitment_signed_LDKChannelMessageHandler_jcall,
9828                 .handle_revoke_and_ack = handle_revoke_and_ack_LDKChannelMessageHandler_jcall,
9829                 .handle_update_fee = handle_update_fee_LDKChannelMessageHandler_jcall,
9830                 .handle_announcement_signatures = handle_announcement_signatures_LDKChannelMessageHandler_jcall,
9831                 .peer_disconnected = peer_disconnected_LDKChannelMessageHandler_jcall,
9832                 .peer_connected = peer_connected_LDKChannelMessageHandler_jcall,
9833                 .handle_channel_reestablish = handle_channel_reestablish_LDKChannelMessageHandler_jcall,
9834                 .handle_channel_update = handle_channel_update_LDKChannelMessageHandler_jcall,
9835                 .handle_error = handle_error_LDKChannelMessageHandler_jcall,
9836                 .free = LDKChannelMessageHandler_JCalls_free,
9837                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(MessageSendEventsProvider),
9838         };
9839         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
9840         return ret;
9841 }
9842 long  __attribute__((export_name("TS_LDKChannelMessageHandler_new"))) TS_LDKChannelMessageHandler_new(JSValue o, JSValue MessageSendEventsProvider) {
9843         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
9844         *res_ptr = LDKChannelMessageHandler_init(o, MessageSendEventsProvider);
9845         return (long)res_ptr;
9846 }
9847 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) {
9848         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9849         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9850         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9851         LDKPublicKey their_node_id_ref;
9852         CHECK(their_node_id->arr_len == 33);
9853         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9854         LDKInitFeatures their_features_conv;
9855         their_features_conv.inner = (void*)(their_features & (~1));
9856         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
9857         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
9858         their_features_conv = InitFeatures_clone(&their_features_conv);
9859         LDKOpenChannel msg_conv;
9860         msg_conv.inner = (void*)(msg & (~1));
9861         msg_conv.is_owned = false;
9862         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9863         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
9864 }
9865
9866 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) {
9867         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9868         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9869         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9870         LDKPublicKey their_node_id_ref;
9871         CHECK(their_node_id->arr_len == 33);
9872         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9873         LDKInitFeatures their_features_conv;
9874         their_features_conv.inner = (void*)(their_features & (~1));
9875         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
9876         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
9877         their_features_conv = InitFeatures_clone(&their_features_conv);
9878         LDKAcceptChannel msg_conv;
9879         msg_conv.inner = (void*)(msg & (~1));
9880         msg_conv.is_owned = false;
9881         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9882         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
9883 }
9884
9885 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) {
9886         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9887         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9888         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9889         LDKPublicKey their_node_id_ref;
9890         CHECK(their_node_id->arr_len == 33);
9891         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9892         LDKFundingCreated msg_conv;
9893         msg_conv.inner = (void*)(msg & (~1));
9894         msg_conv.is_owned = false;
9895         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9896         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9897 }
9898
9899 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) {
9900         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9901         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9902         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9903         LDKPublicKey their_node_id_ref;
9904         CHECK(their_node_id->arr_len == 33);
9905         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9906         LDKFundingSigned msg_conv;
9907         msg_conv.inner = (void*)(msg & (~1));
9908         msg_conv.is_owned = false;
9909         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9910         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9911 }
9912
9913 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) {
9914         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9915         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9916         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9917         LDKPublicKey their_node_id_ref;
9918         CHECK(their_node_id->arr_len == 33);
9919         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9920         LDKChannelReady msg_conv;
9921         msg_conv.inner = (void*)(msg & (~1));
9922         msg_conv.is_owned = false;
9923         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9924         (this_arg_conv->handle_channel_ready)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9925 }
9926
9927 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) {
9928         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9929         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9930         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9931         LDKPublicKey their_node_id_ref;
9932         CHECK(their_node_id->arr_len == 33);
9933         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9934         LDKInitFeatures their_features_conv;
9935         their_features_conv.inner = (void*)(their_features & (~1));
9936         their_features_conv.is_owned = false;
9937         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
9938         LDKShutdown msg_conv;
9939         msg_conv.inner = (void*)(msg & (~1));
9940         msg_conv.is_owned = false;
9941         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9942         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &their_features_conv, &msg_conv);
9943 }
9944
9945 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) {
9946         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9947         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9948         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9949         LDKPublicKey their_node_id_ref;
9950         CHECK(their_node_id->arr_len == 33);
9951         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9952         LDKClosingSigned msg_conv;
9953         msg_conv.inner = (void*)(msg & (~1));
9954         msg_conv.is_owned = false;
9955         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9956         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9957 }
9958
9959 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) {
9960         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9961         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9962         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9963         LDKPublicKey their_node_id_ref;
9964         CHECK(their_node_id->arr_len == 33);
9965         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9966         LDKUpdateAddHTLC msg_conv;
9967         msg_conv.inner = (void*)(msg & (~1));
9968         msg_conv.is_owned = false;
9969         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9970         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9971 }
9972
9973 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) {
9974         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9975         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9976         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9977         LDKPublicKey their_node_id_ref;
9978         CHECK(their_node_id->arr_len == 33);
9979         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9980         LDKUpdateFulfillHTLC msg_conv;
9981         msg_conv.inner = (void*)(msg & (~1));
9982         msg_conv.is_owned = false;
9983         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9984         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9985 }
9986
9987 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) {
9988         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9989         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9990         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9991         LDKPublicKey their_node_id_ref;
9992         CHECK(their_node_id->arr_len == 33);
9993         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9994         LDKUpdateFailHTLC msg_conv;
9995         msg_conv.inner = (void*)(msg & (~1));
9996         msg_conv.is_owned = false;
9997         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9998         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9999 }
10000
10001 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) {
10002         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10003         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10004         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
10005         LDKPublicKey their_node_id_ref;
10006         CHECK(their_node_id->arr_len == 33);
10007         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
10008         LDKUpdateFailMalformedHTLC msg_conv;
10009         msg_conv.inner = (void*)(msg & (~1));
10010         msg_conv.is_owned = false;
10011         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10012         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
10013 }
10014
10015 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) {
10016         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10017         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10018         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
10019         LDKPublicKey their_node_id_ref;
10020         CHECK(their_node_id->arr_len == 33);
10021         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
10022         LDKCommitmentSigned msg_conv;
10023         msg_conv.inner = (void*)(msg & (~1));
10024         msg_conv.is_owned = false;
10025         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10026         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
10027 }
10028
10029 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) {
10030         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10031         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10032         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
10033         LDKPublicKey their_node_id_ref;
10034         CHECK(their_node_id->arr_len == 33);
10035         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
10036         LDKRevokeAndACK msg_conv;
10037         msg_conv.inner = (void*)(msg & (~1));
10038         msg_conv.is_owned = false;
10039         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10040         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
10041 }
10042
10043 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) {
10044         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10045         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10046         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
10047         LDKPublicKey their_node_id_ref;
10048         CHECK(their_node_id->arr_len == 33);
10049         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
10050         LDKUpdateFee msg_conv;
10051         msg_conv.inner = (void*)(msg & (~1));
10052         msg_conv.is_owned = false;
10053         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10054         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
10055 }
10056
10057 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) {
10058         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10059         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10060         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
10061         LDKPublicKey their_node_id_ref;
10062         CHECK(their_node_id->arr_len == 33);
10063         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
10064         LDKAnnouncementSignatures msg_conv;
10065         msg_conv.inner = (void*)(msg & (~1));
10066         msg_conv.is_owned = false;
10067         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10068         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
10069 }
10070
10071 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) {
10072         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10073         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10074         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
10075         LDKPublicKey their_node_id_ref;
10076         CHECK(their_node_id->arr_len == 33);
10077         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
10078         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
10079 }
10080
10081 void  __attribute__((export_name("TS_ChannelMessageHandler_peer_connected"))) TS_ChannelMessageHandler_peer_connected(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
10082         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10083         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10084         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
10085         LDKPublicKey their_node_id_ref;
10086         CHECK(their_node_id->arr_len == 33);
10087         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
10088         LDKInit msg_conv;
10089         msg_conv.inner = (void*)(msg & (~1));
10090         msg_conv.is_owned = false;
10091         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10092         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
10093 }
10094
10095 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) {
10096         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10097         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10098         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
10099         LDKPublicKey their_node_id_ref;
10100         CHECK(their_node_id->arr_len == 33);
10101         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
10102         LDKChannelReestablish msg_conv;
10103         msg_conv.inner = (void*)(msg & (~1));
10104         msg_conv.is_owned = false;
10105         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10106         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
10107 }
10108
10109 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) {
10110         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10111         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10112         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
10113         LDKPublicKey their_node_id_ref;
10114         CHECK(their_node_id->arr_len == 33);
10115         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
10116         LDKChannelUpdate msg_conv;
10117         msg_conv.inner = (void*)(msg & (~1));
10118         msg_conv.is_owned = false;
10119         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10120         (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
10121 }
10122
10123 void  __attribute__((export_name("TS_ChannelMessageHandler_handle_error"))) TS_ChannelMessageHandler_handle_error(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
10124         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10125         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10126         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
10127         LDKPublicKey their_node_id_ref;
10128         CHECK(their_node_id->arr_len == 33);
10129         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
10130         LDKErrorMessage msg_conv;
10131         msg_conv.inner = (void*)(msg & (~1));
10132         msg_conv.is_owned = false;
10133         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10134         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
10135 }
10136
10137 typedef struct LDKRoutingMessageHandler_JCalls {
10138         atomic_size_t refcnt;
10139         uint32_t instance_ptr;
10140         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
10141 } LDKRoutingMessageHandler_JCalls;
10142 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
10143         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
10144         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10145                 FREE(j_calls);
10146         }
10147 }
10148 LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
10149         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
10150         LDKNodeAnnouncement msg_var = *msg;
10151         uint32_t msg_ref = 0;
10152         msg_var = NodeAnnouncement_clone(&msg_var);
10153         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10154         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10155         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10156         msg_ref = (uintptr_t)msg_var.inner;
10157         if (msg_var.is_owned) {
10158                 msg_ref |= 1;
10159         }
10160         uint32_t ret = js_invoke_function_uuuuuu(j_calls->instance_ptr, 75, (uint32_t)msg_ref, 0, 0, 0, 0, 0);
10161         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10162         CHECK_ACCESS(ret_ptr);
10163         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
10164         FREE((void*)ret);
10165         return ret_conv;
10166 }
10167 LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
10168         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
10169         LDKChannelAnnouncement msg_var = *msg;
10170         uint32_t msg_ref = 0;
10171         msg_var = ChannelAnnouncement_clone(&msg_var);
10172         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10173         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10174         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10175         msg_ref = (uintptr_t)msg_var.inner;
10176         if (msg_var.is_owned) {
10177                 msg_ref |= 1;
10178         }
10179         uint32_t ret = js_invoke_function_uuuuuu(j_calls->instance_ptr, 76, (uint32_t)msg_ref, 0, 0, 0, 0, 0);
10180         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10181         CHECK_ACCESS(ret_ptr);
10182         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
10183         FREE((void*)ret);
10184         return ret_conv;
10185 }
10186 LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
10187         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
10188         LDKChannelUpdate msg_var = *msg;
10189         uint32_t msg_ref = 0;
10190         msg_var = ChannelUpdate_clone(&msg_var);
10191         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10192         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10193         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10194         msg_ref = (uintptr_t)msg_var.inner;
10195         if (msg_var.is_owned) {
10196                 msg_ref |= 1;
10197         }
10198         uint32_t ret = js_invoke_function_uuuuuu(j_calls->instance_ptr, 77, (uint32_t)msg_ref, 0, 0, 0, 0, 0);
10199         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10200         CHECK_ACCESS(ret_ptr);
10201         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
10202         FREE((void*)ret);
10203         return ret_conv;
10204 }
10205 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
10206         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
10207         int64_t starting_point_conv = starting_point;
10208         int8_t batch_amount_conv = batch_amount;
10209         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);
10210         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_constr;
10211         ret_constr.datalen = ret->arr_len;
10212         if (ret_constr.datalen > 0)
10213                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
10214         else
10215                 ret_constr.data = NULL;
10216         uint32_t* ret_vals = ret->elems;
10217         for (size_t h = 0; h < ret_constr.datalen; h++) {
10218                 uint32_t ret_conv_59 = ret_vals[h];
10219                 void* ret_conv_59_ptr = (void*)(((uintptr_t)ret_conv_59) & ~1);
10220                 CHECK_ACCESS(ret_conv_59_ptr);
10221                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ret_conv_59_ptr);
10222                 FREE((void*)ret_conv_59);
10223                 ret_constr.data[h] = ret_conv_59_conv;
10224         }
10225         FREE(ret);
10226         return ret_constr;
10227 }
10228 LDKCVec_NodeAnnouncementZ get_next_node_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
10229         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
10230         int8_tArray starting_point_arr = init_int8_tArray(33, __LINE__);
10231         memcpy(starting_point_arr->elems, starting_point.compressed_form, 33);
10232         int8_t batch_amount_conv = batch_amount;
10233         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);
10234         LDKCVec_NodeAnnouncementZ ret_constr;
10235         ret_constr.datalen = ret->arr_len;
10236         if (ret_constr.datalen > 0)
10237                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
10238         else
10239                 ret_constr.data = NULL;
10240         uint32_t* ret_vals = ret->elems;
10241         for (size_t s = 0; s < ret_constr.datalen; s++) {
10242                 uint32_t ret_conv_18 = ret_vals[s];
10243                 LDKNodeAnnouncement ret_conv_18_conv;
10244                 ret_conv_18_conv.inner = (void*)(ret_conv_18 & (~1));
10245                 ret_conv_18_conv.is_owned = (ret_conv_18 & 1) || (ret_conv_18 == 0);
10246                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_18_conv);
10247                 ret_constr.data[s] = ret_conv_18_conv;
10248         }
10249         FREE(ret);
10250         return ret_constr;
10251 }
10252 void peer_connected_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
10253         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
10254         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
10255         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
10256         LDKInit init_var = *init;
10257         uint32_t init_ref = 0;
10258         init_var = Init_clone(&init_var);
10259         CHECK((((uintptr_t)init_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10260         CHECK((((uintptr_t)&init_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10261         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_var);
10262         init_ref = (uintptr_t)init_var.inner;
10263         if (init_var.is_owned) {
10264                 init_ref |= 1;
10265         }
10266         js_invoke_function_uuuuuu(j_calls->instance_ptr, 80, (uint32_t)their_node_id_arr, (uint32_t)init_ref, 0, 0, 0, 0);
10267 }
10268 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
10269         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
10270         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
10271         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
10272         LDKReplyChannelRange msg_var = msg;
10273         uint32_t msg_ref = 0;
10274         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10275         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10276         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10277         msg_ref = (uintptr_t)msg_var.inner;
10278         if (msg_var.is_owned) {
10279                 msg_ref |= 1;
10280         }
10281         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);
10282         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10283         CHECK_ACCESS(ret_ptr);
10284         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
10285         FREE((void*)ret);
10286         return ret_conv;
10287 }
10288 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
10289         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
10290         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
10291         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
10292         LDKReplyShortChannelIdsEnd msg_var = msg;
10293         uint32_t msg_ref = 0;
10294         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10295         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10296         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10297         msg_ref = (uintptr_t)msg_var.inner;
10298         if (msg_var.is_owned) {
10299                 msg_ref |= 1;
10300         }
10301         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);
10302         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10303         CHECK_ACCESS(ret_ptr);
10304         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
10305         FREE((void*)ret);
10306         return ret_conv;
10307 }
10308 LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
10309         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
10310         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
10311         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
10312         LDKQueryChannelRange msg_var = msg;
10313         uint32_t msg_ref = 0;
10314         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10315         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10316         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10317         msg_ref = (uintptr_t)msg_var.inner;
10318         if (msg_var.is_owned) {
10319                 msg_ref |= 1;
10320         }
10321         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);
10322         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10323         CHECK_ACCESS(ret_ptr);
10324         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
10325         FREE((void*)ret);
10326         return ret_conv;
10327 }
10328 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
10329         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
10330         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
10331         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
10332         LDKQueryShortChannelIds msg_var = msg;
10333         uint32_t msg_ref = 0;
10334         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10335         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10336         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10337         msg_ref = (uintptr_t)msg_var.inner;
10338         if (msg_var.is_owned) {
10339                 msg_ref |= 1;
10340         }
10341         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);
10342         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10343         CHECK_ACCESS(ret_ptr);
10344         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
10345         FREE((void*)ret);
10346         return ret_conv;
10347 }
10348 static void LDKRoutingMessageHandler_JCalls_cloned(LDKRoutingMessageHandler* new_obj) {
10349         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) new_obj->this_arg;
10350         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10351         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
10352 }
10353 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (JSValue o, JSValue MessageSendEventsProvider) {
10354         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
10355         atomic_init(&calls->refcnt, 1);
10356         calls->instance_ptr = o;
10357
10358         LDKRoutingMessageHandler ret = {
10359                 .this_arg = (void*) calls,
10360                 .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall,
10361                 .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall,
10362                 .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall,
10363                 .get_next_channel_announcements = get_next_channel_announcements_LDKRoutingMessageHandler_jcall,
10364                 .get_next_node_announcements = get_next_node_announcements_LDKRoutingMessageHandler_jcall,
10365                 .peer_connected = peer_connected_LDKRoutingMessageHandler_jcall,
10366                 .handle_reply_channel_range = handle_reply_channel_range_LDKRoutingMessageHandler_jcall,
10367                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall,
10368                 .handle_query_channel_range = handle_query_channel_range_LDKRoutingMessageHandler_jcall,
10369                 .handle_query_short_channel_ids = handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall,
10370                 .free = LDKRoutingMessageHandler_JCalls_free,
10371                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(MessageSendEventsProvider),
10372         };
10373         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
10374         return ret;
10375 }
10376 long  __attribute__((export_name("TS_LDKRoutingMessageHandler_new"))) TS_LDKRoutingMessageHandler_new(JSValue o, JSValue MessageSendEventsProvider) {
10377         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
10378         *res_ptr = LDKRoutingMessageHandler_init(o, MessageSendEventsProvider);
10379         return (long)res_ptr;
10380 }
10381 uint32_t  __attribute__((export_name("TS_RoutingMessageHandler_handle_node_announcement"))) TS_RoutingMessageHandler_handle_node_announcement(uint32_t this_arg, uint32_t msg) {
10382         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10383         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10384         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
10385         LDKNodeAnnouncement msg_conv;
10386         msg_conv.inner = (void*)(msg & (~1));
10387         msg_conv.is_owned = false;
10388         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10389         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
10390         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
10391         return (uint32_t)ret_conv;
10392 }
10393
10394 uint32_t  __attribute__((export_name("TS_RoutingMessageHandler_handle_channel_announcement"))) TS_RoutingMessageHandler_handle_channel_announcement(uint32_t this_arg, uint32_t msg) {
10395         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10396         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10397         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
10398         LDKChannelAnnouncement msg_conv;
10399         msg_conv.inner = (void*)(msg & (~1));
10400         msg_conv.is_owned = false;
10401         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10402         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
10403         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
10404         return (uint32_t)ret_conv;
10405 }
10406
10407 uint32_t  __attribute__((export_name("TS_RoutingMessageHandler_handle_channel_update"))) TS_RoutingMessageHandler_handle_channel_update(uint32_t this_arg, uint32_t msg) {
10408         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10409         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10410         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
10411         LDKChannelUpdate msg_conv;
10412         msg_conv.inner = (void*)(msg & (~1));
10413         msg_conv.is_owned = false;
10414         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10415         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
10416         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
10417         return (uint32_t)ret_conv;
10418 }
10419
10420 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) {
10421         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10422         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10423         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
10424         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
10425         uint32_tArray ret_arr = NULL;
10426         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
10427         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 8);
10428         for (size_t h = 0; h < ret_var.datalen; h++) {
10429                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv_59_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
10430                 *ret_conv_59_conv = ret_var.data[h];
10431                 ret_arr_ptr[h] = ((uint32_t)ret_conv_59_conv);
10432         }
10433         
10434         FREE(ret_var.data);
10435         return ret_arr;
10436 }
10437
10438 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) {
10439         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10440         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10441         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
10442         LDKPublicKey starting_point_ref;
10443         CHECK(starting_point->arr_len == 33);
10444         memcpy(starting_point_ref.compressed_form, starting_point->elems, 33); FREE(starting_point);
10445         LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
10446         uint32_tArray ret_arr = NULL;
10447         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
10448         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 8);
10449         for (size_t s = 0; s < ret_var.datalen; s++) {
10450                 LDKNodeAnnouncement ret_conv_18_var = ret_var.data[s];
10451                 uint32_t ret_conv_18_ref = 0;
10452                 CHECK((((uintptr_t)ret_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10453                 CHECK((((uintptr_t)&ret_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10454                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_18_var);
10455                 ret_conv_18_ref = (uintptr_t)ret_conv_18_var.inner;
10456                 if (ret_conv_18_var.is_owned) {
10457                         ret_conv_18_ref |= 1;
10458                 }
10459                 ret_arr_ptr[s] = ret_conv_18_ref;
10460         }
10461         
10462         FREE(ret_var.data);
10463         return ret_arr;
10464 }
10465
10466 void  __attribute__((export_name("TS_RoutingMessageHandler_peer_connected"))) TS_RoutingMessageHandler_peer_connected(uint32_t this_arg, int8_tArray their_node_id, uint32_t init) {
10467         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10468         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10469         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
10470         LDKPublicKey their_node_id_ref;
10471         CHECK(their_node_id->arr_len == 33);
10472         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
10473         LDKInit init_conv;
10474         init_conv.inner = (void*)(init & (~1));
10475         init_conv.is_owned = false;
10476         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_conv);
10477         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
10478 }
10479
10480 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) {
10481         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10482         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10483         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
10484         LDKPublicKey their_node_id_ref;
10485         CHECK(their_node_id->arr_len == 33);
10486         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
10487         LDKReplyChannelRange msg_conv;
10488         msg_conv.inner = (void*)(msg & (~1));
10489         msg_conv.is_owned = (msg & 1) || (msg == 0);
10490         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10491         msg_conv = ReplyChannelRange_clone(&msg_conv);
10492         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
10493         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
10494         return (uint32_t)ret_conv;
10495 }
10496
10497 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) {
10498         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10499         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10500         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
10501         LDKPublicKey their_node_id_ref;
10502         CHECK(their_node_id->arr_len == 33);
10503         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
10504         LDKReplyShortChannelIdsEnd msg_conv;
10505         msg_conv.inner = (void*)(msg & (~1));
10506         msg_conv.is_owned = (msg & 1) || (msg == 0);
10507         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10508         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
10509         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
10510         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
10511         return (uint32_t)ret_conv;
10512 }
10513
10514 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) {
10515         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10516         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10517         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
10518         LDKPublicKey their_node_id_ref;
10519         CHECK(their_node_id->arr_len == 33);
10520         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
10521         LDKQueryChannelRange msg_conv;
10522         msg_conv.inner = (void*)(msg & (~1));
10523         msg_conv.is_owned = (msg & 1) || (msg == 0);
10524         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10525         msg_conv = QueryChannelRange_clone(&msg_conv);
10526         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
10527         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
10528         return (uint32_t)ret_conv;
10529 }
10530
10531 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) {
10532         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10533         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10534         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
10535         LDKPublicKey their_node_id_ref;
10536         CHECK(their_node_id->arr_len == 33);
10537         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
10538         LDKQueryShortChannelIds msg_conv;
10539         msg_conv.inner = (void*)(msg & (~1));
10540         msg_conv.is_owned = (msg & 1) || (msg == 0);
10541         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10542         msg_conv = QueryShortChannelIds_clone(&msg_conv);
10543         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
10544         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
10545         return (uint32_t)ret_conv;
10546 }
10547
10548 typedef struct LDKCustomMessageReader_JCalls {
10549         atomic_size_t refcnt;
10550         uint32_t instance_ptr;
10551 } LDKCustomMessageReader_JCalls;
10552 static void LDKCustomMessageReader_JCalls_free(void* this_arg) {
10553         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
10554         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10555                 FREE(j_calls);
10556         }
10557 }
10558 LDKCResult_COption_TypeZDecodeErrorZ read_LDKCustomMessageReader_jcall(const void* this_arg, uint16_t message_type, LDKu8slice buffer) {
10559         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
10560         int16_t message_type_conv = message_type;
10561         LDKu8slice buffer_var = buffer;
10562         int8_tArray buffer_arr = init_int8_tArray(buffer_var.datalen, __LINE__);
10563         memcpy(buffer_arr->elems, buffer_var.data, buffer_var.datalen);
10564         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);
10565         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10566         CHECK_ACCESS(ret_ptr);
10567         LDKCResult_COption_TypeZDecodeErrorZ ret_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(ret_ptr);
10568         FREE((void*)ret);
10569         return ret_conv;
10570 }
10571 static void LDKCustomMessageReader_JCalls_cloned(LDKCustomMessageReader* new_obj) {
10572         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) new_obj->this_arg;
10573         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10574 }
10575 static inline LDKCustomMessageReader LDKCustomMessageReader_init (JSValue o) {
10576         LDKCustomMessageReader_JCalls *calls = MALLOC(sizeof(LDKCustomMessageReader_JCalls), "LDKCustomMessageReader_JCalls");
10577         atomic_init(&calls->refcnt, 1);
10578         calls->instance_ptr = o;
10579
10580         LDKCustomMessageReader ret = {
10581                 .this_arg = (void*) calls,
10582                 .read = read_LDKCustomMessageReader_jcall,
10583                 .free = LDKCustomMessageReader_JCalls_free,
10584         };
10585         return ret;
10586 }
10587 long  __attribute__((export_name("TS_LDKCustomMessageReader_new"))) TS_LDKCustomMessageReader_new(JSValue o) {
10588         LDKCustomMessageReader *res_ptr = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
10589         *res_ptr = LDKCustomMessageReader_init(o);
10590         return (long)res_ptr;
10591 }
10592 uint32_t  __attribute__((export_name("TS_CustomMessageReader_read"))) TS_CustomMessageReader_read(uint32_t this_arg, int16_t message_type, int8_tArray buffer) {
10593         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10594         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10595         LDKCustomMessageReader* this_arg_conv = (LDKCustomMessageReader*)this_arg_ptr;
10596         LDKu8slice buffer_ref;
10597         buffer_ref.datalen = buffer->arr_len;
10598         buffer_ref.data = buffer->elems;
10599         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
10600         *ret_conv = (this_arg_conv->read)(this_arg_conv->this_arg, message_type, buffer_ref);
10601         FREE(buffer);
10602         return (uint32_t)ret_conv;
10603 }
10604
10605 typedef struct LDKCustomMessageHandler_JCalls {
10606         atomic_size_t refcnt;
10607         uint32_t instance_ptr;
10608         LDKCustomMessageReader_JCalls* CustomMessageReader;
10609 } LDKCustomMessageHandler_JCalls;
10610 static void LDKCustomMessageHandler_JCalls_free(void* this_arg) {
10611         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
10612         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10613                 FREE(j_calls);
10614         }
10615 }
10616 LDKCResult_NoneLightningErrorZ handle_custom_message_LDKCustomMessageHandler_jcall(const void* this_arg, LDKType msg, LDKPublicKey sender_node_id) {
10617         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
10618         LDKType* msg_ret = MALLOC(sizeof(LDKType), "LDKType");
10619         *msg_ret = msg;
10620         int8_tArray sender_node_id_arr = init_int8_tArray(33, __LINE__);
10621         memcpy(sender_node_id_arr->elems, sender_node_id.compressed_form, 33);
10622         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);
10623         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10624         CHECK_ACCESS(ret_ptr);
10625         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
10626         FREE((void*)ret);
10627         return ret_conv;
10628 }
10629 LDKCVec_C2Tuple_PublicKeyTypeZZ get_and_clear_pending_msg_LDKCustomMessageHandler_jcall(const void* this_arg) {
10630         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
10631         uint32_tArray ret = (uint32_tArray)js_invoke_function_uuuuuu(j_calls->instance_ptr, 87, 0, 0, 0, 0, 0, 0);
10632         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_constr;
10633         ret_constr.datalen = ret->arr_len;
10634         if (ret_constr.datalen > 0)
10635                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
10636         else
10637                 ret_constr.data = NULL;
10638         uint32_t* ret_vals = ret->elems;
10639         for (size_t z = 0; z < ret_constr.datalen; z++) {
10640                 uint32_t ret_conv_25 = ret_vals[z];
10641                 void* ret_conv_25_ptr = (void*)(((uintptr_t)ret_conv_25) & ~1);
10642                 CHECK_ACCESS(ret_conv_25_ptr);
10643                 LDKC2Tuple_PublicKeyTypeZ ret_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(ret_conv_25_ptr);
10644                 FREE((void*)ret_conv_25);
10645                 ret_constr.data[z] = ret_conv_25_conv;
10646         }
10647         FREE(ret);
10648         return ret_constr;
10649 }
10650 static void LDKCustomMessageHandler_JCalls_cloned(LDKCustomMessageHandler* new_obj) {
10651         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) new_obj->this_arg;
10652         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10653         atomic_fetch_add_explicit(&j_calls->CustomMessageReader->refcnt, 1, memory_order_release);
10654 }
10655 static inline LDKCustomMessageHandler LDKCustomMessageHandler_init (JSValue o, JSValue CustomMessageReader) {
10656         LDKCustomMessageHandler_JCalls *calls = MALLOC(sizeof(LDKCustomMessageHandler_JCalls), "LDKCustomMessageHandler_JCalls");
10657         atomic_init(&calls->refcnt, 1);
10658         calls->instance_ptr = o;
10659
10660         LDKCustomMessageHandler ret = {
10661                 .this_arg = (void*) calls,
10662                 .handle_custom_message = handle_custom_message_LDKCustomMessageHandler_jcall,
10663                 .get_and_clear_pending_msg = get_and_clear_pending_msg_LDKCustomMessageHandler_jcall,
10664                 .free = LDKCustomMessageHandler_JCalls_free,
10665                 .CustomMessageReader = LDKCustomMessageReader_init(CustomMessageReader),
10666         };
10667         calls->CustomMessageReader = ret.CustomMessageReader.this_arg;
10668         return ret;
10669 }
10670 long  __attribute__((export_name("TS_LDKCustomMessageHandler_new"))) TS_LDKCustomMessageHandler_new(JSValue o, JSValue CustomMessageReader) {
10671         LDKCustomMessageHandler *res_ptr = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
10672         *res_ptr = LDKCustomMessageHandler_init(o, CustomMessageReader);
10673         return (long)res_ptr;
10674 }
10675 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) {
10676         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10677         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10678         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
10679         void* msg_ptr = (void*)(((uintptr_t)msg) & ~1);
10680         CHECK_ACCESS(msg_ptr);
10681         LDKType msg_conv = *(LDKType*)(msg_ptr);
10682         if (msg_conv.free == LDKType_JCalls_free) {
10683                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10684                 LDKType_JCalls_cloned(&msg_conv);
10685         }
10686         LDKPublicKey sender_node_id_ref;
10687         CHECK(sender_node_id->arr_len == 33);
10688         memcpy(sender_node_id_ref.compressed_form, sender_node_id->elems, 33); FREE(sender_node_id);
10689         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
10690         *ret_conv = (this_arg_conv->handle_custom_message)(this_arg_conv->this_arg, msg_conv, sender_node_id_ref);
10691         return (uint32_t)ret_conv;
10692 }
10693
10694 uint32_tArray  __attribute__((export_name("TS_CustomMessageHandler_get_and_clear_pending_msg"))) TS_CustomMessageHandler_get_and_clear_pending_msg(uint32_t this_arg) {
10695         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10696         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10697         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
10698         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_var = (this_arg_conv->get_and_clear_pending_msg)(this_arg_conv->this_arg);
10699         uint32_tArray ret_arr = NULL;
10700         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
10701         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 8);
10702         for (size_t z = 0; z < ret_var.datalen; z++) {
10703                 LDKC2Tuple_PublicKeyTypeZ* ret_conv_25_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
10704                 *ret_conv_25_conv = ret_var.data[z];
10705                 ret_arr_ptr[z] = ((uint32_t)ret_conv_25_conv);
10706         }
10707         
10708         FREE(ret_var.data);
10709         return ret_arr;
10710 }
10711
10712 typedef struct LDKSocketDescriptor_JCalls {
10713         atomic_size_t refcnt;
10714         uint32_t instance_ptr;
10715 } LDKSocketDescriptor_JCalls;
10716 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
10717         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
10718         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10719                 FREE(j_calls);
10720         }
10721 }
10722 uintptr_t send_data_LDKSocketDescriptor_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
10723         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
10724         LDKu8slice data_var = data;
10725         int8_tArray data_arr = init_int8_tArray(data_var.datalen, __LINE__);
10726         memcpy(data_arr->elems, data_var.data, data_var.datalen);
10727         jboolean resume_read_conv = resume_read;
10728         return js_invoke_function_uuuuuu(j_calls->instance_ptr, 88, (uint32_t)data_arr, (uint32_t)resume_read_conv, 0, 0, 0, 0);
10729 }
10730 void disconnect_socket_LDKSocketDescriptor_jcall(void* this_arg) {
10731         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
10732         js_invoke_function_uuuuuu(j_calls->instance_ptr, 89, 0, 0, 0, 0, 0, 0);
10733 }
10734 bool eq_LDKSocketDescriptor_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
10735         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
10736         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
10737         *other_arg_clone = SocketDescriptor_clone(other_arg);
10738         return js_invoke_function_uuuuuu(j_calls->instance_ptr, 90, (uint32_t)(uint32_t)other_arg_clone, 0, 0, 0, 0, 0);
10739 }
10740 uint64_t hash_LDKSocketDescriptor_jcall(const void* this_arg) {
10741         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
10742         return js_invoke_function_uuuuuu(j_calls->instance_ptr, 91, 0, 0, 0, 0, 0, 0);
10743 }
10744 static void LDKSocketDescriptor_JCalls_cloned(LDKSocketDescriptor* new_obj) {
10745         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) new_obj->this_arg;
10746         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10747 }
10748 static inline LDKSocketDescriptor LDKSocketDescriptor_init (JSValue o) {
10749         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
10750         atomic_init(&calls->refcnt, 1);
10751         calls->instance_ptr = o;
10752
10753         LDKSocketDescriptor ret = {
10754                 .this_arg = (void*) calls,
10755                 .send_data = send_data_LDKSocketDescriptor_jcall,
10756                 .disconnect_socket = disconnect_socket_LDKSocketDescriptor_jcall,
10757                 .eq = eq_LDKSocketDescriptor_jcall,
10758                 .hash = hash_LDKSocketDescriptor_jcall,
10759                 .cloned = LDKSocketDescriptor_JCalls_cloned,
10760                 .free = LDKSocketDescriptor_JCalls_free,
10761         };
10762         return ret;
10763 }
10764 long  __attribute__((export_name("TS_LDKSocketDescriptor_new"))) TS_LDKSocketDescriptor_new(JSValue o) {
10765         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
10766         *res_ptr = LDKSocketDescriptor_init(o);
10767         return (long)res_ptr;
10768 }
10769 uint32_t  __attribute__((export_name("TS_SocketDescriptor_send_data"))) TS_SocketDescriptor_send_data(uint32_t this_arg, int8_tArray data, jboolean resume_read) {
10770         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10771         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10772         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
10773         LDKu8slice data_ref;
10774         data_ref.datalen = data->arr_len;
10775         data_ref.data = data->elems;
10776         uint32_t ret_conv = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
10777         FREE(data);
10778         return ret_conv;
10779 }
10780
10781 void  __attribute__((export_name("TS_SocketDescriptor_disconnect_socket"))) TS_SocketDescriptor_disconnect_socket(uint32_t this_arg) {
10782         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10783         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10784         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
10785         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
10786 }
10787
10788 int64_t  __attribute__((export_name("TS_SocketDescriptor_hash"))) TS_SocketDescriptor_hash(uint32_t this_arg) {
10789         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10790         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10791         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
10792         int64_t ret_conv = (this_arg_conv->hash)(this_arg_conv->this_arg);
10793         return ret_conv;
10794 }
10795
10796 uint32_t __attribute__((export_name("TS_LDKEffectiveCapacity_ty_from_ptr"))) TS_LDKEffectiveCapacity_ty_from_ptr(uint32_t ptr) {
10797         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)(ptr & ~1);
10798         switch(obj->tag) {
10799                 case LDKEffectiveCapacity_ExactLiquidity: return 0;
10800                 case LDKEffectiveCapacity_MaximumHTLC: return 1;
10801                 case LDKEffectiveCapacity_Total: return 2;
10802                 case LDKEffectiveCapacity_Infinite: return 3;
10803                 case LDKEffectiveCapacity_Unknown: return 4;
10804                 default: abort();
10805         }
10806 }
10807 int64_t __attribute__((export_name("TS_LDKEffectiveCapacity_ExactLiquidity_get_liquidity_msat"))) TS_LDKEffectiveCapacity_ExactLiquidity_get_liquidity_msat(uint32_t ptr) {
10808         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)(ptr & ~1);
10809         assert(obj->tag == LDKEffectiveCapacity_ExactLiquidity);
10810                         int64_t liquidity_msat_conv = obj->exact_liquidity.liquidity_msat;
10811         return liquidity_msat_conv;
10812 }
10813 int64_t __attribute__((export_name("TS_LDKEffectiveCapacity_MaximumHTLC_get_amount_msat"))) TS_LDKEffectiveCapacity_MaximumHTLC_get_amount_msat(uint32_t ptr) {
10814         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)(ptr & ~1);
10815         assert(obj->tag == LDKEffectiveCapacity_MaximumHTLC);
10816                         int64_t amount_msat_conv = obj->maximum_htlc.amount_msat;
10817         return amount_msat_conv;
10818 }
10819 int64_t __attribute__((export_name("TS_LDKEffectiveCapacity_Total_get_capacity_msat"))) TS_LDKEffectiveCapacity_Total_get_capacity_msat(uint32_t ptr) {
10820         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)(ptr & ~1);
10821         assert(obj->tag == LDKEffectiveCapacity_Total);
10822                         int64_t capacity_msat_conv = obj->total.capacity_msat;
10823         return capacity_msat_conv;
10824 }
10825 uint32_t __attribute__((export_name("TS_LDKEffectiveCapacity_Total_get_htlc_maximum_msat"))) TS_LDKEffectiveCapacity_Total_get_htlc_maximum_msat(uint32_t ptr) {
10826         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)(ptr & ~1);
10827         assert(obj->tag == LDKEffectiveCapacity_Total);
10828                         uint32_t htlc_maximum_msat_ref = ((uintptr_t)&obj->total.htlc_maximum_msat) | 1;
10829         return htlc_maximum_msat_ref;
10830 }
10831 typedef struct LDKLockableScore_JCalls {
10832         atomic_size_t refcnt;
10833         uint32_t instance_ptr;
10834 } LDKLockableScore_JCalls;
10835 static void LDKLockableScore_JCalls_free(void* this_arg) {
10836         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
10837         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10838                 FREE(j_calls);
10839         }
10840 }
10841 LDKScore lock_LDKLockableScore_jcall(const void* this_arg) {
10842         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
10843         uint32_t ret = js_invoke_function_uuuuuu(j_calls->instance_ptr, 92, 0, 0, 0, 0, 0, 0);
10844         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10845         CHECK_ACCESS(ret_ptr);
10846         LDKScore ret_conv = *(LDKScore*)(ret_ptr);
10847         if (ret_conv.free == LDKScore_JCalls_free) {
10848                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10849                 LDKScore_JCalls_cloned(&ret_conv);
10850         }// WARNING: we may need a move here but no clone is available for LDKScore
10851         
10852         return ret_conv;
10853 }
10854 static void LDKLockableScore_JCalls_cloned(LDKLockableScore* new_obj) {
10855         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) new_obj->this_arg;
10856         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10857 }
10858 static inline LDKLockableScore LDKLockableScore_init (JSValue o) {
10859         LDKLockableScore_JCalls *calls = MALLOC(sizeof(LDKLockableScore_JCalls), "LDKLockableScore_JCalls");
10860         atomic_init(&calls->refcnt, 1);
10861         calls->instance_ptr = o;
10862
10863         LDKLockableScore ret = {
10864                 .this_arg = (void*) calls,
10865                 .lock = lock_LDKLockableScore_jcall,
10866                 .free = LDKLockableScore_JCalls_free,
10867         };
10868         return ret;
10869 }
10870 long  __attribute__((export_name("TS_LDKLockableScore_new"))) TS_LDKLockableScore_new(JSValue o) {
10871         LDKLockableScore *res_ptr = MALLOC(sizeof(LDKLockableScore), "LDKLockableScore");
10872         *res_ptr = LDKLockableScore_init(o);
10873         return (long)res_ptr;
10874 }
10875 uint32_t  __attribute__((export_name("TS_LockableScore_lock"))) TS_LockableScore_lock(uint32_t this_arg) {
10876         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10877         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10878         LDKLockableScore* this_arg_conv = (LDKLockableScore*)this_arg_ptr;
10879         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
10880         *ret_ret = (this_arg_conv->lock)(this_arg_conv->this_arg);
10881         return (uint32_t)ret_ret;
10882 }
10883
10884 uint32_t __attribute__((export_name("TS_LDKFallback_ty_from_ptr"))) TS_LDKFallback_ty_from_ptr(uint32_t ptr) {
10885         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
10886         switch(obj->tag) {
10887                 case LDKFallback_SegWitProgram: return 0;
10888                 case LDKFallback_PubKeyHash: return 1;
10889                 case LDKFallback_ScriptHash: return 2;
10890                 default: abort();
10891         }
10892 }
10893 int8_t __attribute__((export_name("TS_LDKFallback_SegWitProgram_get_version"))) TS_LDKFallback_SegWitProgram_get_version(uint32_t ptr) {
10894         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
10895         assert(obj->tag == LDKFallback_SegWitProgram);
10896                         uint8_t version_val = obj->seg_wit_program.version._0;
10897         return version_val;
10898 }
10899 int8_tArray __attribute__((export_name("TS_LDKFallback_SegWitProgram_get_program"))) TS_LDKFallback_SegWitProgram_get_program(uint32_t ptr) {
10900         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
10901         assert(obj->tag == LDKFallback_SegWitProgram);
10902                         LDKCVec_u8Z program_var = obj->seg_wit_program.program;
10903                         int8_tArray program_arr = init_int8_tArray(program_var.datalen, __LINE__);
10904                         memcpy(program_arr->elems, program_var.data, program_var.datalen);
10905         return program_arr;
10906 }
10907 int8_tArray __attribute__((export_name("TS_LDKFallback_PubKeyHash_get_pub_key_hash"))) TS_LDKFallback_PubKeyHash_get_pub_key_hash(uint32_t ptr) {
10908         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
10909         assert(obj->tag == LDKFallback_PubKeyHash);
10910                         int8_tArray pub_key_hash_arr = init_int8_tArray(20, __LINE__);
10911                         memcpy(pub_key_hash_arr->elems, obj->pub_key_hash.data, 20);
10912         return pub_key_hash_arr;
10913 }
10914 int8_tArray __attribute__((export_name("TS_LDKFallback_ScriptHash_get_script_hash"))) TS_LDKFallback_ScriptHash_get_script_hash(uint32_t ptr) {
10915         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
10916         assert(obj->tag == LDKFallback_ScriptHash);
10917                         int8_tArray script_hash_arr = init_int8_tArray(20, __LINE__);
10918                         memcpy(script_hash_arr->elems, obj->script_hash.data, 20);
10919         return script_hash_arr;
10920 }
10921 typedef struct LDKPayer_JCalls {
10922         atomic_size_t refcnt;
10923         uint32_t instance_ptr;
10924 } LDKPayer_JCalls;
10925 static void LDKPayer_JCalls_free(void* this_arg) {
10926         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10927         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10928                 FREE(j_calls);
10929         }
10930 }
10931 LDKPublicKey node_id_LDKPayer_jcall(const void* this_arg) {
10932         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10933         int8_tArray ret = (int8_tArray)js_invoke_function_uuuuuu(j_calls->instance_ptr, 93, 0, 0, 0, 0, 0, 0);
10934         LDKPublicKey ret_ref;
10935         CHECK(ret->arr_len == 33);
10936         memcpy(ret_ref.compressed_form, ret->elems, 33); FREE(ret);
10937         return ret_ref;
10938 }
10939 LDKCVec_ChannelDetailsZ first_hops_LDKPayer_jcall(const void* this_arg) {
10940         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10941         uint32_tArray ret = (uint32_tArray)js_invoke_function_uuuuuu(j_calls->instance_ptr, 94, 0, 0, 0, 0, 0, 0);
10942         LDKCVec_ChannelDetailsZ ret_constr;
10943         ret_constr.datalen = ret->arr_len;
10944         if (ret_constr.datalen > 0)
10945                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
10946         else
10947                 ret_constr.data = NULL;
10948         uint32_t* ret_vals = ret->elems;
10949         for (size_t q = 0; q < ret_constr.datalen; q++) {
10950                 uint32_t ret_conv_16 = ret_vals[q];
10951                 LDKChannelDetails ret_conv_16_conv;
10952                 ret_conv_16_conv.inner = (void*)(ret_conv_16 & (~1));
10953                 ret_conv_16_conv.is_owned = (ret_conv_16 & 1) || (ret_conv_16 == 0);
10954                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_conv);
10955                 ret_constr.data[q] = ret_conv_16_conv;
10956         }
10957         FREE(ret);
10958         return ret_constr;
10959 }
10960 LDKCResult_PaymentIdPaymentSendFailureZ send_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_hash, LDKThirtyTwoBytes payment_secret) {
10961         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10962         LDKRoute route_var = *route;
10963         uint32_t route_ref = 0;
10964         route_var = Route_clone(&route_var);
10965         CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10966         CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10967         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
10968         route_ref = (uintptr_t)route_var.inner;
10969         if (route_var.is_owned) {
10970                 route_ref |= 1;
10971         }
10972         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
10973         memcpy(payment_hash_arr->elems, payment_hash.data, 32);
10974         int8_tArray payment_secret_arr = init_int8_tArray(32, __LINE__);
10975         memcpy(payment_secret_arr->elems, payment_secret.data, 32);
10976         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);
10977         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10978         CHECK_ACCESS(ret_ptr);
10979         LDKCResult_PaymentIdPaymentSendFailureZ ret_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(ret_ptr);
10980         FREE((void*)ret);
10981         return ret_conv;
10982 }
10983 LDKCResult_PaymentIdPaymentSendFailureZ send_spontaneous_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_preimage) {
10984         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10985         LDKRoute route_var = *route;
10986         uint32_t route_ref = 0;
10987         route_var = Route_clone(&route_var);
10988         CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10989         CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10990         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
10991         route_ref = (uintptr_t)route_var.inner;
10992         if (route_var.is_owned) {
10993                 route_ref |= 1;
10994         }
10995         int8_tArray payment_preimage_arr = init_int8_tArray(32, __LINE__);
10996         memcpy(payment_preimage_arr->elems, payment_preimage.data, 32);
10997         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);
10998         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10999         CHECK_ACCESS(ret_ptr);
11000         LDKCResult_PaymentIdPaymentSendFailureZ ret_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(ret_ptr);
11001         FREE((void*)ret);
11002         return ret_conv;
11003 }
11004 LDKCResult_NonePaymentSendFailureZ retry_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_id) {
11005         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
11006         LDKRoute route_var = *route;
11007         uint32_t route_ref = 0;
11008         route_var = Route_clone(&route_var);
11009         CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11010         CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11011         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
11012         route_ref = (uintptr_t)route_var.inner;
11013         if (route_var.is_owned) {
11014                 route_ref |= 1;
11015         }
11016         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
11017         memcpy(payment_id_arr->elems, payment_id.data, 32);
11018         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);
11019         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
11020         CHECK_ACCESS(ret_ptr);
11021         LDKCResult_NonePaymentSendFailureZ ret_conv = *(LDKCResult_NonePaymentSendFailureZ*)(ret_ptr);
11022         FREE((void*)ret);
11023         return ret_conv;
11024 }
11025 void abandon_payment_LDKPayer_jcall(const void* this_arg, LDKThirtyTwoBytes payment_id) {
11026         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
11027         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
11028         memcpy(payment_id_arr->elems, payment_id.data, 32);
11029         js_invoke_function_uuuuuu(j_calls->instance_ptr, 98, (uint32_t)payment_id_arr, 0, 0, 0, 0, 0);
11030 }
11031 static void LDKPayer_JCalls_cloned(LDKPayer* new_obj) {
11032         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) new_obj->this_arg;
11033         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11034 }
11035 static inline LDKPayer LDKPayer_init (JSValue o) {
11036         LDKPayer_JCalls *calls = MALLOC(sizeof(LDKPayer_JCalls), "LDKPayer_JCalls");
11037         atomic_init(&calls->refcnt, 1);
11038         calls->instance_ptr = o;
11039
11040         LDKPayer ret = {
11041                 .this_arg = (void*) calls,
11042                 .node_id = node_id_LDKPayer_jcall,
11043                 .first_hops = first_hops_LDKPayer_jcall,
11044                 .send_payment = send_payment_LDKPayer_jcall,
11045                 .send_spontaneous_payment = send_spontaneous_payment_LDKPayer_jcall,
11046                 .retry_payment = retry_payment_LDKPayer_jcall,
11047                 .abandon_payment = abandon_payment_LDKPayer_jcall,
11048                 .free = LDKPayer_JCalls_free,
11049         };
11050         return ret;
11051 }
11052 long  __attribute__((export_name("TS_LDKPayer_new"))) TS_LDKPayer_new(JSValue o) {
11053         LDKPayer *res_ptr = MALLOC(sizeof(LDKPayer), "LDKPayer");
11054         *res_ptr = LDKPayer_init(o);
11055         return (long)res_ptr;
11056 }
11057 int8_tArray  __attribute__((export_name("TS_Payer_node_id"))) TS_Payer_node_id(uint32_t this_arg) {
11058         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11059         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11060         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
11061         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
11062         memcpy(ret_arr->elems, (this_arg_conv->node_id)(this_arg_conv->this_arg).compressed_form, 33);
11063         return ret_arr;
11064 }
11065
11066 uint32_tArray  __attribute__((export_name("TS_Payer_first_hops"))) TS_Payer_first_hops(uint32_t this_arg) {
11067         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11068         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11069         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
11070         LDKCVec_ChannelDetailsZ ret_var = (this_arg_conv->first_hops)(this_arg_conv->this_arg);
11071         uint32_tArray ret_arr = NULL;
11072         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
11073         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 8);
11074         for (size_t q = 0; q < ret_var.datalen; q++) {
11075                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
11076                 uint32_t ret_conv_16_ref = 0;
11077                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11078                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11079                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
11080                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
11081                 if (ret_conv_16_var.is_owned) {
11082                         ret_conv_16_ref |= 1;
11083                 }
11084                 ret_arr_ptr[q] = ret_conv_16_ref;
11085         }
11086         
11087         FREE(ret_var.data);
11088         return ret_arr;
11089 }
11090
11091 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) {
11092         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11093         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11094         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
11095         LDKRoute route_conv;
11096         route_conv.inner = (void*)(route & (~1));
11097         route_conv.is_owned = false;
11098         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
11099         LDKThirtyTwoBytes payment_hash_ref;
11100         CHECK(payment_hash->arr_len == 32);
11101         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
11102         LDKThirtyTwoBytes payment_secret_ref;
11103         CHECK(payment_secret->arr_len == 32);
11104         memcpy(payment_secret_ref.data, payment_secret->elems, 32); FREE(payment_secret);
11105         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
11106         *ret_conv = (this_arg_conv->send_payment)(this_arg_conv->this_arg, &route_conv, payment_hash_ref, payment_secret_ref);
11107         return (uint32_t)ret_conv;
11108 }
11109
11110 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) {
11111         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11112         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11113         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
11114         LDKRoute route_conv;
11115         route_conv.inner = (void*)(route & (~1));
11116         route_conv.is_owned = false;
11117         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
11118         LDKThirtyTwoBytes payment_preimage_ref;
11119         CHECK(payment_preimage->arr_len == 32);
11120         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
11121         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
11122         *ret_conv = (this_arg_conv->send_spontaneous_payment)(this_arg_conv->this_arg, &route_conv, payment_preimage_ref);
11123         return (uint32_t)ret_conv;
11124 }
11125
11126 uint32_t  __attribute__((export_name("TS_Payer_retry_payment"))) TS_Payer_retry_payment(uint32_t this_arg, uint32_t route, int8_tArray payment_id) {
11127         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11128         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11129         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
11130         LDKRoute route_conv;
11131         route_conv.inner = (void*)(route & (~1));
11132         route_conv.is_owned = false;
11133         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
11134         LDKThirtyTwoBytes payment_id_ref;
11135         CHECK(payment_id->arr_len == 32);
11136         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
11137         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
11138         *ret_conv = (this_arg_conv->retry_payment)(this_arg_conv->this_arg, &route_conv, payment_id_ref);
11139         return (uint32_t)ret_conv;
11140 }
11141
11142 void  __attribute__((export_name("TS_Payer_abandon_payment"))) TS_Payer_abandon_payment(uint32_t this_arg, int8_tArray payment_id) {
11143         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11144         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11145         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
11146         LDKThirtyTwoBytes payment_id_ref;
11147         CHECK(payment_id->arr_len == 32);
11148         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
11149         (this_arg_conv->abandon_payment)(this_arg_conv->this_arg, payment_id_ref);
11150 }
11151
11152 typedef struct LDKRouter_JCalls {
11153         atomic_size_t refcnt;
11154         uint32_t instance_ptr;
11155 } LDKRouter_JCalls;
11156 static void LDKRouter_JCalls_free(void* this_arg) {
11157         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
11158         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11159                 FREE(j_calls);
11160         }
11161 }
11162 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) {
11163         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
11164         int8_tArray payer_arr = init_int8_tArray(33, __LINE__);
11165         memcpy(payer_arr->elems, payer.compressed_form, 33);
11166         LDKRouteParameters route_params_var = *route_params;
11167         uint32_t route_params_ref = 0;
11168         route_params_var = RouteParameters_clone(&route_params_var);
11169         CHECK((((uintptr_t)route_params_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11170         CHECK((((uintptr_t)&route_params_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11171         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_var);
11172         route_params_ref = (uintptr_t)route_params_var.inner;
11173         if (route_params_var.is_owned) {
11174                 route_params_ref |= 1;
11175         }
11176         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
11177         memcpy(payment_hash_arr->elems, *payment_hash, 32);
11178         LDKCVec_ChannelDetailsZ *first_hops_var_ptr = first_hops;
11179         uint32_tArray first_hops_arr = NULL;
11180         if (first_hops != NULL) {
11181                 LDKCVec_ChannelDetailsZ first_hops_var = *first_hops_var_ptr;
11182                 first_hops_arr = init_uint32_tArray(first_hops_var.datalen, __LINE__);
11183                 uint32_t *first_hops_arr_ptr = (uint32_t*)(((uint8_t*)first_hops_arr) + 8);
11184                 for (size_t q = 0; q < first_hops_var.datalen; q++) {
11185                         LDKChannelDetails first_hops_conv_16_var =      first_hops_var.data[q];
11186                         uint32_t first_hops_conv_16_ref = 0;
11187                         CHECK((((uintptr_t)first_hops_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11188                         CHECK((((uintptr_t)&first_hops_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11189                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_var);
11190                         first_hops_conv_16_ref = (uintptr_t)first_hops_conv_16_var.inner;
11191                         if (first_hops_conv_16_var.is_owned) {
11192                                 first_hops_conv_16_ref |= 1;
11193                         }
11194                         first_hops_arr_ptr[q] = first_hops_conv_16_ref;
11195                 }
11196         
11197         }
11198         // WARNING: This object doesn't live past this scope, needs clone!
11199         uint32_t ret_scorer = ((uintptr_t)scorer) | 1;
11200         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);
11201         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
11202         CHECK_ACCESS(ret_ptr);
11203         LDKCResult_RouteLightningErrorZ ret_conv = *(LDKCResult_RouteLightningErrorZ*)(ret_ptr);
11204         FREE((void*)ret);
11205         return ret_conv;
11206 }
11207 static void LDKRouter_JCalls_cloned(LDKRouter* new_obj) {
11208         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) new_obj->this_arg;
11209         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11210 }
11211 static inline LDKRouter LDKRouter_init (JSValue o) {
11212         LDKRouter_JCalls *calls = MALLOC(sizeof(LDKRouter_JCalls), "LDKRouter_JCalls");
11213         atomic_init(&calls->refcnt, 1);
11214         calls->instance_ptr = o;
11215
11216         LDKRouter ret = {
11217                 .this_arg = (void*) calls,
11218                 .find_route = find_route_LDKRouter_jcall,
11219                 .free = LDKRouter_JCalls_free,
11220         };
11221         return ret;
11222 }
11223 long  __attribute__((export_name("TS_LDKRouter_new"))) TS_LDKRouter_new(JSValue o) {
11224         LDKRouter *res_ptr = MALLOC(sizeof(LDKRouter), "LDKRouter");
11225         *res_ptr = LDKRouter_init(o);
11226         return (long)res_ptr;
11227 }
11228 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) {
11229         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11230         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11231         LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
11232         LDKPublicKey payer_ref;
11233         CHECK(payer->arr_len == 33);
11234         memcpy(payer_ref.compressed_form, payer->elems, 33); FREE(payer);
11235         LDKRouteParameters route_params_conv;
11236         route_params_conv.inner = (void*)(route_params & (~1));
11237         route_params_conv.is_owned = false;
11238         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
11239         unsigned char payment_hash_arr[32];
11240         CHECK(payment_hash->arr_len == 32);
11241         memcpy(payment_hash_arr, payment_hash->elems, 32); FREE(payment_hash);
11242         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
11243         LDKCVec_ChannelDetailsZ first_hops_constr;
11244         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
11245         if (first_hops != 0) {
11246                 first_hops_constr.datalen = first_hops->arr_len;
11247                 if (first_hops_constr.datalen > 0)
11248                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
11249                 else
11250                         first_hops_constr.data = NULL;
11251                 uint32_t* first_hops_vals = first_hops->elems;
11252                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
11253                         uint32_t first_hops_conv_16 = first_hops_vals[q];
11254                         LDKChannelDetails first_hops_conv_16_conv;
11255                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
11256                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
11257                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
11258                         first_hops_constr.data[q] = first_hops_conv_16_conv;
11259                 }
11260                 FREE(first_hops);
11261                 first_hops_ptr = &first_hops_constr;
11262         }
11263         void* scorer_ptr = (void*)(((uintptr_t)scorer) & ~1);
11264         if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
11265         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
11266         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
11267         *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);
11268         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
11269         return (uint32_t)ret_conv;
11270 }
11271
11272 uint32_t __attribute__((export_name("TS_LDKRetry_ty_from_ptr"))) TS_LDKRetry_ty_from_ptr(uint32_t ptr) {
11273         LDKRetry *obj = (LDKRetry*)(ptr & ~1);
11274         switch(obj->tag) {
11275                 case LDKRetry_Attempts: return 0;
11276                 default: abort();
11277         }
11278 }
11279 uint32_t __attribute__((export_name("TS_LDKRetry_Attempts_get_attempts"))) TS_LDKRetry_Attempts_get_attempts(uint32_t ptr) {
11280         LDKRetry *obj = (LDKRetry*)(ptr & ~1);
11281         assert(obj->tag == LDKRetry_Attempts);
11282                         uint32_t attempts_conv = obj->attempts;
11283         return attempts_conv;
11284 }
11285 jstring  __attribute__((export_name("TS__ldk_get_compiled_version"))) TS__ldk_get_compiled_version() {
11286         LDKStr ret_str = _ldk_get_compiled_version();
11287         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
11288         Str_free(ret_str);
11289         return ret_conv;
11290 }
11291
11292 jstring  __attribute__((export_name("TS__ldk_c_bindings_get_compiled_version"))) TS__ldk_c_bindings_get_compiled_version() {
11293         LDKStr ret_str = _ldk_c_bindings_get_compiled_version();
11294         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
11295         Str_free(ret_str);
11296         return ret_conv;
11297 }
11298
11299 static inline uintptr_t Bech32Error_clone_ptr(LDKBech32Error *NONNULL_PTR arg) {
11300         LDKBech32Error *ret_copy = MALLOC(sizeof(LDKBech32Error), "LDKBech32Error");
11301         *ret_copy = Bech32Error_clone(arg);
11302 uint32_t ret_ref = (uintptr_t)ret_copy;
11303         return ret_ref;
11304 }
11305 uint32_t  __attribute__((export_name("TS_Bech32Error_clone_ptr"))) TS_Bech32Error_clone_ptr(uint32_t arg) {
11306         LDKBech32Error* arg_conv = (LDKBech32Error*)arg;
11307         uint32_t ret_conv = Bech32Error_clone_ptr(arg_conv);
11308         return ret_conv;
11309 }
11310
11311 uint32_t  __attribute__((export_name("TS_Bech32Error_clone"))) TS_Bech32Error_clone(uint32_t orig) {
11312         LDKBech32Error* orig_conv = (LDKBech32Error*)orig;
11313         LDKBech32Error *ret_copy = MALLOC(sizeof(LDKBech32Error), "LDKBech32Error");
11314         *ret_copy = Bech32Error_clone(orig_conv);
11315         uint32_t ret_ref = (uintptr_t)ret_copy;
11316         return ret_ref;
11317 }
11318
11319 void  __attribute__((export_name("TS_Bech32Error_free"))) TS_Bech32Error_free(uint32_t o) {
11320         if ((o & 1) != 0) return;
11321         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
11322         CHECK_ACCESS(o_ptr);
11323         LDKBech32Error o_conv = *(LDKBech32Error*)(o_ptr);
11324         FREE((void*)o);
11325         Bech32Error_free(o_conv);
11326 }
11327
11328 void  __attribute__((export_name("TS_Transaction_free"))) TS_Transaction_free(int8_tArray _res) {
11329         LDKTransaction _res_ref;
11330         _res_ref.datalen = _res->arr_len;
11331         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
11332         memcpy(_res_ref.data, _res->elems, _res_ref.datalen); FREE(_res);
11333         _res_ref.data_is_owned = true;
11334         Transaction_free(_res_ref);
11335 }
11336
11337 uint32_t  __attribute__((export_name("TS_TxOut_new"))) TS_TxOut_new(int8_tArray script_pubkey, int64_t value) {
11338         LDKCVec_u8Z script_pubkey_ref;
11339         script_pubkey_ref.datalen = script_pubkey->arr_len;
11340         script_pubkey_ref.data = MALLOC(script_pubkey_ref.datalen, "LDKCVec_u8Z Bytes");
11341         memcpy(script_pubkey_ref.data, script_pubkey->elems, script_pubkey_ref.datalen); FREE(script_pubkey);
11342         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
11343         *ret_ref = TxOut_new(script_pubkey_ref, value);
11344         return (uint32_t)ret_ref;
11345 }
11346
11347 void  __attribute__((export_name("TS_TxOut_free"))) TS_TxOut_free(uint32_t _res) {
11348         if ((_res & 1) != 0) return;
11349         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11350         CHECK_ACCESS(_res_ptr);
11351         LDKTxOut _res_conv = *(LDKTxOut*)(_res_ptr);
11352         FREE((void*)_res);
11353         TxOut_free(_res_conv);
11354 }
11355
11356 static inline uintptr_t TxOut_clone_ptr(LDKTxOut *NONNULL_PTR arg) {
11357         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
11358         *ret_ref = TxOut_clone(arg);
11359         return (uint32_t)ret_ref;
11360 }
11361 uint32_t  __attribute__((export_name("TS_TxOut_clone_ptr"))) TS_TxOut_clone_ptr(uint32_t arg) {
11362         LDKTxOut* arg_conv = (LDKTxOut*)(arg & ~1);
11363         uint32_t ret_conv = TxOut_clone_ptr(arg_conv);
11364         return ret_conv;
11365 }
11366
11367 uint32_t  __attribute__((export_name("TS_TxOut_clone"))) TS_TxOut_clone(uint32_t orig) {
11368         LDKTxOut* orig_conv = (LDKTxOut*)(orig & ~1);
11369         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
11370         *ret_ref = TxOut_clone(orig_conv);
11371         return (uint32_t)ret_ref;
11372 }
11373
11374 void  __attribute__((export_name("TS_Str_free"))) TS_Str_free(jstring _res) {
11375         LDKStr dummy = { .chars = NULL, .len = 0, .chars_is_owned = false };
11376         Str_free(dummy);
11377 }
11378
11379 uint32_t  __attribute__((export_name("TS_CResult_NoneNoneZ_ok"))) TS_CResult_NoneNoneZ_ok() {
11380         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
11381         *ret_conv = CResult_NoneNoneZ_ok();
11382         return (uint32_t)ret_conv;
11383 }
11384
11385 uint32_t  __attribute__((export_name("TS_CResult_NoneNoneZ_err"))) TS_CResult_NoneNoneZ_err() {
11386         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
11387         *ret_conv = CResult_NoneNoneZ_err();
11388         return (uint32_t)ret_conv;
11389 }
11390
11391 jboolean  __attribute__((export_name("TS_CResult_NoneNoneZ_is_ok"))) TS_CResult_NoneNoneZ_is_ok(uint32_t o) {
11392         LDKCResult_NoneNoneZ* o_conv = (LDKCResult_NoneNoneZ*)(o & ~1);
11393         jboolean ret_conv = CResult_NoneNoneZ_is_ok(o_conv);
11394         return ret_conv;
11395 }
11396
11397 void  __attribute__((export_name("TS_CResult_NoneNoneZ_free"))) TS_CResult_NoneNoneZ_free(uint32_t _res) {
11398         if ((_res & 1) != 0) return;
11399         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11400         CHECK_ACCESS(_res_ptr);
11401         LDKCResult_NoneNoneZ _res_conv = *(LDKCResult_NoneNoneZ*)(_res_ptr);
11402         FREE((void*)_res);
11403         CResult_NoneNoneZ_free(_res_conv);
11404 }
11405
11406 static inline uintptr_t CResult_NoneNoneZ_clone_ptr(LDKCResult_NoneNoneZ *NONNULL_PTR arg) {
11407         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
11408         *ret_conv = CResult_NoneNoneZ_clone(arg);
11409         return (uint32_t)ret_conv;
11410 }
11411 uint32_t  __attribute__((export_name("TS_CResult_NoneNoneZ_clone_ptr"))) TS_CResult_NoneNoneZ_clone_ptr(uint32_t arg) {
11412         LDKCResult_NoneNoneZ* arg_conv = (LDKCResult_NoneNoneZ*)(arg & ~1);
11413         uint32_t ret_conv = CResult_NoneNoneZ_clone_ptr(arg_conv);
11414         return ret_conv;
11415 }
11416
11417 uint32_t  __attribute__((export_name("TS_CResult_NoneNoneZ_clone"))) TS_CResult_NoneNoneZ_clone(uint32_t orig) {
11418         LDKCResult_NoneNoneZ* orig_conv = (LDKCResult_NoneNoneZ*)(orig & ~1);
11419         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
11420         *ret_conv = CResult_NoneNoneZ_clone(orig_conv);
11421         return (uint32_t)ret_conv;
11422 }
11423
11424 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok(uint32_t o) {
11425         LDKCounterpartyCommitmentSecrets o_conv;
11426         o_conv.inner = (void*)(o & (~1));
11427         o_conv.is_owned = (o & 1) || (o == 0);
11428         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11429         o_conv = CounterpartyCommitmentSecrets_clone(&o_conv);
11430         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
11431         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok(o_conv);
11432         return (uint32_t)ret_conv;
11433 }
11434
11435 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err(uint32_t e) {
11436         LDKDecodeError e_conv;
11437         e_conv.inner = (void*)(e & (~1));
11438         e_conv.is_owned = (e & 1) || (e == 0);
11439         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11440         e_conv = DecodeError_clone(&e_conv);
11441         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
11442         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err(e_conv);
11443         return (uint32_t)ret_conv;
11444 }
11445
11446 jboolean  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok(uint32_t o) {
11447         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* o_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(o & ~1);
11448         jboolean ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok(o_conv);
11449         return ret_conv;
11450 }
11451
11452 void  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free(uint32_t _res) {
11453         if ((_res & 1) != 0) return;
11454         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11455         CHECK_ACCESS(_res_ptr);
11456         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(_res_ptr);
11457         FREE((void*)_res);
11458         CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free(_res_conv);
11459 }
11460
11461 static inline uintptr_t CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR arg) {
11462         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
11463         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(arg);
11464         return (uint32_t)ret_conv;
11465 }
11466 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(uint32_t arg) {
11467         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(arg & ~1);
11468         uint32_t ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(arg_conv);
11469         return ret_conv;
11470 }
11471
11472 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(uint32_t orig) {
11473         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(orig & ~1);
11474         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
11475         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(orig_conv);
11476         return (uint32_t)ret_conv;
11477 }
11478
11479 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_ok"))) TS_CResult_SecretKeyErrorZ_ok(int8_tArray o) {
11480         LDKSecretKey o_ref;
11481         CHECK(o->arr_len == 32);
11482         memcpy(o_ref.bytes, o->elems, 32); FREE(o);
11483         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
11484         *ret_conv = CResult_SecretKeyErrorZ_ok(o_ref);
11485         return (uint32_t)ret_conv;
11486 }
11487
11488 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_err"))) TS_CResult_SecretKeyErrorZ_err(uint32_t e) {
11489         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
11490         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
11491         *ret_conv = CResult_SecretKeyErrorZ_err(e_conv);
11492         return (uint32_t)ret_conv;
11493 }
11494
11495 jboolean  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_is_ok"))) TS_CResult_SecretKeyErrorZ_is_ok(uint32_t o) {
11496         LDKCResult_SecretKeyErrorZ* o_conv = (LDKCResult_SecretKeyErrorZ*)(o & ~1);
11497         jboolean ret_conv = CResult_SecretKeyErrorZ_is_ok(o_conv);
11498         return ret_conv;
11499 }
11500
11501 void  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_free"))) TS_CResult_SecretKeyErrorZ_free(uint32_t _res) {
11502         if ((_res & 1) != 0) return;
11503         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11504         CHECK_ACCESS(_res_ptr);
11505         LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(_res_ptr);
11506         FREE((void*)_res);
11507         CResult_SecretKeyErrorZ_free(_res_conv);
11508 }
11509
11510 static inline uintptr_t CResult_SecretKeyErrorZ_clone_ptr(LDKCResult_SecretKeyErrorZ *NONNULL_PTR arg) {
11511         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
11512         *ret_conv = CResult_SecretKeyErrorZ_clone(arg);
11513         return (uint32_t)ret_conv;
11514 }
11515 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_clone_ptr"))) TS_CResult_SecretKeyErrorZ_clone_ptr(uint32_t arg) {
11516         LDKCResult_SecretKeyErrorZ* arg_conv = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
11517         uint32_t ret_conv = CResult_SecretKeyErrorZ_clone_ptr(arg_conv);
11518         return ret_conv;
11519 }
11520
11521 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_clone"))) TS_CResult_SecretKeyErrorZ_clone(uint32_t orig) {
11522         LDKCResult_SecretKeyErrorZ* orig_conv = (LDKCResult_SecretKeyErrorZ*)(orig & ~1);
11523         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
11524         *ret_conv = CResult_SecretKeyErrorZ_clone(orig_conv);
11525         return (uint32_t)ret_conv;
11526 }
11527
11528 uint32_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_ok"))) TS_CResult_PublicKeyErrorZ_ok(int8_tArray o) {
11529         LDKPublicKey o_ref;
11530         CHECK(o->arr_len == 33);
11531         memcpy(o_ref.compressed_form, o->elems, 33); FREE(o);
11532         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
11533         *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
11534         return (uint32_t)ret_conv;
11535 }
11536
11537 uint32_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_err"))) TS_CResult_PublicKeyErrorZ_err(uint32_t e) {
11538         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
11539         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
11540         *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
11541         return (uint32_t)ret_conv;
11542 }
11543
11544 jboolean  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_is_ok"))) TS_CResult_PublicKeyErrorZ_is_ok(uint32_t o) {
11545         LDKCResult_PublicKeyErrorZ* o_conv = (LDKCResult_PublicKeyErrorZ*)(o & ~1);
11546         jboolean ret_conv = CResult_PublicKeyErrorZ_is_ok(o_conv);
11547         return ret_conv;
11548 }
11549
11550 void  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_free"))) TS_CResult_PublicKeyErrorZ_free(uint32_t _res) {
11551         if ((_res & 1) != 0) return;
11552         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11553         CHECK_ACCESS(_res_ptr);
11554         LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(_res_ptr);
11555         FREE((void*)_res);
11556         CResult_PublicKeyErrorZ_free(_res_conv);
11557 }
11558
11559 static inline uintptr_t CResult_PublicKeyErrorZ_clone_ptr(LDKCResult_PublicKeyErrorZ *NONNULL_PTR arg) {
11560         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
11561         *ret_conv = CResult_PublicKeyErrorZ_clone(arg);
11562         return (uint32_t)ret_conv;
11563 }
11564 uint32_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_clone_ptr"))) TS_CResult_PublicKeyErrorZ_clone_ptr(uint32_t arg) {
11565         LDKCResult_PublicKeyErrorZ* arg_conv = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
11566         uint32_t ret_conv = CResult_PublicKeyErrorZ_clone_ptr(arg_conv);
11567         return ret_conv;
11568 }
11569
11570 uint32_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_clone"))) TS_CResult_PublicKeyErrorZ_clone(uint32_t orig) {
11571         LDKCResult_PublicKeyErrorZ* orig_conv = (LDKCResult_PublicKeyErrorZ*)(orig & ~1);
11572         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
11573         *ret_conv = CResult_PublicKeyErrorZ_clone(orig_conv);
11574         return (uint32_t)ret_conv;
11575 }
11576
11577 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_ok"))) TS_CResult_TxCreationKeysDecodeErrorZ_ok(uint32_t o) {
11578         LDKTxCreationKeys o_conv;
11579         o_conv.inner = (void*)(o & (~1));
11580         o_conv.is_owned = (o & 1) || (o == 0);
11581         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11582         o_conv = TxCreationKeys_clone(&o_conv);
11583         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
11584         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
11585         return (uint32_t)ret_conv;
11586 }
11587
11588 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_err"))) TS_CResult_TxCreationKeysDecodeErrorZ_err(uint32_t e) {
11589         LDKDecodeError e_conv;
11590         e_conv.inner = (void*)(e & (~1));
11591         e_conv.is_owned = (e & 1) || (e == 0);
11592         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11593         e_conv = DecodeError_clone(&e_conv);
11594         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
11595         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
11596         return (uint32_t)ret_conv;
11597 }
11598
11599 jboolean  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_is_ok"))) TS_CResult_TxCreationKeysDecodeErrorZ_is_ok(uint32_t o) {
11600         LDKCResult_TxCreationKeysDecodeErrorZ* o_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(o & ~1);
11601         jboolean ret_conv = CResult_TxCreationKeysDecodeErrorZ_is_ok(o_conv);
11602         return ret_conv;
11603 }
11604
11605 void  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_free"))) TS_CResult_TxCreationKeysDecodeErrorZ_free(uint32_t _res) {
11606         if ((_res & 1) != 0) return;
11607         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11608         CHECK_ACCESS(_res_ptr);
11609         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(_res_ptr);
11610         FREE((void*)_res);
11611         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
11612 }
11613
11614 static inline uintptr_t CResult_TxCreationKeysDecodeErrorZ_clone_ptr(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR arg) {
11615         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
11616         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(arg);
11617         return (uint32_t)ret_conv;
11618 }
11619 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_clone_ptr"))) TS_CResult_TxCreationKeysDecodeErrorZ_clone_ptr(uint32_t arg) {
11620         LDKCResult_TxCreationKeysDecodeErrorZ* arg_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
11621         uint32_t ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone_ptr(arg_conv);
11622         return ret_conv;
11623 }
11624
11625 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_clone"))) TS_CResult_TxCreationKeysDecodeErrorZ_clone(uint32_t orig) {
11626         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(orig & ~1);
11627         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
11628         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
11629         return (uint32_t)ret_conv;
11630 }
11631
11632 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_ok"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_ok(uint32_t o) {
11633         LDKChannelPublicKeys o_conv;
11634         o_conv.inner = (void*)(o & (~1));
11635         o_conv.is_owned = (o & 1) || (o == 0);
11636         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11637         o_conv = ChannelPublicKeys_clone(&o_conv);
11638         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
11639         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
11640         return (uint32_t)ret_conv;
11641 }
11642
11643 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_err"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_err(uint32_t e) {
11644         LDKDecodeError e_conv;
11645         e_conv.inner = (void*)(e & (~1));
11646         e_conv.is_owned = (e & 1) || (e == 0);
11647         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11648         e_conv = DecodeError_clone(&e_conv);
11649         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
11650         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
11651         return (uint32_t)ret_conv;
11652 }
11653
11654 jboolean  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_is_ok"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_is_ok(uint32_t o) {
11655         LDKCResult_ChannelPublicKeysDecodeErrorZ* o_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(o & ~1);
11656         jboolean ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_is_ok(o_conv);
11657         return ret_conv;
11658 }
11659
11660 void  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_free"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_free(uint32_t _res) {
11661         if ((_res & 1) != 0) return;
11662         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11663         CHECK_ACCESS(_res_ptr);
11664         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(_res_ptr);
11665         FREE((void*)_res);
11666         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
11667 }
11668
11669 static inline uintptr_t CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR arg) {
11670         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
11671         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(arg);
11672         return (uint32_t)ret_conv;
11673 }
11674 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(uint32_t arg) {
11675         LDKCResult_ChannelPublicKeysDecodeErrorZ* arg_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
11676         uint32_t ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(arg_conv);
11677         return ret_conv;
11678 }
11679
11680 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_clone"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_clone(uint32_t orig) {
11681         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(orig & ~1);
11682         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
11683         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
11684         return (uint32_t)ret_conv;
11685 }
11686
11687 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_ok"))) TS_CResult_TxCreationKeysErrorZ_ok(uint32_t o) {
11688         LDKTxCreationKeys o_conv;
11689         o_conv.inner = (void*)(o & (~1));
11690         o_conv.is_owned = (o & 1) || (o == 0);
11691         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11692         o_conv = TxCreationKeys_clone(&o_conv);
11693         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
11694         *ret_conv = CResult_TxCreationKeysErrorZ_ok(o_conv);
11695         return (uint32_t)ret_conv;
11696 }
11697
11698 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_err"))) TS_CResult_TxCreationKeysErrorZ_err(uint32_t e) {
11699         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
11700         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
11701         *ret_conv = CResult_TxCreationKeysErrorZ_err(e_conv);
11702         return (uint32_t)ret_conv;
11703 }
11704
11705 jboolean  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_is_ok"))) TS_CResult_TxCreationKeysErrorZ_is_ok(uint32_t o) {
11706         LDKCResult_TxCreationKeysErrorZ* o_conv = (LDKCResult_TxCreationKeysErrorZ*)(o & ~1);
11707         jboolean ret_conv = CResult_TxCreationKeysErrorZ_is_ok(o_conv);
11708         return ret_conv;
11709 }
11710
11711 void  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_free"))) TS_CResult_TxCreationKeysErrorZ_free(uint32_t _res) {
11712         if ((_res & 1) != 0) return;
11713         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11714         CHECK_ACCESS(_res_ptr);
11715         LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(_res_ptr);
11716         FREE((void*)_res);
11717         CResult_TxCreationKeysErrorZ_free(_res_conv);
11718 }
11719
11720 static inline uintptr_t CResult_TxCreationKeysErrorZ_clone_ptr(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR arg) {
11721         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
11722         *ret_conv = CResult_TxCreationKeysErrorZ_clone(arg);
11723         return (uint32_t)ret_conv;
11724 }
11725 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_clone_ptr"))) TS_CResult_TxCreationKeysErrorZ_clone_ptr(uint32_t arg) {
11726         LDKCResult_TxCreationKeysErrorZ* arg_conv = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
11727         uint32_t ret_conv = CResult_TxCreationKeysErrorZ_clone_ptr(arg_conv);
11728         return ret_conv;
11729 }
11730
11731 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_clone"))) TS_CResult_TxCreationKeysErrorZ_clone(uint32_t orig) {
11732         LDKCResult_TxCreationKeysErrorZ* orig_conv = (LDKCResult_TxCreationKeysErrorZ*)(orig & ~1);
11733         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
11734         *ret_conv = CResult_TxCreationKeysErrorZ_clone(orig_conv);
11735         return (uint32_t)ret_conv;
11736 }
11737
11738 uint32_t  __attribute__((export_name("TS_COption_u32Z_some"))) TS_COption_u32Z_some(int32_t o) {
11739         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
11740         *ret_copy = COption_u32Z_some(o);
11741         uint32_t ret_ref = (uintptr_t)ret_copy;
11742         return ret_ref;
11743 }
11744
11745 uint32_t  __attribute__((export_name("TS_COption_u32Z_none"))) TS_COption_u32Z_none() {
11746         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
11747         *ret_copy = COption_u32Z_none();
11748         uint32_t ret_ref = (uintptr_t)ret_copy;
11749         return ret_ref;
11750 }
11751
11752 void  __attribute__((export_name("TS_COption_u32Z_free"))) TS_COption_u32Z_free(uint32_t _res) {
11753         if ((_res & 1) != 0) return;
11754         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11755         CHECK_ACCESS(_res_ptr);
11756         LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(_res_ptr);
11757         FREE((void*)_res);
11758         COption_u32Z_free(_res_conv);
11759 }
11760
11761 static inline uintptr_t COption_u32Z_clone_ptr(LDKCOption_u32Z *NONNULL_PTR arg) {
11762         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
11763         *ret_copy = COption_u32Z_clone(arg);
11764 uint32_t ret_ref = (uintptr_t)ret_copy;
11765         return ret_ref;
11766 }
11767 uint32_t  __attribute__((export_name("TS_COption_u32Z_clone_ptr"))) TS_COption_u32Z_clone_ptr(uint32_t arg) {
11768         LDKCOption_u32Z* arg_conv = (LDKCOption_u32Z*)arg;
11769         uint32_t ret_conv = COption_u32Z_clone_ptr(arg_conv);
11770         return ret_conv;
11771 }
11772
11773 uint32_t  __attribute__((export_name("TS_COption_u32Z_clone"))) TS_COption_u32Z_clone(uint32_t orig) {
11774         LDKCOption_u32Z* orig_conv = (LDKCOption_u32Z*)orig;
11775         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
11776         *ret_copy = COption_u32Z_clone(orig_conv);
11777         uint32_t ret_ref = (uintptr_t)ret_copy;
11778         return ret_ref;
11779 }
11780
11781 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_ok"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(uint32_t o) {
11782         LDKHTLCOutputInCommitment o_conv;
11783         o_conv.inner = (void*)(o & (~1));
11784         o_conv.is_owned = (o & 1) || (o == 0);
11785         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11786         o_conv = HTLCOutputInCommitment_clone(&o_conv);
11787         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
11788         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
11789         return (uint32_t)ret_conv;
11790 }
11791
11792 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_err"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_err(uint32_t e) {
11793         LDKDecodeError e_conv;
11794         e_conv.inner = (void*)(e & (~1));
11795         e_conv.is_owned = (e & 1) || (e == 0);
11796         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11797         e_conv = DecodeError_clone(&e_conv);
11798         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
11799         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
11800         return (uint32_t)ret_conv;
11801 }
11802
11803 jboolean  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(uint32_t o) {
11804         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* o_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(o & ~1);
11805         jboolean ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(o_conv);
11806         return ret_conv;
11807 }
11808
11809 void  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_free"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_free(uint32_t _res) {
11810         if ((_res & 1) != 0) return;
11811         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11812         CHECK_ACCESS(_res_ptr);
11813         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(_res_ptr);
11814         FREE((void*)_res);
11815         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
11816 }
11817
11818 static inline uintptr_t CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR arg) {
11819         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
11820         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(arg);
11821         return (uint32_t)ret_conv;
11822 }
11823 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(uint32_t arg) {
11824         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* arg_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
11825         uint32_t ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(arg_conv);
11826         return ret_conv;
11827 }
11828
11829 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(uint32_t orig) {
11830         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(orig & ~1);
11831         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
11832         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
11833         return (uint32_t)ret_conv;
11834 }
11835
11836 uint32_t  __attribute__((export_name("TS_COption_NoneZ_some"))) TS_COption_NoneZ_some() {
11837         uint32_t ret_conv = LDKCOption_NoneZ_to_js(COption_NoneZ_some());
11838         return ret_conv;
11839 }
11840
11841 uint32_t  __attribute__((export_name("TS_COption_NoneZ_none"))) TS_COption_NoneZ_none() {
11842         uint32_t ret_conv = LDKCOption_NoneZ_to_js(COption_NoneZ_none());
11843         return ret_conv;
11844 }
11845
11846 void  __attribute__((export_name("TS_COption_NoneZ_free"))) TS_COption_NoneZ_free(uint32_t _res) {
11847         LDKCOption_NoneZ _res_conv = LDKCOption_NoneZ_from_js(_res);
11848         COption_NoneZ_free(_res_conv);
11849 }
11850
11851 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(uint32_t o) {
11852         LDKCounterpartyChannelTransactionParameters o_conv;
11853         o_conv.inner = (void*)(o & (~1));
11854         o_conv.is_owned = (o & 1) || (o == 0);
11855         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11856         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
11857         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
11858         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
11859         return (uint32_t)ret_conv;
11860 }
11861
11862 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(uint32_t e) {
11863         LDKDecodeError e_conv;
11864         e_conv.inner = (void*)(e & (~1));
11865         e_conv.is_owned = (e & 1) || (e == 0);
11866         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11867         e_conv = DecodeError_clone(&e_conv);
11868         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
11869         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
11870         return (uint32_t)ret_conv;
11871 }
11872
11873 jboolean  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(uint32_t o) {
11874         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(o & ~1);
11875         jboolean ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
11876         return ret_conv;
11877 }
11878
11879 void  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(uint32_t _res) {
11880         if ((_res & 1) != 0) return;
11881         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11882         CHECK_ACCESS(_res_ptr);
11883         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
11884         FREE((void*)_res);
11885         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
11886 }
11887
11888 static inline uintptr_t CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
11889         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
11890         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(arg);
11891         return (uint32_t)ret_conv;
11892 }
11893 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(uint32_t arg) {
11894         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
11895         uint32_t ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
11896         return ret_conv;
11897 }
11898
11899 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(uint32_t orig) {
11900         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
11901         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
11902         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
11903         return (uint32_t)ret_conv;
11904 }
11905
11906 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_ok"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_ok(uint32_t o) {
11907         LDKChannelTransactionParameters o_conv;
11908         o_conv.inner = (void*)(o & (~1));
11909         o_conv.is_owned = (o & 1) || (o == 0);
11910         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11911         o_conv = ChannelTransactionParameters_clone(&o_conv);
11912         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
11913         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
11914         return (uint32_t)ret_conv;
11915 }
11916
11917 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_err"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_err(uint32_t e) {
11918         LDKDecodeError e_conv;
11919         e_conv.inner = (void*)(e & (~1));
11920         e_conv.is_owned = (e & 1) || (e == 0);
11921         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11922         e_conv = DecodeError_clone(&e_conv);
11923         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
11924         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
11925         return (uint32_t)ret_conv;
11926 }
11927
11928 jboolean  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_is_ok"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(uint32_t o) {
11929         LDKCResult_ChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(o & ~1);
11930         jboolean ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
11931         return ret_conv;
11932 }
11933
11934 void  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_free"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_free(uint32_t _res) {
11935         if ((_res & 1) != 0) return;
11936         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11937         CHECK_ACCESS(_res_ptr);
11938         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
11939         FREE((void*)_res);
11940         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
11941 }
11942
11943 static inline uintptr_t CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
11944         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
11945         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(arg);
11946         return (uint32_t)ret_conv;
11947 }
11948 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(uint32_t arg) {
11949         LDKCResult_ChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
11950         uint32_t ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
11951         return ret_conv;
11952 }
11953
11954 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone(uint32_t orig) {
11955         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
11956         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
11957         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
11958         return (uint32_t)ret_conv;
11959 }
11960
11961 void  __attribute__((export_name("TS_CVec_SignatureZ_free"))) TS_CVec_SignatureZ_free(ptrArray _res) {
11962         LDKCVec_SignatureZ _res_constr;
11963         _res_constr.datalen = _res->arr_len;
11964         if (_res_constr.datalen > 0)
11965                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
11966         else
11967                 _res_constr.data = NULL;
11968         int8_tArray* _res_vals = (void*) _res->elems;
11969         for (size_t m = 0; m < _res_constr.datalen; m++) {
11970                 int8_tArray _res_conv_12 = _res_vals[m];
11971                 LDKSignature _res_conv_12_ref;
11972                 CHECK(_res_conv_12->arr_len == 64);
11973                 memcpy(_res_conv_12_ref.compact_form, _res_conv_12->elems, 64); FREE(_res_conv_12);
11974                 _res_constr.data[m] = _res_conv_12_ref;
11975         }
11976         FREE(_res);
11977         CVec_SignatureZ_free(_res_constr);
11978 }
11979
11980 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_ok"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
11981         LDKHolderCommitmentTransaction o_conv;
11982         o_conv.inner = (void*)(o & (~1));
11983         o_conv.is_owned = (o & 1) || (o == 0);
11984         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11985         o_conv = HolderCommitmentTransaction_clone(&o_conv);
11986         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
11987         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
11988         return (uint32_t)ret_conv;
11989 }
11990
11991 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_err"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_err(uint32_t e) {
11992         LDKDecodeError e_conv;
11993         e_conv.inner = (void*)(e & (~1));
11994         e_conv.is_owned = (e & 1) || (e == 0);
11995         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11996         e_conv = DecodeError_clone(&e_conv);
11997         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
11998         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
11999         return (uint32_t)ret_conv;
12000 }
12001
12002 jboolean  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(uint32_t o) {
12003         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(o & ~1);
12004         jboolean ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
12005         return ret_conv;
12006 }
12007
12008 void  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_free"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
12009         if ((_res & 1) != 0) return;
12010         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12011         CHECK_ACCESS(_res_ptr);
12012         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(_res_ptr);
12013         FREE((void*)_res);
12014         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
12015 }
12016
12017 static inline uintptr_t CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
12018         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
12019         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(arg);
12020         return (uint32_t)ret_conv;
12021 }
12022 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(uint32_t arg) {
12023         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
12024         uint32_t ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
12025         return ret_conv;
12026 }
12027
12028 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
12029         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(orig & ~1);
12030         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
12031         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
12032         return (uint32_t)ret_conv;
12033 }
12034
12035 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_ok"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
12036         LDKBuiltCommitmentTransaction o_conv;
12037         o_conv.inner = (void*)(o & (~1));
12038         o_conv.is_owned = (o & 1) || (o == 0);
12039         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12040         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
12041         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
12042         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
12043         return (uint32_t)ret_conv;
12044 }
12045
12046 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_err"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_err(uint32_t e) {
12047         LDKDecodeError e_conv;
12048         e_conv.inner = (void*)(e & (~1));
12049         e_conv.is_owned = (e & 1) || (e == 0);
12050         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12051         e_conv = DecodeError_clone(&e_conv);
12052         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
12053         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
12054         return (uint32_t)ret_conv;
12055 }
12056
12057 jboolean  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(uint32_t o) {
12058         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(o & ~1);
12059         jboolean ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
12060         return ret_conv;
12061 }
12062
12063 void  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_free"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
12064         if ((_res & 1) != 0) return;
12065         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12066         CHECK_ACCESS(_res_ptr);
12067         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(_res_ptr);
12068         FREE((void*)_res);
12069         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
12070 }
12071
12072 static inline uintptr_t CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
12073         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
12074         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(arg);
12075         return (uint32_t)ret_conv;
12076 }
12077 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(uint32_t arg) {
12078         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
12079         uint32_t ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
12080         return ret_conv;
12081 }
12082
12083 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
12084         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(orig & ~1);
12085         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
12086         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
12087         return (uint32_t)ret_conv;
12088 }
12089
12090 uint32_t  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_ok"))) TS_CResult_TrustedClosingTransactionNoneZ_ok(uint32_t o) {
12091         LDKTrustedClosingTransaction o_conv;
12092         o_conv.inner = (void*)(o & (~1));
12093         o_conv.is_owned = (o & 1) || (o == 0);
12094         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12095         // WARNING: we need a move here but no clone is available for LDKTrustedClosingTransaction
12096         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
12097         *ret_conv = CResult_TrustedClosingTransactionNoneZ_ok(o_conv);
12098         return (uint32_t)ret_conv;
12099 }
12100
12101 uint32_t  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_err"))) TS_CResult_TrustedClosingTransactionNoneZ_err() {
12102         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
12103         *ret_conv = CResult_TrustedClosingTransactionNoneZ_err();
12104         return (uint32_t)ret_conv;
12105 }
12106
12107 jboolean  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_is_ok"))) TS_CResult_TrustedClosingTransactionNoneZ_is_ok(uint32_t o) {
12108         LDKCResult_TrustedClosingTransactionNoneZ* o_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(o & ~1);
12109         jboolean ret_conv = CResult_TrustedClosingTransactionNoneZ_is_ok(o_conv);
12110         return ret_conv;
12111 }
12112
12113 void  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_free"))) TS_CResult_TrustedClosingTransactionNoneZ_free(uint32_t _res) {
12114         if ((_res & 1) != 0) return;
12115         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12116         CHECK_ACCESS(_res_ptr);
12117         LDKCResult_TrustedClosingTransactionNoneZ _res_conv = *(LDKCResult_TrustedClosingTransactionNoneZ*)(_res_ptr);
12118         FREE((void*)_res);
12119         CResult_TrustedClosingTransactionNoneZ_free(_res_conv);
12120 }
12121
12122 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_ok"))) TS_CResult_CommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
12123         LDKCommitmentTransaction o_conv;
12124         o_conv.inner = (void*)(o & (~1));
12125         o_conv.is_owned = (o & 1) || (o == 0);
12126         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12127         o_conv = CommitmentTransaction_clone(&o_conv);
12128         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
12129         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
12130         return (uint32_t)ret_conv;
12131 }
12132
12133 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_err"))) TS_CResult_CommitmentTransactionDecodeErrorZ_err(uint32_t e) {
12134         LDKDecodeError e_conv;
12135         e_conv.inner = (void*)(e & (~1));
12136         e_conv.is_owned = (e & 1) || (e == 0);
12137         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12138         e_conv = DecodeError_clone(&e_conv);
12139         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
12140         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
12141         return (uint32_t)ret_conv;
12142 }
12143
12144 jboolean  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_is_ok"))) TS_CResult_CommitmentTransactionDecodeErrorZ_is_ok(uint32_t o) {
12145         LDKCResult_CommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(o & ~1);
12146         jboolean ret_conv = CResult_CommitmentTransactionDecodeErrorZ_is_ok(o_conv);
12147         return ret_conv;
12148 }
12149
12150 void  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_free"))) TS_CResult_CommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
12151         if ((_res & 1) != 0) return;
12152         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12153         CHECK_ACCESS(_res_ptr);
12154         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(_res_ptr);
12155         FREE((void*)_res);
12156         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
12157 }
12158
12159 static inline uintptr_t CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
12160         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
12161         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(arg);
12162         return (uint32_t)ret_conv;
12163 }
12164 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_clone_ptr"))) TS_CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(uint32_t arg) {
12165         LDKCResult_CommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
12166         uint32_t ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
12167         return ret_conv;
12168 }
12169
12170 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_clone"))) TS_CResult_CommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
12171         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(orig & ~1);
12172         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
12173         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
12174         return (uint32_t)ret_conv;
12175 }
12176
12177 uint32_t  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_ok"))) TS_CResult_TrustedCommitmentTransactionNoneZ_ok(uint32_t o) {
12178         LDKTrustedCommitmentTransaction o_conv;
12179         o_conv.inner = (void*)(o & (~1));
12180         o_conv.is_owned = (o & 1) || (o == 0);
12181         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12182         // WARNING: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
12183         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
12184         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
12185         return (uint32_t)ret_conv;
12186 }
12187
12188 uint32_t  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_err"))) TS_CResult_TrustedCommitmentTransactionNoneZ_err() {
12189         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
12190         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
12191         return (uint32_t)ret_conv;
12192 }
12193
12194 jboolean  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_is_ok"))) TS_CResult_TrustedCommitmentTransactionNoneZ_is_ok(uint32_t o) {
12195         LDKCResult_TrustedCommitmentTransactionNoneZ* o_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(o & ~1);
12196         jboolean ret_conv = CResult_TrustedCommitmentTransactionNoneZ_is_ok(o_conv);
12197         return ret_conv;
12198 }
12199
12200 void  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_free"))) TS_CResult_TrustedCommitmentTransactionNoneZ_free(uint32_t _res) {
12201         if ((_res & 1) != 0) return;
12202         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12203         CHECK_ACCESS(_res_ptr);
12204         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(_res_ptr);
12205         FREE((void*)_res);
12206         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
12207 }
12208
12209 uint32_t  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_ok"))) TS_CResult_CVec_SignatureZNoneZ_ok(ptrArray o) {
12210         LDKCVec_SignatureZ o_constr;
12211         o_constr.datalen = o->arr_len;
12212         if (o_constr.datalen > 0)
12213                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
12214         else
12215                 o_constr.data = NULL;
12216         int8_tArray* o_vals = (void*) o->elems;
12217         for (size_t m = 0; m < o_constr.datalen; m++) {
12218                 int8_tArray o_conv_12 = o_vals[m];
12219                 LDKSignature o_conv_12_ref;
12220                 CHECK(o_conv_12->arr_len == 64);
12221                 memcpy(o_conv_12_ref.compact_form, o_conv_12->elems, 64); FREE(o_conv_12);
12222                 o_constr.data[m] = o_conv_12_ref;
12223         }
12224         FREE(o);
12225         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
12226         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
12227         return (uint32_t)ret_conv;
12228 }
12229
12230 uint32_t  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_err"))) TS_CResult_CVec_SignatureZNoneZ_err() {
12231         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
12232         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
12233         return (uint32_t)ret_conv;
12234 }
12235
12236 jboolean  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_is_ok"))) TS_CResult_CVec_SignatureZNoneZ_is_ok(uint32_t o) {
12237         LDKCResult_CVec_SignatureZNoneZ* o_conv = (LDKCResult_CVec_SignatureZNoneZ*)(o & ~1);
12238         jboolean ret_conv = CResult_CVec_SignatureZNoneZ_is_ok(o_conv);
12239         return ret_conv;
12240 }
12241
12242 void  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_free"))) TS_CResult_CVec_SignatureZNoneZ_free(uint32_t _res) {
12243         if ((_res & 1) != 0) return;
12244         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12245         CHECK_ACCESS(_res_ptr);
12246         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(_res_ptr);
12247         FREE((void*)_res);
12248         CResult_CVec_SignatureZNoneZ_free(_res_conv);
12249 }
12250
12251 static inline uintptr_t CResult_CVec_SignatureZNoneZ_clone_ptr(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR arg) {
12252         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
12253         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(arg);
12254         return (uint32_t)ret_conv;
12255 }
12256 uint32_t  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_clone_ptr"))) TS_CResult_CVec_SignatureZNoneZ_clone_ptr(uint32_t arg) {
12257         LDKCResult_CVec_SignatureZNoneZ* arg_conv = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
12258         uint32_t ret_conv = CResult_CVec_SignatureZNoneZ_clone_ptr(arg_conv);
12259         return ret_conv;
12260 }
12261
12262 uint32_t  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_clone"))) TS_CResult_CVec_SignatureZNoneZ_clone(uint32_t orig) {
12263         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)(orig & ~1);
12264         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
12265         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
12266         return (uint32_t)ret_conv;
12267 }
12268
12269 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_ok"))) TS_CResult_ShutdownScriptDecodeErrorZ_ok(uint32_t o) {
12270         LDKShutdownScript o_conv;
12271         o_conv.inner = (void*)(o & (~1));
12272         o_conv.is_owned = (o & 1) || (o == 0);
12273         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12274         o_conv = ShutdownScript_clone(&o_conv);
12275         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
12276         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_ok(o_conv);
12277         return (uint32_t)ret_conv;
12278 }
12279
12280 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_err"))) TS_CResult_ShutdownScriptDecodeErrorZ_err(uint32_t e) {
12281         LDKDecodeError e_conv;
12282         e_conv.inner = (void*)(e & (~1));
12283         e_conv.is_owned = (e & 1) || (e == 0);
12284         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12285         e_conv = DecodeError_clone(&e_conv);
12286         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
12287         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_err(e_conv);
12288         return (uint32_t)ret_conv;
12289 }
12290
12291 jboolean  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_is_ok"))) TS_CResult_ShutdownScriptDecodeErrorZ_is_ok(uint32_t o) {
12292         LDKCResult_ShutdownScriptDecodeErrorZ* o_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(o & ~1);
12293         jboolean ret_conv = CResult_ShutdownScriptDecodeErrorZ_is_ok(o_conv);
12294         return ret_conv;
12295 }
12296
12297 void  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_free"))) TS_CResult_ShutdownScriptDecodeErrorZ_free(uint32_t _res) {
12298         if ((_res & 1) != 0) return;
12299         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12300         CHECK_ACCESS(_res_ptr);
12301         LDKCResult_ShutdownScriptDecodeErrorZ _res_conv = *(LDKCResult_ShutdownScriptDecodeErrorZ*)(_res_ptr);
12302         FREE((void*)_res);
12303         CResult_ShutdownScriptDecodeErrorZ_free(_res_conv);
12304 }
12305
12306 static inline uintptr_t CResult_ShutdownScriptDecodeErrorZ_clone_ptr(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR arg) {
12307         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
12308         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(arg);
12309         return (uint32_t)ret_conv;
12310 }
12311 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_clone_ptr"))) TS_CResult_ShutdownScriptDecodeErrorZ_clone_ptr(uint32_t arg) {
12312         LDKCResult_ShutdownScriptDecodeErrorZ* arg_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(arg & ~1);
12313         uint32_t ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone_ptr(arg_conv);
12314         return ret_conv;
12315 }
12316
12317 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_clone"))) TS_CResult_ShutdownScriptDecodeErrorZ_clone(uint32_t orig) {
12318         LDKCResult_ShutdownScriptDecodeErrorZ* orig_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(orig & ~1);
12319         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
12320         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(orig_conv);
12321         return (uint32_t)ret_conv;
12322 }
12323
12324 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_ok"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_ok(uint32_t o) {
12325         LDKShutdownScript o_conv;
12326         o_conv.inner = (void*)(o & (~1));
12327         o_conv.is_owned = (o & 1) || (o == 0);
12328         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12329         o_conv = ShutdownScript_clone(&o_conv);
12330         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
12331         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_ok(o_conv);
12332         return (uint32_t)ret_conv;
12333 }
12334
12335 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_err"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_err(uint32_t e) {
12336         LDKInvalidShutdownScript e_conv;
12337         e_conv.inner = (void*)(e & (~1));
12338         e_conv.is_owned = (e & 1) || (e == 0);
12339         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12340         e_conv = InvalidShutdownScript_clone(&e_conv);
12341         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
12342         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_err(e_conv);
12343         return (uint32_t)ret_conv;
12344 }
12345
12346 jboolean  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok(uint32_t o) {
12347         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* o_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(o & ~1);
12348         jboolean ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok(o_conv);
12349         return ret_conv;
12350 }
12351
12352 void  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_free"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_free(uint32_t _res) {
12353         if ((_res & 1) != 0) return;
12354         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12355         CHECK_ACCESS(_res_ptr);
12356         LDKCResult_ShutdownScriptInvalidShutdownScriptZ _res_conv = *(LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(_res_ptr);
12357         FREE((void*)_res);
12358         CResult_ShutdownScriptInvalidShutdownScriptZ_free(_res_conv);
12359 }
12360
12361 static inline uintptr_t CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR arg) {
12362         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
12363         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(arg);
12364         return (uint32_t)ret_conv;
12365 }
12366 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(uint32_t arg) {
12367         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* arg_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(arg & ~1);
12368         uint32_t ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(arg_conv);
12369         return ret_conv;
12370 }
12371
12372 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_clone"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_clone(uint32_t orig) {
12373         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* orig_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(orig & ~1);
12374         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
12375         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(orig_conv);
12376         return (uint32_t)ret_conv;
12377 }
12378
12379 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_ok"))) TS_CResult_RouteHopDecodeErrorZ_ok(uint32_t o) {
12380         LDKRouteHop o_conv;
12381         o_conv.inner = (void*)(o & (~1));
12382         o_conv.is_owned = (o & 1) || (o == 0);
12383         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12384         o_conv = RouteHop_clone(&o_conv);
12385         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
12386         *ret_conv = CResult_RouteHopDecodeErrorZ_ok(o_conv);
12387         return (uint32_t)ret_conv;
12388 }
12389
12390 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_err"))) TS_CResult_RouteHopDecodeErrorZ_err(uint32_t e) {
12391         LDKDecodeError e_conv;
12392         e_conv.inner = (void*)(e & (~1));
12393         e_conv.is_owned = (e & 1) || (e == 0);
12394         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12395         e_conv = DecodeError_clone(&e_conv);
12396         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
12397         *ret_conv = CResult_RouteHopDecodeErrorZ_err(e_conv);
12398         return (uint32_t)ret_conv;
12399 }
12400
12401 jboolean  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_is_ok"))) TS_CResult_RouteHopDecodeErrorZ_is_ok(uint32_t o) {
12402         LDKCResult_RouteHopDecodeErrorZ* o_conv = (LDKCResult_RouteHopDecodeErrorZ*)(o & ~1);
12403         jboolean ret_conv = CResult_RouteHopDecodeErrorZ_is_ok(o_conv);
12404         return ret_conv;
12405 }
12406
12407 void  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_free"))) TS_CResult_RouteHopDecodeErrorZ_free(uint32_t _res) {
12408         if ((_res & 1) != 0) return;
12409         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12410         CHECK_ACCESS(_res_ptr);
12411         LDKCResult_RouteHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHopDecodeErrorZ*)(_res_ptr);
12412         FREE((void*)_res);
12413         CResult_RouteHopDecodeErrorZ_free(_res_conv);
12414 }
12415
12416 static inline uintptr_t CResult_RouteHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR arg) {
12417         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
12418         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(arg);
12419         return (uint32_t)ret_conv;
12420 }
12421 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_clone_ptr"))) TS_CResult_RouteHopDecodeErrorZ_clone_ptr(uint32_t arg) {
12422         LDKCResult_RouteHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
12423         uint32_t ret_conv = CResult_RouteHopDecodeErrorZ_clone_ptr(arg_conv);
12424         return ret_conv;
12425 }
12426
12427 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_clone"))) TS_CResult_RouteHopDecodeErrorZ_clone(uint32_t orig) {
12428         LDKCResult_RouteHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHopDecodeErrorZ*)(orig & ~1);
12429         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
12430         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(orig_conv);
12431         return (uint32_t)ret_conv;
12432 }
12433
12434 void  __attribute__((export_name("TS_CVec_RouteHopZ_free"))) TS_CVec_RouteHopZ_free(uint32_tArray _res) {
12435         LDKCVec_RouteHopZ _res_constr;
12436         _res_constr.datalen = _res->arr_len;
12437         if (_res_constr.datalen > 0)
12438                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
12439         else
12440                 _res_constr.data = NULL;
12441         uint32_t* _res_vals = _res->elems;
12442         for (size_t k = 0; k < _res_constr.datalen; k++) {
12443                 uint32_t _res_conv_10 = _res_vals[k];
12444                 LDKRouteHop _res_conv_10_conv;
12445                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
12446                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
12447                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
12448                 _res_constr.data[k] = _res_conv_10_conv;
12449         }
12450         FREE(_res);
12451         CVec_RouteHopZ_free(_res_constr);
12452 }
12453
12454 void  __attribute__((export_name("TS_CVec_CVec_RouteHopZZ_free"))) TS_CVec_CVec_RouteHopZZ_free(ptrArray _res) {
12455         LDKCVec_CVec_RouteHopZZ _res_constr;
12456         _res_constr.datalen = _res->arr_len;
12457         if (_res_constr.datalen > 0)
12458                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
12459         else
12460                 _res_constr.data = NULL;
12461         uint32_tArray* _res_vals = (void*) _res->elems;
12462         for (size_t m = 0; m < _res_constr.datalen; m++) {
12463                 uint32_tArray _res_conv_12 = _res_vals[m];
12464                 LDKCVec_RouteHopZ _res_conv_12_constr;
12465                 _res_conv_12_constr.datalen = _res_conv_12->arr_len;
12466                 if (_res_conv_12_constr.datalen > 0)
12467                         _res_conv_12_constr.data = MALLOC(_res_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
12468                 else
12469                         _res_conv_12_constr.data = NULL;
12470                 uint32_t* _res_conv_12_vals = _res_conv_12->elems;
12471                 for (size_t k = 0; k < _res_conv_12_constr.datalen; k++) {
12472                         uint32_t _res_conv_12_conv_10 = _res_conv_12_vals[k];
12473                         LDKRouteHop _res_conv_12_conv_10_conv;
12474                         _res_conv_12_conv_10_conv.inner = (void*)(_res_conv_12_conv_10 & (~1));
12475                         _res_conv_12_conv_10_conv.is_owned = (_res_conv_12_conv_10 & 1) || (_res_conv_12_conv_10 == 0);
12476                         CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_12_conv_10_conv);
12477                         _res_conv_12_constr.data[k] = _res_conv_12_conv_10_conv;
12478                 }
12479                 FREE(_res_conv_12);
12480                 _res_constr.data[m] = _res_conv_12_constr;
12481         }
12482         FREE(_res);
12483         CVec_CVec_RouteHopZZ_free(_res_constr);
12484 }
12485
12486 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_ok"))) TS_CResult_RouteDecodeErrorZ_ok(uint32_t o) {
12487         LDKRoute o_conv;
12488         o_conv.inner = (void*)(o & (~1));
12489         o_conv.is_owned = (o & 1) || (o == 0);
12490         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12491         o_conv = Route_clone(&o_conv);
12492         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
12493         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
12494         return (uint32_t)ret_conv;
12495 }
12496
12497 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_err"))) TS_CResult_RouteDecodeErrorZ_err(uint32_t e) {
12498         LDKDecodeError e_conv;
12499         e_conv.inner = (void*)(e & (~1));
12500         e_conv.is_owned = (e & 1) || (e == 0);
12501         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12502         e_conv = DecodeError_clone(&e_conv);
12503         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
12504         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
12505         return (uint32_t)ret_conv;
12506 }
12507
12508 jboolean  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_is_ok"))) TS_CResult_RouteDecodeErrorZ_is_ok(uint32_t o) {
12509         LDKCResult_RouteDecodeErrorZ* o_conv = (LDKCResult_RouteDecodeErrorZ*)(o & ~1);
12510         jboolean ret_conv = CResult_RouteDecodeErrorZ_is_ok(o_conv);
12511         return ret_conv;
12512 }
12513
12514 void  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_free"))) TS_CResult_RouteDecodeErrorZ_free(uint32_t _res) {
12515         if ((_res & 1) != 0) return;
12516         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12517         CHECK_ACCESS(_res_ptr);
12518         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(_res_ptr);
12519         FREE((void*)_res);
12520         CResult_RouteDecodeErrorZ_free(_res_conv);
12521 }
12522
12523 static inline uintptr_t CResult_RouteDecodeErrorZ_clone_ptr(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR arg) {
12524         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
12525         *ret_conv = CResult_RouteDecodeErrorZ_clone(arg);
12526         return (uint32_t)ret_conv;
12527 }
12528 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_clone_ptr"))) TS_CResult_RouteDecodeErrorZ_clone_ptr(uint32_t arg) {
12529         LDKCResult_RouteDecodeErrorZ* arg_conv = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
12530         uint32_t ret_conv = CResult_RouteDecodeErrorZ_clone_ptr(arg_conv);
12531         return ret_conv;
12532 }
12533
12534 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_clone"))) TS_CResult_RouteDecodeErrorZ_clone(uint32_t orig) {
12535         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)(orig & ~1);
12536         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
12537         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
12538         return (uint32_t)ret_conv;
12539 }
12540
12541 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_ok"))) TS_CResult_RouteParametersDecodeErrorZ_ok(uint32_t o) {
12542         LDKRouteParameters o_conv;
12543         o_conv.inner = (void*)(o & (~1));
12544         o_conv.is_owned = (o & 1) || (o == 0);
12545         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12546         o_conv = RouteParameters_clone(&o_conv);
12547         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
12548         *ret_conv = CResult_RouteParametersDecodeErrorZ_ok(o_conv);
12549         return (uint32_t)ret_conv;
12550 }
12551
12552 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_err"))) TS_CResult_RouteParametersDecodeErrorZ_err(uint32_t e) {
12553         LDKDecodeError e_conv;
12554         e_conv.inner = (void*)(e & (~1));
12555         e_conv.is_owned = (e & 1) || (e == 0);
12556         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12557         e_conv = DecodeError_clone(&e_conv);
12558         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
12559         *ret_conv = CResult_RouteParametersDecodeErrorZ_err(e_conv);
12560         return (uint32_t)ret_conv;
12561 }
12562
12563 jboolean  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_is_ok"))) TS_CResult_RouteParametersDecodeErrorZ_is_ok(uint32_t o) {
12564         LDKCResult_RouteParametersDecodeErrorZ* o_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(o & ~1);
12565         jboolean ret_conv = CResult_RouteParametersDecodeErrorZ_is_ok(o_conv);
12566         return ret_conv;
12567 }
12568
12569 void  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_free"))) TS_CResult_RouteParametersDecodeErrorZ_free(uint32_t _res) {
12570         if ((_res & 1) != 0) return;
12571         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12572         CHECK_ACCESS(_res_ptr);
12573         LDKCResult_RouteParametersDecodeErrorZ _res_conv = *(LDKCResult_RouteParametersDecodeErrorZ*)(_res_ptr);
12574         FREE((void*)_res);
12575         CResult_RouteParametersDecodeErrorZ_free(_res_conv);
12576 }
12577
12578 static inline uintptr_t CResult_RouteParametersDecodeErrorZ_clone_ptr(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR arg) {
12579         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
12580         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(arg);
12581         return (uint32_t)ret_conv;
12582 }
12583 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_clone_ptr"))) TS_CResult_RouteParametersDecodeErrorZ_clone_ptr(uint32_t arg) {
12584         LDKCResult_RouteParametersDecodeErrorZ* arg_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(arg & ~1);
12585         uint32_t ret_conv = CResult_RouteParametersDecodeErrorZ_clone_ptr(arg_conv);
12586         return ret_conv;
12587 }
12588
12589 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_clone"))) TS_CResult_RouteParametersDecodeErrorZ_clone(uint32_t orig) {
12590         LDKCResult_RouteParametersDecodeErrorZ* orig_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(orig & ~1);
12591         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
12592         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(orig_conv);
12593         return (uint32_t)ret_conv;
12594 }
12595
12596 void  __attribute__((export_name("TS_CVec_RouteHintZ_free"))) TS_CVec_RouteHintZ_free(uint32_tArray _res) {
12597         LDKCVec_RouteHintZ _res_constr;
12598         _res_constr.datalen = _res->arr_len;
12599         if (_res_constr.datalen > 0)
12600                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
12601         else
12602                 _res_constr.data = NULL;
12603         uint32_t* _res_vals = _res->elems;
12604         for (size_t l = 0; l < _res_constr.datalen; l++) {
12605                 uint32_t _res_conv_11 = _res_vals[l];
12606                 LDKRouteHint _res_conv_11_conv;
12607                 _res_conv_11_conv.inner = (void*)(_res_conv_11 & (~1));
12608                 _res_conv_11_conv.is_owned = (_res_conv_11 & 1) || (_res_conv_11 == 0);
12609                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_11_conv);
12610                 _res_constr.data[l] = _res_conv_11_conv;
12611         }
12612         FREE(_res);
12613         CVec_RouteHintZ_free(_res_constr);
12614 }
12615
12616 uint32_t  __attribute__((export_name("TS_COption_u64Z_some"))) TS_COption_u64Z_some(int64_t o) {
12617         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
12618         *ret_copy = COption_u64Z_some(o);
12619         uint32_t ret_ref = (uintptr_t)ret_copy;
12620         return ret_ref;
12621 }
12622
12623 uint32_t  __attribute__((export_name("TS_COption_u64Z_none"))) TS_COption_u64Z_none() {
12624         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
12625         *ret_copy = COption_u64Z_none();
12626         uint32_t ret_ref = (uintptr_t)ret_copy;
12627         return ret_ref;
12628 }
12629
12630 void  __attribute__((export_name("TS_COption_u64Z_free"))) TS_COption_u64Z_free(uint32_t _res) {
12631         if ((_res & 1) != 0) return;
12632         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12633         CHECK_ACCESS(_res_ptr);
12634         LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(_res_ptr);
12635         FREE((void*)_res);
12636         COption_u64Z_free(_res_conv);
12637 }
12638
12639 static inline uintptr_t COption_u64Z_clone_ptr(LDKCOption_u64Z *NONNULL_PTR arg) {
12640         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
12641         *ret_copy = COption_u64Z_clone(arg);
12642 uint32_t ret_ref = (uintptr_t)ret_copy;
12643         return ret_ref;
12644 }
12645 uint32_t  __attribute__((export_name("TS_COption_u64Z_clone_ptr"))) TS_COption_u64Z_clone_ptr(uint32_t arg) {
12646         LDKCOption_u64Z* arg_conv = (LDKCOption_u64Z*)arg;
12647         uint32_t ret_conv = COption_u64Z_clone_ptr(arg_conv);
12648         return ret_conv;
12649 }
12650
12651 uint32_t  __attribute__((export_name("TS_COption_u64Z_clone"))) TS_COption_u64Z_clone(uint32_t orig) {
12652         LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)orig;
12653         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
12654         *ret_copy = COption_u64Z_clone(orig_conv);
12655         uint32_t ret_ref = (uintptr_t)ret_copy;
12656         return ret_ref;
12657 }
12658
12659 void  __attribute__((export_name("TS_CVec_u64Z_free"))) TS_CVec_u64Z_free(int64_tArray _res) {
12660         LDKCVec_u64Z _res_constr;
12661         _res_constr.datalen = _res->arr_len;
12662         if (_res_constr.datalen > 0)
12663                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
12664         else
12665                 _res_constr.data = NULL;
12666         int64_t* _res_vals = _res->elems;
12667         for (size_t i = 0; i < _res_constr.datalen; i++) {
12668                 int64_t _res_conv_8 = _res_vals[i];
12669                 _res_constr.data[i] = _res_conv_8;
12670         }
12671         FREE(_res);
12672         CVec_u64Z_free(_res_constr);
12673 }
12674
12675 uint32_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_ok"))) TS_CResult_PaymentParametersDecodeErrorZ_ok(uint32_t o) {
12676         LDKPaymentParameters o_conv;
12677         o_conv.inner = (void*)(o & (~1));
12678         o_conv.is_owned = (o & 1) || (o == 0);
12679         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12680         o_conv = PaymentParameters_clone(&o_conv);
12681         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
12682         *ret_conv = CResult_PaymentParametersDecodeErrorZ_ok(o_conv);
12683         return (uint32_t)ret_conv;
12684 }
12685
12686 uint32_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_err"))) TS_CResult_PaymentParametersDecodeErrorZ_err(uint32_t e) {
12687         LDKDecodeError e_conv;
12688         e_conv.inner = (void*)(e & (~1));
12689         e_conv.is_owned = (e & 1) || (e == 0);
12690         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12691         e_conv = DecodeError_clone(&e_conv);
12692         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
12693         *ret_conv = CResult_PaymentParametersDecodeErrorZ_err(e_conv);
12694         return (uint32_t)ret_conv;
12695 }
12696
12697 jboolean  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_is_ok"))) TS_CResult_PaymentParametersDecodeErrorZ_is_ok(uint32_t o) {
12698         LDKCResult_PaymentParametersDecodeErrorZ* o_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(o & ~1);
12699         jboolean ret_conv = CResult_PaymentParametersDecodeErrorZ_is_ok(o_conv);
12700         return ret_conv;
12701 }
12702
12703 void  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_free"))) TS_CResult_PaymentParametersDecodeErrorZ_free(uint32_t _res) {
12704         if ((_res & 1) != 0) return;
12705         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12706         CHECK_ACCESS(_res_ptr);
12707         LDKCResult_PaymentParametersDecodeErrorZ _res_conv = *(LDKCResult_PaymentParametersDecodeErrorZ*)(_res_ptr);
12708         FREE((void*)_res);
12709         CResult_PaymentParametersDecodeErrorZ_free(_res_conv);
12710 }
12711
12712 static inline uintptr_t CResult_PaymentParametersDecodeErrorZ_clone_ptr(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR arg) {
12713         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
12714         *ret_conv = CResult_PaymentParametersDecodeErrorZ_clone(arg);
12715         return (uint32_t)ret_conv;
12716 }
12717 uint32_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_clone_ptr"))) TS_CResult_PaymentParametersDecodeErrorZ_clone_ptr(uint32_t arg) {
12718         LDKCResult_PaymentParametersDecodeErrorZ* arg_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(arg & ~1);
12719         uint32_t ret_conv = CResult_PaymentParametersDecodeErrorZ_clone_ptr(arg_conv);
12720         return ret_conv;
12721 }
12722
12723 uint32_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_clone"))) TS_CResult_PaymentParametersDecodeErrorZ_clone(uint32_t orig) {
12724         LDKCResult_PaymentParametersDecodeErrorZ* orig_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(orig & ~1);
12725         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
12726         *ret_conv = CResult_PaymentParametersDecodeErrorZ_clone(orig_conv);
12727         return (uint32_t)ret_conv;
12728 }
12729
12730 void  __attribute__((export_name("TS_CVec_RouteHintHopZ_free"))) TS_CVec_RouteHintHopZ_free(uint32_tArray _res) {
12731         LDKCVec_RouteHintHopZ _res_constr;
12732         _res_constr.datalen = _res->arr_len;
12733         if (_res_constr.datalen > 0)
12734                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
12735         else
12736                 _res_constr.data = NULL;
12737         uint32_t* _res_vals = _res->elems;
12738         for (size_t o = 0; o < _res_constr.datalen; o++) {
12739                 uint32_t _res_conv_14 = _res_vals[o];
12740                 LDKRouteHintHop _res_conv_14_conv;
12741                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
12742                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
12743                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
12744                 _res_constr.data[o] = _res_conv_14_conv;
12745         }
12746         FREE(_res);
12747         CVec_RouteHintHopZ_free(_res_constr);
12748 }
12749
12750 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_ok"))) TS_CResult_RouteHintDecodeErrorZ_ok(uint32_t o) {
12751         LDKRouteHint o_conv;
12752         o_conv.inner = (void*)(o & (~1));
12753         o_conv.is_owned = (o & 1) || (o == 0);
12754         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12755         o_conv = RouteHint_clone(&o_conv);
12756         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
12757         *ret_conv = CResult_RouteHintDecodeErrorZ_ok(o_conv);
12758         return (uint32_t)ret_conv;
12759 }
12760
12761 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_err"))) TS_CResult_RouteHintDecodeErrorZ_err(uint32_t e) {
12762         LDKDecodeError e_conv;
12763         e_conv.inner = (void*)(e & (~1));
12764         e_conv.is_owned = (e & 1) || (e == 0);
12765         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12766         e_conv = DecodeError_clone(&e_conv);
12767         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
12768         *ret_conv = CResult_RouteHintDecodeErrorZ_err(e_conv);
12769         return (uint32_t)ret_conv;
12770 }
12771
12772 jboolean  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_is_ok"))) TS_CResult_RouteHintDecodeErrorZ_is_ok(uint32_t o) {
12773         LDKCResult_RouteHintDecodeErrorZ* o_conv = (LDKCResult_RouteHintDecodeErrorZ*)(o & ~1);
12774         jboolean ret_conv = CResult_RouteHintDecodeErrorZ_is_ok(o_conv);
12775         return ret_conv;
12776 }
12777
12778 void  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_free"))) TS_CResult_RouteHintDecodeErrorZ_free(uint32_t _res) {
12779         if ((_res & 1) != 0) return;
12780         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12781         CHECK_ACCESS(_res_ptr);
12782         LDKCResult_RouteHintDecodeErrorZ _res_conv = *(LDKCResult_RouteHintDecodeErrorZ*)(_res_ptr);
12783         FREE((void*)_res);
12784         CResult_RouteHintDecodeErrorZ_free(_res_conv);
12785 }
12786
12787 static inline uintptr_t CResult_RouteHintDecodeErrorZ_clone_ptr(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR arg) {
12788         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
12789         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(arg);
12790         return (uint32_t)ret_conv;
12791 }
12792 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_clone_ptr"))) TS_CResult_RouteHintDecodeErrorZ_clone_ptr(uint32_t arg) {
12793         LDKCResult_RouteHintDecodeErrorZ* arg_conv = (LDKCResult_RouteHintDecodeErrorZ*)(arg & ~1);
12794         uint32_t ret_conv = CResult_RouteHintDecodeErrorZ_clone_ptr(arg_conv);
12795         return ret_conv;
12796 }
12797
12798 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_clone"))) TS_CResult_RouteHintDecodeErrorZ_clone(uint32_t orig) {
12799         LDKCResult_RouteHintDecodeErrorZ* orig_conv = (LDKCResult_RouteHintDecodeErrorZ*)(orig & ~1);
12800         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
12801         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(orig_conv);
12802         return (uint32_t)ret_conv;
12803 }
12804
12805 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_ok"))) TS_CResult_RouteHintHopDecodeErrorZ_ok(uint32_t o) {
12806         LDKRouteHintHop o_conv;
12807         o_conv.inner = (void*)(o & (~1));
12808         o_conv.is_owned = (o & 1) || (o == 0);
12809         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12810         o_conv = RouteHintHop_clone(&o_conv);
12811         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
12812         *ret_conv = CResult_RouteHintHopDecodeErrorZ_ok(o_conv);
12813         return (uint32_t)ret_conv;
12814 }
12815
12816 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_err"))) TS_CResult_RouteHintHopDecodeErrorZ_err(uint32_t e) {
12817         LDKDecodeError e_conv;
12818         e_conv.inner = (void*)(e & (~1));
12819         e_conv.is_owned = (e & 1) || (e == 0);
12820         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12821         e_conv = DecodeError_clone(&e_conv);
12822         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
12823         *ret_conv = CResult_RouteHintHopDecodeErrorZ_err(e_conv);
12824         return (uint32_t)ret_conv;
12825 }
12826
12827 jboolean  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_is_ok"))) TS_CResult_RouteHintHopDecodeErrorZ_is_ok(uint32_t o) {
12828         LDKCResult_RouteHintHopDecodeErrorZ* o_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(o & ~1);
12829         jboolean ret_conv = CResult_RouteHintHopDecodeErrorZ_is_ok(o_conv);
12830         return ret_conv;
12831 }
12832
12833 void  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_free"))) TS_CResult_RouteHintHopDecodeErrorZ_free(uint32_t _res) {
12834         if ((_res & 1) != 0) return;
12835         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12836         CHECK_ACCESS(_res_ptr);
12837         LDKCResult_RouteHintHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHintHopDecodeErrorZ*)(_res_ptr);
12838         FREE((void*)_res);
12839         CResult_RouteHintHopDecodeErrorZ_free(_res_conv);
12840 }
12841
12842 static inline uintptr_t CResult_RouteHintHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR arg) {
12843         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
12844         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(arg);
12845         return (uint32_t)ret_conv;
12846 }
12847 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_clone_ptr"))) TS_CResult_RouteHintHopDecodeErrorZ_clone_ptr(uint32_t arg) {
12848         LDKCResult_RouteHintHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(arg & ~1);
12849         uint32_t ret_conv = CResult_RouteHintHopDecodeErrorZ_clone_ptr(arg_conv);
12850         return ret_conv;
12851 }
12852
12853 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_clone"))) TS_CResult_RouteHintHopDecodeErrorZ_clone(uint32_t orig) {
12854         LDKCResult_RouteHintHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(orig & ~1);
12855         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
12856         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(orig_conv);
12857         return (uint32_t)ret_conv;
12858 }
12859
12860 void  __attribute__((export_name("TS_CVec_ChannelDetailsZ_free"))) TS_CVec_ChannelDetailsZ_free(uint32_tArray _res) {
12861         LDKCVec_ChannelDetailsZ _res_constr;
12862         _res_constr.datalen = _res->arr_len;
12863         if (_res_constr.datalen > 0)
12864                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
12865         else
12866                 _res_constr.data = NULL;
12867         uint32_t* _res_vals = _res->elems;
12868         for (size_t q = 0; q < _res_constr.datalen; q++) {
12869                 uint32_t _res_conv_16 = _res_vals[q];
12870                 LDKChannelDetails _res_conv_16_conv;
12871                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
12872                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
12873                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
12874                 _res_constr.data[q] = _res_conv_16_conv;
12875         }
12876         FREE(_res);
12877         CVec_ChannelDetailsZ_free(_res_constr);
12878 }
12879
12880 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_ok"))) TS_CResult_RouteLightningErrorZ_ok(uint32_t o) {
12881         LDKRoute o_conv;
12882         o_conv.inner = (void*)(o & (~1));
12883         o_conv.is_owned = (o & 1) || (o == 0);
12884         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12885         o_conv = Route_clone(&o_conv);
12886         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
12887         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
12888         return (uint32_t)ret_conv;
12889 }
12890
12891 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_err"))) TS_CResult_RouteLightningErrorZ_err(uint32_t e) {
12892         LDKLightningError e_conv;
12893         e_conv.inner = (void*)(e & (~1));
12894         e_conv.is_owned = (e & 1) || (e == 0);
12895         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12896         e_conv = LightningError_clone(&e_conv);
12897         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
12898         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
12899         return (uint32_t)ret_conv;
12900 }
12901
12902 jboolean  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_is_ok"))) TS_CResult_RouteLightningErrorZ_is_ok(uint32_t o) {
12903         LDKCResult_RouteLightningErrorZ* o_conv = (LDKCResult_RouteLightningErrorZ*)(o & ~1);
12904         jboolean ret_conv = CResult_RouteLightningErrorZ_is_ok(o_conv);
12905         return ret_conv;
12906 }
12907
12908 void  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_free"))) TS_CResult_RouteLightningErrorZ_free(uint32_t _res) {
12909         if ((_res & 1) != 0) return;
12910         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12911         CHECK_ACCESS(_res_ptr);
12912         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(_res_ptr);
12913         FREE((void*)_res);
12914         CResult_RouteLightningErrorZ_free(_res_conv);
12915 }
12916
12917 static inline uintptr_t CResult_RouteLightningErrorZ_clone_ptr(LDKCResult_RouteLightningErrorZ *NONNULL_PTR arg) {
12918         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
12919         *ret_conv = CResult_RouteLightningErrorZ_clone(arg);
12920         return (uint32_t)ret_conv;
12921 }
12922 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_clone_ptr"))) TS_CResult_RouteLightningErrorZ_clone_ptr(uint32_t arg) {
12923         LDKCResult_RouteLightningErrorZ* arg_conv = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
12924         uint32_t ret_conv = CResult_RouteLightningErrorZ_clone_ptr(arg_conv);
12925         return ret_conv;
12926 }
12927
12928 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_clone"))) TS_CResult_RouteLightningErrorZ_clone(uint32_t orig) {
12929         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)(orig & ~1);
12930         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
12931         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
12932         return (uint32_t)ret_conv;
12933 }
12934
12935 void  __attribute__((export_name("TS_CVec_PublicKeyZ_free"))) TS_CVec_PublicKeyZ_free(ptrArray _res) {
12936         LDKCVec_PublicKeyZ _res_constr;
12937         _res_constr.datalen = _res->arr_len;
12938         if (_res_constr.datalen > 0)
12939                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
12940         else
12941                 _res_constr.data = NULL;
12942         int8_tArray* _res_vals = (void*) _res->elems;
12943         for (size_t m = 0; m < _res_constr.datalen; m++) {
12944                 int8_tArray _res_conv_12 = _res_vals[m];
12945                 LDKPublicKey _res_conv_12_ref;
12946                 CHECK(_res_conv_12->arr_len == 33);
12947                 memcpy(_res_conv_12_ref.compressed_form, _res_conv_12->elems, 33); FREE(_res_conv_12);
12948                 _res_constr.data[m] = _res_conv_12_ref;
12949         }
12950         FREE(_res);
12951         CVec_PublicKeyZ_free(_res_constr);
12952 }
12953
12954 uint32_t  __attribute__((export_name("TS_CResult_PaymentPurposeDecodeErrorZ_ok"))) TS_CResult_PaymentPurposeDecodeErrorZ_ok(uint32_t o) {
12955         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12956         CHECK_ACCESS(o_ptr);
12957         LDKPaymentPurpose o_conv = *(LDKPaymentPurpose*)(o_ptr);
12958         o_conv = PaymentPurpose_clone((LDKPaymentPurpose*)(((uintptr_t)o) & ~1));
12959         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
12960         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_ok(o_conv);
12961         return (uint32_t)ret_conv;
12962 }
12963
12964 uint32_t  __attribute__((export_name("TS_CResult_PaymentPurposeDecodeErrorZ_err"))) TS_CResult_PaymentPurposeDecodeErrorZ_err(uint32_t e) {
12965         LDKDecodeError e_conv;
12966         e_conv.inner = (void*)(e & (~1));
12967         e_conv.is_owned = (e & 1) || (e == 0);
12968         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12969         e_conv = DecodeError_clone(&e_conv);
12970         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
12971         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_err(e_conv);
12972         return (uint32_t)ret_conv;
12973 }
12974
12975 jboolean  __attribute__((export_name("TS_CResult_PaymentPurposeDecodeErrorZ_is_ok"))) TS_CResult_PaymentPurposeDecodeErrorZ_is_ok(uint32_t o) {
12976         LDKCResult_PaymentPurposeDecodeErrorZ* o_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)(o & ~1);
12977         jboolean ret_conv = CResult_PaymentPurposeDecodeErrorZ_is_ok(o_conv);
12978         return ret_conv;
12979 }
12980
12981 void  __attribute__((export_name("TS_CResult_PaymentPurposeDecodeErrorZ_free"))) TS_CResult_PaymentPurposeDecodeErrorZ_free(uint32_t _res) {
12982         if ((_res & 1) != 0) return;
12983         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12984         CHECK_ACCESS(_res_ptr);
12985         LDKCResult_PaymentPurposeDecodeErrorZ _res_conv = *(LDKCResult_PaymentPurposeDecodeErrorZ*)(_res_ptr);
12986         FREE((void*)_res);
12987         CResult_PaymentPurposeDecodeErrorZ_free(_res_conv);
12988 }
12989
12990 static inline uintptr_t CResult_PaymentPurposeDecodeErrorZ_clone_ptr(LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR arg) {
12991         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
12992         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_clone(arg);
12993         return (uint32_t)ret_conv;
12994 }
12995 uint32_t  __attribute__((export_name("TS_CResult_PaymentPurposeDecodeErrorZ_clone_ptr"))) TS_CResult_PaymentPurposeDecodeErrorZ_clone_ptr(uint32_t arg) {
12996         LDKCResult_PaymentPurposeDecodeErrorZ* arg_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)(arg & ~1);
12997         uint32_t ret_conv = CResult_PaymentPurposeDecodeErrorZ_clone_ptr(arg_conv);
12998         return ret_conv;
12999 }
13000
13001 uint32_t  __attribute__((export_name("TS_CResult_PaymentPurposeDecodeErrorZ_clone"))) TS_CResult_PaymentPurposeDecodeErrorZ_clone(uint32_t orig) {
13002         LDKCResult_PaymentPurposeDecodeErrorZ* orig_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)(orig & ~1);
13003         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
13004         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_clone(orig_conv);
13005         return (uint32_t)ret_conv;
13006 }
13007
13008 uint32_t  __attribute__((export_name("TS_COption_ClosureReasonZ_some"))) TS_COption_ClosureReasonZ_some(uint32_t o) {
13009         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
13010         CHECK_ACCESS(o_ptr);
13011         LDKClosureReason o_conv = *(LDKClosureReason*)(o_ptr);
13012         o_conv = ClosureReason_clone((LDKClosureReason*)(((uintptr_t)o) & ~1));
13013         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
13014         *ret_copy = COption_ClosureReasonZ_some(o_conv);
13015         uint32_t ret_ref = (uintptr_t)ret_copy;
13016         return ret_ref;
13017 }
13018
13019 uint32_t  __attribute__((export_name("TS_COption_ClosureReasonZ_none"))) TS_COption_ClosureReasonZ_none() {
13020         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
13021         *ret_copy = COption_ClosureReasonZ_none();
13022         uint32_t ret_ref = (uintptr_t)ret_copy;
13023         return ret_ref;
13024 }
13025
13026 void  __attribute__((export_name("TS_COption_ClosureReasonZ_free"))) TS_COption_ClosureReasonZ_free(uint32_t _res) {
13027         if ((_res & 1) != 0) return;
13028         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13029         CHECK_ACCESS(_res_ptr);
13030         LDKCOption_ClosureReasonZ _res_conv = *(LDKCOption_ClosureReasonZ*)(_res_ptr);
13031         FREE((void*)_res);
13032         COption_ClosureReasonZ_free(_res_conv);
13033 }
13034
13035 static inline uintptr_t COption_ClosureReasonZ_clone_ptr(LDKCOption_ClosureReasonZ *NONNULL_PTR arg) {
13036         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
13037         *ret_copy = COption_ClosureReasonZ_clone(arg);
13038 uint32_t ret_ref = (uintptr_t)ret_copy;
13039         return ret_ref;
13040 }
13041 uint32_t  __attribute__((export_name("TS_COption_ClosureReasonZ_clone_ptr"))) TS_COption_ClosureReasonZ_clone_ptr(uint32_t arg) {
13042         LDKCOption_ClosureReasonZ* arg_conv = (LDKCOption_ClosureReasonZ*)arg;
13043         uint32_t ret_conv = COption_ClosureReasonZ_clone_ptr(arg_conv);
13044         return ret_conv;
13045 }
13046
13047 uint32_t  __attribute__((export_name("TS_COption_ClosureReasonZ_clone"))) TS_COption_ClosureReasonZ_clone(uint32_t orig) {
13048         LDKCOption_ClosureReasonZ* orig_conv = (LDKCOption_ClosureReasonZ*)orig;
13049         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
13050         *ret_copy = COption_ClosureReasonZ_clone(orig_conv);
13051         uint32_t ret_ref = (uintptr_t)ret_copy;
13052         return ret_ref;
13053 }
13054
13055 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_ok"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_ok(uint32_t o) {
13056         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
13057         CHECK_ACCESS(o_ptr);
13058         LDKCOption_ClosureReasonZ o_conv = *(LDKCOption_ClosureReasonZ*)(o_ptr);
13059         o_conv = COption_ClosureReasonZ_clone((LDKCOption_ClosureReasonZ*)(((uintptr_t)o) & ~1));
13060         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
13061         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_ok(o_conv);
13062         return (uint32_t)ret_conv;
13063 }
13064
13065 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_err"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_err(uint32_t e) {
13066         LDKDecodeError e_conv;
13067         e_conv.inner = (void*)(e & (~1));
13068         e_conv.is_owned = (e & 1) || (e == 0);
13069         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13070         e_conv = DecodeError_clone(&e_conv);
13071         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
13072         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_err(e_conv);
13073         return (uint32_t)ret_conv;
13074 }
13075
13076 jboolean  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_is_ok"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(uint32_t o) {
13077         LDKCResult_COption_ClosureReasonZDecodeErrorZ* o_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(o & ~1);
13078         jboolean ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(o_conv);
13079         return ret_conv;
13080 }
13081
13082 void  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_free"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_free(uint32_t _res) {
13083         if ((_res & 1) != 0) return;
13084         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13085         CHECK_ACCESS(_res_ptr);
13086         LDKCResult_COption_ClosureReasonZDecodeErrorZ _res_conv = *(LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(_res_ptr);
13087         FREE((void*)_res);
13088         CResult_COption_ClosureReasonZDecodeErrorZ_free(_res_conv);
13089 }
13090
13091 static inline uintptr_t CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR arg) {
13092         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
13093         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(arg);
13094         return (uint32_t)ret_conv;
13095 }
13096 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(uint32_t arg) {
13097         LDKCResult_COption_ClosureReasonZDecodeErrorZ* arg_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(arg & ~1);
13098         uint32_t ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(arg_conv);
13099         return ret_conv;
13100 }
13101
13102 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_clone"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_clone(uint32_t orig) {
13103         LDKCResult_COption_ClosureReasonZDecodeErrorZ* orig_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(orig & ~1);
13104         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
13105         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(orig_conv);
13106         return (uint32_t)ret_conv;
13107 }
13108
13109 uint32_t  __attribute__((export_name("TS_COption_HTLCDestinationZ_some"))) TS_COption_HTLCDestinationZ_some(uint32_t o) {
13110         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
13111         CHECK_ACCESS(o_ptr);
13112         LDKHTLCDestination o_conv = *(LDKHTLCDestination*)(o_ptr);
13113         o_conv = HTLCDestination_clone((LDKHTLCDestination*)(((uintptr_t)o) & ~1));
13114         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
13115         *ret_copy = COption_HTLCDestinationZ_some(o_conv);
13116         uint32_t ret_ref = (uintptr_t)ret_copy;
13117         return ret_ref;
13118 }
13119
13120 uint32_t  __attribute__((export_name("TS_COption_HTLCDestinationZ_none"))) TS_COption_HTLCDestinationZ_none() {
13121         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
13122         *ret_copy = COption_HTLCDestinationZ_none();
13123         uint32_t ret_ref = (uintptr_t)ret_copy;
13124         return ret_ref;
13125 }
13126
13127 void  __attribute__((export_name("TS_COption_HTLCDestinationZ_free"))) TS_COption_HTLCDestinationZ_free(uint32_t _res) {
13128         if ((_res & 1) != 0) return;
13129         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13130         CHECK_ACCESS(_res_ptr);
13131         LDKCOption_HTLCDestinationZ _res_conv = *(LDKCOption_HTLCDestinationZ*)(_res_ptr);
13132         FREE((void*)_res);
13133         COption_HTLCDestinationZ_free(_res_conv);
13134 }
13135
13136 static inline uintptr_t COption_HTLCDestinationZ_clone_ptr(LDKCOption_HTLCDestinationZ *NONNULL_PTR arg) {
13137         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
13138         *ret_copy = COption_HTLCDestinationZ_clone(arg);
13139 uint32_t ret_ref = (uintptr_t)ret_copy;
13140         return ret_ref;
13141 }
13142 uint32_t  __attribute__((export_name("TS_COption_HTLCDestinationZ_clone_ptr"))) TS_COption_HTLCDestinationZ_clone_ptr(uint32_t arg) {
13143         LDKCOption_HTLCDestinationZ* arg_conv = (LDKCOption_HTLCDestinationZ*)arg;
13144         uint32_t ret_conv = COption_HTLCDestinationZ_clone_ptr(arg_conv);
13145         return ret_conv;
13146 }
13147
13148 uint32_t  __attribute__((export_name("TS_COption_HTLCDestinationZ_clone"))) TS_COption_HTLCDestinationZ_clone(uint32_t orig) {
13149         LDKCOption_HTLCDestinationZ* orig_conv = (LDKCOption_HTLCDestinationZ*)orig;
13150         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
13151         *ret_copy = COption_HTLCDestinationZ_clone(orig_conv);
13152         uint32_t ret_ref = (uintptr_t)ret_copy;
13153         return ret_ref;
13154 }
13155
13156 uint32_t  __attribute__((export_name("TS_CResult_COption_HTLCDestinationZDecodeErrorZ_ok"))) TS_CResult_COption_HTLCDestinationZDecodeErrorZ_ok(uint32_t o) {
13157         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
13158         CHECK_ACCESS(o_ptr);
13159         LDKCOption_HTLCDestinationZ o_conv = *(LDKCOption_HTLCDestinationZ*)(o_ptr);
13160         o_conv = COption_HTLCDestinationZ_clone((LDKCOption_HTLCDestinationZ*)(((uintptr_t)o) & ~1));
13161         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
13162         *ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_ok(o_conv);
13163         return (uint32_t)ret_conv;
13164 }
13165
13166 uint32_t  __attribute__((export_name("TS_CResult_COption_HTLCDestinationZDecodeErrorZ_err"))) TS_CResult_COption_HTLCDestinationZDecodeErrorZ_err(uint32_t e) {
13167         LDKDecodeError e_conv;
13168         e_conv.inner = (void*)(e & (~1));
13169         e_conv.is_owned = (e & 1) || (e == 0);
13170         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13171         e_conv = DecodeError_clone(&e_conv);
13172         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
13173         *ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_err(e_conv);
13174         return (uint32_t)ret_conv;
13175 }
13176
13177 jboolean  __attribute__((export_name("TS_CResult_COption_HTLCDestinationZDecodeErrorZ_is_ok"))) TS_CResult_COption_HTLCDestinationZDecodeErrorZ_is_ok(uint32_t o) {
13178         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* o_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)(o & ~1);
13179         jboolean ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_is_ok(o_conv);
13180         return ret_conv;
13181 }
13182
13183 void  __attribute__((export_name("TS_CResult_COption_HTLCDestinationZDecodeErrorZ_free"))) TS_CResult_COption_HTLCDestinationZDecodeErrorZ_free(uint32_t _res) {
13184         if ((_res & 1) != 0) return;
13185         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13186         CHECK_ACCESS(_res_ptr);
13187         LDKCResult_COption_HTLCDestinationZDecodeErrorZ _res_conv = *(LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)(_res_ptr);
13188         FREE((void*)_res);
13189         CResult_COption_HTLCDestinationZDecodeErrorZ_free(_res_conv);
13190 }
13191
13192 static inline uintptr_t CResult_COption_HTLCDestinationZDecodeErrorZ_clone_ptr(LDKCResult_COption_HTLCDestinationZDecodeErrorZ *NONNULL_PTR arg) {
13193         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
13194         *ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_clone(arg);
13195         return (uint32_t)ret_conv;
13196 }
13197 uint32_t  __attribute__((export_name("TS_CResult_COption_HTLCDestinationZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_HTLCDestinationZDecodeErrorZ_clone_ptr(uint32_t arg) {
13198         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* arg_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)(arg & ~1);
13199         uint32_t ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_clone_ptr(arg_conv);
13200         return ret_conv;
13201 }
13202
13203 uint32_t  __attribute__((export_name("TS_CResult_COption_HTLCDestinationZDecodeErrorZ_clone"))) TS_CResult_COption_HTLCDestinationZDecodeErrorZ_clone(uint32_t orig) {
13204         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* orig_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)(orig & ~1);
13205         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
13206         *ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_clone(orig_conv);
13207         return (uint32_t)ret_conv;
13208 }
13209
13210 uint32_t  __attribute__((export_name("TS_COption_NetworkUpdateZ_some"))) TS_COption_NetworkUpdateZ_some(uint32_t o) {
13211         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
13212         CHECK_ACCESS(o_ptr);
13213         LDKNetworkUpdate o_conv = *(LDKNetworkUpdate*)(o_ptr);
13214         o_conv = NetworkUpdate_clone((LDKNetworkUpdate*)(((uintptr_t)o) & ~1));
13215         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
13216         *ret_copy = COption_NetworkUpdateZ_some(o_conv);
13217         uint32_t ret_ref = (uintptr_t)ret_copy;
13218         return ret_ref;
13219 }
13220
13221 uint32_t  __attribute__((export_name("TS_COption_NetworkUpdateZ_none"))) TS_COption_NetworkUpdateZ_none() {
13222         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
13223         *ret_copy = COption_NetworkUpdateZ_none();
13224         uint32_t ret_ref = (uintptr_t)ret_copy;
13225         return ret_ref;
13226 }
13227
13228 void  __attribute__((export_name("TS_COption_NetworkUpdateZ_free"))) TS_COption_NetworkUpdateZ_free(uint32_t _res) {
13229         if ((_res & 1) != 0) return;
13230         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13231         CHECK_ACCESS(_res_ptr);
13232         LDKCOption_NetworkUpdateZ _res_conv = *(LDKCOption_NetworkUpdateZ*)(_res_ptr);
13233         FREE((void*)_res);
13234         COption_NetworkUpdateZ_free(_res_conv);
13235 }
13236
13237 static inline uintptr_t COption_NetworkUpdateZ_clone_ptr(LDKCOption_NetworkUpdateZ *NONNULL_PTR arg) {
13238         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
13239         *ret_copy = COption_NetworkUpdateZ_clone(arg);
13240 uint32_t ret_ref = (uintptr_t)ret_copy;
13241         return ret_ref;
13242 }
13243 uint32_t  __attribute__((export_name("TS_COption_NetworkUpdateZ_clone_ptr"))) TS_COption_NetworkUpdateZ_clone_ptr(uint32_t arg) {
13244         LDKCOption_NetworkUpdateZ* arg_conv = (LDKCOption_NetworkUpdateZ*)arg;
13245         uint32_t ret_conv = COption_NetworkUpdateZ_clone_ptr(arg_conv);
13246         return ret_conv;
13247 }
13248
13249 uint32_t  __attribute__((export_name("TS_COption_NetworkUpdateZ_clone"))) TS_COption_NetworkUpdateZ_clone(uint32_t orig) {
13250         LDKCOption_NetworkUpdateZ* orig_conv = (LDKCOption_NetworkUpdateZ*)orig;
13251         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
13252         *ret_copy = COption_NetworkUpdateZ_clone(orig_conv);
13253         uint32_t ret_ref = (uintptr_t)ret_copy;
13254         return ret_ref;
13255 }
13256
13257 void  __attribute__((export_name("TS_CVec_SpendableOutputDescriptorZ_free"))) TS_CVec_SpendableOutputDescriptorZ_free(uint32_tArray _res) {
13258         LDKCVec_SpendableOutputDescriptorZ _res_constr;
13259         _res_constr.datalen = _res->arr_len;
13260         if (_res_constr.datalen > 0)
13261                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
13262         else
13263                 _res_constr.data = NULL;
13264         uint32_t* _res_vals = _res->elems;
13265         for (size_t b = 0; b < _res_constr.datalen; b++) {
13266                 uint32_t _res_conv_27 = _res_vals[b];
13267                 void* _res_conv_27_ptr = (void*)(((uintptr_t)_res_conv_27) & ~1);
13268                 CHECK_ACCESS(_res_conv_27_ptr);
13269                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(_res_conv_27_ptr);
13270                 FREE((void*)_res_conv_27);
13271                 _res_constr.data[b] = _res_conv_27_conv;
13272         }
13273         FREE(_res);
13274         CVec_SpendableOutputDescriptorZ_free(_res_constr);
13275 }
13276
13277 uint32_t  __attribute__((export_name("TS_COption_EventZ_some"))) TS_COption_EventZ_some(uint32_t o) {
13278         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
13279         CHECK_ACCESS(o_ptr);
13280         LDKEvent o_conv = *(LDKEvent*)(o_ptr);
13281         o_conv = Event_clone((LDKEvent*)(((uintptr_t)o) & ~1));
13282         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
13283         *ret_copy = COption_EventZ_some(o_conv);
13284         uint32_t ret_ref = (uintptr_t)ret_copy;
13285         return ret_ref;
13286 }
13287
13288 uint32_t  __attribute__((export_name("TS_COption_EventZ_none"))) TS_COption_EventZ_none() {
13289         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
13290         *ret_copy = COption_EventZ_none();
13291         uint32_t ret_ref = (uintptr_t)ret_copy;
13292         return ret_ref;
13293 }
13294
13295 void  __attribute__((export_name("TS_COption_EventZ_free"))) TS_COption_EventZ_free(uint32_t _res) {
13296         if ((_res & 1) != 0) return;
13297         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13298         CHECK_ACCESS(_res_ptr);
13299         LDKCOption_EventZ _res_conv = *(LDKCOption_EventZ*)(_res_ptr);
13300         FREE((void*)_res);
13301         COption_EventZ_free(_res_conv);
13302 }
13303
13304 static inline uintptr_t COption_EventZ_clone_ptr(LDKCOption_EventZ *NONNULL_PTR arg) {
13305         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
13306         *ret_copy = COption_EventZ_clone(arg);
13307 uint32_t ret_ref = (uintptr_t)ret_copy;
13308         return ret_ref;
13309 }
13310 uint32_t  __attribute__((export_name("TS_COption_EventZ_clone_ptr"))) TS_COption_EventZ_clone_ptr(uint32_t arg) {
13311         LDKCOption_EventZ* arg_conv = (LDKCOption_EventZ*)arg;
13312         uint32_t ret_conv = COption_EventZ_clone_ptr(arg_conv);
13313         return ret_conv;
13314 }
13315
13316 uint32_t  __attribute__((export_name("TS_COption_EventZ_clone"))) TS_COption_EventZ_clone(uint32_t orig) {
13317         LDKCOption_EventZ* orig_conv = (LDKCOption_EventZ*)orig;
13318         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
13319         *ret_copy = COption_EventZ_clone(orig_conv);
13320         uint32_t ret_ref = (uintptr_t)ret_copy;
13321         return ret_ref;
13322 }
13323
13324 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_ok"))) TS_CResult_COption_EventZDecodeErrorZ_ok(uint32_t o) {
13325         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
13326         CHECK_ACCESS(o_ptr);
13327         LDKCOption_EventZ o_conv = *(LDKCOption_EventZ*)(o_ptr);
13328         o_conv = COption_EventZ_clone((LDKCOption_EventZ*)(((uintptr_t)o) & ~1));
13329         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
13330         *ret_conv = CResult_COption_EventZDecodeErrorZ_ok(o_conv);
13331         return (uint32_t)ret_conv;
13332 }
13333
13334 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_err"))) TS_CResult_COption_EventZDecodeErrorZ_err(uint32_t e) {
13335         LDKDecodeError e_conv;
13336         e_conv.inner = (void*)(e & (~1));
13337         e_conv.is_owned = (e & 1) || (e == 0);
13338         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13339         e_conv = DecodeError_clone(&e_conv);
13340         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
13341         *ret_conv = CResult_COption_EventZDecodeErrorZ_err(e_conv);
13342         return (uint32_t)ret_conv;
13343 }
13344
13345 jboolean  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_is_ok"))) TS_CResult_COption_EventZDecodeErrorZ_is_ok(uint32_t o) {
13346         LDKCResult_COption_EventZDecodeErrorZ* o_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(o & ~1);
13347         jboolean ret_conv = CResult_COption_EventZDecodeErrorZ_is_ok(o_conv);
13348         return ret_conv;
13349 }
13350
13351 void  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_free"))) TS_CResult_COption_EventZDecodeErrorZ_free(uint32_t _res) {
13352         if ((_res & 1) != 0) return;
13353         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13354         CHECK_ACCESS(_res_ptr);
13355         LDKCResult_COption_EventZDecodeErrorZ _res_conv = *(LDKCResult_COption_EventZDecodeErrorZ*)(_res_ptr);
13356         FREE((void*)_res);
13357         CResult_COption_EventZDecodeErrorZ_free(_res_conv);
13358 }
13359
13360 static inline uintptr_t CResult_COption_EventZDecodeErrorZ_clone_ptr(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR arg) {
13361         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
13362         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(arg);
13363         return (uint32_t)ret_conv;
13364 }
13365 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_EventZDecodeErrorZ_clone_ptr(uint32_t arg) {
13366         LDKCResult_COption_EventZDecodeErrorZ* arg_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(arg & ~1);
13367         uint32_t ret_conv = CResult_COption_EventZDecodeErrorZ_clone_ptr(arg_conv);
13368         return ret_conv;
13369 }
13370
13371 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_clone"))) TS_CResult_COption_EventZDecodeErrorZ_clone(uint32_t orig) {
13372         LDKCResult_COption_EventZDecodeErrorZ* orig_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(orig & ~1);
13373         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
13374         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(orig_conv);
13375         return (uint32_t)ret_conv;
13376 }
13377
13378 void  __attribute__((export_name("TS_CVec_MessageSendEventZ_free"))) TS_CVec_MessageSendEventZ_free(uint32_tArray _res) {
13379         LDKCVec_MessageSendEventZ _res_constr;
13380         _res_constr.datalen = _res->arr_len;
13381         if (_res_constr.datalen > 0)
13382                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
13383         else
13384                 _res_constr.data = NULL;
13385         uint32_t* _res_vals = _res->elems;
13386         for (size_t s = 0; s < _res_constr.datalen; s++) {
13387                 uint32_t _res_conv_18 = _res_vals[s];
13388                 void* _res_conv_18_ptr = (void*)(((uintptr_t)_res_conv_18) & ~1);
13389                 CHECK_ACCESS(_res_conv_18_ptr);
13390                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(_res_conv_18_ptr);
13391                 FREE((void*)_res_conv_18);
13392                 _res_constr.data[s] = _res_conv_18_conv;
13393         }
13394         FREE(_res);
13395         CVec_MessageSendEventZ_free(_res_constr);
13396 }
13397
13398 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_ok"))) TS_CResult_TxOutAccessErrorZ_ok(uint32_t o) {
13399         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
13400         CHECK_ACCESS(o_ptr);
13401         LDKTxOut o_conv = *(LDKTxOut*)(o_ptr);
13402         o_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)o) & ~1));
13403         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
13404         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
13405         return (uint32_t)ret_conv;
13406 }
13407
13408 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_err"))) TS_CResult_TxOutAccessErrorZ_err(uint32_t e) {
13409         LDKAccessError e_conv = LDKAccessError_from_js(e);
13410         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
13411         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
13412         return (uint32_t)ret_conv;
13413 }
13414
13415 jboolean  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_is_ok"))) TS_CResult_TxOutAccessErrorZ_is_ok(uint32_t o) {
13416         LDKCResult_TxOutAccessErrorZ* o_conv = (LDKCResult_TxOutAccessErrorZ*)(o & ~1);
13417         jboolean ret_conv = CResult_TxOutAccessErrorZ_is_ok(o_conv);
13418         return ret_conv;
13419 }
13420
13421 void  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_free"))) TS_CResult_TxOutAccessErrorZ_free(uint32_t _res) {
13422         if ((_res & 1) != 0) return;
13423         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13424         CHECK_ACCESS(_res_ptr);
13425         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(_res_ptr);
13426         FREE((void*)_res);
13427         CResult_TxOutAccessErrorZ_free(_res_conv);
13428 }
13429
13430 static inline uintptr_t CResult_TxOutAccessErrorZ_clone_ptr(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR arg) {
13431         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
13432         *ret_conv = CResult_TxOutAccessErrorZ_clone(arg);
13433         return (uint32_t)ret_conv;
13434 }
13435 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_clone_ptr"))) TS_CResult_TxOutAccessErrorZ_clone_ptr(uint32_t arg) {
13436         LDKCResult_TxOutAccessErrorZ* arg_conv = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
13437         uint32_t ret_conv = CResult_TxOutAccessErrorZ_clone_ptr(arg_conv);
13438         return ret_conv;
13439 }
13440
13441 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_clone"))) TS_CResult_TxOutAccessErrorZ_clone(uint32_t orig) {
13442         LDKCResult_TxOutAccessErrorZ* orig_conv = (LDKCResult_TxOutAccessErrorZ*)(orig & ~1);
13443         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
13444         *ret_conv = CResult_TxOutAccessErrorZ_clone(orig_conv);
13445         return (uint32_t)ret_conv;
13446 }
13447
13448 static inline uintptr_t C2Tuple_usizeTransactionZ_clone_ptr(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR arg) {
13449         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
13450         *ret_conv = C2Tuple_usizeTransactionZ_clone(arg);
13451         return ((uint32_t)ret_conv);
13452 }
13453 uint32_t  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_clone_ptr"))) TS_C2Tuple_usizeTransactionZ_clone_ptr(uint32_t arg) {
13454         LDKC2Tuple_usizeTransactionZ* arg_conv = (LDKC2Tuple_usizeTransactionZ*)(arg & ~1);
13455         uint32_t ret_conv = C2Tuple_usizeTransactionZ_clone_ptr(arg_conv);
13456         return ret_conv;
13457 }
13458
13459 uint32_t  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_clone"))) TS_C2Tuple_usizeTransactionZ_clone(uint32_t orig) {
13460         LDKC2Tuple_usizeTransactionZ* orig_conv = (LDKC2Tuple_usizeTransactionZ*)(orig & ~1);
13461         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
13462         *ret_conv = C2Tuple_usizeTransactionZ_clone(orig_conv);
13463         return ((uint32_t)ret_conv);
13464 }
13465
13466 uint32_t  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_new"))) TS_C2Tuple_usizeTransactionZ_new(uint32_t a, int8_tArray b) {
13467         LDKTransaction b_ref;
13468         b_ref.datalen = b->arr_len;
13469         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
13470         memcpy(b_ref.data, b->elems, b_ref.datalen); FREE(b);
13471         b_ref.data_is_owned = true;
13472         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
13473         *ret_conv = C2Tuple_usizeTransactionZ_new(a, b_ref);
13474         return ((uint32_t)ret_conv);
13475 }
13476
13477 void  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_free"))) TS_C2Tuple_usizeTransactionZ_free(uint32_t _res) {
13478         if ((_res & 1) != 0) return;
13479         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13480         CHECK_ACCESS(_res_ptr);
13481         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_ptr);
13482         FREE((void*)_res);
13483         C2Tuple_usizeTransactionZ_free(_res_conv);
13484 }
13485
13486 void  __attribute__((export_name("TS_CVec_C2Tuple_usizeTransactionZZ_free"))) TS_CVec_C2Tuple_usizeTransactionZZ_free(uint32_tArray _res) {
13487         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
13488         _res_constr.datalen = _res->arr_len;
13489         if (_res_constr.datalen > 0)
13490                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
13491         else
13492                 _res_constr.data = NULL;
13493         uint32_t* _res_vals = _res->elems;
13494         for (size_t c = 0; c < _res_constr.datalen; c++) {
13495                 uint32_t _res_conv_28 = _res_vals[c];
13496                 void* _res_conv_28_ptr = (void*)(((uintptr_t)_res_conv_28) & ~1);
13497                 CHECK_ACCESS(_res_conv_28_ptr);
13498                 LDKC2Tuple_usizeTransactionZ _res_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_conv_28_ptr);
13499                 FREE((void*)_res_conv_28);
13500                 _res_constr.data[c] = _res_conv_28_conv;
13501         }
13502         FREE(_res);
13503         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
13504 }
13505
13506 void  __attribute__((export_name("TS_CVec_TxidZ_free"))) TS_CVec_TxidZ_free(ptrArray _res) {
13507         LDKCVec_TxidZ _res_constr;
13508         _res_constr.datalen = _res->arr_len;
13509         if (_res_constr.datalen > 0)
13510                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
13511         else
13512                 _res_constr.data = NULL;
13513         int8_tArray* _res_vals = (void*) _res->elems;
13514         for (size_t m = 0; m < _res_constr.datalen; m++) {
13515                 int8_tArray _res_conv_12 = _res_vals[m];
13516                 LDKThirtyTwoBytes _res_conv_12_ref;
13517                 CHECK(_res_conv_12->arr_len == 32);
13518                 memcpy(_res_conv_12_ref.data, _res_conv_12->elems, 32); FREE(_res_conv_12);
13519                 _res_constr.data[m] = _res_conv_12_ref;
13520         }
13521         FREE(_res);
13522         CVec_TxidZ_free(_res_constr);
13523 }
13524
13525 uint32_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_ok"))) TS_CResult_NoneChannelMonitorUpdateErrZ_ok() {
13526         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
13527         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_ok();
13528         return (uint32_t)ret_conv;
13529 }
13530
13531 uint32_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_err"))) TS_CResult_NoneChannelMonitorUpdateErrZ_err(uint32_t e) {
13532         LDKChannelMonitorUpdateErr e_conv = LDKChannelMonitorUpdateErr_from_js(e);
13533         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
13534         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_err(e_conv);
13535         return (uint32_t)ret_conv;
13536 }
13537
13538 jboolean  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_is_ok"))) TS_CResult_NoneChannelMonitorUpdateErrZ_is_ok(uint32_t o) {
13539         LDKCResult_NoneChannelMonitorUpdateErrZ* o_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(o & ~1);
13540         jboolean ret_conv = CResult_NoneChannelMonitorUpdateErrZ_is_ok(o_conv);
13541         return ret_conv;
13542 }
13543
13544 void  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_free"))) TS_CResult_NoneChannelMonitorUpdateErrZ_free(uint32_t _res) {
13545         if ((_res & 1) != 0) return;
13546         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13547         CHECK_ACCESS(_res_ptr);
13548         LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(_res_ptr);
13549         FREE((void*)_res);
13550         CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
13551 }
13552
13553 static inline uintptr_t CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR arg) {
13554         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
13555         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(arg);
13556         return (uint32_t)ret_conv;
13557 }
13558 uint32_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_clone_ptr"))) TS_CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(uint32_t arg) {
13559         LDKCResult_NoneChannelMonitorUpdateErrZ* arg_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
13560         uint32_t ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(arg_conv);
13561         return ret_conv;
13562 }
13563
13564 uint32_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_clone"))) TS_CResult_NoneChannelMonitorUpdateErrZ_clone(uint32_t orig) {
13565         LDKCResult_NoneChannelMonitorUpdateErrZ* orig_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(orig & ~1);
13566         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
13567         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(orig_conv);
13568         return (uint32_t)ret_conv;
13569 }
13570
13571 void  __attribute__((export_name("TS_CVec_MonitorEventZ_free"))) TS_CVec_MonitorEventZ_free(uint32_tArray _res) {
13572         LDKCVec_MonitorEventZ _res_constr;
13573         _res_constr.datalen = _res->arr_len;
13574         if (_res_constr.datalen > 0)
13575                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
13576         else
13577                 _res_constr.data = NULL;
13578         uint32_t* _res_vals = _res->elems;
13579         for (size_t o = 0; o < _res_constr.datalen; o++) {
13580                 uint32_t _res_conv_14 = _res_vals[o];
13581                 void* _res_conv_14_ptr = (void*)(((uintptr_t)_res_conv_14) & ~1);
13582                 CHECK_ACCESS(_res_conv_14_ptr);
13583                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(_res_conv_14_ptr);
13584                 FREE((void*)_res_conv_14);
13585                 _res_constr.data[o] = _res_conv_14_conv;
13586         }
13587         FREE(_res);
13588         CVec_MonitorEventZ_free(_res_constr);
13589 }
13590
13591 static inline uintptr_t C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone_ptr(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *NONNULL_PTR arg) {
13592         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ");
13593         *ret_conv = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone(arg);
13594         return ((uint32_t)ret_conv);
13595 }
13596 uint32_t  __attribute__((export_name("TS_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone_ptr"))) TS_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone_ptr(uint32_t arg) {
13597         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* arg_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(arg & ~1);
13598         uint32_t ret_conv = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone_ptr(arg_conv);
13599         return ret_conv;
13600 }
13601
13602 uint32_t  __attribute__((export_name("TS_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone"))) TS_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone(uint32_t orig) {
13603         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* orig_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(orig & ~1);
13604         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ");
13605         *ret_conv = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone(orig_conv);
13606         return ((uint32_t)ret_conv);
13607 }
13608
13609 uint32_t  __attribute__((export_name("TS_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_new"))) TS_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_new(uint32_t a, uint32_tArray b, int8_tArray c) {
13610         LDKOutPoint a_conv;
13611         a_conv.inner = (void*)(a & (~1));
13612         a_conv.is_owned = (a & 1) || (a == 0);
13613         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
13614         a_conv = OutPoint_clone(&a_conv);
13615         LDKCVec_MonitorEventZ b_constr;
13616         b_constr.datalen = b->arr_len;
13617         if (b_constr.datalen > 0)
13618                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
13619         else
13620                 b_constr.data = NULL;
13621         uint32_t* b_vals = b->elems;
13622         for (size_t o = 0; o < b_constr.datalen; o++) {
13623                 uint32_t b_conv_14 = b_vals[o];
13624                 void* b_conv_14_ptr = (void*)(((uintptr_t)b_conv_14) & ~1);
13625                 CHECK_ACCESS(b_conv_14_ptr);
13626                 LDKMonitorEvent b_conv_14_conv = *(LDKMonitorEvent*)(b_conv_14_ptr);
13627                 b_conv_14_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uintptr_t)b_conv_14) & ~1));
13628                 b_constr.data[o] = b_conv_14_conv;
13629         }
13630         FREE(b);
13631         LDKPublicKey c_ref;
13632         CHECK(c->arr_len == 33);
13633         memcpy(c_ref.compressed_form, c->elems, 33); FREE(c);
13634         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ");
13635         *ret_conv = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_new(a_conv, b_constr, c_ref);
13636         return ((uint32_t)ret_conv);
13637 }
13638
13639 void  __attribute__((export_name("TS_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_free"))) TS_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_free(uint32_t _res) {
13640         if ((_res & 1) != 0) return;
13641         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13642         CHECK_ACCESS(_res_ptr);
13643         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ _res_conv = *(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(_res_ptr);
13644         FREE((void*)_res);
13645         C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_free(_res_conv);
13646 }
13647
13648 void  __attribute__((export_name("TS_CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ_free"))) TS_CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ_free(uint32_tArray _res) {
13649         LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ _res_constr;
13650         _res_constr.datalen = _res->arr_len;
13651         if (_res_constr.datalen > 0)
13652                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ Elements");
13653         else
13654                 _res_constr.data = NULL;
13655         uint32_t* _res_vals = _res->elems;
13656         for (size_t x = 0; x < _res_constr.datalen; x++) {
13657                 uint32_t _res_conv_49 = _res_vals[x];
13658                 void* _res_conv_49_ptr = (void*)(((uintptr_t)_res_conv_49) & ~1);
13659                 CHECK_ACCESS(_res_conv_49_ptr);
13660                 LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ _res_conv_49_conv = *(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(_res_conv_49_ptr);
13661                 FREE((void*)_res_conv_49);
13662                 _res_constr.data[x] = _res_conv_49_conv;
13663         }
13664         FREE(_res);
13665         CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ_free(_res_constr);
13666 }
13667
13668 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_some"))) TS_COption_C2Tuple_usizeTransactionZZ_some(uint32_t o) {
13669         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
13670         CHECK_ACCESS(o_ptr);
13671         LDKC2Tuple_usizeTransactionZ o_conv = *(LDKC2Tuple_usizeTransactionZ*)(o_ptr);
13672         o_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)o) & ~1));
13673         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
13674         *ret_copy = COption_C2Tuple_usizeTransactionZZ_some(o_conv);
13675         uint32_t ret_ref = (uintptr_t)ret_copy;
13676         return ret_ref;
13677 }
13678
13679 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_none"))) TS_COption_C2Tuple_usizeTransactionZZ_none() {
13680         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
13681         *ret_copy = COption_C2Tuple_usizeTransactionZZ_none();
13682         uint32_t ret_ref = (uintptr_t)ret_copy;
13683         return ret_ref;
13684 }
13685
13686 void  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_free"))) TS_COption_C2Tuple_usizeTransactionZZ_free(uint32_t _res) {
13687         if ((_res & 1) != 0) return;
13688         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13689         CHECK_ACCESS(_res_ptr);
13690         LDKCOption_C2Tuple_usizeTransactionZZ _res_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(_res_ptr);
13691         FREE((void*)_res);
13692         COption_C2Tuple_usizeTransactionZZ_free(_res_conv);
13693 }
13694
13695 static inline uintptr_t COption_C2Tuple_usizeTransactionZZ_clone_ptr(LDKCOption_C2Tuple_usizeTransactionZZ *NONNULL_PTR arg) {
13696         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
13697         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(arg);
13698 uint32_t ret_ref = (uintptr_t)ret_copy;
13699         return ret_ref;
13700 }
13701 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_clone_ptr"))) TS_COption_C2Tuple_usizeTransactionZZ_clone_ptr(uint32_t arg) {
13702         LDKCOption_C2Tuple_usizeTransactionZZ* arg_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)arg;
13703         uint32_t ret_conv = COption_C2Tuple_usizeTransactionZZ_clone_ptr(arg_conv);
13704         return ret_conv;
13705 }
13706
13707 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_clone"))) TS_COption_C2Tuple_usizeTransactionZZ_clone(uint32_t orig) {
13708         LDKCOption_C2Tuple_usizeTransactionZZ* orig_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)orig;
13709         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
13710         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(orig_conv);
13711         uint32_t ret_ref = (uintptr_t)ret_copy;
13712         return ret_ref;
13713 }
13714
13715 uint32_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_ok"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_ok(uint32_t o) {
13716         LDKFixedPenaltyScorer o_conv;
13717         o_conv.inner = (void*)(o & (~1));
13718         o_conv.is_owned = (o & 1) || (o == 0);
13719         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13720         o_conv = FixedPenaltyScorer_clone(&o_conv);
13721         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
13722         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_ok(o_conv);
13723         return (uint32_t)ret_conv;
13724 }
13725
13726 uint32_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_err"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_err(uint32_t e) {
13727         LDKDecodeError e_conv;
13728         e_conv.inner = (void*)(e & (~1));
13729         e_conv.is_owned = (e & 1) || (e == 0);
13730         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13731         e_conv = DecodeError_clone(&e_conv);
13732         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
13733         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_err(e_conv);
13734         return (uint32_t)ret_conv;
13735 }
13736
13737 jboolean  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_is_ok"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_is_ok(uint32_t o) {
13738         LDKCResult_FixedPenaltyScorerDecodeErrorZ* o_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(o & ~1);
13739         jboolean ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_is_ok(o_conv);
13740         return ret_conv;
13741 }
13742
13743 void  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_free"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_free(uint32_t _res) {
13744         if ((_res & 1) != 0) return;
13745         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13746         CHECK_ACCESS(_res_ptr);
13747         LDKCResult_FixedPenaltyScorerDecodeErrorZ _res_conv = *(LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(_res_ptr);
13748         FREE((void*)_res);
13749         CResult_FixedPenaltyScorerDecodeErrorZ_free(_res_conv);
13750 }
13751
13752 static inline uintptr_t CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR arg) {
13753         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
13754         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone(arg);
13755         return (uint32_t)ret_conv;
13756 }
13757 uint32_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(uint32_t arg) {
13758         LDKCResult_FixedPenaltyScorerDecodeErrorZ* arg_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(arg & ~1);
13759         uint32_t ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(arg_conv);
13760         return ret_conv;
13761 }
13762
13763 uint32_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_clone"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_clone(uint32_t orig) {
13764         LDKCResult_FixedPenaltyScorerDecodeErrorZ* orig_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(orig & ~1);
13765         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
13766         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone(orig_conv);
13767         return (uint32_t)ret_conv;
13768 }
13769
13770 static inline uintptr_t C2Tuple_u64u64Z_clone_ptr(LDKC2Tuple_u64u64Z *NONNULL_PTR arg) {
13771         LDKC2Tuple_u64u64Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
13772         *ret_conv = C2Tuple_u64u64Z_clone(arg);
13773         return ((uint32_t)ret_conv);
13774 }
13775 uint32_t  __attribute__((export_name("TS_C2Tuple_u64u64Z_clone_ptr"))) TS_C2Tuple_u64u64Z_clone_ptr(uint32_t arg) {
13776         LDKC2Tuple_u64u64Z* arg_conv = (LDKC2Tuple_u64u64Z*)(arg & ~1);
13777         uint32_t ret_conv = C2Tuple_u64u64Z_clone_ptr(arg_conv);
13778         return ret_conv;
13779 }
13780
13781 uint32_t  __attribute__((export_name("TS_C2Tuple_u64u64Z_clone"))) TS_C2Tuple_u64u64Z_clone(uint32_t orig) {
13782         LDKC2Tuple_u64u64Z* orig_conv = (LDKC2Tuple_u64u64Z*)(orig & ~1);
13783         LDKC2Tuple_u64u64Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
13784         *ret_conv = C2Tuple_u64u64Z_clone(orig_conv);
13785         return ((uint32_t)ret_conv);
13786 }
13787
13788 uint32_t  __attribute__((export_name("TS_C2Tuple_u64u64Z_new"))) TS_C2Tuple_u64u64Z_new(int64_t a, int64_t b) {
13789         LDKC2Tuple_u64u64Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
13790         *ret_conv = C2Tuple_u64u64Z_new(a, b);
13791         return ((uint32_t)ret_conv);
13792 }
13793
13794 void  __attribute__((export_name("TS_C2Tuple_u64u64Z_free"))) TS_C2Tuple_u64u64Z_free(uint32_t _res) {
13795         if ((_res & 1) != 0) return;
13796         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13797         CHECK_ACCESS(_res_ptr);
13798         LDKC2Tuple_u64u64Z _res_conv = *(LDKC2Tuple_u64u64Z*)(_res_ptr);
13799         FREE((void*)_res);
13800         C2Tuple_u64u64Z_free(_res_conv);
13801 }
13802
13803 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_u64u64ZZ_some"))) TS_COption_C2Tuple_u64u64ZZ_some(uint32_t o) {
13804         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
13805         CHECK_ACCESS(o_ptr);
13806         LDKC2Tuple_u64u64Z o_conv = *(LDKC2Tuple_u64u64Z*)(o_ptr);
13807         o_conv = C2Tuple_u64u64Z_clone((LDKC2Tuple_u64u64Z*)(((uintptr_t)o) & ~1));
13808         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
13809         *ret_copy = COption_C2Tuple_u64u64ZZ_some(o_conv);
13810         uint32_t ret_ref = (uintptr_t)ret_copy;
13811         return ret_ref;
13812 }
13813
13814 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_u64u64ZZ_none"))) TS_COption_C2Tuple_u64u64ZZ_none() {
13815         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
13816         *ret_copy = COption_C2Tuple_u64u64ZZ_none();
13817         uint32_t ret_ref = (uintptr_t)ret_copy;
13818         return ret_ref;
13819 }
13820
13821 void  __attribute__((export_name("TS_COption_C2Tuple_u64u64ZZ_free"))) TS_COption_C2Tuple_u64u64ZZ_free(uint32_t _res) {
13822         if ((_res & 1) != 0) return;
13823         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13824         CHECK_ACCESS(_res_ptr);
13825         LDKCOption_C2Tuple_u64u64ZZ _res_conv = *(LDKCOption_C2Tuple_u64u64ZZ*)(_res_ptr);
13826         FREE((void*)_res);
13827         COption_C2Tuple_u64u64ZZ_free(_res_conv);
13828 }
13829
13830 static inline uintptr_t COption_C2Tuple_u64u64ZZ_clone_ptr(LDKCOption_C2Tuple_u64u64ZZ *NONNULL_PTR arg) {
13831         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
13832         *ret_copy = COption_C2Tuple_u64u64ZZ_clone(arg);
13833 uint32_t ret_ref = (uintptr_t)ret_copy;
13834         return ret_ref;
13835 }
13836 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_u64u64ZZ_clone_ptr"))) TS_COption_C2Tuple_u64u64ZZ_clone_ptr(uint32_t arg) {
13837         LDKCOption_C2Tuple_u64u64ZZ* arg_conv = (LDKCOption_C2Tuple_u64u64ZZ*)arg;
13838         uint32_t ret_conv = COption_C2Tuple_u64u64ZZ_clone_ptr(arg_conv);
13839         return ret_conv;
13840 }
13841
13842 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_u64u64ZZ_clone"))) TS_COption_C2Tuple_u64u64ZZ_clone(uint32_t orig) {
13843         LDKCOption_C2Tuple_u64u64ZZ* orig_conv = (LDKCOption_C2Tuple_u64u64ZZ*)orig;
13844         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
13845         *ret_copy = COption_C2Tuple_u64u64ZZ_clone(orig_conv);
13846         uint32_t ret_ref = (uintptr_t)ret_copy;
13847         return ret_ref;
13848 }
13849
13850 void  __attribute__((export_name("TS_CVec_NodeIdZ_free"))) TS_CVec_NodeIdZ_free(uint32_tArray _res) {
13851         LDKCVec_NodeIdZ _res_constr;
13852         _res_constr.datalen = _res->arr_len;
13853         if (_res_constr.datalen > 0)
13854                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeId), "LDKCVec_NodeIdZ Elements");
13855         else
13856                 _res_constr.data = NULL;
13857         uint32_t* _res_vals = _res->elems;
13858         for (size_t i = 0; i < _res_constr.datalen; i++) {
13859                 uint32_t _res_conv_8 = _res_vals[i];
13860                 LDKNodeId _res_conv_8_conv;
13861                 _res_conv_8_conv.inner = (void*)(_res_conv_8 & (~1));
13862                 _res_conv_8_conv.is_owned = (_res_conv_8 & 1) || (_res_conv_8 == 0);
13863                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_8_conv);
13864                 _res_constr.data[i] = _res_conv_8_conv;
13865         }
13866         FREE(_res);
13867         CVec_NodeIdZ_free(_res_constr);
13868 }
13869
13870 uint32_t  __attribute__((export_name("TS_CResult_ProbabilisticScorerDecodeErrorZ_ok"))) TS_CResult_ProbabilisticScorerDecodeErrorZ_ok(uint32_t o) {
13871         LDKProbabilisticScorer o_conv;
13872         o_conv.inner = (void*)(o & (~1));
13873         o_conv.is_owned = (o & 1) || (o == 0);
13874         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13875         // WARNING: we need a move here but no clone is available for LDKProbabilisticScorer
13876         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
13877         *ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_ok(o_conv);
13878         return (uint32_t)ret_conv;
13879 }
13880
13881 uint32_t  __attribute__((export_name("TS_CResult_ProbabilisticScorerDecodeErrorZ_err"))) TS_CResult_ProbabilisticScorerDecodeErrorZ_err(uint32_t e) {
13882         LDKDecodeError e_conv;
13883         e_conv.inner = (void*)(e & (~1));
13884         e_conv.is_owned = (e & 1) || (e == 0);
13885         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13886         e_conv = DecodeError_clone(&e_conv);
13887         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
13888         *ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_err(e_conv);
13889         return (uint32_t)ret_conv;
13890 }
13891
13892 jboolean  __attribute__((export_name("TS_CResult_ProbabilisticScorerDecodeErrorZ_is_ok"))) TS_CResult_ProbabilisticScorerDecodeErrorZ_is_ok(uint32_t o) {
13893         LDKCResult_ProbabilisticScorerDecodeErrorZ* o_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)(o & ~1);
13894         jboolean ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_is_ok(o_conv);
13895         return ret_conv;
13896 }
13897
13898 void  __attribute__((export_name("TS_CResult_ProbabilisticScorerDecodeErrorZ_free"))) TS_CResult_ProbabilisticScorerDecodeErrorZ_free(uint32_t _res) {
13899         if ((_res & 1) != 0) return;
13900         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13901         CHECK_ACCESS(_res_ptr);
13902         LDKCResult_ProbabilisticScorerDecodeErrorZ _res_conv = *(LDKCResult_ProbabilisticScorerDecodeErrorZ*)(_res_ptr);
13903         FREE((void*)_res);
13904         CResult_ProbabilisticScorerDecodeErrorZ_free(_res_conv);
13905 }
13906
13907 uint32_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_ok"))) TS_CResult_InitFeaturesDecodeErrorZ_ok(uint32_t o) {
13908         LDKInitFeatures o_conv;
13909         o_conv.inner = (void*)(o & (~1));
13910         o_conv.is_owned = (o & 1) || (o == 0);
13911         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13912         o_conv = InitFeatures_clone(&o_conv);
13913         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
13914         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
13915         return (uint32_t)ret_conv;
13916 }
13917
13918 uint32_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_err"))) TS_CResult_InitFeaturesDecodeErrorZ_err(uint32_t e) {
13919         LDKDecodeError e_conv;
13920         e_conv.inner = (void*)(e & (~1));
13921         e_conv.is_owned = (e & 1) || (e == 0);
13922         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13923         e_conv = DecodeError_clone(&e_conv);
13924         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
13925         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
13926         return (uint32_t)ret_conv;
13927 }
13928
13929 jboolean  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_is_ok"))) TS_CResult_InitFeaturesDecodeErrorZ_is_ok(uint32_t o) {
13930         LDKCResult_InitFeaturesDecodeErrorZ* o_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(o & ~1);
13931         jboolean ret_conv = CResult_InitFeaturesDecodeErrorZ_is_ok(o_conv);
13932         return ret_conv;
13933 }
13934
13935 void  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_free"))) TS_CResult_InitFeaturesDecodeErrorZ_free(uint32_t _res) {
13936         if ((_res & 1) != 0) return;
13937         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13938         CHECK_ACCESS(_res_ptr);
13939         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(_res_ptr);
13940         FREE((void*)_res);
13941         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
13942 }
13943
13944 static inline uintptr_t CResult_InitFeaturesDecodeErrorZ_clone_ptr(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR arg) {
13945         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
13946         *ret_conv = CResult_InitFeaturesDecodeErrorZ_clone(arg);
13947         return (uint32_t)ret_conv;
13948 }
13949 uint32_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_clone_ptr"))) TS_CResult_InitFeaturesDecodeErrorZ_clone_ptr(uint32_t arg) {
13950         LDKCResult_InitFeaturesDecodeErrorZ* arg_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
13951         uint32_t ret_conv = CResult_InitFeaturesDecodeErrorZ_clone_ptr(arg_conv);
13952         return ret_conv;
13953 }
13954
13955 uint32_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_clone"))) TS_CResult_InitFeaturesDecodeErrorZ_clone(uint32_t orig) {
13956         LDKCResult_InitFeaturesDecodeErrorZ* orig_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(orig & ~1);
13957         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
13958         *ret_conv = CResult_InitFeaturesDecodeErrorZ_clone(orig_conv);
13959         return (uint32_t)ret_conv;
13960 }
13961
13962 uint32_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_ok"))) TS_CResult_ChannelFeaturesDecodeErrorZ_ok(uint32_t o) {
13963         LDKChannelFeatures o_conv;
13964         o_conv.inner = (void*)(o & (~1));
13965         o_conv.is_owned = (o & 1) || (o == 0);
13966         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13967         o_conv = ChannelFeatures_clone(&o_conv);
13968         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
13969         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
13970         return (uint32_t)ret_conv;
13971 }
13972
13973 uint32_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_err"))) TS_CResult_ChannelFeaturesDecodeErrorZ_err(uint32_t e) {
13974         LDKDecodeError e_conv;
13975         e_conv.inner = (void*)(e & (~1));
13976         e_conv.is_owned = (e & 1) || (e == 0);
13977         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13978         e_conv = DecodeError_clone(&e_conv);
13979         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
13980         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
13981         return (uint32_t)ret_conv;
13982 }
13983
13984 jboolean  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_is_ok"))) TS_CResult_ChannelFeaturesDecodeErrorZ_is_ok(uint32_t o) {
13985         LDKCResult_ChannelFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(o & ~1);
13986         jboolean ret_conv = CResult_ChannelFeaturesDecodeErrorZ_is_ok(o_conv);
13987         return ret_conv;
13988 }
13989
13990 void  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_free"))) TS_CResult_ChannelFeaturesDecodeErrorZ_free(uint32_t _res) {
13991         if ((_res & 1) != 0) return;
13992         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13993         CHECK_ACCESS(_res_ptr);
13994         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(_res_ptr);
13995         FREE((void*)_res);
13996         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
13997 }
13998
13999 static inline uintptr_t CResult_ChannelFeaturesDecodeErrorZ_clone_ptr(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR arg) {
14000         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
14001         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_clone(arg);
14002         return (uint32_t)ret_conv;
14003 }
14004 uint32_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelFeaturesDecodeErrorZ_clone_ptr(uint32_t arg) {
14005         LDKCResult_ChannelFeaturesDecodeErrorZ* arg_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
14006         uint32_t ret_conv = CResult_ChannelFeaturesDecodeErrorZ_clone_ptr(arg_conv);
14007         return ret_conv;
14008 }
14009
14010 uint32_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_clone"))) TS_CResult_ChannelFeaturesDecodeErrorZ_clone(uint32_t orig) {
14011         LDKCResult_ChannelFeaturesDecodeErrorZ* orig_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(orig & ~1);
14012         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
14013         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_clone(orig_conv);
14014         return (uint32_t)ret_conv;
14015 }
14016
14017 uint32_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_ok"))) TS_CResult_NodeFeaturesDecodeErrorZ_ok(uint32_t o) {
14018         LDKNodeFeatures o_conv;
14019         o_conv.inner = (void*)(o & (~1));
14020         o_conv.is_owned = (o & 1) || (o == 0);
14021         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14022         o_conv = NodeFeatures_clone(&o_conv);
14023         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
14024         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
14025         return (uint32_t)ret_conv;
14026 }
14027
14028 uint32_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_err"))) TS_CResult_NodeFeaturesDecodeErrorZ_err(uint32_t e) {
14029         LDKDecodeError e_conv;
14030         e_conv.inner = (void*)(e & (~1));
14031         e_conv.is_owned = (e & 1) || (e == 0);
14032         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14033         e_conv = DecodeError_clone(&e_conv);
14034         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
14035         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
14036         return (uint32_t)ret_conv;
14037 }
14038
14039 jboolean  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_is_ok"))) TS_CResult_NodeFeaturesDecodeErrorZ_is_ok(uint32_t o) {
14040         LDKCResult_NodeFeaturesDecodeErrorZ* o_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(o & ~1);
14041         jboolean ret_conv = CResult_NodeFeaturesDecodeErrorZ_is_ok(o_conv);
14042         return ret_conv;
14043 }
14044
14045 void  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_free"))) TS_CResult_NodeFeaturesDecodeErrorZ_free(uint32_t _res) {
14046         if ((_res & 1) != 0) return;
14047         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14048         CHECK_ACCESS(_res_ptr);
14049         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(_res_ptr);
14050         FREE((void*)_res);
14051         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
14052 }
14053
14054 static inline uintptr_t CResult_NodeFeaturesDecodeErrorZ_clone_ptr(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR arg) {
14055         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
14056         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_clone(arg);
14057         return (uint32_t)ret_conv;
14058 }
14059 uint32_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_clone_ptr"))) TS_CResult_NodeFeaturesDecodeErrorZ_clone_ptr(uint32_t arg) {
14060         LDKCResult_NodeFeaturesDecodeErrorZ* arg_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
14061         uint32_t ret_conv = CResult_NodeFeaturesDecodeErrorZ_clone_ptr(arg_conv);
14062         return ret_conv;
14063 }
14064
14065 uint32_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_clone"))) TS_CResult_NodeFeaturesDecodeErrorZ_clone(uint32_t orig) {
14066         LDKCResult_NodeFeaturesDecodeErrorZ* orig_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(orig & ~1);
14067         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
14068         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_clone(orig_conv);
14069         return (uint32_t)ret_conv;
14070 }
14071
14072 uint32_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_ok"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_ok(uint32_t o) {
14073         LDKInvoiceFeatures o_conv;
14074         o_conv.inner = (void*)(o & (~1));
14075         o_conv.is_owned = (o & 1) || (o == 0);
14076         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14077         o_conv = InvoiceFeatures_clone(&o_conv);
14078         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
14079         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_ok(o_conv);
14080         return (uint32_t)ret_conv;
14081 }
14082
14083 uint32_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_err"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_err(uint32_t e) {
14084         LDKDecodeError e_conv;
14085         e_conv.inner = (void*)(e & (~1));
14086         e_conv.is_owned = (e & 1) || (e == 0);
14087         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14088         e_conv = DecodeError_clone(&e_conv);
14089         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
14090         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_err(e_conv);
14091         return (uint32_t)ret_conv;
14092 }
14093
14094 jboolean  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_is_ok"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_is_ok(uint32_t o) {
14095         LDKCResult_InvoiceFeaturesDecodeErrorZ* o_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(o & ~1);
14096         jboolean ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_is_ok(o_conv);
14097         return ret_conv;
14098 }
14099
14100 void  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_free"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_free(uint32_t _res) {
14101         if ((_res & 1) != 0) return;
14102         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14103         CHECK_ACCESS(_res_ptr);
14104         LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(_res_ptr);
14105         FREE((void*)_res);
14106         CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv);
14107 }
14108
14109 static inline uintptr_t CResult_InvoiceFeaturesDecodeErrorZ_clone_ptr(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR arg) {
14110         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
14111         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_clone(arg);
14112         return (uint32_t)ret_conv;
14113 }
14114 uint32_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_clone_ptr"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_clone_ptr(uint32_t arg) {
14115         LDKCResult_InvoiceFeaturesDecodeErrorZ* arg_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
14116         uint32_t ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_clone_ptr(arg_conv);
14117         return ret_conv;
14118 }
14119
14120 uint32_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_clone"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_clone(uint32_t orig) {
14121         LDKCResult_InvoiceFeaturesDecodeErrorZ* orig_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(orig & ~1);
14122         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
14123         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_clone(orig_conv);
14124         return (uint32_t)ret_conv;
14125 }
14126
14127 uint32_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_ok"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_ok(uint32_t o) {
14128         LDKChannelTypeFeatures o_conv;
14129         o_conv.inner = (void*)(o & (~1));
14130         o_conv.is_owned = (o & 1) || (o == 0);
14131         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14132         o_conv = ChannelTypeFeatures_clone(&o_conv);
14133         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
14134         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_ok(o_conv);
14135         return (uint32_t)ret_conv;
14136 }
14137
14138 uint32_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_err"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_err(uint32_t e) {
14139         LDKDecodeError e_conv;
14140         e_conv.inner = (void*)(e & (~1));
14141         e_conv.is_owned = (e & 1) || (e == 0);
14142         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14143         e_conv = DecodeError_clone(&e_conv);
14144         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
14145         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_err(e_conv);
14146         return (uint32_t)ret_conv;
14147 }
14148
14149 jboolean  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok(uint32_t o) {
14150         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(o & ~1);
14151         jboolean ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok(o_conv);
14152         return ret_conv;
14153 }
14154
14155 void  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_free"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_free(uint32_t _res) {
14156         if ((_res & 1) != 0) return;
14157         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14158         CHECK_ACCESS(_res_ptr);
14159         LDKCResult_ChannelTypeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(_res_ptr);
14160         FREE((void*)_res);
14161         CResult_ChannelTypeFeaturesDecodeErrorZ_free(_res_conv);
14162 }
14163
14164 static inline uintptr_t CResult_ChannelTypeFeaturesDecodeErrorZ_clone_ptr(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR arg) {
14165         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
14166         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_clone(arg);
14167         return (uint32_t)ret_conv;
14168 }
14169 uint32_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_clone_ptr(uint32_t arg) {
14170         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* arg_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(arg & ~1);
14171         uint32_t ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_clone_ptr(arg_conv);
14172         return ret_conv;
14173 }
14174
14175 uint32_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_clone"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_clone(uint32_t orig) {
14176         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* orig_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(orig & ~1);
14177         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
14178         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_clone(orig_conv);
14179         return (uint32_t)ret_conv;
14180 }
14181
14182 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_ok"))) TS_CResult_NodeIdDecodeErrorZ_ok(uint32_t o) {
14183         LDKNodeId o_conv;
14184         o_conv.inner = (void*)(o & (~1));
14185         o_conv.is_owned = (o & 1) || (o == 0);
14186         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14187         o_conv = NodeId_clone(&o_conv);
14188         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
14189         *ret_conv = CResult_NodeIdDecodeErrorZ_ok(o_conv);
14190         return (uint32_t)ret_conv;
14191 }
14192
14193 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_err"))) TS_CResult_NodeIdDecodeErrorZ_err(uint32_t e) {
14194         LDKDecodeError e_conv;
14195         e_conv.inner = (void*)(e & (~1));
14196         e_conv.is_owned = (e & 1) || (e == 0);
14197         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14198         e_conv = DecodeError_clone(&e_conv);
14199         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
14200         *ret_conv = CResult_NodeIdDecodeErrorZ_err(e_conv);
14201         return (uint32_t)ret_conv;
14202 }
14203
14204 jboolean  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_is_ok"))) TS_CResult_NodeIdDecodeErrorZ_is_ok(uint32_t o) {
14205         LDKCResult_NodeIdDecodeErrorZ* o_conv = (LDKCResult_NodeIdDecodeErrorZ*)(o & ~1);
14206         jboolean ret_conv = CResult_NodeIdDecodeErrorZ_is_ok(o_conv);
14207         return ret_conv;
14208 }
14209
14210 void  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_free"))) TS_CResult_NodeIdDecodeErrorZ_free(uint32_t _res) {
14211         if ((_res & 1) != 0) return;
14212         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14213         CHECK_ACCESS(_res_ptr);
14214         LDKCResult_NodeIdDecodeErrorZ _res_conv = *(LDKCResult_NodeIdDecodeErrorZ*)(_res_ptr);
14215         FREE((void*)_res);
14216         CResult_NodeIdDecodeErrorZ_free(_res_conv);
14217 }
14218
14219 static inline uintptr_t CResult_NodeIdDecodeErrorZ_clone_ptr(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR arg) {
14220         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
14221         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(arg);
14222         return (uint32_t)ret_conv;
14223 }
14224 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_clone_ptr"))) TS_CResult_NodeIdDecodeErrorZ_clone_ptr(uint32_t arg) {
14225         LDKCResult_NodeIdDecodeErrorZ* arg_conv = (LDKCResult_NodeIdDecodeErrorZ*)(arg & ~1);
14226         uint32_t ret_conv = CResult_NodeIdDecodeErrorZ_clone_ptr(arg_conv);
14227         return ret_conv;
14228 }
14229
14230 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_clone"))) TS_CResult_NodeIdDecodeErrorZ_clone(uint32_t orig) {
14231         LDKCResult_NodeIdDecodeErrorZ* orig_conv = (LDKCResult_NodeIdDecodeErrorZ*)(orig & ~1);
14232         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
14233         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(orig_conv);
14234         return (uint32_t)ret_conv;
14235 }
14236
14237 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_ok"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_ok(uint32_t o) {
14238         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
14239         CHECK_ACCESS(o_ptr);
14240         LDKCOption_NetworkUpdateZ o_conv = *(LDKCOption_NetworkUpdateZ*)(o_ptr);
14241         o_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uintptr_t)o) & ~1));
14242         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
14243         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_ok(o_conv);
14244         return (uint32_t)ret_conv;
14245 }
14246
14247 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_err"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_err(uint32_t e) {
14248         LDKDecodeError e_conv;
14249         e_conv.inner = (void*)(e & (~1));
14250         e_conv.is_owned = (e & 1) || (e == 0);
14251         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14252         e_conv = DecodeError_clone(&e_conv);
14253         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
14254         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_err(e_conv);
14255         return (uint32_t)ret_conv;
14256 }
14257
14258 jboolean  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok(uint32_t o) {
14259         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* o_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(o & ~1);
14260         jboolean ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok(o_conv);
14261         return ret_conv;
14262 }
14263
14264 void  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_free"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_free(uint32_t _res) {
14265         if ((_res & 1) != 0) return;
14266         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14267         CHECK_ACCESS(_res_ptr);
14268         LDKCResult_COption_NetworkUpdateZDecodeErrorZ _res_conv = *(LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(_res_ptr);
14269         FREE((void*)_res);
14270         CResult_COption_NetworkUpdateZDecodeErrorZ_free(_res_conv);
14271 }
14272
14273 static inline uintptr_t CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR arg) {
14274         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
14275         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(arg);
14276         return (uint32_t)ret_conv;
14277 }
14278 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(uint32_t arg) {
14279         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* arg_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(arg & ~1);
14280         uint32_t ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(arg_conv);
14281         return ret_conv;
14282 }
14283
14284 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_clone"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_clone(uint32_t orig) {
14285         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* orig_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(orig & ~1);
14286         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
14287         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(orig_conv);
14288         return (uint32_t)ret_conv;
14289 }
14290
14291 uint32_t  __attribute__((export_name("TS_COption_AccessZ_some"))) TS_COption_AccessZ_some(uint32_t o) {
14292         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
14293         CHECK_ACCESS(o_ptr);
14294         LDKAccess o_conv = *(LDKAccess*)(o_ptr);
14295         if (o_conv.free == LDKAccess_JCalls_free) {
14296                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14297                 LDKAccess_JCalls_cloned(&o_conv);
14298         }
14299         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
14300         *ret_copy = COption_AccessZ_some(o_conv);
14301         uint32_t ret_ref = (uintptr_t)ret_copy;
14302         return ret_ref;
14303 }
14304
14305 uint32_t  __attribute__((export_name("TS_COption_AccessZ_none"))) TS_COption_AccessZ_none() {
14306         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
14307         *ret_copy = COption_AccessZ_none();
14308         uint32_t ret_ref = (uintptr_t)ret_copy;
14309         return ret_ref;
14310 }
14311
14312 void  __attribute__((export_name("TS_COption_AccessZ_free"))) TS_COption_AccessZ_free(uint32_t _res) {
14313         if ((_res & 1) != 0) return;
14314         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14315         CHECK_ACCESS(_res_ptr);
14316         LDKCOption_AccessZ _res_conv = *(LDKCOption_AccessZ*)(_res_ptr);
14317         FREE((void*)_res);
14318         COption_AccessZ_free(_res_conv);
14319 }
14320
14321 uint32_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_ok"))) TS_CResult_boolLightningErrorZ_ok(jboolean o) {
14322         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
14323         *ret_conv = CResult_boolLightningErrorZ_ok(o);
14324         return (uint32_t)ret_conv;
14325 }
14326
14327 uint32_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_err"))) TS_CResult_boolLightningErrorZ_err(uint32_t e) {
14328         LDKLightningError e_conv;
14329         e_conv.inner = (void*)(e & (~1));
14330         e_conv.is_owned = (e & 1) || (e == 0);
14331         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14332         e_conv = LightningError_clone(&e_conv);
14333         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
14334         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
14335         return (uint32_t)ret_conv;
14336 }
14337
14338 jboolean  __attribute__((export_name("TS_CResult_boolLightningErrorZ_is_ok"))) TS_CResult_boolLightningErrorZ_is_ok(uint32_t o) {
14339         LDKCResult_boolLightningErrorZ* o_conv = (LDKCResult_boolLightningErrorZ*)(o & ~1);
14340         jboolean ret_conv = CResult_boolLightningErrorZ_is_ok(o_conv);
14341         return ret_conv;
14342 }
14343
14344 void  __attribute__((export_name("TS_CResult_boolLightningErrorZ_free"))) TS_CResult_boolLightningErrorZ_free(uint32_t _res) {
14345         if ((_res & 1) != 0) return;
14346         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14347         CHECK_ACCESS(_res_ptr);
14348         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(_res_ptr);
14349         FREE((void*)_res);
14350         CResult_boolLightningErrorZ_free(_res_conv);
14351 }
14352
14353 static inline uintptr_t CResult_boolLightningErrorZ_clone_ptr(LDKCResult_boolLightningErrorZ *NONNULL_PTR arg) {
14354         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
14355         *ret_conv = CResult_boolLightningErrorZ_clone(arg);
14356         return (uint32_t)ret_conv;
14357 }
14358 uint32_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_clone_ptr"))) TS_CResult_boolLightningErrorZ_clone_ptr(uint32_t arg) {
14359         LDKCResult_boolLightningErrorZ* arg_conv = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
14360         uint32_t ret_conv = CResult_boolLightningErrorZ_clone_ptr(arg_conv);
14361         return ret_conv;
14362 }
14363
14364 uint32_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_clone"))) TS_CResult_boolLightningErrorZ_clone(uint32_t orig) {
14365         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)(orig & ~1);
14366         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
14367         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
14368         return (uint32_t)ret_conv;
14369 }
14370
14371 static inline uintptr_t C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR arg) {
14372         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
14373         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(arg);
14374         return ((uint32_t)ret_conv);
14375 }
14376 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(uint32_t arg) {
14377         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* arg_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(arg & ~1);
14378         uint32_t ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(arg_conv);
14379         return ret_conv;
14380 }
14381
14382 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(uint32_t orig) {
14383         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(orig & ~1);
14384         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
14385         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
14386         return ((uint32_t)ret_conv);
14387 }
14388
14389 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(uint32_t a, uint32_t b, uint32_t c) {
14390         LDKChannelAnnouncement a_conv;
14391         a_conv.inner = (void*)(a & (~1));
14392         a_conv.is_owned = (a & 1) || (a == 0);
14393         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
14394         a_conv = ChannelAnnouncement_clone(&a_conv);
14395         LDKChannelUpdate b_conv;
14396         b_conv.inner = (void*)(b & (~1));
14397         b_conv.is_owned = (b & 1) || (b == 0);
14398         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
14399         b_conv = ChannelUpdate_clone(&b_conv);
14400         LDKChannelUpdate c_conv;
14401         c_conv.inner = (void*)(c & (~1));
14402         c_conv.is_owned = (c & 1) || (c == 0);
14403         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
14404         c_conv = ChannelUpdate_clone(&c_conv);
14405         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
14406         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
14407         return ((uint32_t)ret_conv);
14408 }
14409
14410 void  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(uint32_t _res) {
14411         if ((_res & 1) != 0) return;
14412         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14413         CHECK_ACCESS(_res_ptr);
14414         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_ptr);
14415         FREE((void*)_res);
14416         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
14417 }
14418
14419 void  __attribute__((export_name("TS_CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free"))) TS_CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(uint32_tArray _res) {
14420         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_constr;
14421         _res_constr.datalen = _res->arr_len;
14422         if (_res_constr.datalen > 0)
14423                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
14424         else
14425                 _res_constr.data = NULL;
14426         uint32_t* _res_vals = _res->elems;
14427         for (size_t h = 0; h < _res_constr.datalen; h++) {
14428                 uint32_t _res_conv_59 = _res_vals[h];
14429                 void* _res_conv_59_ptr = (void*)(((uintptr_t)_res_conv_59) & ~1);
14430                 CHECK_ACCESS(_res_conv_59_ptr);
14431                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_conv_59_ptr);
14432                 FREE((void*)_res_conv_59);
14433                 _res_constr.data[h] = _res_conv_59_conv;
14434         }
14435         FREE(_res);
14436         CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_constr);
14437 }
14438
14439 void  __attribute__((export_name("TS_CVec_NodeAnnouncementZ_free"))) TS_CVec_NodeAnnouncementZ_free(uint32_tArray _res) {
14440         LDKCVec_NodeAnnouncementZ _res_constr;
14441         _res_constr.datalen = _res->arr_len;
14442         if (_res_constr.datalen > 0)
14443                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
14444         else
14445                 _res_constr.data = NULL;
14446         uint32_t* _res_vals = _res->elems;
14447         for (size_t s = 0; s < _res_constr.datalen; s++) {
14448                 uint32_t _res_conv_18 = _res_vals[s];
14449                 LDKNodeAnnouncement _res_conv_18_conv;
14450                 _res_conv_18_conv.inner = (void*)(_res_conv_18 & (~1));
14451                 _res_conv_18_conv.is_owned = (_res_conv_18 & 1) || (_res_conv_18 == 0);
14452                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_18_conv);
14453                 _res_constr.data[s] = _res_conv_18_conv;
14454         }
14455         FREE(_res);
14456         CVec_NodeAnnouncementZ_free(_res_constr);
14457 }
14458
14459 uint32_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_ok"))) TS_CResult_NoneLightningErrorZ_ok() {
14460         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
14461         *ret_conv = CResult_NoneLightningErrorZ_ok();
14462         return (uint32_t)ret_conv;
14463 }
14464
14465 uint32_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_err"))) TS_CResult_NoneLightningErrorZ_err(uint32_t e) {
14466         LDKLightningError e_conv;
14467         e_conv.inner = (void*)(e & (~1));
14468         e_conv.is_owned = (e & 1) || (e == 0);
14469         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14470         e_conv = LightningError_clone(&e_conv);
14471         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
14472         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
14473         return (uint32_t)ret_conv;
14474 }
14475
14476 jboolean  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_is_ok"))) TS_CResult_NoneLightningErrorZ_is_ok(uint32_t o) {
14477         LDKCResult_NoneLightningErrorZ* o_conv = (LDKCResult_NoneLightningErrorZ*)(o & ~1);
14478         jboolean ret_conv = CResult_NoneLightningErrorZ_is_ok(o_conv);
14479         return ret_conv;
14480 }
14481
14482 void  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_free"))) TS_CResult_NoneLightningErrorZ_free(uint32_t _res) {
14483         if ((_res & 1) != 0) return;
14484         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14485         CHECK_ACCESS(_res_ptr);
14486         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(_res_ptr);
14487         FREE((void*)_res);
14488         CResult_NoneLightningErrorZ_free(_res_conv);
14489 }
14490
14491 static inline uintptr_t CResult_NoneLightningErrorZ_clone_ptr(LDKCResult_NoneLightningErrorZ *NONNULL_PTR arg) {
14492         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
14493         *ret_conv = CResult_NoneLightningErrorZ_clone(arg);
14494         return (uint32_t)ret_conv;
14495 }
14496 uint32_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_clone_ptr"))) TS_CResult_NoneLightningErrorZ_clone_ptr(uint32_t arg) {
14497         LDKCResult_NoneLightningErrorZ* arg_conv = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
14498         uint32_t ret_conv = CResult_NoneLightningErrorZ_clone_ptr(arg_conv);
14499         return ret_conv;
14500 }
14501
14502 uint32_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_clone"))) TS_CResult_NoneLightningErrorZ_clone(uint32_t orig) {
14503         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)(orig & ~1);
14504         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
14505         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
14506         return (uint32_t)ret_conv;
14507 }
14508
14509 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_ok"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_ok(uint32_t o) {
14510         LDKChannelUpdateInfo o_conv;
14511         o_conv.inner = (void*)(o & (~1));
14512         o_conv.is_owned = (o & 1) || (o == 0);
14513         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14514         o_conv = ChannelUpdateInfo_clone(&o_conv);
14515         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
14516         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_ok(o_conv);
14517         return (uint32_t)ret_conv;
14518 }
14519
14520 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_err"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_err(uint32_t e) {
14521         LDKDecodeError e_conv;
14522         e_conv.inner = (void*)(e & (~1));
14523         e_conv.is_owned = (e & 1) || (e == 0);
14524         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14525         e_conv = DecodeError_clone(&e_conv);
14526         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
14527         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_err(e_conv);
14528         return (uint32_t)ret_conv;
14529 }
14530
14531 jboolean  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_is_ok"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_is_ok(uint32_t o) {
14532         LDKCResult_ChannelUpdateInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(o & ~1);
14533         jboolean ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_is_ok(o_conv);
14534         return ret_conv;
14535 }
14536
14537 void  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_free"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_free(uint32_t _res) {
14538         if ((_res & 1) != 0) return;
14539         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14540         CHECK_ACCESS(_res_ptr);
14541         LDKCResult_ChannelUpdateInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(_res_ptr);
14542         FREE((void*)_res);
14543         CResult_ChannelUpdateInfoDecodeErrorZ_free(_res_conv);
14544 }
14545
14546 static inline uintptr_t CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR arg) {
14547         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
14548         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone(arg);
14549         return (uint32_t)ret_conv;
14550 }
14551 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
14552         LDKCResult_ChannelUpdateInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(arg & ~1);
14553         uint32_t ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(arg_conv);
14554         return ret_conv;
14555 }
14556
14557 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_clone"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_clone(uint32_t orig) {
14558         LDKCResult_ChannelUpdateInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(orig & ~1);
14559         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
14560         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone(orig_conv);
14561         return (uint32_t)ret_conv;
14562 }
14563
14564 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_ok"))) TS_CResult_ChannelInfoDecodeErrorZ_ok(uint32_t o) {
14565         LDKChannelInfo o_conv;
14566         o_conv.inner = (void*)(o & (~1));
14567         o_conv.is_owned = (o & 1) || (o == 0);
14568         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14569         o_conv = ChannelInfo_clone(&o_conv);
14570         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
14571         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
14572         return (uint32_t)ret_conv;
14573 }
14574
14575 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_err"))) TS_CResult_ChannelInfoDecodeErrorZ_err(uint32_t e) {
14576         LDKDecodeError e_conv;
14577         e_conv.inner = (void*)(e & (~1));
14578         e_conv.is_owned = (e & 1) || (e == 0);
14579         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14580         e_conv = DecodeError_clone(&e_conv);
14581         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
14582         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
14583         return (uint32_t)ret_conv;
14584 }
14585
14586 jboolean  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_is_ok"))) TS_CResult_ChannelInfoDecodeErrorZ_is_ok(uint32_t o) {
14587         LDKCResult_ChannelInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(o & ~1);
14588         jboolean ret_conv = CResult_ChannelInfoDecodeErrorZ_is_ok(o_conv);
14589         return ret_conv;
14590 }
14591
14592 void  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_free"))) TS_CResult_ChannelInfoDecodeErrorZ_free(uint32_t _res) {
14593         if ((_res & 1) != 0) return;
14594         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14595         CHECK_ACCESS(_res_ptr);
14596         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(_res_ptr);
14597         FREE((void*)_res);
14598         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
14599 }
14600
14601 static inline uintptr_t CResult_ChannelInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR arg) {
14602         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
14603         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(arg);
14604         return (uint32_t)ret_conv;
14605 }
14606 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
14607         LDKCResult_ChannelInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
14608         uint32_t ret_conv = CResult_ChannelInfoDecodeErrorZ_clone_ptr(arg_conv);
14609         return ret_conv;
14610 }
14611
14612 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_clone"))) TS_CResult_ChannelInfoDecodeErrorZ_clone(uint32_t orig) {
14613         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(orig & ~1);
14614         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
14615         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
14616         return (uint32_t)ret_conv;
14617 }
14618
14619 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_ok"))) TS_CResult_RoutingFeesDecodeErrorZ_ok(uint32_t o) {
14620         LDKRoutingFees o_conv;
14621         o_conv.inner = (void*)(o & (~1));
14622         o_conv.is_owned = (o & 1) || (o == 0);
14623         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14624         o_conv = RoutingFees_clone(&o_conv);
14625         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
14626         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
14627         return (uint32_t)ret_conv;
14628 }
14629
14630 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_err"))) TS_CResult_RoutingFeesDecodeErrorZ_err(uint32_t e) {
14631         LDKDecodeError e_conv;
14632         e_conv.inner = (void*)(e & (~1));
14633         e_conv.is_owned = (e & 1) || (e == 0);
14634         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14635         e_conv = DecodeError_clone(&e_conv);
14636         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
14637         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
14638         return (uint32_t)ret_conv;
14639 }
14640
14641 jboolean  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_is_ok"))) TS_CResult_RoutingFeesDecodeErrorZ_is_ok(uint32_t o) {
14642         LDKCResult_RoutingFeesDecodeErrorZ* o_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(o & ~1);
14643         jboolean ret_conv = CResult_RoutingFeesDecodeErrorZ_is_ok(o_conv);
14644         return ret_conv;
14645 }
14646
14647 void  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_free"))) TS_CResult_RoutingFeesDecodeErrorZ_free(uint32_t _res) {
14648         if ((_res & 1) != 0) return;
14649         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14650         CHECK_ACCESS(_res_ptr);
14651         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(_res_ptr);
14652         FREE((void*)_res);
14653         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
14654 }
14655
14656 static inline uintptr_t CResult_RoutingFeesDecodeErrorZ_clone_ptr(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR arg) {
14657         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
14658         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(arg);
14659         return (uint32_t)ret_conv;
14660 }
14661 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_clone_ptr"))) TS_CResult_RoutingFeesDecodeErrorZ_clone_ptr(uint32_t arg) {
14662         LDKCResult_RoutingFeesDecodeErrorZ* arg_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
14663         uint32_t ret_conv = CResult_RoutingFeesDecodeErrorZ_clone_ptr(arg_conv);
14664         return ret_conv;
14665 }
14666
14667 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_clone"))) TS_CResult_RoutingFeesDecodeErrorZ_clone(uint32_t orig) {
14668         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(orig & ~1);
14669         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
14670         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
14671         return (uint32_t)ret_conv;
14672 }
14673
14674 void  __attribute__((export_name("TS_CVec_NetAddressZ_free"))) TS_CVec_NetAddressZ_free(uint32_tArray _res) {
14675         LDKCVec_NetAddressZ _res_constr;
14676         _res_constr.datalen = _res->arr_len;
14677         if (_res_constr.datalen > 0)
14678                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
14679         else
14680                 _res_constr.data = NULL;
14681         uint32_t* _res_vals = _res->elems;
14682         for (size_t m = 0; m < _res_constr.datalen; m++) {
14683                 uint32_t _res_conv_12 = _res_vals[m];
14684                 void* _res_conv_12_ptr = (void*)(((uintptr_t)_res_conv_12) & ~1);
14685                 CHECK_ACCESS(_res_conv_12_ptr);
14686                 LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(_res_conv_12_ptr);
14687                 FREE((void*)_res_conv_12);
14688                 _res_constr.data[m] = _res_conv_12_conv;
14689         }
14690         FREE(_res);
14691         CVec_NetAddressZ_free(_res_constr);
14692 }
14693
14694 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_ok"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_ok(uint32_t o) {
14695         LDKNodeAnnouncementInfo o_conv;
14696         o_conv.inner = (void*)(o & (~1));
14697         o_conv.is_owned = (o & 1) || (o == 0);
14698         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14699         o_conv = NodeAnnouncementInfo_clone(&o_conv);
14700         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
14701         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
14702         return (uint32_t)ret_conv;
14703 }
14704
14705 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_err"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_err(uint32_t e) {
14706         LDKDecodeError e_conv;
14707         e_conv.inner = (void*)(e & (~1));
14708         e_conv.is_owned = (e & 1) || (e == 0);
14709         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14710         e_conv = DecodeError_clone(&e_conv);
14711         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
14712         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
14713         return (uint32_t)ret_conv;
14714 }
14715
14716 jboolean  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok(uint32_t o) {
14717         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(o & ~1);
14718         jboolean ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok(o_conv);
14719         return ret_conv;
14720 }
14721
14722 void  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_free"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_free(uint32_t _res) {
14723         if ((_res & 1) != 0) return;
14724         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14725         CHECK_ACCESS(_res_ptr);
14726         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(_res_ptr);
14727         FREE((void*)_res);
14728         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
14729 }
14730
14731 static inline uintptr_t CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR arg) {
14732         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
14733         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(arg);
14734         return (uint32_t)ret_conv;
14735 }
14736 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
14737         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
14738         uint32_t ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(arg_conv);
14739         return ret_conv;
14740 }
14741
14742 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone(uint32_t orig) {
14743         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(orig & ~1);
14744         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
14745         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
14746         return (uint32_t)ret_conv;
14747 }
14748
14749 uint32_t  __attribute__((export_name("TS_CResult_NodeAliasDecodeErrorZ_ok"))) TS_CResult_NodeAliasDecodeErrorZ_ok(uint32_t o) {
14750         LDKNodeAlias o_conv;
14751         o_conv.inner = (void*)(o & (~1));
14752         o_conv.is_owned = (o & 1) || (o == 0);
14753         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14754         o_conv = NodeAlias_clone(&o_conv);
14755         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
14756         *ret_conv = CResult_NodeAliasDecodeErrorZ_ok(o_conv);
14757         return (uint32_t)ret_conv;
14758 }
14759
14760 uint32_t  __attribute__((export_name("TS_CResult_NodeAliasDecodeErrorZ_err"))) TS_CResult_NodeAliasDecodeErrorZ_err(uint32_t e) {
14761         LDKDecodeError e_conv;
14762         e_conv.inner = (void*)(e & (~1));
14763         e_conv.is_owned = (e & 1) || (e == 0);
14764         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14765         e_conv = DecodeError_clone(&e_conv);
14766         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
14767         *ret_conv = CResult_NodeAliasDecodeErrorZ_err(e_conv);
14768         return (uint32_t)ret_conv;
14769 }
14770
14771 jboolean  __attribute__((export_name("TS_CResult_NodeAliasDecodeErrorZ_is_ok"))) TS_CResult_NodeAliasDecodeErrorZ_is_ok(uint32_t o) {
14772         LDKCResult_NodeAliasDecodeErrorZ* o_conv = (LDKCResult_NodeAliasDecodeErrorZ*)(o & ~1);
14773         jboolean ret_conv = CResult_NodeAliasDecodeErrorZ_is_ok(o_conv);
14774         return ret_conv;
14775 }
14776
14777 void  __attribute__((export_name("TS_CResult_NodeAliasDecodeErrorZ_free"))) TS_CResult_NodeAliasDecodeErrorZ_free(uint32_t _res) {
14778         if ((_res & 1) != 0) return;
14779         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14780         CHECK_ACCESS(_res_ptr);
14781         LDKCResult_NodeAliasDecodeErrorZ _res_conv = *(LDKCResult_NodeAliasDecodeErrorZ*)(_res_ptr);
14782         FREE((void*)_res);
14783         CResult_NodeAliasDecodeErrorZ_free(_res_conv);
14784 }
14785
14786 static inline uintptr_t CResult_NodeAliasDecodeErrorZ_clone_ptr(LDKCResult_NodeAliasDecodeErrorZ *NONNULL_PTR arg) {
14787         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
14788         *ret_conv = CResult_NodeAliasDecodeErrorZ_clone(arg);
14789         return (uint32_t)ret_conv;
14790 }
14791 uint32_t  __attribute__((export_name("TS_CResult_NodeAliasDecodeErrorZ_clone_ptr"))) TS_CResult_NodeAliasDecodeErrorZ_clone_ptr(uint32_t arg) {
14792         LDKCResult_NodeAliasDecodeErrorZ* arg_conv = (LDKCResult_NodeAliasDecodeErrorZ*)(arg & ~1);
14793         uint32_t ret_conv = CResult_NodeAliasDecodeErrorZ_clone_ptr(arg_conv);
14794         return ret_conv;
14795 }
14796
14797 uint32_t  __attribute__((export_name("TS_CResult_NodeAliasDecodeErrorZ_clone"))) TS_CResult_NodeAliasDecodeErrorZ_clone(uint32_t orig) {
14798         LDKCResult_NodeAliasDecodeErrorZ* orig_conv = (LDKCResult_NodeAliasDecodeErrorZ*)(orig & ~1);
14799         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
14800         *ret_conv = CResult_NodeAliasDecodeErrorZ_clone(orig_conv);
14801         return (uint32_t)ret_conv;
14802 }
14803
14804 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_ok"))) TS_CResult_NodeInfoDecodeErrorZ_ok(uint32_t o) {
14805         LDKNodeInfo o_conv;
14806         o_conv.inner = (void*)(o & (~1));
14807         o_conv.is_owned = (o & 1) || (o == 0);
14808         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14809         o_conv = NodeInfo_clone(&o_conv);
14810         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
14811         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
14812         return (uint32_t)ret_conv;
14813 }
14814
14815 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_err"))) TS_CResult_NodeInfoDecodeErrorZ_err(uint32_t e) {
14816         LDKDecodeError e_conv;
14817         e_conv.inner = (void*)(e & (~1));
14818         e_conv.is_owned = (e & 1) || (e == 0);
14819         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14820         e_conv = DecodeError_clone(&e_conv);
14821         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
14822         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
14823         return (uint32_t)ret_conv;
14824 }
14825
14826 jboolean  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_is_ok"))) TS_CResult_NodeInfoDecodeErrorZ_is_ok(uint32_t o) {
14827         LDKCResult_NodeInfoDecodeErrorZ* o_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(o & ~1);
14828         jboolean ret_conv = CResult_NodeInfoDecodeErrorZ_is_ok(o_conv);
14829         return ret_conv;
14830 }
14831
14832 void  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_free"))) TS_CResult_NodeInfoDecodeErrorZ_free(uint32_t _res) {
14833         if ((_res & 1) != 0) return;
14834         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14835         CHECK_ACCESS(_res_ptr);
14836         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(_res_ptr);
14837         FREE((void*)_res);
14838         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
14839 }
14840
14841 static inline uintptr_t CResult_NodeInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR arg) {
14842         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
14843         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(arg);
14844         return (uint32_t)ret_conv;
14845 }
14846 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_clone_ptr"))) TS_CResult_NodeInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
14847         LDKCResult_NodeInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
14848         uint32_t ret_conv = CResult_NodeInfoDecodeErrorZ_clone_ptr(arg_conv);
14849         return ret_conv;
14850 }
14851
14852 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_clone"))) TS_CResult_NodeInfoDecodeErrorZ_clone(uint32_t orig) {
14853         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(orig & ~1);
14854         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
14855         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
14856         return (uint32_t)ret_conv;
14857 }
14858
14859 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_ok"))) TS_CResult_NetworkGraphDecodeErrorZ_ok(uint32_t o) {
14860         LDKNetworkGraph o_conv;
14861         o_conv.inner = (void*)(o & (~1));
14862         o_conv.is_owned = (o & 1) || (o == 0);
14863         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14864         // WARNING: we need a move here but no clone is available for LDKNetworkGraph
14865         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
14866         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
14867         return (uint32_t)ret_conv;
14868 }
14869
14870 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_err"))) TS_CResult_NetworkGraphDecodeErrorZ_err(uint32_t e) {
14871         LDKDecodeError e_conv;
14872         e_conv.inner = (void*)(e & (~1));
14873         e_conv.is_owned = (e & 1) || (e == 0);
14874         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14875         e_conv = DecodeError_clone(&e_conv);
14876         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
14877         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
14878         return (uint32_t)ret_conv;
14879 }
14880
14881 jboolean  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_is_ok"))) TS_CResult_NetworkGraphDecodeErrorZ_is_ok(uint32_t o) {
14882         LDKCResult_NetworkGraphDecodeErrorZ* o_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(o & ~1);
14883         jboolean ret_conv = CResult_NetworkGraphDecodeErrorZ_is_ok(o_conv);
14884         return ret_conv;
14885 }
14886
14887 void  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_free"))) TS_CResult_NetworkGraphDecodeErrorZ_free(uint32_t _res) {
14888         if ((_res & 1) != 0) return;
14889         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14890         CHECK_ACCESS(_res_ptr);
14891         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(_res_ptr);
14892         FREE((void*)_res);
14893         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
14894 }
14895
14896 uint32_t  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_some"))) TS_COption_CVec_NetAddressZZ_some(uint32_tArray o) {
14897         LDKCVec_NetAddressZ o_constr;
14898         o_constr.datalen = o->arr_len;
14899         if (o_constr.datalen > 0)
14900                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
14901         else
14902                 o_constr.data = NULL;
14903         uint32_t* o_vals = o->elems;
14904         for (size_t m = 0; m < o_constr.datalen; m++) {
14905                 uint32_t o_conv_12 = o_vals[m];
14906                 void* o_conv_12_ptr = (void*)(((uintptr_t)o_conv_12) & ~1);
14907                 CHECK_ACCESS(o_conv_12_ptr);
14908                 LDKNetAddress o_conv_12_conv = *(LDKNetAddress*)(o_conv_12_ptr);
14909                 o_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)o_conv_12) & ~1));
14910                 o_constr.data[m] = o_conv_12_conv;
14911         }
14912         FREE(o);
14913         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
14914         *ret_copy = COption_CVec_NetAddressZZ_some(o_constr);
14915         uint32_t ret_ref = (uintptr_t)ret_copy;
14916         return ret_ref;
14917 }
14918
14919 uint32_t  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_none"))) TS_COption_CVec_NetAddressZZ_none() {
14920         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
14921         *ret_copy = COption_CVec_NetAddressZZ_none();
14922         uint32_t ret_ref = (uintptr_t)ret_copy;
14923         return ret_ref;
14924 }
14925
14926 void  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_free"))) TS_COption_CVec_NetAddressZZ_free(uint32_t _res) {
14927         if ((_res & 1) != 0) return;
14928         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14929         CHECK_ACCESS(_res_ptr);
14930         LDKCOption_CVec_NetAddressZZ _res_conv = *(LDKCOption_CVec_NetAddressZZ*)(_res_ptr);
14931         FREE((void*)_res);
14932         COption_CVec_NetAddressZZ_free(_res_conv);
14933 }
14934
14935 static inline uintptr_t COption_CVec_NetAddressZZ_clone_ptr(LDKCOption_CVec_NetAddressZZ *NONNULL_PTR arg) {
14936         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
14937         *ret_copy = COption_CVec_NetAddressZZ_clone(arg);
14938 uint32_t ret_ref = (uintptr_t)ret_copy;
14939         return ret_ref;
14940 }
14941 uint32_t  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_clone_ptr"))) TS_COption_CVec_NetAddressZZ_clone_ptr(uint32_t arg) {
14942         LDKCOption_CVec_NetAddressZZ* arg_conv = (LDKCOption_CVec_NetAddressZZ*)arg;
14943         uint32_t ret_conv = COption_CVec_NetAddressZZ_clone_ptr(arg_conv);
14944         return ret_conv;
14945 }
14946
14947 uint32_t  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_clone"))) TS_COption_CVec_NetAddressZZ_clone(uint32_t orig) {
14948         LDKCOption_CVec_NetAddressZZ* orig_conv = (LDKCOption_CVec_NetAddressZZ*)orig;
14949         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
14950         *ret_copy = COption_CVec_NetAddressZZ_clone(orig_conv);
14951         uint32_t ret_ref = (uintptr_t)ret_copy;
14952         return ret_ref;
14953 }
14954
14955 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
14956         LDKDelayedPaymentOutputDescriptor o_conv;
14957         o_conv.inner = (void*)(o & (~1));
14958         o_conv.is_owned = (o & 1) || (o == 0);
14959         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14960         o_conv = DelayedPaymentOutputDescriptor_clone(&o_conv);
14961         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
14962         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
14963         return (uint32_t)ret_conv;
14964 }
14965
14966 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(uint32_t e) {
14967         LDKDecodeError e_conv;
14968         e_conv.inner = (void*)(e & (~1));
14969         e_conv.is_owned = (e & 1) || (e == 0);
14970         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14971         e_conv = DecodeError_clone(&e_conv);
14972         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
14973         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
14974         return (uint32_t)ret_conv;
14975 }
14976
14977 jboolean  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(uint32_t o) {
14978         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(o & ~1);
14979         jboolean ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
14980         return ret_conv;
14981 }
14982
14983 void  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
14984         if ((_res & 1) != 0) return;
14985         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14986         CHECK_ACCESS(_res_ptr);
14987         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
14988         FREE((void*)_res);
14989         CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
14990 }
14991
14992 static inline uintptr_t CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
14993         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
14994         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(arg);
14995         return (uint32_t)ret_conv;
14996 }
14997 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(uint32_t arg) {
14998         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
14999         uint32_t ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
15000         return ret_conv;
15001 }
15002
15003 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
15004         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
15005         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
15006         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
15007         return (uint32_t)ret_conv;
15008 }
15009
15010 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
15011         LDKStaticPaymentOutputDescriptor o_conv;
15012         o_conv.inner = (void*)(o & (~1));
15013         o_conv.is_owned = (o & 1) || (o == 0);
15014         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15015         o_conv = StaticPaymentOutputDescriptor_clone(&o_conv);
15016         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
15017         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
15018         return (uint32_t)ret_conv;
15019 }
15020
15021 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(uint32_t e) {
15022         LDKDecodeError e_conv;
15023         e_conv.inner = (void*)(e & (~1));
15024         e_conv.is_owned = (e & 1) || (e == 0);
15025         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15026         e_conv = DecodeError_clone(&e_conv);
15027         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
15028         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
15029         return (uint32_t)ret_conv;
15030 }
15031
15032 jboolean  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok(uint32_t o) {
15033         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(o & ~1);
15034         jboolean ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
15035         return ret_conv;
15036 }
15037
15038 void  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
15039         if ((_res & 1) != 0) return;
15040         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15041         CHECK_ACCESS(_res_ptr);
15042         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
15043         FREE((void*)_res);
15044         CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
15045 }
15046
15047 static inline uintptr_t CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
15048         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
15049         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(arg);
15050         return (uint32_t)ret_conv;
15051 }
15052 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(uint32_t arg) {
15053         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
15054         uint32_t ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
15055         return ret_conv;
15056 }
15057
15058 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
15059         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
15060         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
15061         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
15062         return (uint32_t)ret_conv;
15063 }
15064
15065 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_ok"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
15066         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15067         CHECK_ACCESS(o_ptr);
15068         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(o_ptr);
15069         o_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)o) & ~1));
15070         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
15071         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
15072         return (uint32_t)ret_conv;
15073 }
15074
15075 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_err"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_err(uint32_t e) {
15076         LDKDecodeError e_conv;
15077         e_conv.inner = (void*)(e & (~1));
15078         e_conv.is_owned = (e & 1) || (e == 0);
15079         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15080         e_conv = DecodeError_clone(&e_conv);
15081         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
15082         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
15083         return (uint32_t)ret_conv;
15084 }
15085
15086 jboolean  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok(uint32_t o) {
15087         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(o & ~1);
15088         jboolean ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok(o_conv);
15089         return ret_conv;
15090 }
15091
15092 void  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_free"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
15093         if ((_res & 1) != 0) return;
15094         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15095         CHECK_ACCESS(_res_ptr);
15096         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(_res_ptr);
15097         FREE((void*)_res);
15098         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
15099 }
15100
15101 static inline uintptr_t CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
15102         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
15103         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(arg);
15104         return (uint32_t)ret_conv;
15105 }
15106 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(uint32_t arg) {
15107         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
15108         uint32_t ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
15109         return ret_conv;
15110 }
15111
15112 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
15113         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(orig & ~1);
15114         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
15115         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
15116         return (uint32_t)ret_conv;
15117 }
15118
15119 void  __attribute__((export_name("TS_CVec_PaymentPreimageZ_free"))) TS_CVec_PaymentPreimageZ_free(ptrArray _res) {
15120         LDKCVec_PaymentPreimageZ _res_constr;
15121         _res_constr.datalen = _res->arr_len;
15122         if (_res_constr.datalen > 0)
15123                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
15124         else
15125                 _res_constr.data = NULL;
15126         int8_tArray* _res_vals = (void*) _res->elems;
15127         for (size_t m = 0; m < _res_constr.datalen; m++) {
15128                 int8_tArray _res_conv_12 = _res_vals[m];
15129                 LDKThirtyTwoBytes _res_conv_12_ref;
15130                 CHECK(_res_conv_12->arr_len == 32);
15131                 memcpy(_res_conv_12_ref.data, _res_conv_12->elems, 32); FREE(_res_conv_12);
15132                 _res_constr.data[m] = _res_conv_12_ref;
15133         }
15134         FREE(_res);
15135         CVec_PaymentPreimageZ_free(_res_constr);
15136 }
15137
15138 static inline uintptr_t C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR arg) {
15139         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
15140         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(arg);
15141         return ((uint32_t)ret_conv);
15142 }
15143 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_clone_ptr"))) TS_C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(uint32_t arg) {
15144         LDKC2Tuple_SignatureCVec_SignatureZZ* arg_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(arg & ~1);
15145         uint32_t ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(arg_conv);
15146         return ret_conv;
15147 }
15148
15149 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_clone"))) TS_C2Tuple_SignatureCVec_SignatureZZ_clone(uint32_t orig) {
15150         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(orig & ~1);
15151         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
15152         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
15153         return ((uint32_t)ret_conv);
15154 }
15155
15156 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_new"))) TS_C2Tuple_SignatureCVec_SignatureZZ_new(int8_tArray a, ptrArray b) {
15157         LDKSignature a_ref;
15158         CHECK(a->arr_len == 64);
15159         memcpy(a_ref.compact_form, a->elems, 64); FREE(a);
15160         LDKCVec_SignatureZ b_constr;
15161         b_constr.datalen = b->arr_len;
15162         if (b_constr.datalen > 0)
15163                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
15164         else
15165                 b_constr.data = NULL;
15166         int8_tArray* b_vals = (void*) b->elems;
15167         for (size_t m = 0; m < b_constr.datalen; m++) {
15168                 int8_tArray b_conv_12 = b_vals[m];
15169                 LDKSignature b_conv_12_ref;
15170                 CHECK(b_conv_12->arr_len == 64);
15171                 memcpy(b_conv_12_ref.compact_form, b_conv_12->elems, 64); FREE(b_conv_12);
15172                 b_constr.data[m] = b_conv_12_ref;
15173         }
15174         FREE(b);
15175         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
15176         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
15177         return ((uint32_t)ret_conv);
15178 }
15179
15180 void  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_free"))) TS_C2Tuple_SignatureCVec_SignatureZZ_free(uint32_t _res) {
15181         if ((_res & 1) != 0) return;
15182         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15183         CHECK_ACCESS(_res_ptr);
15184         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(_res_ptr);
15185         FREE((void*)_res);
15186         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
15187 }
15188
15189 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(uint32_t o) {
15190         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15191         CHECK_ACCESS(o_ptr);
15192         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(o_ptr);
15193         o_conv = C2Tuple_SignatureCVec_SignatureZZ_clone((LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uintptr_t)o) & ~1));
15194         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
15195         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
15196         return (uint32_t)ret_conv;
15197 }
15198
15199 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err() {
15200         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
15201         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
15202         return (uint32_t)ret_conv;
15203 }
15204
15205 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok(uint32_t o) {
15206         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* o_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(o & ~1);
15207         jboolean ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok(o_conv);
15208         return ret_conv;
15209 }
15210
15211 void  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(uint32_t _res) {
15212         if ((_res & 1) != 0) return;
15213         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15214         CHECK_ACCESS(_res_ptr);
15215         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(_res_ptr);
15216         FREE((void*)_res);
15217         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
15218 }
15219
15220 static inline uintptr_t CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR arg) {
15221         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
15222         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(arg);
15223         return (uint32_t)ret_conv;
15224 }
15225 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(uint32_t arg) {
15226         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* arg_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
15227         uint32_t ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(arg_conv);
15228         return ret_conv;
15229 }
15230
15231 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(uint32_t orig) {
15232         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(orig & ~1);
15233         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
15234         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
15235         return (uint32_t)ret_conv;
15236 }
15237
15238 uint32_t  __attribute__((export_name("TS_CResult_SignatureNoneZ_ok"))) TS_CResult_SignatureNoneZ_ok(int8_tArray o) {
15239         LDKSignature o_ref;
15240         CHECK(o->arr_len == 64);
15241         memcpy(o_ref.compact_form, o->elems, 64); FREE(o);
15242         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
15243         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
15244         return (uint32_t)ret_conv;
15245 }
15246
15247 uint32_t  __attribute__((export_name("TS_CResult_SignatureNoneZ_err"))) TS_CResult_SignatureNoneZ_err() {
15248         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
15249         *ret_conv = CResult_SignatureNoneZ_err();
15250         return (uint32_t)ret_conv;
15251 }
15252
15253 jboolean  __attribute__((export_name("TS_CResult_SignatureNoneZ_is_ok"))) TS_CResult_SignatureNoneZ_is_ok(uint32_t o) {
15254         LDKCResult_SignatureNoneZ* o_conv = (LDKCResult_SignatureNoneZ*)(o & ~1);
15255         jboolean ret_conv = CResult_SignatureNoneZ_is_ok(o_conv);
15256         return ret_conv;
15257 }
15258
15259 void  __attribute__((export_name("TS_CResult_SignatureNoneZ_free"))) TS_CResult_SignatureNoneZ_free(uint32_t _res) {
15260         if ((_res & 1) != 0) return;
15261         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15262         CHECK_ACCESS(_res_ptr);
15263         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(_res_ptr);
15264         FREE((void*)_res);
15265         CResult_SignatureNoneZ_free(_res_conv);
15266 }
15267
15268 static inline uintptr_t CResult_SignatureNoneZ_clone_ptr(LDKCResult_SignatureNoneZ *NONNULL_PTR arg) {
15269         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
15270         *ret_conv = CResult_SignatureNoneZ_clone(arg);
15271         return (uint32_t)ret_conv;
15272 }
15273 uint32_t  __attribute__((export_name("TS_CResult_SignatureNoneZ_clone_ptr"))) TS_CResult_SignatureNoneZ_clone_ptr(uint32_t arg) {
15274         LDKCResult_SignatureNoneZ* arg_conv = (LDKCResult_SignatureNoneZ*)(arg & ~1);
15275         uint32_t ret_conv = CResult_SignatureNoneZ_clone_ptr(arg_conv);
15276         return ret_conv;
15277 }
15278
15279 uint32_t  __attribute__((export_name("TS_CResult_SignatureNoneZ_clone"))) TS_CResult_SignatureNoneZ_clone(uint32_t orig) {
15280         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)(orig & ~1);
15281         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
15282         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
15283         return (uint32_t)ret_conv;
15284 }
15285
15286 static inline uintptr_t C2Tuple_SignatureSignatureZ_clone_ptr(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR arg) {
15287         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
15288         *ret_conv = C2Tuple_SignatureSignatureZ_clone(arg);
15289         return ((uint32_t)ret_conv);
15290 }
15291 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_clone_ptr"))) TS_C2Tuple_SignatureSignatureZ_clone_ptr(uint32_t arg) {
15292         LDKC2Tuple_SignatureSignatureZ* arg_conv = (LDKC2Tuple_SignatureSignatureZ*)(arg & ~1);
15293         uint32_t ret_conv = C2Tuple_SignatureSignatureZ_clone_ptr(arg_conv);
15294         return ret_conv;
15295 }
15296
15297 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_clone"))) TS_C2Tuple_SignatureSignatureZ_clone(uint32_t orig) {
15298         LDKC2Tuple_SignatureSignatureZ* orig_conv = (LDKC2Tuple_SignatureSignatureZ*)(orig & ~1);
15299         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
15300         *ret_conv = C2Tuple_SignatureSignatureZ_clone(orig_conv);
15301         return ((uint32_t)ret_conv);
15302 }
15303
15304 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_new"))) TS_C2Tuple_SignatureSignatureZ_new(int8_tArray a, int8_tArray b) {
15305         LDKSignature a_ref;
15306         CHECK(a->arr_len == 64);
15307         memcpy(a_ref.compact_form, a->elems, 64); FREE(a);
15308         LDKSignature b_ref;
15309         CHECK(b->arr_len == 64);
15310         memcpy(b_ref.compact_form, b->elems, 64); FREE(b);
15311         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
15312         *ret_conv = C2Tuple_SignatureSignatureZ_new(a_ref, b_ref);
15313         return ((uint32_t)ret_conv);
15314 }
15315
15316 void  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_free"))) TS_C2Tuple_SignatureSignatureZ_free(uint32_t _res) {
15317         if ((_res & 1) != 0) return;
15318         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15319         CHECK_ACCESS(_res_ptr);
15320         LDKC2Tuple_SignatureSignatureZ _res_conv = *(LDKC2Tuple_SignatureSignatureZ*)(_res_ptr);
15321         FREE((void*)_res);
15322         C2Tuple_SignatureSignatureZ_free(_res_conv);
15323 }
15324
15325 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_ok"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_ok(uint32_t o) {
15326         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15327         CHECK_ACCESS(o_ptr);
15328         LDKC2Tuple_SignatureSignatureZ o_conv = *(LDKC2Tuple_SignatureSignatureZ*)(o_ptr);
15329         o_conv = C2Tuple_SignatureSignatureZ_clone((LDKC2Tuple_SignatureSignatureZ*)(((uintptr_t)o) & ~1));
15330         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
15331         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_ok(o_conv);
15332         return (uint32_t)ret_conv;
15333 }
15334
15335 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_err"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_err() {
15336         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
15337         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_err();
15338         return (uint32_t)ret_conv;
15339 }
15340
15341 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_is_ok"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_is_ok(uint32_t o) {
15342         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* o_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(o & ~1);
15343         jboolean ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_is_ok(o_conv);
15344         return ret_conv;
15345 }
15346
15347 void  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_free"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_free(uint32_t _res) {
15348         if ((_res & 1) != 0) return;
15349         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15350         CHECK_ACCESS(_res_ptr);
15351         LDKCResult_C2Tuple_SignatureSignatureZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(_res_ptr);
15352         FREE((void*)_res);
15353         CResult_C2Tuple_SignatureSignatureZNoneZ_free(_res_conv);
15354 }
15355
15356 static inline uintptr_t CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR arg) {
15357         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
15358         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone(arg);
15359         return (uint32_t)ret_conv;
15360 }
15361 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr(uint32_t arg) {
15362         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* arg_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(arg & ~1);
15363         uint32_t ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr(arg_conv);
15364         return ret_conv;
15365 }
15366
15367 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_clone"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_clone(uint32_t orig) {
15368         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(orig & ~1);
15369         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
15370         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone(orig_conv);
15371         return (uint32_t)ret_conv;
15372 }
15373
15374 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_ok"))) TS_CResult_SecretKeyNoneZ_ok(int8_tArray o) {
15375         LDKSecretKey o_ref;
15376         CHECK(o->arr_len == 32);
15377         memcpy(o_ref.bytes, o->elems, 32); FREE(o);
15378         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
15379         *ret_conv = CResult_SecretKeyNoneZ_ok(o_ref);
15380         return (uint32_t)ret_conv;
15381 }
15382
15383 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_err"))) TS_CResult_SecretKeyNoneZ_err() {
15384         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
15385         *ret_conv = CResult_SecretKeyNoneZ_err();
15386         return (uint32_t)ret_conv;
15387 }
15388
15389 jboolean  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_is_ok"))) TS_CResult_SecretKeyNoneZ_is_ok(uint32_t o) {
15390         LDKCResult_SecretKeyNoneZ* o_conv = (LDKCResult_SecretKeyNoneZ*)(o & ~1);
15391         jboolean ret_conv = CResult_SecretKeyNoneZ_is_ok(o_conv);
15392         return ret_conv;
15393 }
15394
15395 void  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_free"))) TS_CResult_SecretKeyNoneZ_free(uint32_t _res) {
15396         if ((_res & 1) != 0) return;
15397         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15398         CHECK_ACCESS(_res_ptr);
15399         LDKCResult_SecretKeyNoneZ _res_conv = *(LDKCResult_SecretKeyNoneZ*)(_res_ptr);
15400         FREE((void*)_res);
15401         CResult_SecretKeyNoneZ_free(_res_conv);
15402 }
15403
15404 static inline uintptr_t CResult_SecretKeyNoneZ_clone_ptr(LDKCResult_SecretKeyNoneZ *NONNULL_PTR arg) {
15405         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
15406         *ret_conv = CResult_SecretKeyNoneZ_clone(arg);
15407         return (uint32_t)ret_conv;
15408 }
15409 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_clone_ptr"))) TS_CResult_SecretKeyNoneZ_clone_ptr(uint32_t arg) {
15410         LDKCResult_SecretKeyNoneZ* arg_conv = (LDKCResult_SecretKeyNoneZ*)(arg & ~1);
15411         uint32_t ret_conv = CResult_SecretKeyNoneZ_clone_ptr(arg_conv);
15412         return ret_conv;
15413 }
15414
15415 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_clone"))) TS_CResult_SecretKeyNoneZ_clone(uint32_t orig) {
15416         LDKCResult_SecretKeyNoneZ* orig_conv = (LDKCResult_SecretKeyNoneZ*)(orig & ~1);
15417         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
15418         *ret_conv = CResult_SecretKeyNoneZ_clone(orig_conv);
15419         return (uint32_t)ret_conv;
15420 }
15421
15422 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_ok"))) TS_CResult_SignDecodeErrorZ_ok(uint32_t o) {
15423         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15424         CHECK_ACCESS(o_ptr);
15425         LDKSign o_conv = *(LDKSign*)(o_ptr);
15426         if (o_conv.free == LDKSign_JCalls_free) {
15427                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
15428                 LDKSign_JCalls_cloned(&o_conv);
15429         }
15430         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
15431         *ret_conv = CResult_SignDecodeErrorZ_ok(o_conv);
15432         return (uint32_t)ret_conv;
15433 }
15434
15435 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_err"))) TS_CResult_SignDecodeErrorZ_err(uint32_t e) {
15436         LDKDecodeError e_conv;
15437         e_conv.inner = (void*)(e & (~1));
15438         e_conv.is_owned = (e & 1) || (e == 0);
15439         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15440         e_conv = DecodeError_clone(&e_conv);
15441         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
15442         *ret_conv = CResult_SignDecodeErrorZ_err(e_conv);
15443         return (uint32_t)ret_conv;
15444 }
15445
15446 jboolean  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_is_ok"))) TS_CResult_SignDecodeErrorZ_is_ok(uint32_t o) {
15447         LDKCResult_SignDecodeErrorZ* o_conv = (LDKCResult_SignDecodeErrorZ*)(o & ~1);
15448         jboolean ret_conv = CResult_SignDecodeErrorZ_is_ok(o_conv);
15449         return ret_conv;
15450 }
15451
15452 void  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_free"))) TS_CResult_SignDecodeErrorZ_free(uint32_t _res) {
15453         if ((_res & 1) != 0) return;
15454         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15455         CHECK_ACCESS(_res_ptr);
15456         LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(_res_ptr);
15457         FREE((void*)_res);
15458         CResult_SignDecodeErrorZ_free(_res_conv);
15459 }
15460
15461 static inline uintptr_t CResult_SignDecodeErrorZ_clone_ptr(LDKCResult_SignDecodeErrorZ *NONNULL_PTR arg) {
15462         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
15463         *ret_conv = CResult_SignDecodeErrorZ_clone(arg);
15464         return (uint32_t)ret_conv;
15465 }
15466 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_clone_ptr"))) TS_CResult_SignDecodeErrorZ_clone_ptr(uint32_t arg) {
15467         LDKCResult_SignDecodeErrorZ* arg_conv = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
15468         uint32_t ret_conv = CResult_SignDecodeErrorZ_clone_ptr(arg_conv);
15469         return ret_conv;
15470 }
15471
15472 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_clone"))) TS_CResult_SignDecodeErrorZ_clone(uint32_t orig) {
15473         LDKCResult_SignDecodeErrorZ* orig_conv = (LDKCResult_SignDecodeErrorZ*)(orig & ~1);
15474         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
15475         *ret_conv = CResult_SignDecodeErrorZ_clone(orig_conv);
15476         return (uint32_t)ret_conv;
15477 }
15478
15479 void  __attribute__((export_name("TS_CVec_u5Z_free"))) TS_CVec_u5Z_free(ptrArray _res) {
15480         LDKCVec_u5Z _res_constr;
15481         _res_constr.datalen = _res->arr_len;
15482         if (_res_constr.datalen > 0)
15483                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
15484         else
15485                 _res_constr.data = NULL;
15486         int8_t* _res_vals = (void*) _res->elems;
15487         for (size_t h = 0; h < _res_constr.datalen; h++) {
15488                 int8_t _res_conv_7 = _res_vals[h];
15489                 
15490                 _res_constr.data[h] = (LDKu5){ ._0 = _res_conv_7 };
15491         }
15492         FREE(_res);
15493         CVec_u5Z_free(_res_constr);
15494 }
15495
15496 uint32_t  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_ok"))) TS_CResult_RecoverableSignatureNoneZ_ok(int8_tArray o) {
15497         LDKRecoverableSignature o_ref;
15498         CHECK(o->arr_len == 68);
15499         memcpy(o_ref.serialized_form, o->elems, 68); FREE(o);
15500         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
15501         *ret_conv = CResult_RecoverableSignatureNoneZ_ok(o_ref);
15502         return (uint32_t)ret_conv;
15503 }
15504
15505 uint32_t  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_err"))) TS_CResult_RecoverableSignatureNoneZ_err() {
15506         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
15507         *ret_conv = CResult_RecoverableSignatureNoneZ_err();
15508         return (uint32_t)ret_conv;
15509 }
15510
15511 jboolean  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_is_ok"))) TS_CResult_RecoverableSignatureNoneZ_is_ok(uint32_t o) {
15512         LDKCResult_RecoverableSignatureNoneZ* o_conv = (LDKCResult_RecoverableSignatureNoneZ*)(o & ~1);
15513         jboolean ret_conv = CResult_RecoverableSignatureNoneZ_is_ok(o_conv);
15514         return ret_conv;
15515 }
15516
15517 void  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_free"))) TS_CResult_RecoverableSignatureNoneZ_free(uint32_t _res) {
15518         if ((_res & 1) != 0) return;
15519         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15520         CHECK_ACCESS(_res_ptr);
15521         LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(_res_ptr);
15522         FREE((void*)_res);
15523         CResult_RecoverableSignatureNoneZ_free(_res_conv);
15524 }
15525
15526 static inline uintptr_t CResult_RecoverableSignatureNoneZ_clone_ptr(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR arg) {
15527         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
15528         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(arg);
15529         return (uint32_t)ret_conv;
15530 }
15531 uint32_t  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_clone_ptr"))) TS_CResult_RecoverableSignatureNoneZ_clone_ptr(uint32_t arg) {
15532         LDKCResult_RecoverableSignatureNoneZ* arg_conv = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
15533         uint32_t ret_conv = CResult_RecoverableSignatureNoneZ_clone_ptr(arg_conv);
15534         return ret_conv;
15535 }
15536
15537 uint32_t  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_clone"))) TS_CResult_RecoverableSignatureNoneZ_clone(uint32_t orig) {
15538         LDKCResult_RecoverableSignatureNoneZ* orig_conv = (LDKCResult_RecoverableSignatureNoneZ*)(orig & ~1);
15539         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
15540         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(orig_conv);
15541         return (uint32_t)ret_conv;
15542 }
15543
15544 void  __attribute__((export_name("TS_CVec_u8Z_free"))) TS_CVec_u8Z_free(int8_tArray _res) {
15545         LDKCVec_u8Z _res_ref;
15546         _res_ref.datalen = _res->arr_len;
15547         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
15548         memcpy(_res_ref.data, _res->elems, _res_ref.datalen); FREE(_res);
15549         CVec_u8Z_free(_res_ref);
15550 }
15551
15552 void  __attribute__((export_name("TS_CVec_CVec_u8ZZ_free"))) TS_CVec_CVec_u8ZZ_free(ptrArray _res) {
15553         LDKCVec_CVec_u8ZZ _res_constr;
15554         _res_constr.datalen = _res->arr_len;
15555         if (_res_constr.datalen > 0)
15556                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
15557         else
15558                 _res_constr.data = NULL;
15559         int8_tArray* _res_vals = (void*) _res->elems;
15560         for (size_t m = 0; m < _res_constr.datalen; m++) {
15561                 int8_tArray _res_conv_12 = _res_vals[m];
15562                 LDKCVec_u8Z _res_conv_12_ref;
15563                 _res_conv_12_ref.datalen = _res_conv_12->arr_len;
15564                 _res_conv_12_ref.data = MALLOC(_res_conv_12_ref.datalen, "LDKCVec_u8Z Bytes");
15565                 memcpy(_res_conv_12_ref.data, _res_conv_12->elems, _res_conv_12_ref.datalen); FREE(_res_conv_12);
15566                 _res_constr.data[m] = _res_conv_12_ref;
15567         }
15568         FREE(_res);
15569         CVec_CVec_u8ZZ_free(_res_constr);
15570 }
15571
15572 uint32_t  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_ok"))) TS_CResult_CVec_CVec_u8ZZNoneZ_ok(ptrArray o) {
15573         LDKCVec_CVec_u8ZZ o_constr;
15574         o_constr.datalen = o->arr_len;
15575         if (o_constr.datalen > 0)
15576                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
15577         else
15578                 o_constr.data = NULL;
15579         int8_tArray* o_vals = (void*) o->elems;
15580         for (size_t m = 0; m < o_constr.datalen; m++) {
15581                 int8_tArray o_conv_12 = o_vals[m];
15582                 LDKCVec_u8Z o_conv_12_ref;
15583                 o_conv_12_ref.datalen = o_conv_12->arr_len;
15584                 o_conv_12_ref.data = MALLOC(o_conv_12_ref.datalen, "LDKCVec_u8Z Bytes");
15585                 memcpy(o_conv_12_ref.data, o_conv_12->elems, o_conv_12_ref.datalen); FREE(o_conv_12);
15586                 o_constr.data[m] = o_conv_12_ref;
15587         }
15588         FREE(o);
15589         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
15590         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
15591         return (uint32_t)ret_conv;
15592 }
15593
15594 uint32_t  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_err"))) TS_CResult_CVec_CVec_u8ZZNoneZ_err() {
15595         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
15596         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
15597         return (uint32_t)ret_conv;
15598 }
15599
15600 jboolean  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_is_ok"))) TS_CResult_CVec_CVec_u8ZZNoneZ_is_ok(uint32_t o) {
15601         LDKCResult_CVec_CVec_u8ZZNoneZ* o_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(o & ~1);
15602         jboolean ret_conv = CResult_CVec_CVec_u8ZZNoneZ_is_ok(o_conv);
15603         return ret_conv;
15604 }
15605
15606 void  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_free"))) TS_CResult_CVec_CVec_u8ZZNoneZ_free(uint32_t _res) {
15607         if ((_res & 1) != 0) return;
15608         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15609         CHECK_ACCESS(_res_ptr);
15610         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(_res_ptr);
15611         FREE((void*)_res);
15612         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
15613 }
15614
15615 static inline uintptr_t CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR arg) {
15616         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
15617         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(arg);
15618         return (uint32_t)ret_conv;
15619 }
15620 uint32_t  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_clone_ptr"))) TS_CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(uint32_t arg) {
15621         LDKCResult_CVec_CVec_u8ZZNoneZ* arg_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
15622         uint32_t ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(arg_conv);
15623         return ret_conv;
15624 }
15625
15626 uint32_t  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_clone"))) TS_CResult_CVec_CVec_u8ZZNoneZ_clone(uint32_t orig) {
15627         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(orig & ~1);
15628         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
15629         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
15630         return (uint32_t)ret_conv;
15631 }
15632
15633 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_ok"))) TS_CResult_InMemorySignerDecodeErrorZ_ok(uint32_t o) {
15634         LDKInMemorySigner o_conv;
15635         o_conv.inner = (void*)(o & (~1));
15636         o_conv.is_owned = (o & 1) || (o == 0);
15637         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15638         o_conv = InMemorySigner_clone(&o_conv);
15639         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
15640         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
15641         return (uint32_t)ret_conv;
15642 }
15643
15644 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_err"))) TS_CResult_InMemorySignerDecodeErrorZ_err(uint32_t e) {
15645         LDKDecodeError e_conv;
15646         e_conv.inner = (void*)(e & (~1));
15647         e_conv.is_owned = (e & 1) || (e == 0);
15648         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15649         e_conv = DecodeError_clone(&e_conv);
15650         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
15651         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
15652         return (uint32_t)ret_conv;
15653 }
15654
15655 jboolean  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_is_ok"))) TS_CResult_InMemorySignerDecodeErrorZ_is_ok(uint32_t o) {
15656         LDKCResult_InMemorySignerDecodeErrorZ* o_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(o & ~1);
15657         jboolean ret_conv = CResult_InMemorySignerDecodeErrorZ_is_ok(o_conv);
15658         return ret_conv;
15659 }
15660
15661 void  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_free"))) TS_CResult_InMemorySignerDecodeErrorZ_free(uint32_t _res) {
15662         if ((_res & 1) != 0) return;
15663         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15664         CHECK_ACCESS(_res_ptr);
15665         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(_res_ptr);
15666         FREE((void*)_res);
15667         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
15668 }
15669
15670 static inline uintptr_t CResult_InMemorySignerDecodeErrorZ_clone_ptr(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR arg) {
15671         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
15672         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(arg);
15673         return (uint32_t)ret_conv;
15674 }
15675 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_clone_ptr"))) TS_CResult_InMemorySignerDecodeErrorZ_clone_ptr(uint32_t arg) {
15676         LDKCResult_InMemorySignerDecodeErrorZ* arg_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
15677         uint32_t ret_conv = CResult_InMemorySignerDecodeErrorZ_clone_ptr(arg_conv);
15678         return ret_conv;
15679 }
15680
15681 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_clone"))) TS_CResult_InMemorySignerDecodeErrorZ_clone(uint32_t orig) {
15682         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(orig & ~1);
15683         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
15684         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
15685         return (uint32_t)ret_conv;
15686 }
15687
15688 void  __attribute__((export_name("TS_CVec_TxOutZ_free"))) TS_CVec_TxOutZ_free(uint32_tArray _res) {
15689         LDKCVec_TxOutZ _res_constr;
15690         _res_constr.datalen = _res->arr_len;
15691         if (_res_constr.datalen > 0)
15692                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
15693         else
15694                 _res_constr.data = NULL;
15695         uint32_t* _res_vals = _res->elems;
15696         for (size_t h = 0; h < _res_constr.datalen; h++) {
15697                 uint32_t _res_conv_7 = _res_vals[h];
15698                 void* _res_conv_7_ptr = (void*)(((uintptr_t)_res_conv_7) & ~1);
15699                 CHECK_ACCESS(_res_conv_7_ptr);
15700                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(_res_conv_7_ptr);
15701                 FREE((void*)_res_conv_7);
15702                 _res_constr.data[h] = _res_conv_7_conv;
15703         }
15704         FREE(_res);
15705         CVec_TxOutZ_free(_res_constr);
15706 }
15707
15708 uint32_t  __attribute__((export_name("TS_CResult_TransactionNoneZ_ok"))) TS_CResult_TransactionNoneZ_ok(int8_tArray o) {
15709         LDKTransaction o_ref;
15710         o_ref.datalen = o->arr_len;
15711         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
15712         memcpy(o_ref.data, o->elems, o_ref.datalen); FREE(o);
15713         o_ref.data_is_owned = true;
15714         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
15715         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
15716         return (uint32_t)ret_conv;
15717 }
15718
15719 uint32_t  __attribute__((export_name("TS_CResult_TransactionNoneZ_err"))) TS_CResult_TransactionNoneZ_err() {
15720         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
15721         *ret_conv = CResult_TransactionNoneZ_err();
15722         return (uint32_t)ret_conv;
15723 }
15724
15725 jboolean  __attribute__((export_name("TS_CResult_TransactionNoneZ_is_ok"))) TS_CResult_TransactionNoneZ_is_ok(uint32_t o) {
15726         LDKCResult_TransactionNoneZ* o_conv = (LDKCResult_TransactionNoneZ*)(o & ~1);
15727         jboolean ret_conv = CResult_TransactionNoneZ_is_ok(o_conv);
15728         return ret_conv;
15729 }
15730
15731 void  __attribute__((export_name("TS_CResult_TransactionNoneZ_free"))) TS_CResult_TransactionNoneZ_free(uint32_t _res) {
15732         if ((_res & 1) != 0) return;
15733         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15734         CHECK_ACCESS(_res_ptr);
15735         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(_res_ptr);
15736         FREE((void*)_res);
15737         CResult_TransactionNoneZ_free(_res_conv);
15738 }
15739
15740 static inline uintptr_t CResult_TransactionNoneZ_clone_ptr(LDKCResult_TransactionNoneZ *NONNULL_PTR arg) {
15741         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
15742         *ret_conv = CResult_TransactionNoneZ_clone(arg);
15743         return (uint32_t)ret_conv;
15744 }
15745 uint32_t  __attribute__((export_name("TS_CResult_TransactionNoneZ_clone_ptr"))) TS_CResult_TransactionNoneZ_clone_ptr(uint32_t arg) {
15746         LDKCResult_TransactionNoneZ* arg_conv = (LDKCResult_TransactionNoneZ*)(arg & ~1);
15747         uint32_t ret_conv = CResult_TransactionNoneZ_clone_ptr(arg_conv);
15748         return ret_conv;
15749 }
15750
15751 uint32_t  __attribute__((export_name("TS_CResult_TransactionNoneZ_clone"))) TS_CResult_TransactionNoneZ_clone(uint32_t orig) {
15752         LDKCResult_TransactionNoneZ* orig_conv = (LDKCResult_TransactionNoneZ*)(orig & ~1);
15753         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
15754         *ret_conv = CResult_TransactionNoneZ_clone(orig_conv);
15755         return (uint32_t)ret_conv;
15756 }
15757
15758 uint32_t  __attribute__((export_name("TS_COption_u16Z_some"))) TS_COption_u16Z_some(int16_t o) {
15759         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
15760         *ret_copy = COption_u16Z_some(o);
15761         uint32_t ret_ref = (uintptr_t)ret_copy;
15762         return ret_ref;
15763 }
15764
15765 uint32_t  __attribute__((export_name("TS_COption_u16Z_none"))) TS_COption_u16Z_none() {
15766         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
15767         *ret_copy = COption_u16Z_none();
15768         uint32_t ret_ref = (uintptr_t)ret_copy;
15769         return ret_ref;
15770 }
15771
15772 void  __attribute__((export_name("TS_COption_u16Z_free"))) TS_COption_u16Z_free(uint32_t _res) {
15773         if ((_res & 1) != 0) return;
15774         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15775         CHECK_ACCESS(_res_ptr);
15776         LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(_res_ptr);
15777         FREE((void*)_res);
15778         COption_u16Z_free(_res_conv);
15779 }
15780
15781 static inline uintptr_t COption_u16Z_clone_ptr(LDKCOption_u16Z *NONNULL_PTR arg) {
15782         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
15783         *ret_copy = COption_u16Z_clone(arg);
15784 uint32_t ret_ref = (uintptr_t)ret_copy;
15785         return ret_ref;
15786 }
15787 uint32_t  __attribute__((export_name("TS_COption_u16Z_clone_ptr"))) TS_COption_u16Z_clone_ptr(uint32_t arg) {
15788         LDKCOption_u16Z* arg_conv = (LDKCOption_u16Z*)arg;
15789         uint32_t ret_conv = COption_u16Z_clone_ptr(arg_conv);
15790         return ret_conv;
15791 }
15792
15793 uint32_t  __attribute__((export_name("TS_COption_u16Z_clone"))) TS_COption_u16Z_clone(uint32_t orig) {
15794         LDKCOption_u16Z* orig_conv = (LDKCOption_u16Z*)orig;
15795         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
15796         *ret_copy = COption_u16Z_clone(orig_conv);
15797         uint32_t ret_ref = (uintptr_t)ret_copy;
15798         return ret_ref;
15799 }
15800
15801 uint32_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_ok"))) TS_CResult_NoneAPIErrorZ_ok() {
15802         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
15803         *ret_conv = CResult_NoneAPIErrorZ_ok();
15804         return (uint32_t)ret_conv;
15805 }
15806
15807 uint32_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_err"))) TS_CResult_NoneAPIErrorZ_err(uint32_t e) {
15808         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
15809         CHECK_ACCESS(e_ptr);
15810         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
15811         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
15812         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
15813         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
15814         return (uint32_t)ret_conv;
15815 }
15816
15817 jboolean  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_is_ok"))) TS_CResult_NoneAPIErrorZ_is_ok(uint32_t o) {
15818         LDKCResult_NoneAPIErrorZ* o_conv = (LDKCResult_NoneAPIErrorZ*)(o & ~1);
15819         jboolean ret_conv = CResult_NoneAPIErrorZ_is_ok(o_conv);
15820         return ret_conv;
15821 }
15822
15823 void  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_free"))) TS_CResult_NoneAPIErrorZ_free(uint32_t _res) {
15824         if ((_res & 1) != 0) return;
15825         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15826         CHECK_ACCESS(_res_ptr);
15827         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_ptr);
15828         FREE((void*)_res);
15829         CResult_NoneAPIErrorZ_free(_res_conv);
15830 }
15831
15832 static inline uintptr_t CResult_NoneAPIErrorZ_clone_ptr(LDKCResult_NoneAPIErrorZ *NONNULL_PTR arg) {
15833         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
15834         *ret_conv = CResult_NoneAPIErrorZ_clone(arg);
15835         return (uint32_t)ret_conv;
15836 }
15837 uint32_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_clone_ptr"))) TS_CResult_NoneAPIErrorZ_clone_ptr(uint32_t arg) {
15838         LDKCResult_NoneAPIErrorZ* arg_conv = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
15839         uint32_t ret_conv = CResult_NoneAPIErrorZ_clone_ptr(arg_conv);
15840         return ret_conv;
15841 }
15842
15843 uint32_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_clone"))) TS_CResult_NoneAPIErrorZ_clone(uint32_t orig) {
15844         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)(orig & ~1);
15845         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
15846         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
15847         return (uint32_t)ret_conv;
15848 }
15849
15850 void  __attribute__((export_name("TS_CVec_CResult_NoneAPIErrorZZ_free"))) TS_CVec_CResult_NoneAPIErrorZZ_free(uint32_tArray _res) {
15851         LDKCVec_CResult_NoneAPIErrorZZ _res_constr;
15852         _res_constr.datalen = _res->arr_len;
15853         if (_res_constr.datalen > 0)
15854                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
15855         else
15856                 _res_constr.data = NULL;
15857         uint32_t* _res_vals = _res->elems;
15858         for (size_t w = 0; w < _res_constr.datalen; w++) {
15859                 uint32_t _res_conv_22 = _res_vals[w];
15860                 void* _res_conv_22_ptr = (void*)(((uintptr_t)_res_conv_22) & ~1);
15861                 CHECK_ACCESS(_res_conv_22_ptr);
15862                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_conv_22_ptr);
15863                 FREE((void*)_res_conv_22);
15864                 _res_constr.data[w] = _res_conv_22_conv;
15865         }
15866         FREE(_res);
15867         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
15868 }
15869
15870 void  __attribute__((export_name("TS_CVec_APIErrorZ_free"))) TS_CVec_APIErrorZ_free(uint32_tArray _res) {
15871         LDKCVec_APIErrorZ _res_constr;
15872         _res_constr.datalen = _res->arr_len;
15873         if (_res_constr.datalen > 0)
15874                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
15875         else
15876                 _res_constr.data = NULL;
15877         uint32_t* _res_vals = _res->elems;
15878         for (size_t k = 0; k < _res_constr.datalen; k++) {
15879                 uint32_t _res_conv_10 = _res_vals[k];
15880                 void* _res_conv_10_ptr = (void*)(((uintptr_t)_res_conv_10) & ~1);
15881                 CHECK_ACCESS(_res_conv_10_ptr);
15882                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(_res_conv_10_ptr);
15883                 FREE((void*)_res_conv_10);
15884                 _res_constr.data[k] = _res_conv_10_conv;
15885         }
15886         FREE(_res);
15887         CVec_APIErrorZ_free(_res_constr);
15888 }
15889
15890 uint32_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_ok"))) TS_CResult__u832APIErrorZ_ok(int8_tArray o) {
15891         LDKThirtyTwoBytes o_ref;
15892         CHECK(o->arr_len == 32);
15893         memcpy(o_ref.data, o->elems, 32); FREE(o);
15894         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
15895         *ret_conv = CResult__u832APIErrorZ_ok(o_ref);
15896         return (uint32_t)ret_conv;
15897 }
15898
15899 uint32_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_err"))) TS_CResult__u832APIErrorZ_err(uint32_t e) {
15900         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
15901         CHECK_ACCESS(e_ptr);
15902         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
15903         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
15904         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
15905         *ret_conv = CResult__u832APIErrorZ_err(e_conv);
15906         return (uint32_t)ret_conv;
15907 }
15908
15909 jboolean  __attribute__((export_name("TS_CResult__u832APIErrorZ_is_ok"))) TS_CResult__u832APIErrorZ_is_ok(uint32_t o) {
15910         LDKCResult__u832APIErrorZ* o_conv = (LDKCResult__u832APIErrorZ*)(o & ~1);
15911         jboolean ret_conv = CResult__u832APIErrorZ_is_ok(o_conv);
15912         return ret_conv;
15913 }
15914
15915 void  __attribute__((export_name("TS_CResult__u832APIErrorZ_free"))) TS_CResult__u832APIErrorZ_free(uint32_t _res) {
15916         if ((_res & 1) != 0) return;
15917         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15918         CHECK_ACCESS(_res_ptr);
15919         LDKCResult__u832APIErrorZ _res_conv = *(LDKCResult__u832APIErrorZ*)(_res_ptr);
15920         FREE((void*)_res);
15921         CResult__u832APIErrorZ_free(_res_conv);
15922 }
15923
15924 static inline uintptr_t CResult__u832APIErrorZ_clone_ptr(LDKCResult__u832APIErrorZ *NONNULL_PTR arg) {
15925         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
15926         *ret_conv = CResult__u832APIErrorZ_clone(arg);
15927         return (uint32_t)ret_conv;
15928 }
15929 uint32_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_clone_ptr"))) TS_CResult__u832APIErrorZ_clone_ptr(uint32_t arg) {
15930         LDKCResult__u832APIErrorZ* arg_conv = (LDKCResult__u832APIErrorZ*)(arg & ~1);
15931         uint32_t ret_conv = CResult__u832APIErrorZ_clone_ptr(arg_conv);
15932         return ret_conv;
15933 }
15934
15935 uint32_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_clone"))) TS_CResult__u832APIErrorZ_clone(uint32_t orig) {
15936         LDKCResult__u832APIErrorZ* orig_conv = (LDKCResult__u832APIErrorZ*)(orig & ~1);
15937         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
15938         *ret_conv = CResult__u832APIErrorZ_clone(orig_conv);
15939         return (uint32_t)ret_conv;
15940 }
15941
15942 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_ok"))) TS_CResult_PaymentIdPaymentSendFailureZ_ok(int8_tArray o) {
15943         LDKThirtyTwoBytes o_ref;
15944         CHECK(o->arr_len == 32);
15945         memcpy(o_ref.data, o->elems, 32); FREE(o);
15946         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
15947         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_ok(o_ref);
15948         return (uint32_t)ret_conv;
15949 }
15950
15951 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_err"))) TS_CResult_PaymentIdPaymentSendFailureZ_err(uint32_t e) {
15952         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
15953         CHECK_ACCESS(e_ptr);
15954         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
15955         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
15956         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
15957         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_err(e_conv);
15958         return (uint32_t)ret_conv;
15959 }
15960
15961 jboolean  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_is_ok"))) TS_CResult_PaymentIdPaymentSendFailureZ_is_ok(uint32_t o) {
15962         LDKCResult_PaymentIdPaymentSendFailureZ* o_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(o & ~1);
15963         jboolean ret_conv = CResult_PaymentIdPaymentSendFailureZ_is_ok(o_conv);
15964         return ret_conv;
15965 }
15966
15967 void  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_free"))) TS_CResult_PaymentIdPaymentSendFailureZ_free(uint32_t _res) {
15968         if ((_res & 1) != 0) return;
15969         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15970         CHECK_ACCESS(_res_ptr);
15971         LDKCResult_PaymentIdPaymentSendFailureZ _res_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(_res_ptr);
15972         FREE((void*)_res);
15973         CResult_PaymentIdPaymentSendFailureZ_free(_res_conv);
15974 }
15975
15976 static inline uintptr_t CResult_PaymentIdPaymentSendFailureZ_clone_ptr(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR arg) {
15977         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
15978         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(arg);
15979         return (uint32_t)ret_conv;
15980 }
15981 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_clone_ptr"))) TS_CResult_PaymentIdPaymentSendFailureZ_clone_ptr(uint32_t arg) {
15982         LDKCResult_PaymentIdPaymentSendFailureZ* arg_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(arg & ~1);
15983         uint32_t ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone_ptr(arg_conv);
15984         return ret_conv;
15985 }
15986
15987 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_clone"))) TS_CResult_PaymentIdPaymentSendFailureZ_clone(uint32_t orig) {
15988         LDKCResult_PaymentIdPaymentSendFailureZ* orig_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(orig & ~1);
15989         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
15990         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(orig_conv);
15991         return (uint32_t)ret_conv;
15992 }
15993
15994 uint32_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_ok"))) TS_CResult_NonePaymentSendFailureZ_ok() {
15995         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
15996         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
15997         return (uint32_t)ret_conv;
15998 }
15999
16000 uint32_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_err"))) TS_CResult_NonePaymentSendFailureZ_err(uint32_t e) {
16001         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
16002         CHECK_ACCESS(e_ptr);
16003         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
16004         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
16005         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
16006         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
16007         return (uint32_t)ret_conv;
16008 }
16009
16010 jboolean  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_is_ok"))) TS_CResult_NonePaymentSendFailureZ_is_ok(uint32_t o) {
16011         LDKCResult_NonePaymentSendFailureZ* o_conv = (LDKCResult_NonePaymentSendFailureZ*)(o & ~1);
16012         jboolean ret_conv = CResult_NonePaymentSendFailureZ_is_ok(o_conv);
16013         return ret_conv;
16014 }
16015
16016 void  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_free"))) TS_CResult_NonePaymentSendFailureZ_free(uint32_t _res) {
16017         if ((_res & 1) != 0) return;
16018         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16019         CHECK_ACCESS(_res_ptr);
16020         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(_res_ptr);
16021         FREE((void*)_res);
16022         CResult_NonePaymentSendFailureZ_free(_res_conv);
16023 }
16024
16025 static inline uintptr_t CResult_NonePaymentSendFailureZ_clone_ptr(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR arg) {
16026         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
16027         *ret_conv = CResult_NonePaymentSendFailureZ_clone(arg);
16028         return (uint32_t)ret_conv;
16029 }
16030 uint32_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_clone_ptr"))) TS_CResult_NonePaymentSendFailureZ_clone_ptr(uint32_t arg) {
16031         LDKCResult_NonePaymentSendFailureZ* arg_conv = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
16032         uint32_t ret_conv = CResult_NonePaymentSendFailureZ_clone_ptr(arg_conv);
16033         return ret_conv;
16034 }
16035
16036 uint32_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_clone"))) TS_CResult_NonePaymentSendFailureZ_clone(uint32_t orig) {
16037         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)(orig & ~1);
16038         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
16039         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
16040         return (uint32_t)ret_conv;
16041 }
16042
16043 static inline uintptr_t C2Tuple_PaymentHashPaymentIdZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR arg) {
16044         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
16045         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(arg);
16046         return ((uint32_t)ret_conv);
16047 }
16048 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_clone_ptr"))) TS_C2Tuple_PaymentHashPaymentIdZ_clone_ptr(uint32_t arg) {
16049         LDKC2Tuple_PaymentHashPaymentIdZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(arg & ~1);
16050         uint32_t ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone_ptr(arg_conv);
16051         return ret_conv;
16052 }
16053
16054 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_clone"))) TS_C2Tuple_PaymentHashPaymentIdZ_clone(uint32_t orig) {
16055         LDKC2Tuple_PaymentHashPaymentIdZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(orig & ~1);
16056         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
16057         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(orig_conv);
16058         return ((uint32_t)ret_conv);
16059 }
16060
16061 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_new"))) TS_C2Tuple_PaymentHashPaymentIdZ_new(int8_tArray a, int8_tArray b) {
16062         LDKThirtyTwoBytes a_ref;
16063         CHECK(a->arr_len == 32);
16064         memcpy(a_ref.data, a->elems, 32); FREE(a);
16065         LDKThirtyTwoBytes b_ref;
16066         CHECK(b->arr_len == 32);
16067         memcpy(b_ref.data, b->elems, 32); FREE(b);
16068         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
16069         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_new(a_ref, b_ref);
16070         return ((uint32_t)ret_conv);
16071 }
16072
16073 void  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_free"))) TS_C2Tuple_PaymentHashPaymentIdZ_free(uint32_t _res) {
16074         if ((_res & 1) != 0) return;
16075         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16076         CHECK_ACCESS(_res_ptr);
16077         LDKC2Tuple_PaymentHashPaymentIdZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(_res_ptr);
16078         FREE((void*)_res);
16079         C2Tuple_PaymentHashPaymentIdZ_free(_res_conv);
16080 }
16081
16082 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(uint32_t o) {
16083         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16084         CHECK_ACCESS(o_ptr);
16085         LDKC2Tuple_PaymentHashPaymentIdZ o_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(o_ptr);
16086         o_conv = C2Tuple_PaymentHashPaymentIdZ_clone((LDKC2Tuple_PaymentHashPaymentIdZ*)(((uintptr_t)o) & ~1));
16087         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
16088         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(o_conv);
16089         return (uint32_t)ret_conv;
16090 }
16091
16092 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(uint32_t e) {
16093         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
16094         CHECK_ACCESS(e_ptr);
16095         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
16096         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
16097         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
16098         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(e_conv);
16099         return (uint32_t)ret_conv;
16100 }
16101
16102 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok(uint32_t o) {
16103         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(o & ~1);
16104         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok(o_conv);
16105         return ret_conv;
16106 }
16107
16108 void  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(uint32_t _res) {
16109         if ((_res & 1) != 0) return;
16110         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16111         CHECK_ACCESS(_res_ptr);
16112         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(_res_ptr);
16113         FREE((void*)_res);
16114         CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(_res_conv);
16115 }
16116
16117 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR arg) {
16118         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
16119         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(arg);
16120         return (uint32_t)ret_conv;
16121 }
16122 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(uint32_t arg) {
16123         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(arg & ~1);
16124         uint32_t ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(arg_conv);
16125         return ret_conv;
16126 }
16127
16128 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(uint32_t orig) {
16129         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(orig & ~1);
16130         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
16131         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(orig_conv);
16132         return (uint32_t)ret_conv;
16133 }
16134
16135 void  __attribute__((export_name("TS_CVec_ThirtyTwoBytesZ_free"))) TS_CVec_ThirtyTwoBytesZ_free(ptrArray _res) {
16136         LDKCVec_ThirtyTwoBytesZ _res_constr;
16137         _res_constr.datalen = _res->arr_len;
16138         if (_res_constr.datalen > 0)
16139                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_ThirtyTwoBytesZ Elements");
16140         else
16141                 _res_constr.data = NULL;
16142         int8_tArray* _res_vals = (void*) _res->elems;
16143         for (size_t m = 0; m < _res_constr.datalen; m++) {
16144                 int8_tArray _res_conv_12 = _res_vals[m];
16145                 LDKThirtyTwoBytes _res_conv_12_ref;
16146                 CHECK(_res_conv_12->arr_len == 32);
16147                 memcpy(_res_conv_12_ref.data, _res_conv_12->elems, 32); FREE(_res_conv_12);
16148                 _res_constr.data[m] = _res_conv_12_ref;
16149         }
16150         FREE(_res);
16151         CVec_ThirtyTwoBytesZ_free(_res_constr);
16152 }
16153
16154 static inline uintptr_t C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR arg) {
16155         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
16156         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(arg);
16157         return ((uint32_t)ret_conv);
16158 }
16159 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_clone_ptr"))) TS_C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(uint32_t arg) {
16160         LDKC2Tuple_PaymentHashPaymentSecretZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(arg & ~1);
16161         uint32_t ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(arg_conv);
16162         return ret_conv;
16163 }
16164
16165 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_clone"))) TS_C2Tuple_PaymentHashPaymentSecretZ_clone(uint32_t orig) {
16166         LDKC2Tuple_PaymentHashPaymentSecretZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(orig & ~1);
16167         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
16168         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(orig_conv);
16169         return ((uint32_t)ret_conv);
16170 }
16171
16172 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_new"))) TS_C2Tuple_PaymentHashPaymentSecretZ_new(int8_tArray a, int8_tArray b) {
16173         LDKThirtyTwoBytes a_ref;
16174         CHECK(a->arr_len == 32);
16175         memcpy(a_ref.data, a->elems, 32); FREE(a);
16176         LDKThirtyTwoBytes b_ref;
16177         CHECK(b->arr_len == 32);
16178         memcpy(b_ref.data, b->elems, 32); FREE(b);
16179         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
16180         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_new(a_ref, b_ref);
16181         return ((uint32_t)ret_conv);
16182 }
16183
16184 void  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_free"))) TS_C2Tuple_PaymentHashPaymentSecretZ_free(uint32_t _res) {
16185         if ((_res & 1) != 0) return;
16186         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16187         CHECK_ACCESS(_res_ptr);
16188         LDKC2Tuple_PaymentHashPaymentSecretZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(_res_ptr);
16189         FREE((void*)_res);
16190         C2Tuple_PaymentHashPaymentSecretZ_free(_res_conv);
16191 }
16192
16193 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok(uint32_t o) {
16194         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16195         CHECK_ACCESS(o_ptr);
16196         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
16197         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uintptr_t)o) & ~1));
16198         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
16199         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok(o_conv);
16200         return (uint32_t)ret_conv;
16201 }
16202
16203 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err() {
16204         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
16205         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err();
16206         return (uint32_t)ret_conv;
16207 }
16208
16209 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok(uint32_t o) {
16210         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(o & ~1);
16211         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok(o_conv);
16212         return ret_conv;
16213 }
16214
16215 void  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free(uint32_t _res) {
16216         if ((_res & 1) != 0) return;
16217         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16218         CHECK_ACCESS(_res_ptr);
16219         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(_res_ptr);
16220         FREE((void*)_res);
16221         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free(_res_conv);
16222 }
16223
16224 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR arg) {
16225         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
16226         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(arg);
16227         return (uint32_t)ret_conv;
16228 }
16229 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(uint32_t arg) {
16230         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(arg & ~1);
16231         uint32_t ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(arg_conv);
16232         return ret_conv;
16233 }
16234
16235 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(uint32_t orig) {
16236         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(orig & ~1);
16237         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
16238         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(orig_conv);
16239         return (uint32_t)ret_conv;
16240 }
16241
16242 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok(uint32_t o) {
16243         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16244         CHECK_ACCESS(o_ptr);
16245         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
16246         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uintptr_t)o) & ~1));
16247         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
16248         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok(o_conv);
16249         return (uint32_t)ret_conv;
16250 }
16251
16252 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err(uint32_t e) {
16253         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
16254         CHECK_ACCESS(e_ptr);
16255         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
16256         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
16257         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
16258         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err(e_conv);
16259         return (uint32_t)ret_conv;
16260 }
16261
16262 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok(uint32_t o) {
16263         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(o & ~1);
16264         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok(o_conv);
16265         return ret_conv;
16266 }
16267
16268 void  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free(uint32_t _res) {
16269         if ((_res & 1) != 0) return;
16270         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16271         CHECK_ACCESS(_res_ptr);
16272         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(_res_ptr);
16273         FREE((void*)_res);
16274         CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free(_res_conv);
16275 }
16276
16277 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR arg) {
16278         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
16279         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(arg);
16280         return (uint32_t)ret_conv;
16281 }
16282 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(uint32_t arg) {
16283         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(arg & ~1);
16284         uint32_t ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(arg_conv);
16285         return ret_conv;
16286 }
16287
16288 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(uint32_t orig) {
16289         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(orig & ~1);
16290         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
16291         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(orig_conv);
16292         return (uint32_t)ret_conv;
16293 }
16294
16295 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_ok"))) TS_CResult_PaymentSecretNoneZ_ok(int8_tArray o) {
16296         LDKThirtyTwoBytes o_ref;
16297         CHECK(o->arr_len == 32);
16298         memcpy(o_ref.data, o->elems, 32); FREE(o);
16299         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
16300         *ret_conv = CResult_PaymentSecretNoneZ_ok(o_ref);
16301         return (uint32_t)ret_conv;
16302 }
16303
16304 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_err"))) TS_CResult_PaymentSecretNoneZ_err() {
16305         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
16306         *ret_conv = CResult_PaymentSecretNoneZ_err();
16307         return (uint32_t)ret_conv;
16308 }
16309
16310 jboolean  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_is_ok"))) TS_CResult_PaymentSecretNoneZ_is_ok(uint32_t o) {
16311         LDKCResult_PaymentSecretNoneZ* o_conv = (LDKCResult_PaymentSecretNoneZ*)(o & ~1);
16312         jboolean ret_conv = CResult_PaymentSecretNoneZ_is_ok(o_conv);
16313         return ret_conv;
16314 }
16315
16316 void  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_free"))) TS_CResult_PaymentSecretNoneZ_free(uint32_t _res) {
16317         if ((_res & 1) != 0) return;
16318         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16319         CHECK_ACCESS(_res_ptr);
16320         LDKCResult_PaymentSecretNoneZ _res_conv = *(LDKCResult_PaymentSecretNoneZ*)(_res_ptr);
16321         FREE((void*)_res);
16322         CResult_PaymentSecretNoneZ_free(_res_conv);
16323 }
16324
16325 static inline uintptr_t CResult_PaymentSecretNoneZ_clone_ptr(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR arg) {
16326         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
16327         *ret_conv = CResult_PaymentSecretNoneZ_clone(arg);
16328         return (uint32_t)ret_conv;
16329 }
16330 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_clone_ptr"))) TS_CResult_PaymentSecretNoneZ_clone_ptr(uint32_t arg) {
16331         LDKCResult_PaymentSecretNoneZ* arg_conv = (LDKCResult_PaymentSecretNoneZ*)(arg & ~1);
16332         uint32_t ret_conv = CResult_PaymentSecretNoneZ_clone_ptr(arg_conv);
16333         return ret_conv;
16334 }
16335
16336 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_clone"))) TS_CResult_PaymentSecretNoneZ_clone(uint32_t orig) {
16337         LDKCResult_PaymentSecretNoneZ* orig_conv = (LDKCResult_PaymentSecretNoneZ*)(orig & ~1);
16338         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
16339         *ret_conv = CResult_PaymentSecretNoneZ_clone(orig_conv);
16340         return (uint32_t)ret_conv;
16341 }
16342
16343 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_ok"))) TS_CResult_PaymentSecretAPIErrorZ_ok(int8_tArray o) {
16344         LDKThirtyTwoBytes o_ref;
16345         CHECK(o->arr_len == 32);
16346         memcpy(o_ref.data, o->elems, 32); FREE(o);
16347         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
16348         *ret_conv = CResult_PaymentSecretAPIErrorZ_ok(o_ref);
16349         return (uint32_t)ret_conv;
16350 }
16351
16352 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_err"))) TS_CResult_PaymentSecretAPIErrorZ_err(uint32_t e) {
16353         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
16354         CHECK_ACCESS(e_ptr);
16355         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
16356         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
16357         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
16358         *ret_conv = CResult_PaymentSecretAPIErrorZ_err(e_conv);
16359         return (uint32_t)ret_conv;
16360 }
16361
16362 jboolean  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_is_ok"))) TS_CResult_PaymentSecretAPIErrorZ_is_ok(uint32_t o) {
16363         LDKCResult_PaymentSecretAPIErrorZ* o_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(o & ~1);
16364         jboolean ret_conv = CResult_PaymentSecretAPIErrorZ_is_ok(o_conv);
16365         return ret_conv;
16366 }
16367
16368 void  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_free"))) TS_CResult_PaymentSecretAPIErrorZ_free(uint32_t _res) {
16369         if ((_res & 1) != 0) return;
16370         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16371         CHECK_ACCESS(_res_ptr);
16372         LDKCResult_PaymentSecretAPIErrorZ _res_conv = *(LDKCResult_PaymentSecretAPIErrorZ*)(_res_ptr);
16373         FREE((void*)_res);
16374         CResult_PaymentSecretAPIErrorZ_free(_res_conv);
16375 }
16376
16377 static inline uintptr_t CResult_PaymentSecretAPIErrorZ_clone_ptr(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR arg) {
16378         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
16379         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(arg);
16380         return (uint32_t)ret_conv;
16381 }
16382 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_clone_ptr"))) TS_CResult_PaymentSecretAPIErrorZ_clone_ptr(uint32_t arg) {
16383         LDKCResult_PaymentSecretAPIErrorZ* arg_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
16384         uint32_t ret_conv = CResult_PaymentSecretAPIErrorZ_clone_ptr(arg_conv);
16385         return ret_conv;
16386 }
16387
16388 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_clone"))) TS_CResult_PaymentSecretAPIErrorZ_clone(uint32_t orig) {
16389         LDKCResult_PaymentSecretAPIErrorZ* orig_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(orig & ~1);
16390         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
16391         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(orig_conv);
16392         return (uint32_t)ret_conv;
16393 }
16394
16395 uint32_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_ok"))) TS_CResult_PaymentPreimageAPIErrorZ_ok(int8_tArray o) {
16396         LDKThirtyTwoBytes o_ref;
16397         CHECK(o->arr_len == 32);
16398         memcpy(o_ref.data, o->elems, 32); FREE(o);
16399         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
16400         *ret_conv = CResult_PaymentPreimageAPIErrorZ_ok(o_ref);
16401         return (uint32_t)ret_conv;
16402 }
16403
16404 uint32_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_err"))) TS_CResult_PaymentPreimageAPIErrorZ_err(uint32_t e) {
16405         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
16406         CHECK_ACCESS(e_ptr);
16407         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
16408         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
16409         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
16410         *ret_conv = CResult_PaymentPreimageAPIErrorZ_err(e_conv);
16411         return (uint32_t)ret_conv;
16412 }
16413
16414 jboolean  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_is_ok"))) TS_CResult_PaymentPreimageAPIErrorZ_is_ok(uint32_t o) {
16415         LDKCResult_PaymentPreimageAPIErrorZ* o_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(o & ~1);
16416         jboolean ret_conv = CResult_PaymentPreimageAPIErrorZ_is_ok(o_conv);
16417         return ret_conv;
16418 }
16419
16420 void  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_free"))) TS_CResult_PaymentPreimageAPIErrorZ_free(uint32_t _res) {
16421         if ((_res & 1) != 0) return;
16422         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16423         CHECK_ACCESS(_res_ptr);
16424         LDKCResult_PaymentPreimageAPIErrorZ _res_conv = *(LDKCResult_PaymentPreimageAPIErrorZ*)(_res_ptr);
16425         FREE((void*)_res);
16426         CResult_PaymentPreimageAPIErrorZ_free(_res_conv);
16427 }
16428
16429 static inline uintptr_t CResult_PaymentPreimageAPIErrorZ_clone_ptr(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR arg) {
16430         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
16431         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(arg);
16432         return (uint32_t)ret_conv;
16433 }
16434 uint32_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_clone_ptr"))) TS_CResult_PaymentPreimageAPIErrorZ_clone_ptr(uint32_t arg) {
16435         LDKCResult_PaymentPreimageAPIErrorZ* arg_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(arg & ~1);
16436         uint32_t ret_conv = CResult_PaymentPreimageAPIErrorZ_clone_ptr(arg_conv);
16437         return ret_conv;
16438 }
16439
16440 uint32_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_clone"))) TS_CResult_PaymentPreimageAPIErrorZ_clone(uint32_t orig) {
16441         LDKCResult_PaymentPreimageAPIErrorZ* orig_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(orig & ~1);
16442         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
16443         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(orig_conv);
16444         return (uint32_t)ret_conv;
16445 }
16446
16447 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_ok"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_ok(uint32_t o) {
16448         LDKCounterpartyForwardingInfo o_conv;
16449         o_conv.inner = (void*)(o & (~1));
16450         o_conv.is_owned = (o & 1) || (o == 0);
16451         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16452         o_conv = CounterpartyForwardingInfo_clone(&o_conv);
16453         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
16454         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_ok(o_conv);
16455         return (uint32_t)ret_conv;
16456 }
16457
16458 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_err"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_err(uint32_t e) {
16459         LDKDecodeError e_conv;
16460         e_conv.inner = (void*)(e & (~1));
16461         e_conv.is_owned = (e & 1) || (e == 0);
16462         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16463         e_conv = DecodeError_clone(&e_conv);
16464         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
16465         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_err(e_conv);
16466         return (uint32_t)ret_conv;
16467 }
16468
16469 jboolean  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok(uint32_t o) {
16470         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* o_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(o & ~1);
16471         jboolean ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok(o_conv);
16472         return ret_conv;
16473 }
16474
16475 void  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_free"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_free(uint32_t _res) {
16476         if ((_res & 1) != 0) return;
16477         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16478         CHECK_ACCESS(_res_ptr);
16479         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(_res_ptr);
16480         FREE((void*)_res);
16481         CResult_CounterpartyForwardingInfoDecodeErrorZ_free(_res_conv);
16482 }
16483
16484 static inline uintptr_t CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR arg) {
16485         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
16486         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(arg);
16487         return (uint32_t)ret_conv;
16488 }
16489 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
16490         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(arg & ~1);
16491         uint32_t ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(arg_conv);
16492         return ret_conv;
16493 }
16494
16495 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_clone"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(uint32_t orig) {
16496         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(orig & ~1);
16497         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
16498         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(orig_conv);
16499         return (uint32_t)ret_conv;
16500 }
16501
16502 uint32_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_ok"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_ok(uint32_t o) {
16503         LDKChannelCounterparty o_conv;
16504         o_conv.inner = (void*)(o & (~1));
16505         o_conv.is_owned = (o & 1) || (o == 0);
16506         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16507         o_conv = ChannelCounterparty_clone(&o_conv);
16508         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
16509         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_ok(o_conv);
16510         return (uint32_t)ret_conv;
16511 }
16512
16513 uint32_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_err"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_err(uint32_t e) {
16514         LDKDecodeError e_conv;
16515         e_conv.inner = (void*)(e & (~1));
16516         e_conv.is_owned = (e & 1) || (e == 0);
16517         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16518         e_conv = DecodeError_clone(&e_conv);
16519         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
16520         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_err(e_conv);
16521         return (uint32_t)ret_conv;
16522 }
16523
16524 jboolean  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_is_ok"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_is_ok(uint32_t o) {
16525         LDKCResult_ChannelCounterpartyDecodeErrorZ* o_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(o & ~1);
16526         jboolean ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_is_ok(o_conv);
16527         return ret_conv;
16528 }
16529
16530 void  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_free"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_free(uint32_t _res) {
16531         if ((_res & 1) != 0) return;
16532         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16533         CHECK_ACCESS(_res_ptr);
16534         LDKCResult_ChannelCounterpartyDecodeErrorZ _res_conv = *(LDKCResult_ChannelCounterpartyDecodeErrorZ*)(_res_ptr);
16535         FREE((void*)_res);
16536         CResult_ChannelCounterpartyDecodeErrorZ_free(_res_conv);
16537 }
16538
16539 static inline uintptr_t CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR arg) {
16540         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
16541         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone(arg);
16542         return (uint32_t)ret_conv;
16543 }
16544 uint32_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(uint32_t arg) {
16545         LDKCResult_ChannelCounterpartyDecodeErrorZ* arg_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(arg & ~1);
16546         uint32_t ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(arg_conv);
16547         return ret_conv;
16548 }
16549
16550 uint32_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_clone"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_clone(uint32_t orig) {
16551         LDKCResult_ChannelCounterpartyDecodeErrorZ* orig_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(orig & ~1);
16552         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
16553         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone(orig_conv);
16554         return (uint32_t)ret_conv;
16555 }
16556
16557 uint32_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_ok"))) TS_CResult_ChannelDetailsDecodeErrorZ_ok(uint32_t o) {
16558         LDKChannelDetails o_conv;
16559         o_conv.inner = (void*)(o & (~1));
16560         o_conv.is_owned = (o & 1) || (o == 0);
16561         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16562         o_conv = ChannelDetails_clone(&o_conv);
16563         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
16564         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_ok(o_conv);
16565         return (uint32_t)ret_conv;
16566 }
16567
16568 uint32_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_err"))) TS_CResult_ChannelDetailsDecodeErrorZ_err(uint32_t e) {
16569         LDKDecodeError e_conv;
16570         e_conv.inner = (void*)(e & (~1));
16571         e_conv.is_owned = (e & 1) || (e == 0);
16572         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16573         e_conv = DecodeError_clone(&e_conv);
16574         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
16575         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_err(e_conv);
16576         return (uint32_t)ret_conv;
16577 }
16578
16579 jboolean  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_is_ok"))) TS_CResult_ChannelDetailsDecodeErrorZ_is_ok(uint32_t o) {
16580         LDKCResult_ChannelDetailsDecodeErrorZ* o_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(o & ~1);
16581         jboolean ret_conv = CResult_ChannelDetailsDecodeErrorZ_is_ok(o_conv);
16582         return ret_conv;
16583 }
16584
16585 void  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_free"))) TS_CResult_ChannelDetailsDecodeErrorZ_free(uint32_t _res) {
16586         if ((_res & 1) != 0) return;
16587         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16588         CHECK_ACCESS(_res_ptr);
16589         LDKCResult_ChannelDetailsDecodeErrorZ _res_conv = *(LDKCResult_ChannelDetailsDecodeErrorZ*)(_res_ptr);
16590         FREE((void*)_res);
16591         CResult_ChannelDetailsDecodeErrorZ_free(_res_conv);
16592 }
16593
16594 static inline uintptr_t CResult_ChannelDetailsDecodeErrorZ_clone_ptr(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR arg) {
16595         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
16596         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone(arg);
16597         return (uint32_t)ret_conv;
16598 }
16599 uint32_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelDetailsDecodeErrorZ_clone_ptr(uint32_t arg) {
16600         LDKCResult_ChannelDetailsDecodeErrorZ* arg_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(arg & ~1);
16601         uint32_t ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone_ptr(arg_conv);
16602         return ret_conv;
16603 }
16604
16605 uint32_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_clone"))) TS_CResult_ChannelDetailsDecodeErrorZ_clone(uint32_t orig) {
16606         LDKCResult_ChannelDetailsDecodeErrorZ* orig_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(orig & ~1);
16607         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
16608         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone(orig_conv);
16609         return (uint32_t)ret_conv;
16610 }
16611
16612 uint32_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_ok"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_ok(uint32_t o) {
16613         LDKPhantomRouteHints o_conv;
16614         o_conv.inner = (void*)(o & (~1));
16615         o_conv.is_owned = (o & 1) || (o == 0);
16616         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16617         o_conv = PhantomRouteHints_clone(&o_conv);
16618         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
16619         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_ok(o_conv);
16620         return (uint32_t)ret_conv;
16621 }
16622
16623 uint32_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_err"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_err(uint32_t e) {
16624         LDKDecodeError e_conv;
16625         e_conv.inner = (void*)(e & (~1));
16626         e_conv.is_owned = (e & 1) || (e == 0);
16627         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16628         e_conv = DecodeError_clone(&e_conv);
16629         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
16630         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_err(e_conv);
16631         return (uint32_t)ret_conv;
16632 }
16633
16634 jboolean  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_is_ok"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_is_ok(uint32_t o) {
16635         LDKCResult_PhantomRouteHintsDecodeErrorZ* o_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(o & ~1);
16636         jboolean ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_is_ok(o_conv);
16637         return ret_conv;
16638 }
16639
16640 void  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_free"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_free(uint32_t _res) {
16641         if ((_res & 1) != 0) return;
16642         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16643         CHECK_ACCESS(_res_ptr);
16644         LDKCResult_PhantomRouteHintsDecodeErrorZ _res_conv = *(LDKCResult_PhantomRouteHintsDecodeErrorZ*)(_res_ptr);
16645         FREE((void*)_res);
16646         CResult_PhantomRouteHintsDecodeErrorZ_free(_res_conv);
16647 }
16648
16649 static inline uintptr_t CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR arg) {
16650         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
16651         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone(arg);
16652         return (uint32_t)ret_conv;
16653 }
16654 uint32_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(uint32_t arg) {
16655         LDKCResult_PhantomRouteHintsDecodeErrorZ* arg_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(arg & ~1);
16656         uint32_t ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(arg_conv);
16657         return ret_conv;
16658 }
16659
16660 uint32_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_clone"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_clone(uint32_t orig) {
16661         LDKCResult_PhantomRouteHintsDecodeErrorZ* orig_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(orig & ~1);
16662         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
16663         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone(orig_conv);
16664         return (uint32_t)ret_conv;
16665 }
16666
16667 void  __attribute__((export_name("TS_CVec_ChannelMonitorZ_free"))) TS_CVec_ChannelMonitorZ_free(uint32_tArray _res) {
16668         LDKCVec_ChannelMonitorZ _res_constr;
16669         _res_constr.datalen = _res->arr_len;
16670         if (_res_constr.datalen > 0)
16671                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
16672         else
16673                 _res_constr.data = NULL;
16674         uint32_t* _res_vals = _res->elems;
16675         for (size_t q = 0; q < _res_constr.datalen; q++) {
16676                 uint32_t _res_conv_16 = _res_vals[q];
16677                 LDKChannelMonitor _res_conv_16_conv;
16678                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
16679                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
16680                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
16681                 _res_constr.data[q] = _res_conv_16_conv;
16682         }
16683         FREE(_res);
16684         CVec_ChannelMonitorZ_free(_res_constr);
16685 }
16686
16687 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_new"))) TS_C2Tuple_BlockHashChannelManagerZ_new(int8_tArray a, uint32_t b) {
16688         LDKThirtyTwoBytes a_ref;
16689         CHECK(a->arr_len == 32);
16690         memcpy(a_ref.data, a->elems, 32); FREE(a);
16691         LDKChannelManager b_conv;
16692         b_conv.inner = (void*)(b & (~1));
16693         b_conv.is_owned = (b & 1) || (b == 0);
16694         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
16695         // WARNING: we need a move here but no clone is available for LDKChannelManager
16696         LDKC2Tuple_BlockHashChannelManagerZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
16697         *ret_conv = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
16698         return ((uint32_t)ret_conv);
16699 }
16700
16701 void  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_free"))) TS_C2Tuple_BlockHashChannelManagerZ_free(uint32_t _res) {
16702         if ((_res & 1) != 0) return;
16703         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16704         CHECK_ACCESS(_res_ptr);
16705         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(_res_ptr);
16706         FREE((void*)_res);
16707         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
16708 }
16709
16710 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(uint32_t o) {
16711         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16712         CHECK_ACCESS(o_ptr);
16713         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(o_ptr);
16714         // WARNING: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelManagerZ
16715         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
16716         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
16717         return (uint32_t)ret_conv;
16718 }
16719
16720 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(uint32_t e) {
16721         LDKDecodeError e_conv;
16722         e_conv.inner = (void*)(e & (~1));
16723         e_conv.is_owned = (e & 1) || (e == 0);
16724         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16725         e_conv = DecodeError_clone(&e_conv);
16726         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
16727         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
16728         return (uint32_t)ret_conv;
16729 }
16730
16731 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok(uint32_t o) {
16732         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(o & ~1);
16733         jboolean ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok(o_conv);
16734         return ret_conv;
16735 }
16736
16737 void  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(uint32_t _res) {
16738         if ((_res & 1) != 0) return;
16739         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16740         CHECK_ACCESS(_res_ptr);
16741         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(_res_ptr);
16742         FREE((void*)_res);
16743         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
16744 }
16745
16746 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_ok"))) TS_CResult_ChannelConfigDecodeErrorZ_ok(uint32_t o) {
16747         LDKChannelConfig o_conv;
16748         o_conv.inner = (void*)(o & (~1));
16749         o_conv.is_owned = (o & 1) || (o == 0);
16750         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16751         o_conv = ChannelConfig_clone(&o_conv);
16752         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
16753         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
16754         return (uint32_t)ret_conv;
16755 }
16756
16757 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_err"))) TS_CResult_ChannelConfigDecodeErrorZ_err(uint32_t e) {
16758         LDKDecodeError e_conv;
16759         e_conv.inner = (void*)(e & (~1));
16760         e_conv.is_owned = (e & 1) || (e == 0);
16761         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16762         e_conv = DecodeError_clone(&e_conv);
16763         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
16764         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
16765         return (uint32_t)ret_conv;
16766 }
16767
16768 jboolean  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_is_ok"))) TS_CResult_ChannelConfigDecodeErrorZ_is_ok(uint32_t o) {
16769         LDKCResult_ChannelConfigDecodeErrorZ* o_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(o & ~1);
16770         jboolean ret_conv = CResult_ChannelConfigDecodeErrorZ_is_ok(o_conv);
16771         return ret_conv;
16772 }
16773
16774 void  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_free"))) TS_CResult_ChannelConfigDecodeErrorZ_free(uint32_t _res) {
16775         if ((_res & 1) != 0) return;
16776         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16777         CHECK_ACCESS(_res_ptr);
16778         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(_res_ptr);
16779         FREE((void*)_res);
16780         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
16781 }
16782
16783 static inline uintptr_t CResult_ChannelConfigDecodeErrorZ_clone_ptr(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR arg) {
16784         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
16785         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(arg);
16786         return (uint32_t)ret_conv;
16787 }
16788 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelConfigDecodeErrorZ_clone_ptr(uint32_t arg) {
16789         LDKCResult_ChannelConfigDecodeErrorZ* arg_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
16790         uint32_t ret_conv = CResult_ChannelConfigDecodeErrorZ_clone_ptr(arg_conv);
16791         return ret_conv;
16792 }
16793
16794 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_clone"))) TS_CResult_ChannelConfigDecodeErrorZ_clone(uint32_t orig) {
16795         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(orig & ~1);
16796         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
16797         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
16798         return (uint32_t)ret_conv;
16799 }
16800
16801 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_ok"))) TS_CResult_OutPointDecodeErrorZ_ok(uint32_t o) {
16802         LDKOutPoint o_conv;
16803         o_conv.inner = (void*)(o & (~1));
16804         o_conv.is_owned = (o & 1) || (o == 0);
16805         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16806         o_conv = OutPoint_clone(&o_conv);
16807         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
16808         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
16809         return (uint32_t)ret_conv;
16810 }
16811
16812 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_err"))) TS_CResult_OutPointDecodeErrorZ_err(uint32_t e) {
16813         LDKDecodeError e_conv;
16814         e_conv.inner = (void*)(e & (~1));
16815         e_conv.is_owned = (e & 1) || (e == 0);
16816         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16817         e_conv = DecodeError_clone(&e_conv);
16818         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
16819         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
16820         return (uint32_t)ret_conv;
16821 }
16822
16823 jboolean  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_is_ok"))) TS_CResult_OutPointDecodeErrorZ_is_ok(uint32_t o) {
16824         LDKCResult_OutPointDecodeErrorZ* o_conv = (LDKCResult_OutPointDecodeErrorZ*)(o & ~1);
16825         jboolean ret_conv = CResult_OutPointDecodeErrorZ_is_ok(o_conv);
16826         return ret_conv;
16827 }
16828
16829 void  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_free"))) TS_CResult_OutPointDecodeErrorZ_free(uint32_t _res) {
16830         if ((_res & 1) != 0) return;
16831         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16832         CHECK_ACCESS(_res_ptr);
16833         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(_res_ptr);
16834         FREE((void*)_res);
16835         CResult_OutPointDecodeErrorZ_free(_res_conv);
16836 }
16837
16838 static inline uintptr_t CResult_OutPointDecodeErrorZ_clone_ptr(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR arg) {
16839         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
16840         *ret_conv = CResult_OutPointDecodeErrorZ_clone(arg);
16841         return (uint32_t)ret_conv;
16842 }
16843 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_clone_ptr"))) TS_CResult_OutPointDecodeErrorZ_clone_ptr(uint32_t arg) {
16844         LDKCResult_OutPointDecodeErrorZ* arg_conv = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
16845         uint32_t ret_conv = CResult_OutPointDecodeErrorZ_clone_ptr(arg_conv);
16846         return ret_conv;
16847 }
16848
16849 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_clone"))) TS_CResult_OutPointDecodeErrorZ_clone(uint32_t orig) {
16850         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)(orig & ~1);
16851         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
16852         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
16853         return (uint32_t)ret_conv;
16854 }
16855
16856 uint32_t  __attribute__((export_name("TS_COption_TypeZ_some"))) TS_COption_TypeZ_some(uint32_t o) {
16857         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16858         CHECK_ACCESS(o_ptr);
16859         LDKType o_conv = *(LDKType*)(o_ptr);
16860         if (o_conv.free == LDKType_JCalls_free) {
16861                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16862                 LDKType_JCalls_cloned(&o_conv);
16863         }
16864         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
16865         *ret_copy = COption_TypeZ_some(o_conv);
16866         uint32_t ret_ref = (uintptr_t)ret_copy;
16867         return ret_ref;
16868 }
16869
16870 uint32_t  __attribute__((export_name("TS_COption_TypeZ_none"))) TS_COption_TypeZ_none() {
16871         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
16872         *ret_copy = COption_TypeZ_none();
16873         uint32_t ret_ref = (uintptr_t)ret_copy;
16874         return ret_ref;
16875 }
16876
16877 void  __attribute__((export_name("TS_COption_TypeZ_free"))) TS_COption_TypeZ_free(uint32_t _res) {
16878         if ((_res & 1) != 0) return;
16879         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16880         CHECK_ACCESS(_res_ptr);
16881         LDKCOption_TypeZ _res_conv = *(LDKCOption_TypeZ*)(_res_ptr);
16882         FREE((void*)_res);
16883         COption_TypeZ_free(_res_conv);
16884 }
16885
16886 static inline uintptr_t COption_TypeZ_clone_ptr(LDKCOption_TypeZ *NONNULL_PTR arg) {
16887         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
16888         *ret_copy = COption_TypeZ_clone(arg);
16889 uint32_t ret_ref = (uintptr_t)ret_copy;
16890         return ret_ref;
16891 }
16892 uint32_t  __attribute__((export_name("TS_COption_TypeZ_clone_ptr"))) TS_COption_TypeZ_clone_ptr(uint32_t arg) {
16893         LDKCOption_TypeZ* arg_conv = (LDKCOption_TypeZ*)arg;
16894         uint32_t ret_conv = COption_TypeZ_clone_ptr(arg_conv);
16895         return ret_conv;
16896 }
16897
16898 uint32_t  __attribute__((export_name("TS_COption_TypeZ_clone"))) TS_COption_TypeZ_clone(uint32_t orig) {
16899         LDKCOption_TypeZ* orig_conv = (LDKCOption_TypeZ*)orig;
16900         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
16901         *ret_copy = COption_TypeZ_clone(orig_conv);
16902         uint32_t ret_ref = (uintptr_t)ret_copy;
16903         return ret_ref;
16904 }
16905
16906 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_ok"))) TS_CResult_COption_TypeZDecodeErrorZ_ok(uint32_t o) {
16907         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16908         CHECK_ACCESS(o_ptr);
16909         LDKCOption_TypeZ o_conv = *(LDKCOption_TypeZ*)(o_ptr);
16910         o_conv = COption_TypeZ_clone((LDKCOption_TypeZ*)(((uintptr_t)o) & ~1));
16911         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
16912         *ret_conv = CResult_COption_TypeZDecodeErrorZ_ok(o_conv);
16913         return (uint32_t)ret_conv;
16914 }
16915
16916 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_err"))) TS_CResult_COption_TypeZDecodeErrorZ_err(uint32_t e) {
16917         LDKDecodeError e_conv;
16918         e_conv.inner = (void*)(e & (~1));
16919         e_conv.is_owned = (e & 1) || (e == 0);
16920         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16921         e_conv = DecodeError_clone(&e_conv);
16922         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
16923         *ret_conv = CResult_COption_TypeZDecodeErrorZ_err(e_conv);
16924         return (uint32_t)ret_conv;
16925 }
16926
16927 jboolean  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_is_ok"))) TS_CResult_COption_TypeZDecodeErrorZ_is_ok(uint32_t o) {
16928         LDKCResult_COption_TypeZDecodeErrorZ* o_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(o & ~1);
16929         jboolean ret_conv = CResult_COption_TypeZDecodeErrorZ_is_ok(o_conv);
16930         return ret_conv;
16931 }
16932
16933 void  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_free"))) TS_CResult_COption_TypeZDecodeErrorZ_free(uint32_t _res) {
16934         if ((_res & 1) != 0) return;
16935         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16936         CHECK_ACCESS(_res_ptr);
16937         LDKCResult_COption_TypeZDecodeErrorZ _res_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(_res_ptr);
16938         FREE((void*)_res);
16939         CResult_COption_TypeZDecodeErrorZ_free(_res_conv);
16940 }
16941
16942 static inline uintptr_t CResult_COption_TypeZDecodeErrorZ_clone_ptr(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR arg) {
16943         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
16944         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(arg);
16945         return (uint32_t)ret_conv;
16946 }
16947 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_TypeZDecodeErrorZ_clone_ptr(uint32_t arg) {
16948         LDKCResult_COption_TypeZDecodeErrorZ* arg_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(arg & ~1);
16949         uint32_t ret_conv = CResult_COption_TypeZDecodeErrorZ_clone_ptr(arg_conv);
16950         return ret_conv;
16951 }
16952
16953 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_clone"))) TS_CResult_COption_TypeZDecodeErrorZ_clone(uint32_t orig) {
16954         LDKCResult_COption_TypeZDecodeErrorZ* orig_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(orig & ~1);
16955         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
16956         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(orig_conv);
16957         return (uint32_t)ret_conv;
16958 }
16959
16960 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_ok"))) TS_CResult_PaymentIdPaymentErrorZ_ok(int8_tArray o) {
16961         LDKThirtyTwoBytes o_ref;
16962         CHECK(o->arr_len == 32);
16963         memcpy(o_ref.data, o->elems, 32); FREE(o);
16964         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
16965         *ret_conv = CResult_PaymentIdPaymentErrorZ_ok(o_ref);
16966         return (uint32_t)ret_conv;
16967 }
16968
16969 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_err"))) TS_CResult_PaymentIdPaymentErrorZ_err(uint32_t e) {
16970         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
16971         CHECK_ACCESS(e_ptr);
16972         LDKPaymentError e_conv = *(LDKPaymentError*)(e_ptr);
16973         e_conv = PaymentError_clone((LDKPaymentError*)(((uintptr_t)e) & ~1));
16974         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
16975         *ret_conv = CResult_PaymentIdPaymentErrorZ_err(e_conv);
16976         return (uint32_t)ret_conv;
16977 }
16978
16979 jboolean  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_is_ok"))) TS_CResult_PaymentIdPaymentErrorZ_is_ok(uint32_t o) {
16980         LDKCResult_PaymentIdPaymentErrorZ* o_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(o & ~1);
16981         jboolean ret_conv = CResult_PaymentIdPaymentErrorZ_is_ok(o_conv);
16982         return ret_conv;
16983 }
16984
16985 void  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_free"))) TS_CResult_PaymentIdPaymentErrorZ_free(uint32_t _res) {
16986         if ((_res & 1) != 0) return;
16987         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16988         CHECK_ACCESS(_res_ptr);
16989         LDKCResult_PaymentIdPaymentErrorZ _res_conv = *(LDKCResult_PaymentIdPaymentErrorZ*)(_res_ptr);
16990         FREE((void*)_res);
16991         CResult_PaymentIdPaymentErrorZ_free(_res_conv);
16992 }
16993
16994 static inline uintptr_t CResult_PaymentIdPaymentErrorZ_clone_ptr(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR arg) {
16995         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
16996         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(arg);
16997         return (uint32_t)ret_conv;
16998 }
16999 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_clone_ptr"))) TS_CResult_PaymentIdPaymentErrorZ_clone_ptr(uint32_t arg) {
17000         LDKCResult_PaymentIdPaymentErrorZ* arg_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(arg & ~1);
17001         uint32_t ret_conv = CResult_PaymentIdPaymentErrorZ_clone_ptr(arg_conv);
17002         return ret_conv;
17003 }
17004
17005 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_clone"))) TS_CResult_PaymentIdPaymentErrorZ_clone(uint32_t orig) {
17006         LDKCResult_PaymentIdPaymentErrorZ* orig_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(orig & ~1);
17007         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
17008         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(orig_conv);
17009         return (uint32_t)ret_conv;
17010 }
17011
17012 uint32_t  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_ok"))) TS_CResult_SiPrefixParseErrorZ_ok(uint32_t o) {
17013         LDKSiPrefix o_conv = LDKSiPrefix_from_js(o);
17014         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
17015         *ret_conv = CResult_SiPrefixParseErrorZ_ok(o_conv);
17016         return (uint32_t)ret_conv;
17017 }
17018
17019 uint32_t  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_err"))) TS_CResult_SiPrefixParseErrorZ_err(uint32_t e) {
17020         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
17021         CHECK_ACCESS(e_ptr);
17022         LDKParseError e_conv = *(LDKParseError*)(e_ptr);
17023         e_conv = ParseError_clone((LDKParseError*)(((uintptr_t)e) & ~1));
17024         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
17025         *ret_conv = CResult_SiPrefixParseErrorZ_err(e_conv);
17026         return (uint32_t)ret_conv;
17027 }
17028
17029 jboolean  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_is_ok"))) TS_CResult_SiPrefixParseErrorZ_is_ok(uint32_t o) {
17030         LDKCResult_SiPrefixParseErrorZ* o_conv = (LDKCResult_SiPrefixParseErrorZ*)(o & ~1);
17031         jboolean ret_conv = CResult_SiPrefixParseErrorZ_is_ok(o_conv);
17032         return ret_conv;
17033 }
17034
17035 void  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_free"))) TS_CResult_SiPrefixParseErrorZ_free(uint32_t _res) {
17036         if ((_res & 1) != 0) return;
17037         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17038         CHECK_ACCESS(_res_ptr);
17039         LDKCResult_SiPrefixParseErrorZ _res_conv = *(LDKCResult_SiPrefixParseErrorZ*)(_res_ptr);
17040         FREE((void*)_res);
17041         CResult_SiPrefixParseErrorZ_free(_res_conv);
17042 }
17043
17044 static inline uintptr_t CResult_SiPrefixParseErrorZ_clone_ptr(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR arg) {
17045         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
17046         *ret_conv = CResult_SiPrefixParseErrorZ_clone(arg);
17047         return (uint32_t)ret_conv;
17048 }
17049 uint32_t  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_clone_ptr"))) TS_CResult_SiPrefixParseErrorZ_clone_ptr(uint32_t arg) {
17050         LDKCResult_SiPrefixParseErrorZ* arg_conv = (LDKCResult_SiPrefixParseErrorZ*)(arg & ~1);
17051         uint32_t ret_conv = CResult_SiPrefixParseErrorZ_clone_ptr(arg_conv);
17052         return ret_conv;
17053 }
17054
17055 uint32_t  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_clone"))) TS_CResult_SiPrefixParseErrorZ_clone(uint32_t orig) {
17056         LDKCResult_SiPrefixParseErrorZ* orig_conv = (LDKCResult_SiPrefixParseErrorZ*)(orig & ~1);
17057         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
17058         *ret_conv = CResult_SiPrefixParseErrorZ_clone(orig_conv);
17059         return (uint32_t)ret_conv;
17060 }
17061
17062 uint32_t  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_ok"))) TS_CResult_InvoiceParseOrSemanticErrorZ_ok(uint32_t o) {
17063         LDKInvoice o_conv;
17064         o_conv.inner = (void*)(o & (~1));
17065         o_conv.is_owned = (o & 1) || (o == 0);
17066         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17067         o_conv = Invoice_clone(&o_conv);
17068         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
17069         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_ok(o_conv);
17070         return (uint32_t)ret_conv;
17071 }
17072
17073 uint32_t  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_err"))) TS_CResult_InvoiceParseOrSemanticErrorZ_err(uint32_t e) {
17074         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
17075         CHECK_ACCESS(e_ptr);
17076         LDKParseOrSemanticError e_conv = *(LDKParseOrSemanticError*)(e_ptr);
17077         e_conv = ParseOrSemanticError_clone((LDKParseOrSemanticError*)(((uintptr_t)e) & ~1));
17078         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
17079         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_err(e_conv);
17080         return (uint32_t)ret_conv;
17081 }
17082
17083 jboolean  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_is_ok"))) TS_CResult_InvoiceParseOrSemanticErrorZ_is_ok(uint32_t o) {
17084         LDKCResult_InvoiceParseOrSemanticErrorZ* o_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(o & ~1);
17085         jboolean ret_conv = CResult_InvoiceParseOrSemanticErrorZ_is_ok(o_conv);
17086         return ret_conv;
17087 }
17088
17089 void  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_free"))) TS_CResult_InvoiceParseOrSemanticErrorZ_free(uint32_t _res) {
17090         if ((_res & 1) != 0) return;
17091         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17092         CHECK_ACCESS(_res_ptr);
17093         LDKCResult_InvoiceParseOrSemanticErrorZ _res_conv = *(LDKCResult_InvoiceParseOrSemanticErrorZ*)(_res_ptr);
17094         FREE((void*)_res);
17095         CResult_InvoiceParseOrSemanticErrorZ_free(_res_conv);
17096 }
17097
17098 static inline uintptr_t CResult_InvoiceParseOrSemanticErrorZ_clone_ptr(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR arg) {
17099         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
17100         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone(arg);
17101         return (uint32_t)ret_conv;
17102 }
17103 uint32_t  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_clone_ptr"))) TS_CResult_InvoiceParseOrSemanticErrorZ_clone_ptr(uint32_t arg) {
17104         LDKCResult_InvoiceParseOrSemanticErrorZ* arg_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(arg & ~1);
17105         uint32_t ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone_ptr(arg_conv);
17106         return ret_conv;
17107 }
17108
17109 uint32_t  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_clone"))) TS_CResult_InvoiceParseOrSemanticErrorZ_clone(uint32_t orig) {
17110         LDKCResult_InvoiceParseOrSemanticErrorZ* orig_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(orig & ~1);
17111         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
17112         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone(orig_conv);
17113         return (uint32_t)ret_conv;
17114 }
17115
17116 uint32_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_ok"))) TS_CResult_SignedRawInvoiceParseErrorZ_ok(uint32_t o) {
17117         LDKSignedRawInvoice o_conv;
17118         o_conv.inner = (void*)(o & (~1));
17119         o_conv.is_owned = (o & 1) || (o == 0);
17120         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17121         o_conv = SignedRawInvoice_clone(&o_conv);
17122         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
17123         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_ok(o_conv);
17124         return (uint32_t)ret_conv;
17125 }
17126
17127 uint32_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_err"))) TS_CResult_SignedRawInvoiceParseErrorZ_err(uint32_t e) {
17128         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
17129         CHECK_ACCESS(e_ptr);
17130         LDKParseError e_conv = *(LDKParseError*)(e_ptr);
17131         e_conv = ParseError_clone((LDKParseError*)(((uintptr_t)e) & ~1));
17132         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
17133         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_err(e_conv);
17134         return (uint32_t)ret_conv;
17135 }
17136
17137 jboolean  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_is_ok"))) TS_CResult_SignedRawInvoiceParseErrorZ_is_ok(uint32_t o) {
17138         LDKCResult_SignedRawInvoiceParseErrorZ* o_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(o & ~1);
17139         jboolean ret_conv = CResult_SignedRawInvoiceParseErrorZ_is_ok(o_conv);
17140         return ret_conv;
17141 }
17142
17143 void  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_free"))) TS_CResult_SignedRawInvoiceParseErrorZ_free(uint32_t _res) {
17144         if ((_res & 1) != 0) return;
17145         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17146         CHECK_ACCESS(_res_ptr);
17147         LDKCResult_SignedRawInvoiceParseErrorZ _res_conv = *(LDKCResult_SignedRawInvoiceParseErrorZ*)(_res_ptr);
17148         FREE((void*)_res);
17149         CResult_SignedRawInvoiceParseErrorZ_free(_res_conv);
17150 }
17151
17152 static inline uintptr_t CResult_SignedRawInvoiceParseErrorZ_clone_ptr(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR arg) {
17153         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
17154         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone(arg);
17155         return (uint32_t)ret_conv;
17156 }
17157 uint32_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_clone_ptr"))) TS_CResult_SignedRawInvoiceParseErrorZ_clone_ptr(uint32_t arg) {
17158         LDKCResult_SignedRawInvoiceParseErrorZ* arg_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(arg & ~1);
17159         uint32_t ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone_ptr(arg_conv);
17160         return ret_conv;
17161 }
17162
17163 uint32_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_clone"))) TS_CResult_SignedRawInvoiceParseErrorZ_clone(uint32_t orig) {
17164         LDKCResult_SignedRawInvoiceParseErrorZ* orig_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(orig & ~1);
17165         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
17166         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone(orig_conv);
17167         return (uint32_t)ret_conv;
17168 }
17169
17170 static inline uintptr_t C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR arg) {
17171         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
17172         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(arg);
17173         return ((uint32_t)ret_conv);
17174 }
17175 uint32_t  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(uint32_t arg) {
17176         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* arg_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(arg & ~1);
17177         uint32_t ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(arg_conv);
17178         return ret_conv;
17179 }
17180
17181 uint32_t  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(uint32_t orig) {
17182         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* orig_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(orig & ~1);
17183         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
17184         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(orig_conv);
17185         return ((uint32_t)ret_conv);
17186 }
17187
17188 uint32_t  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_new"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(uint32_t a, int8_tArray b, uint32_t c) {
17189         LDKRawInvoice a_conv;
17190         a_conv.inner = (void*)(a & (~1));
17191         a_conv.is_owned = (a & 1) || (a == 0);
17192         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
17193         a_conv = RawInvoice_clone(&a_conv);
17194         LDKThirtyTwoBytes b_ref;
17195         CHECK(b->arr_len == 32);
17196         memcpy(b_ref.data, b->elems, 32); FREE(b);
17197         LDKInvoiceSignature c_conv;
17198         c_conv.inner = (void*)(c & (~1));
17199         c_conv.is_owned = (c & 1) || (c == 0);
17200         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
17201         c_conv = InvoiceSignature_clone(&c_conv);
17202         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
17203         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(a_conv, b_ref, c_conv);
17204         return ((uint32_t)ret_conv);
17205 }
17206
17207 void  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_free"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(uint32_t _res) {
17208         if ((_res & 1) != 0) return;
17209         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17210         CHECK_ACCESS(_res_ptr);
17211         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res_conv = *(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(_res_ptr);
17212         FREE((void*)_res);
17213         C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(_res_conv);
17214 }
17215
17216 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_ok"))) TS_CResult_PayeePubKeyErrorZ_ok(uint32_t o) {
17217         LDKPayeePubKey o_conv;
17218         o_conv.inner = (void*)(o & (~1));
17219         o_conv.is_owned = (o & 1) || (o == 0);
17220         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17221         o_conv = PayeePubKey_clone(&o_conv);
17222         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
17223         *ret_conv = CResult_PayeePubKeyErrorZ_ok(o_conv);
17224         return (uint32_t)ret_conv;
17225 }
17226
17227 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_err"))) TS_CResult_PayeePubKeyErrorZ_err(uint32_t e) {
17228         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
17229         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
17230         *ret_conv = CResult_PayeePubKeyErrorZ_err(e_conv);
17231         return (uint32_t)ret_conv;
17232 }
17233
17234 jboolean  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_is_ok"))) TS_CResult_PayeePubKeyErrorZ_is_ok(uint32_t o) {
17235         LDKCResult_PayeePubKeyErrorZ* o_conv = (LDKCResult_PayeePubKeyErrorZ*)(o & ~1);
17236         jboolean ret_conv = CResult_PayeePubKeyErrorZ_is_ok(o_conv);
17237         return ret_conv;
17238 }
17239
17240 void  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_free"))) TS_CResult_PayeePubKeyErrorZ_free(uint32_t _res) {
17241         if ((_res & 1) != 0) return;
17242         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17243         CHECK_ACCESS(_res_ptr);
17244         LDKCResult_PayeePubKeyErrorZ _res_conv = *(LDKCResult_PayeePubKeyErrorZ*)(_res_ptr);
17245         FREE((void*)_res);
17246         CResult_PayeePubKeyErrorZ_free(_res_conv);
17247 }
17248
17249 static inline uintptr_t CResult_PayeePubKeyErrorZ_clone_ptr(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR arg) {
17250         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
17251         *ret_conv = CResult_PayeePubKeyErrorZ_clone(arg);
17252         return (uint32_t)ret_conv;
17253 }
17254 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_clone_ptr"))) TS_CResult_PayeePubKeyErrorZ_clone_ptr(uint32_t arg) {
17255         LDKCResult_PayeePubKeyErrorZ* arg_conv = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
17256         uint32_t ret_conv = CResult_PayeePubKeyErrorZ_clone_ptr(arg_conv);
17257         return ret_conv;
17258 }
17259
17260 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_clone"))) TS_CResult_PayeePubKeyErrorZ_clone(uint32_t orig) {
17261         LDKCResult_PayeePubKeyErrorZ* orig_conv = (LDKCResult_PayeePubKeyErrorZ*)(orig & ~1);
17262         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
17263         *ret_conv = CResult_PayeePubKeyErrorZ_clone(orig_conv);
17264         return (uint32_t)ret_conv;
17265 }
17266
17267 void  __attribute__((export_name("TS_CVec_PrivateRouteZ_free"))) TS_CVec_PrivateRouteZ_free(uint32_tArray _res) {
17268         LDKCVec_PrivateRouteZ _res_constr;
17269         _res_constr.datalen = _res->arr_len;
17270         if (_res_constr.datalen > 0)
17271                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPrivateRoute), "LDKCVec_PrivateRouteZ Elements");
17272         else
17273                 _res_constr.data = NULL;
17274         uint32_t* _res_vals = _res->elems;
17275         for (size_t o = 0; o < _res_constr.datalen; o++) {
17276                 uint32_t _res_conv_14 = _res_vals[o];
17277                 LDKPrivateRoute _res_conv_14_conv;
17278                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
17279                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
17280                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
17281                 _res_constr.data[o] = _res_conv_14_conv;
17282         }
17283         FREE(_res);
17284         CVec_PrivateRouteZ_free(_res_constr);
17285 }
17286
17287 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_ok"))) TS_CResult_PositiveTimestampCreationErrorZ_ok(uint32_t o) {
17288         LDKPositiveTimestamp o_conv;
17289         o_conv.inner = (void*)(o & (~1));
17290         o_conv.is_owned = (o & 1) || (o == 0);
17291         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17292         o_conv = PositiveTimestamp_clone(&o_conv);
17293         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
17294         *ret_conv = CResult_PositiveTimestampCreationErrorZ_ok(o_conv);
17295         return (uint32_t)ret_conv;
17296 }
17297
17298 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_err"))) TS_CResult_PositiveTimestampCreationErrorZ_err(uint32_t e) {
17299         LDKCreationError e_conv = LDKCreationError_from_js(e);
17300         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
17301         *ret_conv = CResult_PositiveTimestampCreationErrorZ_err(e_conv);
17302         return (uint32_t)ret_conv;
17303 }
17304
17305 jboolean  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_is_ok"))) TS_CResult_PositiveTimestampCreationErrorZ_is_ok(uint32_t o) {
17306         LDKCResult_PositiveTimestampCreationErrorZ* o_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(o & ~1);
17307         jboolean ret_conv = CResult_PositiveTimestampCreationErrorZ_is_ok(o_conv);
17308         return ret_conv;
17309 }
17310
17311 void  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_free"))) TS_CResult_PositiveTimestampCreationErrorZ_free(uint32_t _res) {
17312         if ((_res & 1) != 0) return;
17313         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17314         CHECK_ACCESS(_res_ptr);
17315         LDKCResult_PositiveTimestampCreationErrorZ _res_conv = *(LDKCResult_PositiveTimestampCreationErrorZ*)(_res_ptr);
17316         FREE((void*)_res);
17317         CResult_PositiveTimestampCreationErrorZ_free(_res_conv);
17318 }
17319
17320 static inline uintptr_t CResult_PositiveTimestampCreationErrorZ_clone_ptr(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR arg) {
17321         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
17322         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(arg);
17323         return (uint32_t)ret_conv;
17324 }
17325 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_clone_ptr"))) TS_CResult_PositiveTimestampCreationErrorZ_clone_ptr(uint32_t arg) {
17326         LDKCResult_PositiveTimestampCreationErrorZ* arg_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
17327         uint32_t ret_conv = CResult_PositiveTimestampCreationErrorZ_clone_ptr(arg_conv);
17328         return ret_conv;
17329 }
17330
17331 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_clone"))) TS_CResult_PositiveTimestampCreationErrorZ_clone(uint32_t orig) {
17332         LDKCResult_PositiveTimestampCreationErrorZ* orig_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(orig & ~1);
17333         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
17334         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(orig_conv);
17335         return (uint32_t)ret_conv;
17336 }
17337
17338 uint32_t  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_ok"))) TS_CResult_NoneSemanticErrorZ_ok() {
17339         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
17340         *ret_conv = CResult_NoneSemanticErrorZ_ok();
17341         return (uint32_t)ret_conv;
17342 }
17343
17344 uint32_t  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_err"))) TS_CResult_NoneSemanticErrorZ_err(uint32_t e) {
17345         LDKSemanticError e_conv = LDKSemanticError_from_js(e);
17346         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
17347         *ret_conv = CResult_NoneSemanticErrorZ_err(e_conv);
17348         return (uint32_t)ret_conv;
17349 }
17350
17351 jboolean  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_is_ok"))) TS_CResult_NoneSemanticErrorZ_is_ok(uint32_t o) {
17352         LDKCResult_NoneSemanticErrorZ* o_conv = (LDKCResult_NoneSemanticErrorZ*)(o & ~1);
17353         jboolean ret_conv = CResult_NoneSemanticErrorZ_is_ok(o_conv);
17354         return ret_conv;
17355 }
17356
17357 void  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_free"))) TS_CResult_NoneSemanticErrorZ_free(uint32_t _res) {
17358         if ((_res & 1) != 0) return;
17359         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17360         CHECK_ACCESS(_res_ptr);
17361         LDKCResult_NoneSemanticErrorZ _res_conv = *(LDKCResult_NoneSemanticErrorZ*)(_res_ptr);
17362         FREE((void*)_res);
17363         CResult_NoneSemanticErrorZ_free(_res_conv);
17364 }
17365
17366 static inline uintptr_t CResult_NoneSemanticErrorZ_clone_ptr(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR arg) {
17367         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
17368         *ret_conv = CResult_NoneSemanticErrorZ_clone(arg);
17369         return (uint32_t)ret_conv;
17370 }
17371 uint32_t  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_clone_ptr"))) TS_CResult_NoneSemanticErrorZ_clone_ptr(uint32_t arg) {
17372         LDKCResult_NoneSemanticErrorZ* arg_conv = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
17373         uint32_t ret_conv = CResult_NoneSemanticErrorZ_clone_ptr(arg_conv);
17374         return ret_conv;
17375 }
17376
17377 uint32_t  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_clone"))) TS_CResult_NoneSemanticErrorZ_clone(uint32_t orig) {
17378         LDKCResult_NoneSemanticErrorZ* orig_conv = (LDKCResult_NoneSemanticErrorZ*)(orig & ~1);
17379         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
17380         *ret_conv = CResult_NoneSemanticErrorZ_clone(orig_conv);
17381         return (uint32_t)ret_conv;
17382 }
17383
17384 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_ok"))) TS_CResult_InvoiceSemanticErrorZ_ok(uint32_t o) {
17385         LDKInvoice o_conv;
17386         o_conv.inner = (void*)(o & (~1));
17387         o_conv.is_owned = (o & 1) || (o == 0);
17388         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17389         o_conv = Invoice_clone(&o_conv);
17390         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
17391         *ret_conv = CResult_InvoiceSemanticErrorZ_ok(o_conv);
17392         return (uint32_t)ret_conv;
17393 }
17394
17395 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_err"))) TS_CResult_InvoiceSemanticErrorZ_err(uint32_t e) {
17396         LDKSemanticError e_conv = LDKSemanticError_from_js(e);
17397         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
17398         *ret_conv = CResult_InvoiceSemanticErrorZ_err(e_conv);
17399         return (uint32_t)ret_conv;
17400 }
17401
17402 jboolean  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_is_ok"))) TS_CResult_InvoiceSemanticErrorZ_is_ok(uint32_t o) {
17403         LDKCResult_InvoiceSemanticErrorZ* o_conv = (LDKCResult_InvoiceSemanticErrorZ*)(o & ~1);
17404         jboolean ret_conv = CResult_InvoiceSemanticErrorZ_is_ok(o_conv);
17405         return ret_conv;
17406 }
17407
17408 void  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_free"))) TS_CResult_InvoiceSemanticErrorZ_free(uint32_t _res) {
17409         if ((_res & 1) != 0) return;
17410         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17411         CHECK_ACCESS(_res_ptr);
17412         LDKCResult_InvoiceSemanticErrorZ _res_conv = *(LDKCResult_InvoiceSemanticErrorZ*)(_res_ptr);
17413         FREE((void*)_res);
17414         CResult_InvoiceSemanticErrorZ_free(_res_conv);
17415 }
17416
17417 static inline uintptr_t CResult_InvoiceSemanticErrorZ_clone_ptr(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR arg) {
17418         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
17419         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(arg);
17420         return (uint32_t)ret_conv;
17421 }
17422 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_clone_ptr"))) TS_CResult_InvoiceSemanticErrorZ_clone_ptr(uint32_t arg) {
17423         LDKCResult_InvoiceSemanticErrorZ* arg_conv = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
17424         uint32_t ret_conv = CResult_InvoiceSemanticErrorZ_clone_ptr(arg_conv);
17425         return ret_conv;
17426 }
17427
17428 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_clone"))) TS_CResult_InvoiceSemanticErrorZ_clone(uint32_t orig) {
17429         LDKCResult_InvoiceSemanticErrorZ* orig_conv = (LDKCResult_InvoiceSemanticErrorZ*)(orig & ~1);
17430         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
17431         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(orig_conv);
17432         return (uint32_t)ret_conv;
17433 }
17434
17435 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_ok"))) TS_CResult_DescriptionCreationErrorZ_ok(uint32_t o) {
17436         LDKDescription o_conv;
17437         o_conv.inner = (void*)(o & (~1));
17438         o_conv.is_owned = (o & 1) || (o == 0);
17439         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17440         o_conv = Description_clone(&o_conv);
17441         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
17442         *ret_conv = CResult_DescriptionCreationErrorZ_ok(o_conv);
17443         return (uint32_t)ret_conv;
17444 }
17445
17446 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_err"))) TS_CResult_DescriptionCreationErrorZ_err(uint32_t e) {
17447         LDKCreationError e_conv = LDKCreationError_from_js(e);
17448         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
17449         *ret_conv = CResult_DescriptionCreationErrorZ_err(e_conv);
17450         return (uint32_t)ret_conv;
17451 }
17452
17453 jboolean  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_is_ok"))) TS_CResult_DescriptionCreationErrorZ_is_ok(uint32_t o) {
17454         LDKCResult_DescriptionCreationErrorZ* o_conv = (LDKCResult_DescriptionCreationErrorZ*)(o & ~1);
17455         jboolean ret_conv = CResult_DescriptionCreationErrorZ_is_ok(o_conv);
17456         return ret_conv;
17457 }
17458
17459 void  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_free"))) TS_CResult_DescriptionCreationErrorZ_free(uint32_t _res) {
17460         if ((_res & 1) != 0) return;
17461         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17462         CHECK_ACCESS(_res_ptr);
17463         LDKCResult_DescriptionCreationErrorZ _res_conv = *(LDKCResult_DescriptionCreationErrorZ*)(_res_ptr);
17464         FREE((void*)_res);
17465         CResult_DescriptionCreationErrorZ_free(_res_conv);
17466 }
17467
17468 static inline uintptr_t CResult_DescriptionCreationErrorZ_clone_ptr(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR arg) {
17469         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
17470         *ret_conv = CResult_DescriptionCreationErrorZ_clone(arg);
17471         return (uint32_t)ret_conv;
17472 }
17473 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_clone_ptr"))) TS_CResult_DescriptionCreationErrorZ_clone_ptr(uint32_t arg) {
17474         LDKCResult_DescriptionCreationErrorZ* arg_conv = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
17475         uint32_t ret_conv = CResult_DescriptionCreationErrorZ_clone_ptr(arg_conv);
17476         return ret_conv;
17477 }
17478
17479 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_clone"))) TS_CResult_DescriptionCreationErrorZ_clone(uint32_t orig) {
17480         LDKCResult_DescriptionCreationErrorZ* orig_conv = (LDKCResult_DescriptionCreationErrorZ*)(orig & ~1);
17481         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
17482         *ret_conv = CResult_DescriptionCreationErrorZ_clone(orig_conv);
17483         return (uint32_t)ret_conv;
17484 }
17485
17486 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_ok"))) TS_CResult_PrivateRouteCreationErrorZ_ok(uint32_t o) {
17487         LDKPrivateRoute o_conv;
17488         o_conv.inner = (void*)(o & (~1));
17489         o_conv.is_owned = (o & 1) || (o == 0);
17490         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17491         o_conv = PrivateRoute_clone(&o_conv);
17492         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
17493         *ret_conv = CResult_PrivateRouteCreationErrorZ_ok(o_conv);
17494         return (uint32_t)ret_conv;
17495 }
17496
17497 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_err"))) TS_CResult_PrivateRouteCreationErrorZ_err(uint32_t e) {
17498         LDKCreationError e_conv = LDKCreationError_from_js(e);
17499         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
17500         *ret_conv = CResult_PrivateRouteCreationErrorZ_err(e_conv);
17501         return (uint32_t)ret_conv;
17502 }
17503
17504 jboolean  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_is_ok"))) TS_CResult_PrivateRouteCreationErrorZ_is_ok(uint32_t o) {
17505         LDKCResult_PrivateRouteCreationErrorZ* o_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(o & ~1);
17506         jboolean ret_conv = CResult_PrivateRouteCreationErrorZ_is_ok(o_conv);
17507         return ret_conv;
17508 }
17509
17510 void  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_free"))) TS_CResult_PrivateRouteCreationErrorZ_free(uint32_t _res) {
17511         if ((_res & 1) != 0) return;
17512         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17513         CHECK_ACCESS(_res_ptr);
17514         LDKCResult_PrivateRouteCreationErrorZ _res_conv = *(LDKCResult_PrivateRouteCreationErrorZ*)(_res_ptr);
17515         FREE((void*)_res);
17516         CResult_PrivateRouteCreationErrorZ_free(_res_conv);
17517 }
17518
17519 static inline uintptr_t CResult_PrivateRouteCreationErrorZ_clone_ptr(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR arg) {
17520         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
17521         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(arg);
17522         return (uint32_t)ret_conv;
17523 }
17524 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_clone_ptr"))) TS_CResult_PrivateRouteCreationErrorZ_clone_ptr(uint32_t arg) {
17525         LDKCResult_PrivateRouteCreationErrorZ* arg_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
17526         uint32_t ret_conv = CResult_PrivateRouteCreationErrorZ_clone_ptr(arg_conv);
17527         return ret_conv;
17528 }
17529
17530 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_clone"))) TS_CResult_PrivateRouteCreationErrorZ_clone(uint32_t orig) {
17531         LDKCResult_PrivateRouteCreationErrorZ* orig_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(orig & ~1);
17532         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
17533         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(orig_conv);
17534         return (uint32_t)ret_conv;
17535 }
17536
17537 uint32_t  __attribute__((export_name("TS_CResult_StringErrorZ_ok"))) TS_CResult_StringErrorZ_ok(jstring o) {
17538         LDKStr o_conv = str_ref_to_owned_c(o);
17539         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
17540         *ret_conv = CResult_StringErrorZ_ok(o_conv);
17541         return (uint32_t)ret_conv;
17542 }
17543
17544 uint32_t  __attribute__((export_name("TS_CResult_StringErrorZ_err"))) TS_CResult_StringErrorZ_err(uint32_t e) {
17545         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
17546         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
17547         *ret_conv = CResult_StringErrorZ_err(e_conv);
17548         return (uint32_t)ret_conv;
17549 }
17550
17551 jboolean  __attribute__((export_name("TS_CResult_StringErrorZ_is_ok"))) TS_CResult_StringErrorZ_is_ok(uint32_t o) {
17552         LDKCResult_StringErrorZ* o_conv = (LDKCResult_StringErrorZ*)(o & ~1);
17553         jboolean ret_conv = CResult_StringErrorZ_is_ok(o_conv);
17554         return ret_conv;
17555 }
17556
17557 void  __attribute__((export_name("TS_CResult_StringErrorZ_free"))) TS_CResult_StringErrorZ_free(uint32_t _res) {
17558         if ((_res & 1) != 0) return;
17559         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17560         CHECK_ACCESS(_res_ptr);
17561         LDKCResult_StringErrorZ _res_conv = *(LDKCResult_StringErrorZ*)(_res_ptr);
17562         FREE((void*)_res);
17563         CResult_StringErrorZ_free(_res_conv);
17564 }
17565
17566 static inline uintptr_t CResult_StringErrorZ_clone_ptr(LDKCResult_StringErrorZ *NONNULL_PTR arg) {
17567         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
17568         *ret_conv = CResult_StringErrorZ_clone(arg);
17569         return (uint32_t)ret_conv;
17570 }
17571 uint32_t  __attribute__((export_name("TS_CResult_StringErrorZ_clone_ptr"))) TS_CResult_StringErrorZ_clone_ptr(uint32_t arg) {
17572         LDKCResult_StringErrorZ* arg_conv = (LDKCResult_StringErrorZ*)(arg & ~1);
17573         uint32_t ret_conv = CResult_StringErrorZ_clone_ptr(arg_conv);
17574         return ret_conv;
17575 }
17576
17577 uint32_t  __attribute__((export_name("TS_CResult_StringErrorZ_clone"))) TS_CResult_StringErrorZ_clone(uint32_t orig) {
17578         LDKCResult_StringErrorZ* orig_conv = (LDKCResult_StringErrorZ*)(orig & ~1);
17579         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
17580         *ret_conv = CResult_StringErrorZ_clone(orig_conv);
17581         return (uint32_t)ret_conv;
17582 }
17583
17584 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_ok"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_ok(uint32_t o) {
17585         LDKChannelMonitorUpdate o_conv;
17586         o_conv.inner = (void*)(o & (~1));
17587         o_conv.is_owned = (o & 1) || (o == 0);
17588         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17589         o_conv = ChannelMonitorUpdate_clone(&o_conv);
17590         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
17591         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
17592         return (uint32_t)ret_conv;
17593 }
17594
17595 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_err"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_err(uint32_t e) {
17596         LDKDecodeError e_conv;
17597         e_conv.inner = (void*)(e & (~1));
17598         e_conv.is_owned = (e & 1) || (e == 0);
17599         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17600         e_conv = DecodeError_clone(&e_conv);
17601         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
17602         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
17603         return (uint32_t)ret_conv;
17604 }
17605
17606 jboolean  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(uint32_t o) {
17607         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(o & ~1);
17608         jboolean ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(o_conv);
17609         return ret_conv;
17610 }
17611
17612 void  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_free"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_free(uint32_t _res) {
17613         if ((_res & 1) != 0) return;
17614         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17615         CHECK_ACCESS(_res_ptr);
17616         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(_res_ptr);
17617         FREE((void*)_res);
17618         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
17619 }
17620
17621 static inline uintptr_t CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR arg) {
17622         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
17623         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(arg);
17624         return (uint32_t)ret_conv;
17625 }
17626 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(uint32_t arg) {
17627         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
17628         uint32_t ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(arg_conv);
17629         return ret_conv;
17630 }
17631
17632 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone(uint32_t orig) {
17633         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(orig & ~1);
17634         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
17635         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
17636         return (uint32_t)ret_conv;
17637 }
17638
17639 uint32_t  __attribute__((export_name("TS_COption_MonitorEventZ_some"))) TS_COption_MonitorEventZ_some(uint32_t o) {
17640         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
17641         CHECK_ACCESS(o_ptr);
17642         LDKMonitorEvent o_conv = *(LDKMonitorEvent*)(o_ptr);
17643         o_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uintptr_t)o) & ~1));
17644         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
17645         *ret_copy = COption_MonitorEventZ_some(o_conv);
17646         uint32_t ret_ref = (uintptr_t)ret_copy;
17647         return ret_ref;
17648 }
17649
17650 uint32_t  __attribute__((export_name("TS_COption_MonitorEventZ_none"))) TS_COption_MonitorEventZ_none() {
17651         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
17652         *ret_copy = COption_MonitorEventZ_none();
17653         uint32_t ret_ref = (uintptr_t)ret_copy;
17654         return ret_ref;
17655 }
17656
17657 void  __attribute__((export_name("TS_COption_MonitorEventZ_free"))) TS_COption_MonitorEventZ_free(uint32_t _res) {
17658         if ((_res & 1) != 0) return;
17659         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17660         CHECK_ACCESS(_res_ptr);
17661         LDKCOption_MonitorEventZ _res_conv = *(LDKCOption_MonitorEventZ*)(_res_ptr);
17662         FREE((void*)_res);
17663         COption_MonitorEventZ_free(_res_conv);
17664 }
17665
17666 static inline uintptr_t COption_MonitorEventZ_clone_ptr(LDKCOption_MonitorEventZ *NONNULL_PTR arg) {
17667         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
17668         *ret_copy = COption_MonitorEventZ_clone(arg);
17669 uint32_t ret_ref = (uintptr_t)ret_copy;
17670         return ret_ref;
17671 }
17672 uint32_t  __attribute__((export_name("TS_COption_MonitorEventZ_clone_ptr"))) TS_COption_MonitorEventZ_clone_ptr(uint32_t arg) {
17673         LDKCOption_MonitorEventZ* arg_conv = (LDKCOption_MonitorEventZ*)arg;
17674         uint32_t ret_conv = COption_MonitorEventZ_clone_ptr(arg_conv);
17675         return ret_conv;
17676 }
17677
17678 uint32_t  __attribute__((export_name("TS_COption_MonitorEventZ_clone"))) TS_COption_MonitorEventZ_clone(uint32_t orig) {
17679         LDKCOption_MonitorEventZ* orig_conv = (LDKCOption_MonitorEventZ*)orig;
17680         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
17681         *ret_copy = COption_MonitorEventZ_clone(orig_conv);
17682         uint32_t ret_ref = (uintptr_t)ret_copy;
17683         return ret_ref;
17684 }
17685
17686 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_ok"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_ok(uint32_t o) {
17687         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
17688         CHECK_ACCESS(o_ptr);
17689         LDKCOption_MonitorEventZ o_conv = *(LDKCOption_MonitorEventZ*)(o_ptr);
17690         o_conv = COption_MonitorEventZ_clone((LDKCOption_MonitorEventZ*)(((uintptr_t)o) & ~1));
17691         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
17692         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_ok(o_conv);
17693         return (uint32_t)ret_conv;
17694 }
17695
17696 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_err"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_err(uint32_t e) {
17697         LDKDecodeError e_conv;
17698         e_conv.inner = (void*)(e & (~1));
17699         e_conv.is_owned = (e & 1) || (e == 0);
17700         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17701         e_conv = DecodeError_clone(&e_conv);
17702         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
17703         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_err(e_conv);
17704         return (uint32_t)ret_conv;
17705 }
17706
17707 jboolean  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_is_ok"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_is_ok(uint32_t o) {
17708         LDKCResult_COption_MonitorEventZDecodeErrorZ* o_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(o & ~1);
17709         jboolean ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_is_ok(o_conv);
17710         return ret_conv;
17711 }
17712
17713 void  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_free"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_free(uint32_t _res) {
17714         if ((_res & 1) != 0) return;
17715         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17716         CHECK_ACCESS(_res_ptr);
17717         LDKCResult_COption_MonitorEventZDecodeErrorZ _res_conv = *(LDKCResult_COption_MonitorEventZDecodeErrorZ*)(_res_ptr);
17718         FREE((void*)_res);
17719         CResult_COption_MonitorEventZDecodeErrorZ_free(_res_conv);
17720 }
17721
17722 static inline uintptr_t CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR arg) {
17723         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
17724         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(arg);
17725         return (uint32_t)ret_conv;
17726 }
17727 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(uint32_t arg) {
17728         LDKCResult_COption_MonitorEventZDecodeErrorZ* arg_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(arg & ~1);
17729         uint32_t ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(arg_conv);
17730         return ret_conv;
17731 }
17732
17733 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_clone"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_clone(uint32_t orig) {
17734         LDKCResult_COption_MonitorEventZDecodeErrorZ* orig_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(orig & ~1);
17735         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
17736         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(orig_conv);
17737         return (uint32_t)ret_conv;
17738 }
17739
17740 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_ok"))) TS_CResult_HTLCUpdateDecodeErrorZ_ok(uint32_t o) {
17741         LDKHTLCUpdate o_conv;
17742         o_conv.inner = (void*)(o & (~1));
17743         o_conv.is_owned = (o & 1) || (o == 0);
17744         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17745         o_conv = HTLCUpdate_clone(&o_conv);
17746         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
17747         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
17748         return (uint32_t)ret_conv;
17749 }
17750
17751 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_err"))) TS_CResult_HTLCUpdateDecodeErrorZ_err(uint32_t e) {
17752         LDKDecodeError e_conv;
17753         e_conv.inner = (void*)(e & (~1));
17754         e_conv.is_owned = (e & 1) || (e == 0);
17755         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17756         e_conv = DecodeError_clone(&e_conv);
17757         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
17758         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
17759         return (uint32_t)ret_conv;
17760 }
17761
17762 jboolean  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_is_ok"))) TS_CResult_HTLCUpdateDecodeErrorZ_is_ok(uint32_t o) {
17763         LDKCResult_HTLCUpdateDecodeErrorZ* o_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(o & ~1);
17764         jboolean ret_conv = CResult_HTLCUpdateDecodeErrorZ_is_ok(o_conv);
17765         return ret_conv;
17766 }
17767
17768 void  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_free"))) TS_CResult_HTLCUpdateDecodeErrorZ_free(uint32_t _res) {
17769         if ((_res & 1) != 0) return;
17770         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17771         CHECK_ACCESS(_res_ptr);
17772         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(_res_ptr);
17773         FREE((void*)_res);
17774         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
17775 }
17776
17777 static inline uintptr_t CResult_HTLCUpdateDecodeErrorZ_clone_ptr(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR arg) {
17778         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
17779         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(arg);
17780         return (uint32_t)ret_conv;
17781 }
17782 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_clone_ptr"))) TS_CResult_HTLCUpdateDecodeErrorZ_clone_ptr(uint32_t arg) {
17783         LDKCResult_HTLCUpdateDecodeErrorZ* arg_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
17784         uint32_t ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone_ptr(arg_conv);
17785         return ret_conv;
17786 }
17787
17788 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_clone"))) TS_CResult_HTLCUpdateDecodeErrorZ_clone(uint32_t orig) {
17789         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(orig & ~1);
17790         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
17791         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
17792         return (uint32_t)ret_conv;
17793 }
17794
17795 static inline uintptr_t C2Tuple_OutPointScriptZ_clone_ptr(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR arg) {
17796         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
17797         *ret_conv = C2Tuple_OutPointScriptZ_clone(arg);
17798         return ((uint32_t)ret_conv);
17799 }
17800 uint32_t  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_clone_ptr"))) TS_C2Tuple_OutPointScriptZ_clone_ptr(uint32_t arg) {
17801         LDKC2Tuple_OutPointScriptZ* arg_conv = (LDKC2Tuple_OutPointScriptZ*)(arg & ~1);
17802         uint32_t ret_conv = C2Tuple_OutPointScriptZ_clone_ptr(arg_conv);
17803         return ret_conv;
17804 }
17805
17806 uint32_t  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_clone"))) TS_C2Tuple_OutPointScriptZ_clone(uint32_t orig) {
17807         LDKC2Tuple_OutPointScriptZ* orig_conv = (LDKC2Tuple_OutPointScriptZ*)(orig & ~1);
17808         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
17809         *ret_conv = C2Tuple_OutPointScriptZ_clone(orig_conv);
17810         return ((uint32_t)ret_conv);
17811 }
17812
17813 uint32_t  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_new"))) TS_C2Tuple_OutPointScriptZ_new(uint32_t a, int8_tArray b) {
17814         LDKOutPoint a_conv;
17815         a_conv.inner = (void*)(a & (~1));
17816         a_conv.is_owned = (a & 1) || (a == 0);
17817         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
17818         a_conv = OutPoint_clone(&a_conv);
17819         LDKCVec_u8Z b_ref;
17820         b_ref.datalen = b->arr_len;
17821         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
17822         memcpy(b_ref.data, b->elems, b_ref.datalen); FREE(b);
17823         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
17824         *ret_conv = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
17825         return ((uint32_t)ret_conv);
17826 }
17827
17828 void  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_free"))) TS_C2Tuple_OutPointScriptZ_free(uint32_t _res) {
17829         if ((_res & 1) != 0) return;
17830         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17831         CHECK_ACCESS(_res_ptr);
17832         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(_res_ptr);
17833         FREE((void*)_res);
17834         C2Tuple_OutPointScriptZ_free(_res_conv);
17835 }
17836
17837 static inline uintptr_t C2Tuple_u32ScriptZ_clone_ptr(LDKC2Tuple_u32ScriptZ *NONNULL_PTR arg) {
17838         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
17839         *ret_conv = C2Tuple_u32ScriptZ_clone(arg);
17840         return ((uint32_t)ret_conv);
17841 }
17842 uint32_t  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_clone_ptr"))) TS_C2Tuple_u32ScriptZ_clone_ptr(uint32_t arg) {
17843         LDKC2Tuple_u32ScriptZ* arg_conv = (LDKC2Tuple_u32ScriptZ*)(arg & ~1);
17844         uint32_t ret_conv = C2Tuple_u32ScriptZ_clone_ptr(arg_conv);
17845         return ret_conv;
17846 }
17847
17848 uint32_t  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_clone"))) TS_C2Tuple_u32ScriptZ_clone(uint32_t orig) {
17849         LDKC2Tuple_u32ScriptZ* orig_conv = (LDKC2Tuple_u32ScriptZ*)(orig & ~1);
17850         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
17851         *ret_conv = C2Tuple_u32ScriptZ_clone(orig_conv);
17852         return ((uint32_t)ret_conv);
17853 }
17854
17855 uint32_t  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_new"))) TS_C2Tuple_u32ScriptZ_new(int32_t a, int8_tArray b) {
17856         LDKCVec_u8Z b_ref;
17857         b_ref.datalen = b->arr_len;
17858         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
17859         memcpy(b_ref.data, b->elems, b_ref.datalen); FREE(b);
17860         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
17861         *ret_conv = C2Tuple_u32ScriptZ_new(a, b_ref);
17862         return ((uint32_t)ret_conv);
17863 }
17864
17865 void  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_free"))) TS_C2Tuple_u32ScriptZ_free(uint32_t _res) {
17866         if ((_res & 1) != 0) return;
17867         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17868         CHECK_ACCESS(_res_ptr);
17869         LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_ptr);
17870         FREE((void*)_res);
17871         C2Tuple_u32ScriptZ_free(_res_conv);
17872 }
17873
17874 void  __attribute__((export_name("TS_CVec_C2Tuple_u32ScriptZZ_free"))) TS_CVec_C2Tuple_u32ScriptZZ_free(uint32_tArray _res) {
17875         LDKCVec_C2Tuple_u32ScriptZZ _res_constr;
17876         _res_constr.datalen = _res->arr_len;
17877         if (_res_constr.datalen > 0)
17878                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
17879         else
17880                 _res_constr.data = NULL;
17881         uint32_t* _res_vals = _res->elems;
17882         for (size_t v = 0; v < _res_constr.datalen; v++) {
17883                 uint32_t _res_conv_21 = _res_vals[v];
17884                 void* _res_conv_21_ptr = (void*)(((uintptr_t)_res_conv_21) & ~1);
17885                 CHECK_ACCESS(_res_conv_21_ptr);
17886                 LDKC2Tuple_u32ScriptZ _res_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_conv_21_ptr);
17887                 FREE((void*)_res_conv_21);
17888                 _res_constr.data[v] = _res_conv_21_conv;
17889         }
17890         FREE(_res);
17891         CVec_C2Tuple_u32ScriptZZ_free(_res_constr);
17892 }
17893
17894 static inline uintptr_t C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR arg) {
17895         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
17896         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(arg);
17897         return ((uint32_t)ret_conv);
17898 }
17899 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(uint32_t arg) {
17900         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(arg & ~1);
17901         uint32_t ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(arg_conv);
17902         return ret_conv;
17903 }
17904
17905 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(uint32_t orig) {
17906         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(orig & ~1);
17907         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
17908         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(orig_conv);
17909         return ((uint32_t)ret_conv);
17910 }
17911
17912 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(int8_tArray a, uint32_tArray b) {
17913         LDKThirtyTwoBytes a_ref;
17914         CHECK(a->arr_len == 32);
17915         memcpy(a_ref.data, a->elems, 32); FREE(a);
17916         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
17917         b_constr.datalen = b->arr_len;
17918         if (b_constr.datalen > 0)
17919                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
17920         else
17921                 b_constr.data = NULL;
17922         uint32_t* b_vals = b->elems;
17923         for (size_t v = 0; v < b_constr.datalen; v++) {
17924                 uint32_t b_conv_21 = b_vals[v];
17925                 void* b_conv_21_ptr = (void*)(((uintptr_t)b_conv_21) & ~1);
17926                 CHECK_ACCESS(b_conv_21_ptr);
17927                 LDKC2Tuple_u32ScriptZ b_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(b_conv_21_ptr);
17928                 b_conv_21_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uintptr_t)b_conv_21) & ~1));
17929                 b_constr.data[v] = b_conv_21_conv;
17930         }
17931         FREE(b);
17932         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
17933         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a_ref, b_constr);
17934         return ((uint32_t)ret_conv);
17935 }
17936
17937 void  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(uint32_t _res) {
17938         if ((_res & 1) != 0) return;
17939         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17940         CHECK_ACCESS(_res_ptr);
17941         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_ptr);
17942         FREE((void*)_res);
17943         C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
17944 }
17945
17946 void  __attribute__((export_name("TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free"))) TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(uint32_tArray _res) {
17947         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res_constr;
17948         _res_constr.datalen = _res->arr_len;
17949         if (_res_constr.datalen > 0)
17950                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Elements");
17951         else
17952                 _res_constr.data = NULL;
17953         uint32_t* _res_vals = _res->elems;
17954         for (size_t o = 0; o < _res_constr.datalen; o++) {
17955                 uint32_t _res_conv_40 = _res_vals[o];
17956                 void* _res_conv_40_ptr = (void*)(((uintptr_t)_res_conv_40) & ~1);
17957                 CHECK_ACCESS(_res_conv_40_ptr);
17958                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_40_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_conv_40_ptr);
17959                 FREE((void*)_res_conv_40);
17960                 _res_constr.data[o] = _res_conv_40_conv;
17961         }
17962         FREE(_res);
17963         CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res_constr);
17964 }
17965
17966 void  __attribute__((export_name("TS_CVec_EventZ_free"))) TS_CVec_EventZ_free(uint32_tArray _res) {
17967         LDKCVec_EventZ _res_constr;
17968         _res_constr.datalen = _res->arr_len;
17969         if (_res_constr.datalen > 0)
17970                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
17971         else
17972                 _res_constr.data = NULL;
17973         uint32_t* _res_vals = _res->elems;
17974         for (size_t h = 0; h < _res_constr.datalen; h++) {
17975                 uint32_t _res_conv_7 = _res_vals[h];
17976                 void* _res_conv_7_ptr = (void*)(((uintptr_t)_res_conv_7) & ~1);
17977                 CHECK_ACCESS(_res_conv_7_ptr);
17978                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(_res_conv_7_ptr);
17979                 FREE((void*)_res_conv_7);
17980                 _res_constr.data[h] = _res_conv_7_conv;
17981         }
17982         FREE(_res);
17983         CVec_EventZ_free(_res_constr);
17984 }
17985
17986 void  __attribute__((export_name("TS_CVec_TransactionZ_free"))) TS_CVec_TransactionZ_free(ptrArray _res) {
17987         LDKCVec_TransactionZ _res_constr;
17988         _res_constr.datalen = _res->arr_len;
17989         if (_res_constr.datalen > 0)
17990                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
17991         else
17992                 _res_constr.data = NULL;
17993         int8_tArray* _res_vals = (void*) _res->elems;
17994         for (size_t m = 0; m < _res_constr.datalen; m++) {
17995                 int8_tArray _res_conv_12 = _res_vals[m];
17996                 LDKTransaction _res_conv_12_ref;
17997                 _res_conv_12_ref.datalen = _res_conv_12->arr_len;
17998                 _res_conv_12_ref.data = MALLOC(_res_conv_12_ref.datalen, "LDKTransaction Bytes");
17999                 memcpy(_res_conv_12_ref.data, _res_conv_12->elems, _res_conv_12_ref.datalen); FREE(_res_conv_12);
18000                 _res_conv_12_ref.data_is_owned = true;
18001                 _res_constr.data[m] = _res_conv_12_ref;
18002         }
18003         FREE(_res);
18004         CVec_TransactionZ_free(_res_constr);
18005 }
18006
18007 static inline uintptr_t C2Tuple_u32TxOutZ_clone_ptr(LDKC2Tuple_u32TxOutZ *NONNULL_PTR arg) {
18008         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
18009         *ret_conv = C2Tuple_u32TxOutZ_clone(arg);
18010         return ((uint32_t)ret_conv);
18011 }
18012 uint32_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_clone_ptr"))) TS_C2Tuple_u32TxOutZ_clone_ptr(uint32_t arg) {
18013         LDKC2Tuple_u32TxOutZ* arg_conv = (LDKC2Tuple_u32TxOutZ*)(arg & ~1);
18014         uint32_t ret_conv = C2Tuple_u32TxOutZ_clone_ptr(arg_conv);
18015         return ret_conv;
18016 }
18017
18018 uint32_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_clone"))) TS_C2Tuple_u32TxOutZ_clone(uint32_t orig) {
18019         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)(orig & ~1);
18020         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
18021         *ret_conv = C2Tuple_u32TxOutZ_clone(orig_conv);
18022         return ((uint32_t)ret_conv);
18023 }
18024
18025 uint32_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_new"))) TS_C2Tuple_u32TxOutZ_new(int32_t a, uint32_t b) {
18026         void* b_ptr = (void*)(((uintptr_t)b) & ~1);
18027         CHECK_ACCESS(b_ptr);
18028         LDKTxOut b_conv = *(LDKTxOut*)(b_ptr);
18029         b_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)b) & ~1));
18030         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
18031         *ret_conv = C2Tuple_u32TxOutZ_new(a, b_conv);
18032         return ((uint32_t)ret_conv);
18033 }
18034
18035 void  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_free"))) TS_C2Tuple_u32TxOutZ_free(uint32_t _res) {
18036         if ((_res & 1) != 0) return;
18037         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18038         CHECK_ACCESS(_res_ptr);
18039         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_ptr);
18040         FREE((void*)_res);
18041         C2Tuple_u32TxOutZ_free(_res_conv);
18042 }
18043
18044 void  __attribute__((export_name("TS_CVec_C2Tuple_u32TxOutZZ_free"))) TS_CVec_C2Tuple_u32TxOutZZ_free(uint32_tArray _res) {
18045         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
18046         _res_constr.datalen = _res->arr_len;
18047         if (_res_constr.datalen > 0)
18048                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
18049         else
18050                 _res_constr.data = NULL;
18051         uint32_t* _res_vals = _res->elems;
18052         for (size_t u = 0; u < _res_constr.datalen; u++) {
18053                 uint32_t _res_conv_20 = _res_vals[u];
18054                 void* _res_conv_20_ptr = (void*)(((uintptr_t)_res_conv_20) & ~1);
18055                 CHECK_ACCESS(_res_conv_20_ptr);
18056                 LDKC2Tuple_u32TxOutZ _res_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_conv_20_ptr);
18057                 FREE((void*)_res_conv_20);
18058                 _res_constr.data[u] = _res_conv_20_conv;
18059         }
18060         FREE(_res);
18061         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
18062 }
18063
18064 static inline uintptr_t C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR arg) {
18065         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
18066         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(arg);
18067         return ((uint32_t)ret_conv);
18068 }
18069 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(uint32_t arg) {
18070         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(arg & ~1);
18071         uint32_t ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(arg_conv);
18072         return ret_conv;
18073 }
18074
18075 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(uint32_t orig) {
18076         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(orig & ~1);
18077         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
18078         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(orig_conv);
18079         return ((uint32_t)ret_conv);
18080 }
18081
18082 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(int8_tArray a, uint32_tArray b) {
18083         LDKThirtyTwoBytes a_ref;
18084         CHECK(a->arr_len == 32);
18085         memcpy(a_ref.data, a->elems, 32); FREE(a);
18086         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
18087         b_constr.datalen = b->arr_len;
18088         if (b_constr.datalen > 0)
18089                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
18090         else
18091                 b_constr.data = NULL;
18092         uint32_t* b_vals = b->elems;
18093         for (size_t u = 0; u < b_constr.datalen; u++) {
18094                 uint32_t b_conv_20 = b_vals[u];
18095                 void* b_conv_20_ptr = (void*)(((uintptr_t)b_conv_20) & ~1);
18096                 CHECK_ACCESS(b_conv_20_ptr);
18097                 LDKC2Tuple_u32TxOutZ b_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(b_conv_20_ptr);
18098                 b_conv_20_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uintptr_t)b_conv_20) & ~1));
18099                 b_constr.data[u] = b_conv_20_conv;
18100         }
18101         FREE(b);
18102         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
18103         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
18104         return ((uint32_t)ret_conv);
18105 }
18106
18107 void  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(uint32_t _res) {
18108         if ((_res & 1) != 0) return;
18109         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18110         CHECK_ACCESS(_res_ptr);
18111         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_ptr);
18112         FREE((void*)_res);
18113         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
18114 }
18115
18116 void  __attribute__((export_name("TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free"))) TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(uint32_tArray _res) {
18117         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
18118         _res_constr.datalen = _res->arr_len;
18119         if (_res_constr.datalen > 0)
18120                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
18121         else
18122                 _res_constr.data = NULL;
18123         uint32_t* _res_vals = _res->elems;
18124         for (size_t n = 0; n < _res_constr.datalen; n++) {
18125                 uint32_t _res_conv_39 = _res_vals[n];
18126                 void* _res_conv_39_ptr = (void*)(((uintptr_t)_res_conv_39) & ~1);
18127                 CHECK_ACCESS(_res_conv_39_ptr);
18128                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_39_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_conv_39_ptr);
18129                 FREE((void*)_res_conv_39);
18130                 _res_constr.data[n] = _res_conv_39_conv;
18131         }
18132         FREE(_res);
18133         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
18134 }
18135
18136 void  __attribute__((export_name("TS_CVec_BalanceZ_free"))) TS_CVec_BalanceZ_free(uint32_tArray _res) {
18137         LDKCVec_BalanceZ _res_constr;
18138         _res_constr.datalen = _res->arr_len;
18139         if (_res_constr.datalen > 0)
18140                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKBalance), "LDKCVec_BalanceZ Elements");
18141         else
18142                 _res_constr.data = NULL;
18143         uint32_t* _res_vals = _res->elems;
18144         for (size_t j = 0; j < _res_constr.datalen; j++) {
18145                 uint32_t _res_conv_9 = _res_vals[j];
18146                 void* _res_conv_9_ptr = (void*)(((uintptr_t)_res_conv_9) & ~1);
18147                 CHECK_ACCESS(_res_conv_9_ptr);
18148                 LDKBalance _res_conv_9_conv = *(LDKBalance*)(_res_conv_9_ptr);
18149                 FREE((void*)_res_conv_9);
18150                 _res_constr.data[j] = _res_conv_9_conv;
18151         }
18152         FREE(_res);
18153         CVec_BalanceZ_free(_res_constr);
18154 }
18155
18156 static inline uintptr_t C2Tuple_BlockHashChannelMonitorZ_clone_ptr(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR arg) {
18157         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
18158         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(arg);
18159         return ((uint32_t)ret_conv);
18160 }
18161 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_clone_ptr"))) TS_C2Tuple_BlockHashChannelMonitorZ_clone_ptr(uint32_t arg) {
18162         LDKC2Tuple_BlockHashChannelMonitorZ* arg_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(arg & ~1);
18163         uint32_t ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone_ptr(arg_conv);
18164         return ret_conv;
18165 }
18166
18167 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_clone"))) TS_C2Tuple_BlockHashChannelMonitorZ_clone(uint32_t orig) {
18168         LDKC2Tuple_BlockHashChannelMonitorZ* orig_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(orig & ~1);
18169         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
18170         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(orig_conv);
18171         return ((uint32_t)ret_conv);
18172 }
18173
18174 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_new"))) TS_C2Tuple_BlockHashChannelMonitorZ_new(int8_tArray a, uint32_t b) {
18175         LDKThirtyTwoBytes a_ref;
18176         CHECK(a->arr_len == 32);
18177         memcpy(a_ref.data, a->elems, 32); FREE(a);
18178         LDKChannelMonitor b_conv;
18179         b_conv.inner = (void*)(b & (~1));
18180         b_conv.is_owned = (b & 1) || (b == 0);
18181         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
18182         b_conv = ChannelMonitor_clone(&b_conv);
18183         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
18184         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
18185         return ((uint32_t)ret_conv);
18186 }
18187
18188 void  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_free"))) TS_C2Tuple_BlockHashChannelMonitorZ_free(uint32_t _res) {
18189         if ((_res & 1) != 0) return;
18190         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18191         CHECK_ACCESS(_res_ptr);
18192         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_ptr);
18193         FREE((void*)_res);
18194         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
18195 }
18196
18197 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(uint32_t o) {
18198         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
18199         CHECK_ACCESS(o_ptr);
18200         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_ptr);
18201         o_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uintptr_t)o) & ~1));
18202         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
18203         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
18204         return (uint32_t)ret_conv;
18205 }
18206
18207 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(uint32_t e) {
18208         LDKDecodeError e_conv;
18209         e_conv.inner = (void*)(e & (~1));
18210         e_conv.is_owned = (e & 1) || (e == 0);
18211         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18212         e_conv = DecodeError_clone(&e_conv);
18213         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
18214         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
18215         return (uint32_t)ret_conv;
18216 }
18217
18218 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok(uint32_t o) {
18219         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(o & ~1);
18220         jboolean ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok(o_conv);
18221         return ret_conv;
18222 }
18223
18224 void  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(uint32_t _res) {
18225         if ((_res & 1) != 0) return;
18226         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18227         CHECK_ACCESS(_res_ptr);
18228         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(_res_ptr);
18229         FREE((void*)_res);
18230         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
18231 }
18232
18233 static inline uintptr_t CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR arg) {
18234         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
18235         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(arg);
18236         return (uint32_t)ret_conv;
18237 }
18238 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(uint32_t arg) {
18239         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* arg_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
18240         uint32_t ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(arg_conv);
18241         return ret_conv;
18242 }
18243
18244 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(uint32_t orig) {
18245         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* orig_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(orig & ~1);
18246         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
18247         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(orig_conv);
18248         return (uint32_t)ret_conv;
18249 }
18250
18251 static inline uintptr_t C2Tuple_PublicKeyTypeZ_clone_ptr(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR arg) {
18252         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
18253         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(arg);
18254         return ((uint32_t)ret_conv);
18255 }
18256 uint32_t  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_clone_ptr"))) TS_C2Tuple_PublicKeyTypeZ_clone_ptr(uint32_t arg) {
18257         LDKC2Tuple_PublicKeyTypeZ* arg_conv = (LDKC2Tuple_PublicKeyTypeZ*)(arg & ~1);
18258         uint32_t ret_conv = C2Tuple_PublicKeyTypeZ_clone_ptr(arg_conv);
18259         return ret_conv;
18260 }
18261
18262 uint32_t  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_clone"))) TS_C2Tuple_PublicKeyTypeZ_clone(uint32_t orig) {
18263         LDKC2Tuple_PublicKeyTypeZ* orig_conv = (LDKC2Tuple_PublicKeyTypeZ*)(orig & ~1);
18264         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
18265         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(orig_conv);
18266         return ((uint32_t)ret_conv);
18267 }
18268
18269 uint32_t  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_new"))) TS_C2Tuple_PublicKeyTypeZ_new(int8_tArray a, uint32_t b) {
18270         LDKPublicKey a_ref;
18271         CHECK(a->arr_len == 33);
18272         memcpy(a_ref.compressed_form, a->elems, 33); FREE(a);
18273         void* b_ptr = (void*)(((uintptr_t)b) & ~1);
18274         CHECK_ACCESS(b_ptr);
18275         LDKType b_conv = *(LDKType*)(b_ptr);
18276         if (b_conv.free == LDKType_JCalls_free) {
18277                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
18278                 LDKType_JCalls_cloned(&b_conv);
18279         }
18280         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
18281         *ret_conv = C2Tuple_PublicKeyTypeZ_new(a_ref, b_conv);
18282         return ((uint32_t)ret_conv);
18283 }
18284
18285 void  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_free"))) TS_C2Tuple_PublicKeyTypeZ_free(uint32_t _res) {
18286         if ((_res & 1) != 0) return;
18287         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18288         CHECK_ACCESS(_res_ptr);
18289         LDKC2Tuple_PublicKeyTypeZ _res_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_ptr);
18290         FREE((void*)_res);
18291         C2Tuple_PublicKeyTypeZ_free(_res_conv);
18292 }
18293
18294 void  __attribute__((export_name("TS_CVec_C2Tuple_PublicKeyTypeZZ_free"))) TS_CVec_C2Tuple_PublicKeyTypeZZ_free(uint32_tArray _res) {
18295         LDKCVec_C2Tuple_PublicKeyTypeZZ _res_constr;
18296         _res_constr.datalen = _res->arr_len;
18297         if (_res_constr.datalen > 0)
18298                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
18299         else
18300                 _res_constr.data = NULL;
18301         uint32_t* _res_vals = _res->elems;
18302         for (size_t z = 0; z < _res_constr.datalen; z++) {
18303                 uint32_t _res_conv_25 = _res_vals[z];
18304                 void* _res_conv_25_ptr = (void*)(((uintptr_t)_res_conv_25) & ~1);
18305                 CHECK_ACCESS(_res_conv_25_ptr);
18306                 LDKC2Tuple_PublicKeyTypeZ _res_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_conv_25_ptr);
18307                 FREE((void*)_res_conv_25);
18308                 _res_constr.data[z] = _res_conv_25_conv;
18309         }
18310         FREE(_res);
18311         CVec_C2Tuple_PublicKeyTypeZZ_free(_res_constr);
18312 }
18313
18314 uint32_t  __attribute__((export_name("TS_COption_NetAddressZ_some"))) TS_COption_NetAddressZ_some(uint32_t o) {
18315         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
18316         CHECK_ACCESS(o_ptr);
18317         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
18318         o_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)o) & ~1));
18319         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
18320         *ret_copy = COption_NetAddressZ_some(o_conv);
18321         uint32_t ret_ref = (uintptr_t)ret_copy;
18322         return ret_ref;
18323 }
18324
18325 uint32_t  __attribute__((export_name("TS_COption_NetAddressZ_none"))) TS_COption_NetAddressZ_none() {
18326         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
18327         *ret_copy = COption_NetAddressZ_none();
18328         uint32_t ret_ref = (uintptr_t)ret_copy;
18329         return ret_ref;
18330 }
18331
18332 void  __attribute__((export_name("TS_COption_NetAddressZ_free"))) TS_COption_NetAddressZ_free(uint32_t _res) {
18333         if ((_res & 1) != 0) return;
18334         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18335         CHECK_ACCESS(_res_ptr);
18336         LDKCOption_NetAddressZ _res_conv = *(LDKCOption_NetAddressZ*)(_res_ptr);
18337         FREE((void*)_res);
18338         COption_NetAddressZ_free(_res_conv);
18339 }
18340
18341 static inline uintptr_t COption_NetAddressZ_clone_ptr(LDKCOption_NetAddressZ *NONNULL_PTR arg) {
18342         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
18343         *ret_copy = COption_NetAddressZ_clone(arg);
18344 uint32_t ret_ref = (uintptr_t)ret_copy;
18345         return ret_ref;
18346 }
18347 uint32_t  __attribute__((export_name("TS_COption_NetAddressZ_clone_ptr"))) TS_COption_NetAddressZ_clone_ptr(uint32_t arg) {
18348         LDKCOption_NetAddressZ* arg_conv = (LDKCOption_NetAddressZ*)arg;
18349         uint32_t ret_conv = COption_NetAddressZ_clone_ptr(arg_conv);
18350         return ret_conv;
18351 }
18352
18353 uint32_t  __attribute__((export_name("TS_COption_NetAddressZ_clone"))) TS_COption_NetAddressZ_clone(uint32_t orig) {
18354         LDKCOption_NetAddressZ* orig_conv = (LDKCOption_NetAddressZ*)orig;
18355         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
18356         *ret_copy = COption_NetAddressZ_clone(orig_conv);
18357         uint32_t ret_ref = (uintptr_t)ret_copy;
18358         return ret_ref;
18359 }
18360
18361 uint32_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_ok"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_ok(int8_tArray o) {
18362         LDKCVec_u8Z o_ref;
18363         o_ref.datalen = o->arr_len;
18364         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
18365         memcpy(o_ref.data, o->elems, o_ref.datalen); FREE(o);
18366         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
18367         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
18368         return (uint32_t)ret_conv;
18369 }
18370
18371 uint32_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_err"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_err(uint32_t e) {
18372         LDKPeerHandleError e_conv;
18373         e_conv.inner = (void*)(e & (~1));
18374         e_conv.is_owned = (e & 1) || (e == 0);
18375         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18376         e_conv = PeerHandleError_clone(&e_conv);
18377         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
18378         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
18379         return (uint32_t)ret_conv;
18380 }
18381
18382 jboolean  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_is_ok"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_is_ok(uint32_t o) {
18383         LDKCResult_CVec_u8ZPeerHandleErrorZ* o_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(o & ~1);
18384         jboolean ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_is_ok(o_conv);
18385         return ret_conv;
18386 }
18387
18388 void  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_free"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_free(uint32_t _res) {
18389         if ((_res & 1) != 0) return;
18390         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18391         CHECK_ACCESS(_res_ptr);
18392         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(_res_ptr);
18393         FREE((void*)_res);
18394         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
18395 }
18396
18397 static inline uintptr_t CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR arg) {
18398         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
18399         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(arg);
18400         return (uint32_t)ret_conv;
18401 }
18402 uint32_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(uint32_t arg) {
18403         LDKCResult_CVec_u8ZPeerHandleErrorZ* arg_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
18404         uint32_t ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(arg_conv);
18405         return ret_conv;
18406 }
18407
18408 uint32_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_clone"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_clone(uint32_t orig) {
18409         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(orig & ~1);
18410         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
18411         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
18412         return (uint32_t)ret_conv;
18413 }
18414
18415 uint32_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_ok"))) TS_CResult_NonePeerHandleErrorZ_ok() {
18416         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
18417         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
18418         return (uint32_t)ret_conv;
18419 }
18420
18421 uint32_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_err"))) TS_CResult_NonePeerHandleErrorZ_err(uint32_t e) {
18422         LDKPeerHandleError e_conv;
18423         e_conv.inner = (void*)(e & (~1));
18424         e_conv.is_owned = (e & 1) || (e == 0);
18425         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18426         e_conv = PeerHandleError_clone(&e_conv);
18427         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
18428         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
18429         return (uint32_t)ret_conv;
18430 }
18431
18432 jboolean  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_is_ok"))) TS_CResult_NonePeerHandleErrorZ_is_ok(uint32_t o) {
18433         LDKCResult_NonePeerHandleErrorZ* o_conv = (LDKCResult_NonePeerHandleErrorZ*)(o & ~1);
18434         jboolean ret_conv = CResult_NonePeerHandleErrorZ_is_ok(o_conv);
18435         return ret_conv;
18436 }
18437
18438 void  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_free"))) TS_CResult_NonePeerHandleErrorZ_free(uint32_t _res) {
18439         if ((_res & 1) != 0) return;
18440         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18441         CHECK_ACCESS(_res_ptr);
18442         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(_res_ptr);
18443         FREE((void*)_res);
18444         CResult_NonePeerHandleErrorZ_free(_res_conv);
18445 }
18446
18447 static inline uintptr_t CResult_NonePeerHandleErrorZ_clone_ptr(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR arg) {
18448         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
18449         *ret_conv = CResult_NonePeerHandleErrorZ_clone(arg);
18450         return (uint32_t)ret_conv;
18451 }
18452 uint32_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_clone_ptr"))) TS_CResult_NonePeerHandleErrorZ_clone_ptr(uint32_t arg) {
18453         LDKCResult_NonePeerHandleErrorZ* arg_conv = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
18454         uint32_t ret_conv = CResult_NonePeerHandleErrorZ_clone_ptr(arg_conv);
18455         return ret_conv;
18456 }
18457
18458 uint32_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_clone"))) TS_CResult_NonePeerHandleErrorZ_clone(uint32_t orig) {
18459         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)(orig & ~1);
18460         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
18461         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
18462         return (uint32_t)ret_conv;
18463 }
18464
18465 uint32_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_ok"))) TS_CResult_boolPeerHandleErrorZ_ok(jboolean o) {
18466         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
18467         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
18468         return (uint32_t)ret_conv;
18469 }
18470
18471 uint32_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_err"))) TS_CResult_boolPeerHandleErrorZ_err(uint32_t e) {
18472         LDKPeerHandleError e_conv;
18473         e_conv.inner = (void*)(e & (~1));
18474         e_conv.is_owned = (e & 1) || (e == 0);
18475         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18476         e_conv = PeerHandleError_clone(&e_conv);
18477         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
18478         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
18479         return (uint32_t)ret_conv;
18480 }
18481
18482 jboolean  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_is_ok"))) TS_CResult_boolPeerHandleErrorZ_is_ok(uint32_t o) {
18483         LDKCResult_boolPeerHandleErrorZ* o_conv = (LDKCResult_boolPeerHandleErrorZ*)(o & ~1);
18484         jboolean ret_conv = CResult_boolPeerHandleErrorZ_is_ok(o_conv);
18485         return ret_conv;
18486 }
18487
18488 void  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_free"))) TS_CResult_boolPeerHandleErrorZ_free(uint32_t _res) {
18489         if ((_res & 1) != 0) return;
18490         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18491         CHECK_ACCESS(_res_ptr);
18492         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(_res_ptr);
18493         FREE((void*)_res);
18494         CResult_boolPeerHandleErrorZ_free(_res_conv);
18495 }
18496
18497 static inline uintptr_t CResult_boolPeerHandleErrorZ_clone_ptr(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR arg) {
18498         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
18499         *ret_conv = CResult_boolPeerHandleErrorZ_clone(arg);
18500         return (uint32_t)ret_conv;
18501 }
18502 uint32_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_clone_ptr"))) TS_CResult_boolPeerHandleErrorZ_clone_ptr(uint32_t arg) {
18503         LDKCResult_boolPeerHandleErrorZ* arg_conv = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
18504         uint32_t ret_conv = CResult_boolPeerHandleErrorZ_clone_ptr(arg_conv);
18505         return ret_conv;
18506 }
18507
18508 uint32_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_clone"))) TS_CResult_boolPeerHandleErrorZ_clone(uint32_t orig) {
18509         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)(orig & ~1);
18510         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
18511         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
18512         return (uint32_t)ret_conv;
18513 }
18514
18515 uint32_t  __attribute__((export_name("TS_CResult_NoneErrorZ_ok"))) TS_CResult_NoneErrorZ_ok() {
18516         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
18517         *ret_conv = CResult_NoneErrorZ_ok();
18518         return (uint32_t)ret_conv;
18519 }
18520
18521 uint32_t  __attribute__((export_name("TS_CResult_NoneErrorZ_err"))) TS_CResult_NoneErrorZ_err(uint32_t e) {
18522         LDKIOError e_conv = LDKIOError_from_js(e);
18523         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
18524         *ret_conv = CResult_NoneErrorZ_err(e_conv);
18525         return (uint32_t)ret_conv;
18526 }
18527
18528 jboolean  __attribute__((export_name("TS_CResult_NoneErrorZ_is_ok"))) TS_CResult_NoneErrorZ_is_ok(uint32_t o) {
18529         LDKCResult_NoneErrorZ* o_conv = (LDKCResult_NoneErrorZ*)(o & ~1);
18530         jboolean ret_conv = CResult_NoneErrorZ_is_ok(o_conv);
18531         return ret_conv;
18532 }
18533
18534 void  __attribute__((export_name("TS_CResult_NoneErrorZ_free"))) TS_CResult_NoneErrorZ_free(uint32_t _res) {
18535         if ((_res & 1) != 0) return;
18536         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18537         CHECK_ACCESS(_res_ptr);
18538         LDKCResult_NoneErrorZ _res_conv = *(LDKCResult_NoneErrorZ*)(_res_ptr);
18539         FREE((void*)_res);
18540         CResult_NoneErrorZ_free(_res_conv);
18541 }
18542
18543 static inline uintptr_t CResult_NoneErrorZ_clone_ptr(LDKCResult_NoneErrorZ *NONNULL_PTR arg) {
18544         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
18545         *ret_conv = CResult_NoneErrorZ_clone(arg);
18546         return (uint32_t)ret_conv;
18547 }
18548 uint32_t  __attribute__((export_name("TS_CResult_NoneErrorZ_clone_ptr"))) TS_CResult_NoneErrorZ_clone_ptr(uint32_t arg) {
18549         LDKCResult_NoneErrorZ* arg_conv = (LDKCResult_NoneErrorZ*)(arg & ~1);
18550         uint32_t ret_conv = CResult_NoneErrorZ_clone_ptr(arg_conv);
18551         return ret_conv;
18552 }
18553
18554 uint32_t  __attribute__((export_name("TS_CResult_NoneErrorZ_clone"))) TS_CResult_NoneErrorZ_clone(uint32_t orig) {
18555         LDKCResult_NoneErrorZ* orig_conv = (LDKCResult_NoneErrorZ*)(orig & ~1);
18556         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
18557         *ret_conv = CResult_NoneErrorZ_clone(orig_conv);
18558         return (uint32_t)ret_conv;
18559 }
18560
18561 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_ok"))) TS_CResult_NetAddressDecodeErrorZ_ok(uint32_t o) {
18562         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
18563         CHECK_ACCESS(o_ptr);
18564         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
18565         o_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)o) & ~1));
18566         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
18567         *ret_conv = CResult_NetAddressDecodeErrorZ_ok(o_conv);
18568         return (uint32_t)ret_conv;
18569 }
18570
18571 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_err"))) TS_CResult_NetAddressDecodeErrorZ_err(uint32_t e) {
18572         LDKDecodeError e_conv;
18573         e_conv.inner = (void*)(e & (~1));
18574         e_conv.is_owned = (e & 1) || (e == 0);
18575         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18576         e_conv = DecodeError_clone(&e_conv);
18577         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
18578         *ret_conv = CResult_NetAddressDecodeErrorZ_err(e_conv);
18579         return (uint32_t)ret_conv;
18580 }
18581
18582 jboolean  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_is_ok"))) TS_CResult_NetAddressDecodeErrorZ_is_ok(uint32_t o) {
18583         LDKCResult_NetAddressDecodeErrorZ* o_conv = (LDKCResult_NetAddressDecodeErrorZ*)(o & ~1);
18584         jboolean ret_conv = CResult_NetAddressDecodeErrorZ_is_ok(o_conv);
18585         return ret_conv;
18586 }
18587
18588 void  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_free"))) TS_CResult_NetAddressDecodeErrorZ_free(uint32_t _res) {
18589         if ((_res & 1) != 0) return;
18590         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18591         CHECK_ACCESS(_res_ptr);
18592         LDKCResult_NetAddressDecodeErrorZ _res_conv = *(LDKCResult_NetAddressDecodeErrorZ*)(_res_ptr);
18593         FREE((void*)_res);
18594         CResult_NetAddressDecodeErrorZ_free(_res_conv);
18595 }
18596
18597 static inline uintptr_t CResult_NetAddressDecodeErrorZ_clone_ptr(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR arg) {
18598         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
18599         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(arg);
18600         return (uint32_t)ret_conv;
18601 }
18602 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_clone_ptr"))) TS_CResult_NetAddressDecodeErrorZ_clone_ptr(uint32_t arg) {
18603         LDKCResult_NetAddressDecodeErrorZ* arg_conv = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
18604         uint32_t ret_conv = CResult_NetAddressDecodeErrorZ_clone_ptr(arg_conv);
18605         return ret_conv;
18606 }
18607
18608 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_clone"))) TS_CResult_NetAddressDecodeErrorZ_clone(uint32_t orig) {
18609         LDKCResult_NetAddressDecodeErrorZ* orig_conv = (LDKCResult_NetAddressDecodeErrorZ*)(orig & ~1);
18610         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
18611         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(orig_conv);
18612         return (uint32_t)ret_conv;
18613 }
18614
18615 void  __attribute__((export_name("TS_CVec_UpdateAddHTLCZ_free"))) TS_CVec_UpdateAddHTLCZ_free(uint32_tArray _res) {
18616         LDKCVec_UpdateAddHTLCZ _res_constr;
18617         _res_constr.datalen = _res->arr_len;
18618         if (_res_constr.datalen > 0)
18619                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
18620         else
18621                 _res_constr.data = NULL;
18622         uint32_t* _res_vals = _res->elems;
18623         for (size_t p = 0; p < _res_constr.datalen; p++) {
18624                 uint32_t _res_conv_15 = _res_vals[p];
18625                 LDKUpdateAddHTLC _res_conv_15_conv;
18626                 _res_conv_15_conv.inner = (void*)(_res_conv_15 & (~1));
18627                 _res_conv_15_conv.is_owned = (_res_conv_15 & 1) || (_res_conv_15 == 0);
18628                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_15_conv);
18629                 _res_constr.data[p] = _res_conv_15_conv;
18630         }
18631         FREE(_res);
18632         CVec_UpdateAddHTLCZ_free(_res_constr);
18633 }
18634
18635 void  __attribute__((export_name("TS_CVec_UpdateFulfillHTLCZ_free"))) TS_CVec_UpdateFulfillHTLCZ_free(uint32_tArray _res) {
18636         LDKCVec_UpdateFulfillHTLCZ _res_constr;
18637         _res_constr.datalen = _res->arr_len;
18638         if (_res_constr.datalen > 0)
18639                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
18640         else
18641                 _res_constr.data = NULL;
18642         uint32_t* _res_vals = _res->elems;
18643         for (size_t t = 0; t < _res_constr.datalen; t++) {
18644                 uint32_t _res_conv_19 = _res_vals[t];
18645                 LDKUpdateFulfillHTLC _res_conv_19_conv;
18646                 _res_conv_19_conv.inner = (void*)(_res_conv_19 & (~1));
18647                 _res_conv_19_conv.is_owned = (_res_conv_19 & 1) || (_res_conv_19 == 0);
18648                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_19_conv);
18649                 _res_constr.data[t] = _res_conv_19_conv;
18650         }
18651         FREE(_res);
18652         CVec_UpdateFulfillHTLCZ_free(_res_constr);
18653 }
18654
18655 void  __attribute__((export_name("TS_CVec_UpdateFailHTLCZ_free"))) TS_CVec_UpdateFailHTLCZ_free(uint32_tArray _res) {
18656         LDKCVec_UpdateFailHTLCZ _res_constr;
18657         _res_constr.datalen = _res->arr_len;
18658         if (_res_constr.datalen > 0)
18659                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
18660         else
18661                 _res_constr.data = NULL;
18662         uint32_t* _res_vals = _res->elems;
18663         for (size_t q = 0; q < _res_constr.datalen; q++) {
18664                 uint32_t _res_conv_16 = _res_vals[q];
18665                 LDKUpdateFailHTLC _res_conv_16_conv;
18666                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
18667                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
18668                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
18669                 _res_constr.data[q] = _res_conv_16_conv;
18670         }
18671         FREE(_res);
18672         CVec_UpdateFailHTLCZ_free(_res_constr);
18673 }
18674
18675 void  __attribute__((export_name("TS_CVec_UpdateFailMalformedHTLCZ_free"))) TS_CVec_UpdateFailMalformedHTLCZ_free(uint32_tArray _res) {
18676         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
18677         _res_constr.datalen = _res->arr_len;
18678         if (_res_constr.datalen > 0)
18679                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
18680         else
18681                 _res_constr.data = NULL;
18682         uint32_t* _res_vals = _res->elems;
18683         for (size_t z = 0; z < _res_constr.datalen; z++) {
18684                 uint32_t _res_conv_25 = _res_vals[z];
18685                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
18686                 _res_conv_25_conv.inner = (void*)(_res_conv_25 & (~1));
18687                 _res_conv_25_conv.is_owned = (_res_conv_25 & 1) || (_res_conv_25 == 0);
18688                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_25_conv);
18689                 _res_constr.data[z] = _res_conv_25_conv;
18690         }
18691         FREE(_res);
18692         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
18693 }
18694
18695 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_ok"))) TS_CResult_AcceptChannelDecodeErrorZ_ok(uint32_t o) {
18696         LDKAcceptChannel o_conv;
18697         o_conv.inner = (void*)(o & (~1));
18698         o_conv.is_owned = (o & 1) || (o == 0);
18699         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18700         o_conv = AcceptChannel_clone(&o_conv);
18701         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
18702         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
18703         return (uint32_t)ret_conv;
18704 }
18705
18706 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_err"))) TS_CResult_AcceptChannelDecodeErrorZ_err(uint32_t e) {
18707         LDKDecodeError e_conv;
18708         e_conv.inner = (void*)(e & (~1));
18709         e_conv.is_owned = (e & 1) || (e == 0);
18710         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18711         e_conv = DecodeError_clone(&e_conv);
18712         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
18713         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
18714         return (uint32_t)ret_conv;
18715 }
18716
18717 jboolean  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_is_ok"))) TS_CResult_AcceptChannelDecodeErrorZ_is_ok(uint32_t o) {
18718         LDKCResult_AcceptChannelDecodeErrorZ* o_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(o & ~1);
18719         jboolean ret_conv = CResult_AcceptChannelDecodeErrorZ_is_ok(o_conv);
18720         return ret_conv;
18721 }
18722
18723 void  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_free"))) TS_CResult_AcceptChannelDecodeErrorZ_free(uint32_t _res) {
18724         if ((_res & 1) != 0) return;
18725         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18726         CHECK_ACCESS(_res_ptr);
18727         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(_res_ptr);
18728         FREE((void*)_res);
18729         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
18730 }
18731
18732 static inline uintptr_t CResult_AcceptChannelDecodeErrorZ_clone_ptr(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR arg) {
18733         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
18734         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(arg);
18735         return (uint32_t)ret_conv;
18736 }
18737 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_clone_ptr"))) TS_CResult_AcceptChannelDecodeErrorZ_clone_ptr(uint32_t arg) {
18738         LDKCResult_AcceptChannelDecodeErrorZ* arg_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
18739         uint32_t ret_conv = CResult_AcceptChannelDecodeErrorZ_clone_ptr(arg_conv);
18740         return ret_conv;
18741 }
18742
18743 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_clone"))) TS_CResult_AcceptChannelDecodeErrorZ_clone(uint32_t orig) {
18744         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(orig & ~1);
18745         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
18746         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
18747         return (uint32_t)ret_conv;
18748 }
18749
18750 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_ok"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_ok(uint32_t o) {
18751         LDKAnnouncementSignatures o_conv;
18752         o_conv.inner = (void*)(o & (~1));
18753         o_conv.is_owned = (o & 1) || (o == 0);
18754         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18755         o_conv = AnnouncementSignatures_clone(&o_conv);
18756         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
18757         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
18758         return (uint32_t)ret_conv;
18759 }
18760
18761 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_err"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_err(uint32_t e) {
18762         LDKDecodeError e_conv;
18763         e_conv.inner = (void*)(e & (~1));
18764         e_conv.is_owned = (e & 1) || (e == 0);
18765         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18766         e_conv = DecodeError_clone(&e_conv);
18767         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
18768         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
18769         return (uint32_t)ret_conv;
18770 }
18771
18772 jboolean  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_is_ok"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(uint32_t o) {
18773         LDKCResult_AnnouncementSignaturesDecodeErrorZ* o_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(o & ~1);
18774         jboolean ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(o_conv);
18775         return ret_conv;
18776 }
18777
18778 void  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_free"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_free(uint32_t _res) {
18779         if ((_res & 1) != 0) return;
18780         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18781         CHECK_ACCESS(_res_ptr);
18782         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(_res_ptr);
18783         FREE((void*)_res);
18784         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
18785 }
18786
18787 static inline uintptr_t CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR arg) {
18788         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
18789         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(arg);
18790         return (uint32_t)ret_conv;
18791 }
18792 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(uint32_t arg) {
18793         LDKCResult_AnnouncementSignaturesDecodeErrorZ* arg_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
18794         uint32_t ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(arg_conv);
18795         return ret_conv;
18796 }
18797
18798 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone(uint32_t orig) {
18799         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(orig & ~1);
18800         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
18801         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
18802         return (uint32_t)ret_conv;
18803 }
18804
18805 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_ok"))) TS_CResult_ChannelReestablishDecodeErrorZ_ok(uint32_t o) {
18806         LDKChannelReestablish o_conv;
18807         o_conv.inner = (void*)(o & (~1));
18808         o_conv.is_owned = (o & 1) || (o == 0);
18809         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18810         o_conv = ChannelReestablish_clone(&o_conv);
18811         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
18812         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
18813         return (uint32_t)ret_conv;
18814 }
18815
18816 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_err"))) TS_CResult_ChannelReestablishDecodeErrorZ_err(uint32_t e) {
18817         LDKDecodeError e_conv;
18818         e_conv.inner = (void*)(e & (~1));
18819         e_conv.is_owned = (e & 1) || (e == 0);
18820         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18821         e_conv = DecodeError_clone(&e_conv);
18822         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
18823         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
18824         return (uint32_t)ret_conv;
18825 }
18826
18827 jboolean  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_is_ok"))) TS_CResult_ChannelReestablishDecodeErrorZ_is_ok(uint32_t o) {
18828         LDKCResult_ChannelReestablishDecodeErrorZ* o_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(o & ~1);
18829         jboolean ret_conv = CResult_ChannelReestablishDecodeErrorZ_is_ok(o_conv);
18830         return ret_conv;
18831 }
18832
18833 void  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_free"))) TS_CResult_ChannelReestablishDecodeErrorZ_free(uint32_t _res) {
18834         if ((_res & 1) != 0) return;
18835         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18836         CHECK_ACCESS(_res_ptr);
18837         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(_res_ptr);
18838         FREE((void*)_res);
18839         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
18840 }
18841
18842 static inline uintptr_t CResult_ChannelReestablishDecodeErrorZ_clone_ptr(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR arg) {
18843         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
18844         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(arg);
18845         return (uint32_t)ret_conv;
18846 }
18847 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelReestablishDecodeErrorZ_clone_ptr(uint32_t arg) {
18848         LDKCResult_ChannelReestablishDecodeErrorZ* arg_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
18849         uint32_t ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone_ptr(arg_conv);
18850         return ret_conv;
18851 }
18852
18853 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_clone"))) TS_CResult_ChannelReestablishDecodeErrorZ_clone(uint32_t orig) {
18854         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(orig & ~1);
18855         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
18856         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
18857         return (uint32_t)ret_conv;
18858 }
18859
18860 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_ok"))) TS_CResult_ClosingSignedDecodeErrorZ_ok(uint32_t o) {
18861         LDKClosingSigned o_conv;
18862         o_conv.inner = (void*)(o & (~1));
18863         o_conv.is_owned = (o & 1) || (o == 0);
18864         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18865         o_conv = ClosingSigned_clone(&o_conv);
18866         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
18867         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
18868         return (uint32_t)ret_conv;
18869 }
18870
18871 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_err"))) TS_CResult_ClosingSignedDecodeErrorZ_err(uint32_t e) {
18872         LDKDecodeError e_conv;
18873         e_conv.inner = (void*)(e & (~1));
18874         e_conv.is_owned = (e & 1) || (e == 0);
18875         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18876         e_conv = DecodeError_clone(&e_conv);
18877         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
18878         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
18879         return (uint32_t)ret_conv;
18880 }
18881
18882 jboolean  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_is_ok"))) TS_CResult_ClosingSignedDecodeErrorZ_is_ok(uint32_t o) {
18883         LDKCResult_ClosingSignedDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(o & ~1);
18884         jboolean ret_conv = CResult_ClosingSignedDecodeErrorZ_is_ok(o_conv);
18885         return ret_conv;
18886 }
18887
18888 void  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_free"))) TS_CResult_ClosingSignedDecodeErrorZ_free(uint32_t _res) {
18889         if ((_res & 1) != 0) return;
18890         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18891         CHECK_ACCESS(_res_ptr);
18892         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(_res_ptr);
18893         FREE((void*)_res);
18894         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
18895 }
18896
18897 static inline uintptr_t CResult_ClosingSignedDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR arg) {
18898         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
18899         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(arg);
18900         return (uint32_t)ret_conv;
18901 }
18902 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_clone_ptr"))) TS_CResult_ClosingSignedDecodeErrorZ_clone_ptr(uint32_t arg) {
18903         LDKCResult_ClosingSignedDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
18904         uint32_t ret_conv = CResult_ClosingSignedDecodeErrorZ_clone_ptr(arg_conv);
18905         return ret_conv;
18906 }
18907
18908 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_clone"))) TS_CResult_ClosingSignedDecodeErrorZ_clone(uint32_t orig) {
18909         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(orig & ~1);
18910         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
18911         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
18912         return (uint32_t)ret_conv;
18913 }
18914
18915 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_ok"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(uint32_t o) {
18916         LDKClosingSignedFeeRange o_conv;
18917         o_conv.inner = (void*)(o & (~1));
18918         o_conv.is_owned = (o & 1) || (o == 0);
18919         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18920         o_conv = ClosingSignedFeeRange_clone(&o_conv);
18921         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
18922         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(o_conv);
18923         return (uint32_t)ret_conv;
18924 }
18925
18926 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_err"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_err(uint32_t e) {
18927         LDKDecodeError e_conv;
18928         e_conv.inner = (void*)(e & (~1));
18929         e_conv.is_owned = (e & 1) || (e == 0);
18930         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18931         e_conv = DecodeError_clone(&e_conv);
18932         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
18933         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_err(e_conv);
18934         return (uint32_t)ret_conv;
18935 }
18936
18937 jboolean  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(uint32_t o) {
18938         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(o & ~1);
18939         jboolean ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(o_conv);
18940         return ret_conv;
18941 }
18942
18943 void  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_free"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_free(uint32_t _res) {
18944         if ((_res & 1) != 0) return;
18945         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18946         CHECK_ACCESS(_res_ptr);
18947         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(_res_ptr);
18948         FREE((void*)_res);
18949         CResult_ClosingSignedFeeRangeDecodeErrorZ_free(_res_conv);
18950 }
18951
18952 static inline uintptr_t CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR arg) {
18953         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
18954         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(arg);
18955         return (uint32_t)ret_conv;
18956 }
18957 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(uint32_t arg) {
18958         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(arg & ~1);
18959         uint32_t ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(arg_conv);
18960         return ret_conv;
18961 }
18962
18963 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(uint32_t orig) {
18964         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(orig & ~1);
18965         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
18966         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(orig_conv);
18967         return (uint32_t)ret_conv;
18968 }
18969
18970 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_ok"))) TS_CResult_CommitmentSignedDecodeErrorZ_ok(uint32_t o) {
18971         LDKCommitmentSigned o_conv;
18972         o_conv.inner = (void*)(o & (~1));
18973         o_conv.is_owned = (o & 1) || (o == 0);
18974         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18975         o_conv = CommitmentSigned_clone(&o_conv);
18976         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
18977         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
18978         return (uint32_t)ret_conv;
18979 }
18980
18981 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_err"))) TS_CResult_CommitmentSignedDecodeErrorZ_err(uint32_t e) {
18982         LDKDecodeError e_conv;
18983         e_conv.inner = (void*)(e & (~1));
18984         e_conv.is_owned = (e & 1) || (e == 0);
18985         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18986         e_conv = DecodeError_clone(&e_conv);
18987         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
18988         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
18989         return (uint32_t)ret_conv;
18990 }
18991
18992 jboolean  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_is_ok"))) TS_CResult_CommitmentSignedDecodeErrorZ_is_ok(uint32_t o) {
18993         LDKCResult_CommitmentSignedDecodeErrorZ* o_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(o & ~1);
18994         jboolean ret_conv = CResult_CommitmentSignedDecodeErrorZ_is_ok(o_conv);
18995         return ret_conv;
18996 }
18997
18998 void  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_free"))) TS_CResult_CommitmentSignedDecodeErrorZ_free(uint32_t _res) {
18999         if ((_res & 1) != 0) return;
19000         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19001         CHECK_ACCESS(_res_ptr);
19002         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(_res_ptr);
19003         FREE((void*)_res);
19004         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
19005 }
19006
19007 static inline uintptr_t CResult_CommitmentSignedDecodeErrorZ_clone_ptr(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR arg) {
19008         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
19009         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(arg);
19010         return (uint32_t)ret_conv;
19011 }
19012 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_clone_ptr"))) TS_CResult_CommitmentSignedDecodeErrorZ_clone_ptr(uint32_t arg) {
19013         LDKCResult_CommitmentSignedDecodeErrorZ* arg_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
19014         uint32_t ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone_ptr(arg_conv);
19015         return ret_conv;
19016 }
19017
19018 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_clone"))) TS_CResult_CommitmentSignedDecodeErrorZ_clone(uint32_t orig) {
19019         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(orig & ~1);
19020         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
19021         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
19022         return (uint32_t)ret_conv;
19023 }
19024
19025 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_ok"))) TS_CResult_FundingCreatedDecodeErrorZ_ok(uint32_t o) {
19026         LDKFundingCreated o_conv;
19027         o_conv.inner = (void*)(o & (~1));
19028         o_conv.is_owned = (o & 1) || (o == 0);
19029         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19030         o_conv = FundingCreated_clone(&o_conv);
19031         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
19032         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
19033         return (uint32_t)ret_conv;
19034 }
19035
19036 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_err"))) TS_CResult_FundingCreatedDecodeErrorZ_err(uint32_t e) {
19037         LDKDecodeError e_conv;
19038         e_conv.inner = (void*)(e & (~1));
19039         e_conv.is_owned = (e & 1) || (e == 0);
19040         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19041         e_conv = DecodeError_clone(&e_conv);
19042         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
19043         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
19044         return (uint32_t)ret_conv;
19045 }
19046
19047 jboolean  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_is_ok"))) TS_CResult_FundingCreatedDecodeErrorZ_is_ok(uint32_t o) {
19048         LDKCResult_FundingCreatedDecodeErrorZ* o_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(o & ~1);
19049         jboolean ret_conv = CResult_FundingCreatedDecodeErrorZ_is_ok(o_conv);
19050         return ret_conv;
19051 }
19052
19053 void  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_free"))) TS_CResult_FundingCreatedDecodeErrorZ_free(uint32_t _res) {
19054         if ((_res & 1) != 0) return;
19055         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19056         CHECK_ACCESS(_res_ptr);
19057         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(_res_ptr);
19058         FREE((void*)_res);
19059         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
19060 }
19061
19062 static inline uintptr_t CResult_FundingCreatedDecodeErrorZ_clone_ptr(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR arg) {
19063         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
19064         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(arg);
19065         return (uint32_t)ret_conv;
19066 }
19067 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_clone_ptr"))) TS_CResult_FundingCreatedDecodeErrorZ_clone_ptr(uint32_t arg) {
19068         LDKCResult_FundingCreatedDecodeErrorZ* arg_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
19069         uint32_t ret_conv = CResult_FundingCreatedDecodeErrorZ_clone_ptr(arg_conv);
19070         return ret_conv;
19071 }
19072
19073 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_clone"))) TS_CResult_FundingCreatedDecodeErrorZ_clone(uint32_t orig) {
19074         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(orig & ~1);
19075         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
19076         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
19077         return (uint32_t)ret_conv;
19078 }
19079
19080 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_ok"))) TS_CResult_FundingSignedDecodeErrorZ_ok(uint32_t o) {
19081         LDKFundingSigned o_conv;
19082         o_conv.inner = (void*)(o & (~1));
19083         o_conv.is_owned = (o & 1) || (o == 0);
19084         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19085         o_conv = FundingSigned_clone(&o_conv);
19086         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
19087         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
19088         return (uint32_t)ret_conv;
19089 }
19090
19091 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_err"))) TS_CResult_FundingSignedDecodeErrorZ_err(uint32_t e) {
19092         LDKDecodeError e_conv;
19093         e_conv.inner = (void*)(e & (~1));
19094         e_conv.is_owned = (e & 1) || (e == 0);
19095         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19096         e_conv = DecodeError_clone(&e_conv);
19097         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
19098         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
19099         return (uint32_t)ret_conv;
19100 }
19101
19102 jboolean  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_is_ok"))) TS_CResult_FundingSignedDecodeErrorZ_is_ok(uint32_t o) {
19103         LDKCResult_FundingSignedDecodeErrorZ* o_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(o & ~1);
19104         jboolean ret_conv = CResult_FundingSignedDecodeErrorZ_is_ok(o_conv);
19105         return ret_conv;
19106 }
19107
19108 void  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_free"))) TS_CResult_FundingSignedDecodeErrorZ_free(uint32_t _res) {
19109         if ((_res & 1) != 0) return;
19110         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19111         CHECK_ACCESS(_res_ptr);
19112         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(_res_ptr);
19113         FREE((void*)_res);
19114         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
19115 }
19116
19117 static inline uintptr_t CResult_FundingSignedDecodeErrorZ_clone_ptr(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR arg) {
19118         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
19119         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(arg);
19120         return (uint32_t)ret_conv;
19121 }
19122 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_clone_ptr"))) TS_CResult_FundingSignedDecodeErrorZ_clone_ptr(uint32_t arg) {
19123         LDKCResult_FundingSignedDecodeErrorZ* arg_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
19124         uint32_t ret_conv = CResult_FundingSignedDecodeErrorZ_clone_ptr(arg_conv);
19125         return ret_conv;
19126 }
19127
19128 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_clone"))) TS_CResult_FundingSignedDecodeErrorZ_clone(uint32_t orig) {
19129         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(orig & ~1);
19130         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
19131         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
19132         return (uint32_t)ret_conv;
19133 }
19134
19135 uint32_t  __attribute__((export_name("TS_CResult_ChannelReadyDecodeErrorZ_ok"))) TS_CResult_ChannelReadyDecodeErrorZ_ok(uint32_t o) {
19136         LDKChannelReady o_conv;
19137         o_conv.inner = (void*)(o & (~1));
19138         o_conv.is_owned = (o & 1) || (o == 0);
19139         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19140         o_conv = ChannelReady_clone(&o_conv);
19141         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
19142         *ret_conv = CResult_ChannelReadyDecodeErrorZ_ok(o_conv);
19143         return (uint32_t)ret_conv;
19144 }
19145
19146 uint32_t  __attribute__((export_name("TS_CResult_ChannelReadyDecodeErrorZ_err"))) TS_CResult_ChannelReadyDecodeErrorZ_err(uint32_t e) {
19147         LDKDecodeError e_conv;
19148         e_conv.inner = (void*)(e & (~1));
19149         e_conv.is_owned = (e & 1) || (e == 0);
19150         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19151         e_conv = DecodeError_clone(&e_conv);
19152         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
19153         *ret_conv = CResult_ChannelReadyDecodeErrorZ_err(e_conv);
19154         return (uint32_t)ret_conv;
19155 }
19156
19157 jboolean  __attribute__((export_name("TS_CResult_ChannelReadyDecodeErrorZ_is_ok"))) TS_CResult_ChannelReadyDecodeErrorZ_is_ok(uint32_t o) {
19158         LDKCResult_ChannelReadyDecodeErrorZ* o_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)(o & ~1);
19159         jboolean ret_conv = CResult_ChannelReadyDecodeErrorZ_is_ok(o_conv);
19160         return ret_conv;
19161 }
19162
19163 void  __attribute__((export_name("TS_CResult_ChannelReadyDecodeErrorZ_free"))) TS_CResult_ChannelReadyDecodeErrorZ_free(uint32_t _res) {
19164         if ((_res & 1) != 0) return;
19165         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19166         CHECK_ACCESS(_res_ptr);
19167         LDKCResult_ChannelReadyDecodeErrorZ _res_conv = *(LDKCResult_ChannelReadyDecodeErrorZ*)(_res_ptr);
19168         FREE((void*)_res);
19169         CResult_ChannelReadyDecodeErrorZ_free(_res_conv);
19170 }
19171
19172 static inline uintptr_t CResult_ChannelReadyDecodeErrorZ_clone_ptr(LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR arg) {
19173         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
19174         *ret_conv = CResult_ChannelReadyDecodeErrorZ_clone(arg);
19175         return (uint32_t)ret_conv;
19176 }
19177 uint32_t  __attribute__((export_name("TS_CResult_ChannelReadyDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelReadyDecodeErrorZ_clone_ptr(uint32_t arg) {
19178         LDKCResult_ChannelReadyDecodeErrorZ* arg_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)(arg & ~1);
19179         uint32_t ret_conv = CResult_ChannelReadyDecodeErrorZ_clone_ptr(arg_conv);
19180         return ret_conv;
19181 }
19182
19183 uint32_t  __attribute__((export_name("TS_CResult_ChannelReadyDecodeErrorZ_clone"))) TS_CResult_ChannelReadyDecodeErrorZ_clone(uint32_t orig) {
19184         LDKCResult_ChannelReadyDecodeErrorZ* orig_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)(orig & ~1);
19185         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
19186         *ret_conv = CResult_ChannelReadyDecodeErrorZ_clone(orig_conv);
19187         return (uint32_t)ret_conv;
19188 }
19189
19190 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_ok"))) TS_CResult_InitDecodeErrorZ_ok(uint32_t o) {
19191         LDKInit o_conv;
19192         o_conv.inner = (void*)(o & (~1));
19193         o_conv.is_owned = (o & 1) || (o == 0);
19194         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19195         o_conv = Init_clone(&o_conv);
19196         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
19197         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
19198         return (uint32_t)ret_conv;
19199 }
19200
19201 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_err"))) TS_CResult_InitDecodeErrorZ_err(uint32_t e) {
19202         LDKDecodeError e_conv;
19203         e_conv.inner = (void*)(e & (~1));
19204         e_conv.is_owned = (e & 1) || (e == 0);
19205         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19206         e_conv = DecodeError_clone(&e_conv);
19207         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
19208         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
19209         return (uint32_t)ret_conv;
19210 }
19211
19212 jboolean  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_is_ok"))) TS_CResult_InitDecodeErrorZ_is_ok(uint32_t o) {
19213         LDKCResult_InitDecodeErrorZ* o_conv = (LDKCResult_InitDecodeErrorZ*)(o & ~1);
19214         jboolean ret_conv = CResult_InitDecodeErrorZ_is_ok(o_conv);
19215         return ret_conv;
19216 }
19217
19218 void  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_free"))) TS_CResult_InitDecodeErrorZ_free(uint32_t _res) {
19219         if ((_res & 1) != 0) return;
19220         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19221         CHECK_ACCESS(_res_ptr);
19222         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(_res_ptr);
19223         FREE((void*)_res);
19224         CResult_InitDecodeErrorZ_free(_res_conv);
19225 }
19226
19227 static inline uintptr_t CResult_InitDecodeErrorZ_clone_ptr(LDKCResult_InitDecodeErrorZ *NONNULL_PTR arg) {
19228         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
19229         *ret_conv = CResult_InitDecodeErrorZ_clone(arg);
19230         return (uint32_t)ret_conv;
19231 }
19232 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_clone_ptr"))) TS_CResult_InitDecodeErrorZ_clone_ptr(uint32_t arg) {
19233         LDKCResult_InitDecodeErrorZ* arg_conv = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
19234         uint32_t ret_conv = CResult_InitDecodeErrorZ_clone_ptr(arg_conv);
19235         return ret_conv;
19236 }
19237
19238 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_clone"))) TS_CResult_InitDecodeErrorZ_clone(uint32_t orig) {
19239         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)(orig & ~1);
19240         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
19241         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
19242         return (uint32_t)ret_conv;
19243 }
19244
19245 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_ok"))) TS_CResult_OpenChannelDecodeErrorZ_ok(uint32_t o) {
19246         LDKOpenChannel o_conv;
19247         o_conv.inner = (void*)(o & (~1));
19248         o_conv.is_owned = (o & 1) || (o == 0);
19249         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19250         o_conv = OpenChannel_clone(&o_conv);
19251         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
19252         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
19253         return (uint32_t)ret_conv;
19254 }
19255
19256 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_err"))) TS_CResult_OpenChannelDecodeErrorZ_err(uint32_t e) {
19257         LDKDecodeError e_conv;
19258         e_conv.inner = (void*)(e & (~1));
19259         e_conv.is_owned = (e & 1) || (e == 0);
19260         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19261         e_conv = DecodeError_clone(&e_conv);
19262         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
19263         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
19264         return (uint32_t)ret_conv;
19265 }
19266
19267 jboolean  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_is_ok"))) TS_CResult_OpenChannelDecodeErrorZ_is_ok(uint32_t o) {
19268         LDKCResult_OpenChannelDecodeErrorZ* o_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(o & ~1);
19269         jboolean ret_conv = CResult_OpenChannelDecodeErrorZ_is_ok(o_conv);
19270         return ret_conv;
19271 }
19272
19273 void  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_free"))) TS_CResult_OpenChannelDecodeErrorZ_free(uint32_t _res) {
19274         if ((_res & 1) != 0) return;
19275         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19276         CHECK_ACCESS(_res_ptr);
19277         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(_res_ptr);
19278         FREE((void*)_res);
19279         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
19280 }
19281
19282 static inline uintptr_t CResult_OpenChannelDecodeErrorZ_clone_ptr(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR arg) {
19283         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
19284         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(arg);
19285         return (uint32_t)ret_conv;
19286 }
19287 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_clone_ptr"))) TS_CResult_OpenChannelDecodeErrorZ_clone_ptr(uint32_t arg) {
19288         LDKCResult_OpenChannelDecodeErrorZ* arg_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
19289         uint32_t ret_conv = CResult_OpenChannelDecodeErrorZ_clone_ptr(arg_conv);
19290         return ret_conv;
19291 }
19292
19293 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_clone"))) TS_CResult_OpenChannelDecodeErrorZ_clone(uint32_t orig) {
19294         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(orig & ~1);
19295         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
19296         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
19297         return (uint32_t)ret_conv;
19298 }
19299
19300 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_ok"))) TS_CResult_RevokeAndACKDecodeErrorZ_ok(uint32_t o) {
19301         LDKRevokeAndACK o_conv;
19302         o_conv.inner = (void*)(o & (~1));
19303         o_conv.is_owned = (o & 1) || (o == 0);
19304         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19305         o_conv = RevokeAndACK_clone(&o_conv);
19306         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
19307         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
19308         return (uint32_t)ret_conv;
19309 }
19310
19311 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_err"))) TS_CResult_RevokeAndACKDecodeErrorZ_err(uint32_t e) {
19312         LDKDecodeError e_conv;
19313         e_conv.inner = (void*)(e & (~1));
19314         e_conv.is_owned = (e & 1) || (e == 0);
19315         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19316         e_conv = DecodeError_clone(&e_conv);
19317         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
19318         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
19319         return (uint32_t)ret_conv;
19320 }
19321
19322 jboolean  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_is_ok"))) TS_CResult_RevokeAndACKDecodeErrorZ_is_ok(uint32_t o) {
19323         LDKCResult_RevokeAndACKDecodeErrorZ* o_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(o & ~1);
19324         jboolean ret_conv = CResult_RevokeAndACKDecodeErrorZ_is_ok(o_conv);
19325         return ret_conv;
19326 }
19327
19328 void  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_free"))) TS_CResult_RevokeAndACKDecodeErrorZ_free(uint32_t _res) {
19329         if ((_res & 1) != 0) return;
19330         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19331         CHECK_ACCESS(_res_ptr);
19332         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(_res_ptr);
19333         FREE((void*)_res);
19334         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
19335 }
19336
19337 static inline uintptr_t CResult_RevokeAndACKDecodeErrorZ_clone_ptr(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR arg) {
19338         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
19339         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(arg);
19340         return (uint32_t)ret_conv;
19341 }
19342 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_clone_ptr"))) TS_CResult_RevokeAndACKDecodeErrorZ_clone_ptr(uint32_t arg) {
19343         LDKCResult_RevokeAndACKDecodeErrorZ* arg_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
19344         uint32_t ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone_ptr(arg_conv);
19345         return ret_conv;
19346 }
19347
19348 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_clone"))) TS_CResult_RevokeAndACKDecodeErrorZ_clone(uint32_t orig) {
19349         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(orig & ~1);
19350         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
19351         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
19352         return (uint32_t)ret_conv;
19353 }
19354
19355 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_ok"))) TS_CResult_ShutdownDecodeErrorZ_ok(uint32_t o) {
19356         LDKShutdown o_conv;
19357         o_conv.inner = (void*)(o & (~1));
19358         o_conv.is_owned = (o & 1) || (o == 0);
19359         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19360         o_conv = Shutdown_clone(&o_conv);
19361         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
19362         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
19363         return (uint32_t)ret_conv;
19364 }
19365
19366 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_err"))) TS_CResult_ShutdownDecodeErrorZ_err(uint32_t e) {
19367         LDKDecodeError e_conv;
19368         e_conv.inner = (void*)(e & (~1));
19369         e_conv.is_owned = (e & 1) || (e == 0);
19370         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19371         e_conv = DecodeError_clone(&e_conv);
19372         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
19373         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
19374         return (uint32_t)ret_conv;
19375 }
19376
19377 jboolean  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_is_ok"))) TS_CResult_ShutdownDecodeErrorZ_is_ok(uint32_t o) {
19378         LDKCResult_ShutdownDecodeErrorZ* o_conv = (LDKCResult_ShutdownDecodeErrorZ*)(o & ~1);
19379         jboolean ret_conv = CResult_ShutdownDecodeErrorZ_is_ok(o_conv);
19380         return ret_conv;
19381 }
19382
19383 void  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_free"))) TS_CResult_ShutdownDecodeErrorZ_free(uint32_t _res) {
19384         if ((_res & 1) != 0) return;
19385         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19386         CHECK_ACCESS(_res_ptr);
19387         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(_res_ptr);
19388         FREE((void*)_res);
19389         CResult_ShutdownDecodeErrorZ_free(_res_conv);
19390 }
19391
19392 static inline uintptr_t CResult_ShutdownDecodeErrorZ_clone_ptr(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR arg) {
19393         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
19394         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(arg);
19395         return (uint32_t)ret_conv;
19396 }
19397 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_clone_ptr"))) TS_CResult_ShutdownDecodeErrorZ_clone_ptr(uint32_t arg) {
19398         LDKCResult_ShutdownDecodeErrorZ* arg_conv = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
19399         uint32_t ret_conv = CResult_ShutdownDecodeErrorZ_clone_ptr(arg_conv);
19400         return ret_conv;
19401 }
19402
19403 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_clone"))) TS_CResult_ShutdownDecodeErrorZ_clone(uint32_t orig) {
19404         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)(orig & ~1);
19405         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
19406         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
19407         return (uint32_t)ret_conv;
19408 }
19409
19410 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_ok"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_ok(uint32_t o) {
19411         LDKUpdateFailHTLC o_conv;
19412         o_conv.inner = (void*)(o & (~1));
19413         o_conv.is_owned = (o & 1) || (o == 0);
19414         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19415         o_conv = UpdateFailHTLC_clone(&o_conv);
19416         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
19417         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
19418         return (uint32_t)ret_conv;
19419 }
19420
19421 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_err"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_err(uint32_t e) {
19422         LDKDecodeError e_conv;
19423         e_conv.inner = (void*)(e & (~1));
19424         e_conv.is_owned = (e & 1) || (e == 0);
19425         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19426         e_conv = DecodeError_clone(&e_conv);
19427         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
19428         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
19429         return (uint32_t)ret_conv;
19430 }
19431
19432 jboolean  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_is_ok"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_is_ok(uint32_t o) {
19433         LDKCResult_UpdateFailHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(o & ~1);
19434         jboolean ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_is_ok(o_conv);
19435         return ret_conv;
19436 }
19437
19438 void  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_free"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_free(uint32_t _res) {
19439         if ((_res & 1) != 0) return;
19440         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19441         CHECK_ACCESS(_res_ptr);
19442         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(_res_ptr);
19443         FREE((void*)_res);
19444         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
19445 }
19446
19447 static inline uintptr_t CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR arg) {
19448         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
19449         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(arg);
19450         return (uint32_t)ret_conv;
19451 }
19452 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(uint32_t arg) {
19453         LDKCResult_UpdateFailHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
19454         uint32_t ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(arg_conv);
19455         return ret_conv;
19456 }
19457
19458 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_clone"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_clone(uint32_t orig) {
19459         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(orig & ~1);
19460         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
19461         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
19462         return (uint32_t)ret_conv;
19463 }
19464
19465 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(uint32_t o) {
19466         LDKUpdateFailMalformedHTLC o_conv;
19467         o_conv.inner = (void*)(o & (~1));
19468         o_conv.is_owned = (o & 1) || (o == 0);
19469         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19470         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
19471         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
19472         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
19473         return (uint32_t)ret_conv;
19474 }
19475
19476 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_err"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(uint32_t e) {
19477         LDKDecodeError e_conv;
19478         e_conv.inner = (void*)(e & (~1));
19479         e_conv.is_owned = (e & 1) || (e == 0);
19480         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19481         e_conv = DecodeError_clone(&e_conv);
19482         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
19483         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
19484         return (uint32_t)ret_conv;
19485 }
19486
19487 jboolean  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(uint32_t o) {
19488         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(o & ~1);
19489         jboolean ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(o_conv);
19490         return ret_conv;
19491 }
19492
19493 void  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_free"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(uint32_t _res) {
19494         if ((_res & 1) != 0) return;
19495         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19496         CHECK_ACCESS(_res_ptr);
19497         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(_res_ptr);
19498         FREE((void*)_res);
19499         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
19500 }
19501
19502 static inline uintptr_t CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR arg) {
19503         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
19504         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(arg);
19505         return (uint32_t)ret_conv;
19506 }
19507 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(uint32_t arg) {
19508         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
19509         uint32_t ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(arg_conv);
19510         return ret_conv;
19511 }
19512
19513 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(uint32_t orig) {
19514         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(orig & ~1);
19515         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
19516         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
19517         return (uint32_t)ret_conv;
19518 }
19519
19520 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_ok"))) TS_CResult_UpdateFeeDecodeErrorZ_ok(uint32_t o) {
19521         LDKUpdateFee o_conv;
19522         o_conv.inner = (void*)(o & (~1));
19523         o_conv.is_owned = (o & 1) || (o == 0);
19524         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19525         o_conv = UpdateFee_clone(&o_conv);
19526         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
19527         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
19528         return (uint32_t)ret_conv;
19529 }
19530
19531 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_err"))) TS_CResult_UpdateFeeDecodeErrorZ_err(uint32_t e) {
19532         LDKDecodeError e_conv;
19533         e_conv.inner = (void*)(e & (~1));
19534         e_conv.is_owned = (e & 1) || (e == 0);
19535         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19536         e_conv = DecodeError_clone(&e_conv);
19537         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
19538         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
19539         return (uint32_t)ret_conv;
19540 }
19541
19542 jboolean  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_is_ok"))) TS_CResult_UpdateFeeDecodeErrorZ_is_ok(uint32_t o) {
19543         LDKCResult_UpdateFeeDecodeErrorZ* o_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(o & ~1);
19544         jboolean ret_conv = CResult_UpdateFeeDecodeErrorZ_is_ok(o_conv);
19545         return ret_conv;
19546 }
19547
19548 void  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_free"))) TS_CResult_UpdateFeeDecodeErrorZ_free(uint32_t _res) {
19549         if ((_res & 1) != 0) return;
19550         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19551         CHECK_ACCESS(_res_ptr);
19552         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(_res_ptr);
19553         FREE((void*)_res);
19554         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
19555 }
19556
19557 static inline uintptr_t CResult_UpdateFeeDecodeErrorZ_clone_ptr(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR arg) {
19558         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
19559         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(arg);
19560         return (uint32_t)ret_conv;
19561 }
19562 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateFeeDecodeErrorZ_clone_ptr(uint32_t arg) {
19563         LDKCResult_UpdateFeeDecodeErrorZ* arg_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
19564         uint32_t ret_conv = CResult_UpdateFeeDecodeErrorZ_clone_ptr(arg_conv);
19565         return ret_conv;
19566 }
19567
19568 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_clone"))) TS_CResult_UpdateFeeDecodeErrorZ_clone(uint32_t orig) {
19569         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(orig & ~1);
19570         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
19571         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
19572         return (uint32_t)ret_conv;
19573 }
19574
19575 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_ok"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_ok(uint32_t o) {
19576         LDKUpdateFulfillHTLC o_conv;
19577         o_conv.inner = (void*)(o & (~1));
19578         o_conv.is_owned = (o & 1) || (o == 0);
19579         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19580         o_conv = UpdateFulfillHTLC_clone(&o_conv);
19581         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
19582         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
19583         return (uint32_t)ret_conv;
19584 }
19585
19586 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_err"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_err(uint32_t e) {
19587         LDKDecodeError e_conv;
19588         e_conv.inner = (void*)(e & (~1));
19589         e_conv.is_owned = (e & 1) || (e == 0);
19590         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19591         e_conv = DecodeError_clone(&e_conv);
19592         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
19593         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
19594         return (uint32_t)ret_conv;
19595 }
19596
19597 jboolean  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(uint32_t o) {
19598         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(o & ~1);
19599         jboolean ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(o_conv);
19600         return ret_conv;
19601 }
19602
19603 void  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_free"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_free(uint32_t _res) {
19604         if ((_res & 1) != 0) return;
19605         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19606         CHECK_ACCESS(_res_ptr);
19607         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(_res_ptr);
19608         FREE((void*)_res);
19609         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
19610 }
19611
19612 static inline uintptr_t CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR arg) {
19613         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
19614         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(arg);
19615         return (uint32_t)ret_conv;
19616 }
19617 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(uint32_t arg) {
19618         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
19619         uint32_t ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(arg_conv);
19620         return ret_conv;
19621 }
19622
19623 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone(uint32_t orig) {
19624         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(orig & ~1);
19625         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
19626         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
19627         return (uint32_t)ret_conv;
19628 }
19629
19630 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_ok"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_ok(uint32_t o) {
19631         LDKUpdateAddHTLC o_conv;
19632         o_conv.inner = (void*)(o & (~1));
19633         o_conv.is_owned = (o & 1) || (o == 0);
19634         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19635         o_conv = UpdateAddHTLC_clone(&o_conv);
19636         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
19637         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
19638         return (uint32_t)ret_conv;
19639 }
19640
19641 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_err"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_err(uint32_t e) {
19642         LDKDecodeError e_conv;
19643         e_conv.inner = (void*)(e & (~1));
19644         e_conv.is_owned = (e & 1) || (e == 0);
19645         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19646         e_conv = DecodeError_clone(&e_conv);
19647         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
19648         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
19649         return (uint32_t)ret_conv;
19650 }
19651
19652 jboolean  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_is_ok"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_is_ok(uint32_t o) {
19653         LDKCResult_UpdateAddHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(o & ~1);
19654         jboolean ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_is_ok(o_conv);
19655         return ret_conv;
19656 }
19657
19658 void  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_free"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_free(uint32_t _res) {
19659         if ((_res & 1) != 0) return;
19660         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19661         CHECK_ACCESS(_res_ptr);
19662         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(_res_ptr);
19663         FREE((void*)_res);
19664         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
19665 }
19666
19667 static inline uintptr_t CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR arg) {
19668         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
19669         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(arg);
19670         return (uint32_t)ret_conv;
19671 }
19672 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(uint32_t arg) {
19673         LDKCResult_UpdateAddHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
19674         uint32_t ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(arg_conv);
19675         return ret_conv;
19676 }
19677
19678 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_clone"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_clone(uint32_t orig) {
19679         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(orig & ~1);
19680         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
19681         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
19682         return (uint32_t)ret_conv;
19683 }
19684
19685 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_ok"))) TS_CResult_PingDecodeErrorZ_ok(uint32_t o) {
19686         LDKPing o_conv;
19687         o_conv.inner = (void*)(o & (~1));
19688         o_conv.is_owned = (o & 1) || (o == 0);
19689         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19690         o_conv = Ping_clone(&o_conv);
19691         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
19692         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
19693         return (uint32_t)ret_conv;
19694 }
19695
19696 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_err"))) TS_CResult_PingDecodeErrorZ_err(uint32_t e) {
19697         LDKDecodeError e_conv;
19698         e_conv.inner = (void*)(e & (~1));
19699         e_conv.is_owned = (e & 1) || (e == 0);
19700         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19701         e_conv = DecodeError_clone(&e_conv);
19702         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
19703         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
19704         return (uint32_t)ret_conv;
19705 }
19706
19707 jboolean  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_is_ok"))) TS_CResult_PingDecodeErrorZ_is_ok(uint32_t o) {
19708         LDKCResult_PingDecodeErrorZ* o_conv = (LDKCResult_PingDecodeErrorZ*)(o & ~1);
19709         jboolean ret_conv = CResult_PingDecodeErrorZ_is_ok(o_conv);
19710         return ret_conv;
19711 }
19712
19713 void  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_free"))) TS_CResult_PingDecodeErrorZ_free(uint32_t _res) {
19714         if ((_res & 1) != 0) return;
19715         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19716         CHECK_ACCESS(_res_ptr);
19717         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(_res_ptr);
19718         FREE((void*)_res);
19719         CResult_PingDecodeErrorZ_free(_res_conv);
19720 }
19721
19722 static inline uintptr_t CResult_PingDecodeErrorZ_clone_ptr(LDKCResult_PingDecodeErrorZ *NONNULL_PTR arg) {
19723         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
19724         *ret_conv = CResult_PingDecodeErrorZ_clone(arg);
19725         return (uint32_t)ret_conv;
19726 }
19727 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_clone_ptr"))) TS_CResult_PingDecodeErrorZ_clone_ptr(uint32_t arg) {
19728         LDKCResult_PingDecodeErrorZ* arg_conv = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
19729         uint32_t ret_conv = CResult_PingDecodeErrorZ_clone_ptr(arg_conv);
19730         return ret_conv;
19731 }
19732
19733 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_clone"))) TS_CResult_PingDecodeErrorZ_clone(uint32_t orig) {
19734         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)(orig & ~1);
19735         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
19736         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
19737         return (uint32_t)ret_conv;
19738 }
19739
19740 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_ok"))) TS_CResult_PongDecodeErrorZ_ok(uint32_t o) {
19741         LDKPong o_conv;
19742         o_conv.inner = (void*)(o & (~1));
19743         o_conv.is_owned = (o & 1) || (o == 0);
19744         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19745         o_conv = Pong_clone(&o_conv);
19746         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
19747         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
19748         return (uint32_t)ret_conv;
19749 }
19750
19751 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_err"))) TS_CResult_PongDecodeErrorZ_err(uint32_t e) {
19752         LDKDecodeError e_conv;
19753         e_conv.inner = (void*)(e & (~1));
19754         e_conv.is_owned = (e & 1) || (e == 0);
19755         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19756         e_conv = DecodeError_clone(&e_conv);
19757         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
19758         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
19759         return (uint32_t)ret_conv;
19760 }
19761
19762 jboolean  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_is_ok"))) TS_CResult_PongDecodeErrorZ_is_ok(uint32_t o) {
19763         LDKCResult_PongDecodeErrorZ* o_conv = (LDKCResult_PongDecodeErrorZ*)(o & ~1);
19764         jboolean ret_conv = CResult_PongDecodeErrorZ_is_ok(o_conv);
19765         return ret_conv;
19766 }
19767
19768 void  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_free"))) TS_CResult_PongDecodeErrorZ_free(uint32_t _res) {
19769         if ((_res & 1) != 0) return;
19770         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19771         CHECK_ACCESS(_res_ptr);
19772         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(_res_ptr);
19773         FREE((void*)_res);
19774         CResult_PongDecodeErrorZ_free(_res_conv);
19775 }
19776
19777 static inline uintptr_t CResult_PongDecodeErrorZ_clone_ptr(LDKCResult_PongDecodeErrorZ *NONNULL_PTR arg) {
19778         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
19779         *ret_conv = CResult_PongDecodeErrorZ_clone(arg);
19780         return (uint32_t)ret_conv;
19781 }
19782 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_clone_ptr"))) TS_CResult_PongDecodeErrorZ_clone_ptr(uint32_t arg) {
19783         LDKCResult_PongDecodeErrorZ* arg_conv = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
19784         uint32_t ret_conv = CResult_PongDecodeErrorZ_clone_ptr(arg_conv);
19785         return ret_conv;
19786 }
19787
19788 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_clone"))) TS_CResult_PongDecodeErrorZ_clone(uint32_t orig) {
19789         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)(orig & ~1);
19790         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
19791         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
19792         return (uint32_t)ret_conv;
19793 }
19794
19795 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(uint32_t o) {
19796         LDKUnsignedChannelAnnouncement o_conv;
19797         o_conv.inner = (void*)(o & (~1));
19798         o_conv.is_owned = (o & 1) || (o == 0);
19799         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19800         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
19801         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
19802         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
19803         return (uint32_t)ret_conv;
19804 }
19805
19806 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_err"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(uint32_t e) {
19807         LDKDecodeError e_conv;
19808         e_conv.inner = (void*)(e & (~1));
19809         e_conv.is_owned = (e & 1) || (e == 0);
19810         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19811         e_conv = DecodeError_clone(&e_conv);
19812         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
19813         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
19814         return (uint32_t)ret_conv;
19815 }
19816
19817 jboolean  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(uint32_t o) {
19818         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(o & ~1);
19819         jboolean ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
19820         return ret_conv;
19821 }
19822
19823 void  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_free"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(uint32_t _res) {
19824         if ((_res & 1) != 0) return;
19825         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19826         CHECK_ACCESS(_res_ptr);
19827         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(_res_ptr);
19828         FREE((void*)_res);
19829         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
19830 }
19831
19832 static inline uintptr_t CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
19833         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
19834         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(arg);
19835         return (uint32_t)ret_conv;
19836 }
19837 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(uint32_t arg) {
19838         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
19839         uint32_t ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
19840         return ret_conv;
19841 }
19842
19843 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(uint32_t orig) {
19844         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(orig & ~1);
19845         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
19846         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
19847         return (uint32_t)ret_conv;
19848 }
19849
19850 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_ok"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_ok(uint32_t o) {
19851         LDKChannelAnnouncement o_conv;
19852         o_conv.inner = (void*)(o & (~1));
19853         o_conv.is_owned = (o & 1) || (o == 0);
19854         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19855         o_conv = ChannelAnnouncement_clone(&o_conv);
19856         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
19857         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
19858         return (uint32_t)ret_conv;
19859 }
19860
19861 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_err"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_err(uint32_t e) {
19862         LDKDecodeError e_conv;
19863         e_conv.inner = (void*)(e & (~1));
19864         e_conv.is_owned = (e & 1) || (e == 0);
19865         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19866         e_conv = DecodeError_clone(&e_conv);
19867         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
19868         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
19869         return (uint32_t)ret_conv;
19870 }
19871
19872 jboolean  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_is_ok"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_is_ok(uint32_t o) {
19873         LDKCResult_ChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(o & ~1);
19874         jboolean ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
19875         return ret_conv;
19876 }
19877
19878 void  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_free"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_free(uint32_t _res) {
19879         if ((_res & 1) != 0) return;
19880         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19881         CHECK_ACCESS(_res_ptr);
19882         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(_res_ptr);
19883         FREE((void*)_res);
19884         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
19885 }
19886
19887 static inline uintptr_t CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
19888         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
19889         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(arg);
19890         return (uint32_t)ret_conv;
19891 }
19892 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(uint32_t arg) {
19893         LDKCResult_ChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
19894         uint32_t ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
19895         return ret_conv;
19896 }
19897
19898 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_clone"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_clone(uint32_t orig) {
19899         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(orig & ~1);
19900         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
19901         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
19902         return (uint32_t)ret_conv;
19903 }
19904
19905 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_ok"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_ok(uint32_t o) {
19906         LDKUnsignedChannelUpdate o_conv;
19907         o_conv.inner = (void*)(o & (~1));
19908         o_conv.is_owned = (o & 1) || (o == 0);
19909         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19910         o_conv = UnsignedChannelUpdate_clone(&o_conv);
19911         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
19912         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
19913         return (uint32_t)ret_conv;
19914 }
19915
19916 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_err"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_err(uint32_t e) {
19917         LDKDecodeError e_conv;
19918         e_conv.inner = (void*)(e & (~1));
19919         e_conv.is_owned = (e & 1) || (e == 0);
19920         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19921         e_conv = DecodeError_clone(&e_conv);
19922         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
19923         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
19924         return (uint32_t)ret_conv;
19925 }
19926
19927 jboolean  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(uint32_t o) {
19928         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(o & ~1);
19929         jboolean ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(o_conv);
19930         return ret_conv;
19931 }
19932
19933 void  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_free"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_free(uint32_t _res) {
19934         if ((_res & 1) != 0) return;
19935         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19936         CHECK_ACCESS(_res_ptr);
19937         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(_res_ptr);
19938         FREE((void*)_res);
19939         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
19940 }
19941
19942 static inline uintptr_t CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
19943         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
19944         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(arg);
19945         return (uint32_t)ret_conv;
19946 }
19947 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(uint32_t arg) {
19948         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
19949         uint32_t ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
19950         return ret_conv;
19951 }
19952
19953 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone(uint32_t orig) {
19954         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(orig & ~1);
19955         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
19956         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
19957         return (uint32_t)ret_conv;
19958 }
19959
19960 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_ok"))) TS_CResult_ChannelUpdateDecodeErrorZ_ok(uint32_t o) {
19961         LDKChannelUpdate o_conv;
19962         o_conv.inner = (void*)(o & (~1));
19963         o_conv.is_owned = (o & 1) || (o == 0);
19964         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19965         o_conv = ChannelUpdate_clone(&o_conv);
19966         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
19967         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
19968         return (uint32_t)ret_conv;
19969 }
19970
19971 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_err"))) TS_CResult_ChannelUpdateDecodeErrorZ_err(uint32_t e) {
19972         LDKDecodeError e_conv;
19973         e_conv.inner = (void*)(e & (~1));
19974         e_conv.is_owned = (e & 1) || (e == 0);
19975         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19976         e_conv = DecodeError_clone(&e_conv);
19977         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
19978         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
19979         return (uint32_t)ret_conv;
19980 }
19981
19982 jboolean  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_is_ok"))) TS_CResult_ChannelUpdateDecodeErrorZ_is_ok(uint32_t o) {
19983         LDKCResult_ChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(o & ~1);
19984         jboolean ret_conv = CResult_ChannelUpdateDecodeErrorZ_is_ok(o_conv);
19985         return ret_conv;
19986 }
19987
19988 void  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_free"))) TS_CResult_ChannelUpdateDecodeErrorZ_free(uint32_t _res) {
19989         if ((_res & 1) != 0) return;
19990         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19991         CHECK_ACCESS(_res_ptr);
19992         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(_res_ptr);
19993         FREE((void*)_res);
19994         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
19995 }
19996
19997 static inline uintptr_t CResult_ChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
19998         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
19999         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(arg);
20000         return (uint32_t)ret_conv;
20001 }
20002 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelUpdateDecodeErrorZ_clone_ptr(uint32_t arg) {
20003         LDKCResult_ChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
20004         uint32_t ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
20005         return ret_conv;
20006 }
20007
20008 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_clone"))) TS_CResult_ChannelUpdateDecodeErrorZ_clone(uint32_t orig) {
20009         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(orig & ~1);
20010         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
20011         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
20012         return (uint32_t)ret_conv;
20013 }
20014
20015 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_ok"))) TS_CResult_ErrorMessageDecodeErrorZ_ok(uint32_t o) {
20016         LDKErrorMessage o_conv;
20017         o_conv.inner = (void*)(o & (~1));
20018         o_conv.is_owned = (o & 1) || (o == 0);
20019         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20020         o_conv = ErrorMessage_clone(&o_conv);
20021         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
20022         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
20023         return (uint32_t)ret_conv;
20024 }
20025
20026 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_err"))) TS_CResult_ErrorMessageDecodeErrorZ_err(uint32_t e) {
20027         LDKDecodeError e_conv;
20028         e_conv.inner = (void*)(e & (~1));
20029         e_conv.is_owned = (e & 1) || (e == 0);
20030         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20031         e_conv = DecodeError_clone(&e_conv);
20032         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
20033         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
20034         return (uint32_t)ret_conv;
20035 }
20036
20037 jboolean  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_is_ok"))) TS_CResult_ErrorMessageDecodeErrorZ_is_ok(uint32_t o) {
20038         LDKCResult_ErrorMessageDecodeErrorZ* o_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(o & ~1);
20039         jboolean ret_conv = CResult_ErrorMessageDecodeErrorZ_is_ok(o_conv);
20040         return ret_conv;
20041 }
20042
20043 void  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_free"))) TS_CResult_ErrorMessageDecodeErrorZ_free(uint32_t _res) {
20044         if ((_res & 1) != 0) return;
20045         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20046         CHECK_ACCESS(_res_ptr);
20047         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(_res_ptr);
20048         FREE((void*)_res);
20049         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
20050 }
20051
20052 static inline uintptr_t CResult_ErrorMessageDecodeErrorZ_clone_ptr(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR arg) {
20053         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
20054         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(arg);
20055         return (uint32_t)ret_conv;
20056 }
20057 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_clone_ptr"))) TS_CResult_ErrorMessageDecodeErrorZ_clone_ptr(uint32_t arg) {
20058         LDKCResult_ErrorMessageDecodeErrorZ* arg_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
20059         uint32_t ret_conv = CResult_ErrorMessageDecodeErrorZ_clone_ptr(arg_conv);
20060         return ret_conv;
20061 }
20062
20063 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_clone"))) TS_CResult_ErrorMessageDecodeErrorZ_clone(uint32_t orig) {
20064         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(orig & ~1);
20065         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
20066         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
20067         return (uint32_t)ret_conv;
20068 }
20069
20070 uint32_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_ok"))) TS_CResult_WarningMessageDecodeErrorZ_ok(uint32_t o) {
20071         LDKWarningMessage o_conv;
20072         o_conv.inner = (void*)(o & (~1));
20073         o_conv.is_owned = (o & 1) || (o == 0);
20074         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20075         o_conv = WarningMessage_clone(&o_conv);
20076         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
20077         *ret_conv = CResult_WarningMessageDecodeErrorZ_ok(o_conv);
20078         return (uint32_t)ret_conv;
20079 }
20080
20081 uint32_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_err"))) TS_CResult_WarningMessageDecodeErrorZ_err(uint32_t e) {
20082         LDKDecodeError e_conv;
20083         e_conv.inner = (void*)(e & (~1));
20084         e_conv.is_owned = (e & 1) || (e == 0);
20085         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20086         e_conv = DecodeError_clone(&e_conv);
20087         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
20088         *ret_conv = CResult_WarningMessageDecodeErrorZ_err(e_conv);
20089         return (uint32_t)ret_conv;
20090 }
20091
20092 jboolean  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_is_ok"))) TS_CResult_WarningMessageDecodeErrorZ_is_ok(uint32_t o) {
20093         LDKCResult_WarningMessageDecodeErrorZ* o_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(o & ~1);
20094         jboolean ret_conv = CResult_WarningMessageDecodeErrorZ_is_ok(o_conv);
20095         return ret_conv;
20096 }
20097
20098 void  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_free"))) TS_CResult_WarningMessageDecodeErrorZ_free(uint32_t _res) {
20099         if ((_res & 1) != 0) return;
20100         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20101         CHECK_ACCESS(_res_ptr);
20102         LDKCResult_WarningMessageDecodeErrorZ _res_conv = *(LDKCResult_WarningMessageDecodeErrorZ*)(_res_ptr);
20103         FREE((void*)_res);
20104         CResult_WarningMessageDecodeErrorZ_free(_res_conv);
20105 }
20106
20107 static inline uintptr_t CResult_WarningMessageDecodeErrorZ_clone_ptr(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR arg) {
20108         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
20109         *ret_conv = CResult_WarningMessageDecodeErrorZ_clone(arg);
20110         return (uint32_t)ret_conv;
20111 }
20112 uint32_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_clone_ptr"))) TS_CResult_WarningMessageDecodeErrorZ_clone_ptr(uint32_t arg) {
20113         LDKCResult_WarningMessageDecodeErrorZ* arg_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(arg & ~1);
20114         uint32_t ret_conv = CResult_WarningMessageDecodeErrorZ_clone_ptr(arg_conv);
20115         return ret_conv;
20116 }
20117
20118 uint32_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_clone"))) TS_CResult_WarningMessageDecodeErrorZ_clone(uint32_t orig) {
20119         LDKCResult_WarningMessageDecodeErrorZ* orig_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(orig & ~1);
20120         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
20121         *ret_conv = CResult_WarningMessageDecodeErrorZ_clone(orig_conv);
20122         return (uint32_t)ret_conv;
20123 }
20124
20125 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(uint32_t o) {
20126         LDKUnsignedNodeAnnouncement o_conv;
20127         o_conv.inner = (void*)(o & (~1));
20128         o_conv.is_owned = (o & 1) || (o == 0);
20129         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20130         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
20131         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
20132         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
20133         return (uint32_t)ret_conv;
20134 }
20135
20136 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_err"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(uint32_t e) {
20137         LDKDecodeError e_conv;
20138         e_conv.inner = (void*)(e & (~1));
20139         e_conv.is_owned = (e & 1) || (e == 0);
20140         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20141         e_conv = DecodeError_clone(&e_conv);
20142         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
20143         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
20144         return (uint32_t)ret_conv;
20145 }
20146
20147 jboolean  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(uint32_t o) {
20148         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(o & ~1);
20149         jboolean ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(o_conv);
20150         return ret_conv;
20151 }
20152
20153 void  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_free"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(uint32_t _res) {
20154         if ((_res & 1) != 0) return;
20155         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20156         CHECK_ACCESS(_res_ptr);
20157         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(_res_ptr);
20158         FREE((void*)_res);
20159         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
20160 }
20161
20162 static inline uintptr_t CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
20163         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
20164         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(arg);
20165         return (uint32_t)ret_conv;
20166 }
20167 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(uint32_t arg) {
20168         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
20169         uint32_t ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
20170         return ret_conv;
20171 }
20172
20173 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(uint32_t orig) {
20174         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(orig & ~1);
20175         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
20176         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
20177         return (uint32_t)ret_conv;
20178 }
20179
20180 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_ok"))) TS_CResult_NodeAnnouncementDecodeErrorZ_ok(uint32_t o) {
20181         LDKNodeAnnouncement o_conv;
20182         o_conv.inner = (void*)(o & (~1));
20183         o_conv.is_owned = (o & 1) || (o == 0);
20184         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20185         o_conv = NodeAnnouncement_clone(&o_conv);
20186         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
20187         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
20188         return (uint32_t)ret_conv;
20189 }
20190
20191 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_err"))) TS_CResult_NodeAnnouncementDecodeErrorZ_err(uint32_t e) {
20192         LDKDecodeError e_conv;
20193         e_conv.inner = (void*)(e & (~1));
20194         e_conv.is_owned = (e & 1) || (e == 0);
20195         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20196         e_conv = DecodeError_clone(&e_conv);
20197         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
20198         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
20199         return (uint32_t)ret_conv;
20200 }
20201
20202 jboolean  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_is_ok"))) TS_CResult_NodeAnnouncementDecodeErrorZ_is_ok(uint32_t o) {
20203         LDKCResult_NodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(o & ~1);
20204         jboolean ret_conv = CResult_NodeAnnouncementDecodeErrorZ_is_ok(o_conv);
20205         return ret_conv;
20206 }
20207
20208 void  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_free"))) TS_CResult_NodeAnnouncementDecodeErrorZ_free(uint32_t _res) {
20209         if ((_res & 1) != 0) return;
20210         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20211         CHECK_ACCESS(_res_ptr);
20212         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(_res_ptr);
20213         FREE((void*)_res);
20214         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
20215 }
20216
20217 static inline uintptr_t CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
20218         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
20219         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(arg);
20220         return (uint32_t)ret_conv;
20221 }
20222 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_clone_ptr"))) TS_CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(uint32_t arg) {
20223         LDKCResult_NodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
20224         uint32_t ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
20225         return ret_conv;
20226 }
20227
20228 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_clone"))) TS_CResult_NodeAnnouncementDecodeErrorZ_clone(uint32_t orig) {
20229         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(orig & ~1);
20230         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
20231         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
20232         return (uint32_t)ret_conv;
20233 }
20234
20235 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_ok"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_ok(uint32_t o) {
20236         LDKQueryShortChannelIds o_conv;
20237         o_conv.inner = (void*)(o & (~1));
20238         o_conv.is_owned = (o & 1) || (o == 0);
20239         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20240         o_conv = QueryShortChannelIds_clone(&o_conv);
20241         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
20242         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
20243         return (uint32_t)ret_conv;
20244 }
20245
20246 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_err"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_err(uint32_t e) {
20247         LDKDecodeError e_conv;
20248         e_conv.inner = (void*)(e & (~1));
20249         e_conv.is_owned = (e & 1) || (e == 0);
20250         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20251         e_conv = DecodeError_clone(&e_conv);
20252         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
20253         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
20254         return (uint32_t)ret_conv;
20255 }
20256
20257 jboolean  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_is_ok"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(uint32_t o) {
20258         LDKCResult_QueryShortChannelIdsDecodeErrorZ* o_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(o & ~1);
20259         jboolean ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(o_conv);
20260         return ret_conv;
20261 }
20262
20263 void  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_free"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_free(uint32_t _res) {
20264         if ((_res & 1) != 0) return;
20265         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20266         CHECK_ACCESS(_res_ptr);
20267         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(_res_ptr);
20268         FREE((void*)_res);
20269         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
20270 }
20271
20272 static inline uintptr_t CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR arg) {
20273         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
20274         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(arg);
20275         return (uint32_t)ret_conv;
20276 }
20277 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(uint32_t arg) {
20278         LDKCResult_QueryShortChannelIdsDecodeErrorZ* arg_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
20279         uint32_t ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(arg_conv);
20280         return ret_conv;
20281 }
20282
20283 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone(uint32_t orig) {
20284         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(orig & ~1);
20285         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
20286         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
20287         return (uint32_t)ret_conv;
20288 }
20289
20290 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(uint32_t o) {
20291         LDKReplyShortChannelIdsEnd o_conv;
20292         o_conv.inner = (void*)(o & (~1));
20293         o_conv.is_owned = (o & 1) || (o == 0);
20294         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20295         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
20296         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
20297         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
20298         return (uint32_t)ret_conv;
20299 }
20300
20301 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_err"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(uint32_t e) {
20302         LDKDecodeError e_conv;
20303         e_conv.inner = (void*)(e & (~1));
20304         e_conv.is_owned = (e & 1) || (e == 0);
20305         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20306         e_conv = DecodeError_clone(&e_conv);
20307         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
20308         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
20309         return (uint32_t)ret_conv;
20310 }
20311
20312 jboolean  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(uint32_t o) {
20313         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* o_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(o & ~1);
20314         jboolean ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(o_conv);
20315         return ret_conv;
20316 }
20317
20318 void  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_free"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(uint32_t _res) {
20319         if ((_res & 1) != 0) return;
20320         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20321         CHECK_ACCESS(_res_ptr);
20322         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(_res_ptr);
20323         FREE((void*)_res);
20324         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
20325 }
20326
20327 static inline uintptr_t CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR arg) {
20328         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
20329         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(arg);
20330         return (uint32_t)ret_conv;
20331 }
20332 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(uint32_t arg) {
20333         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* arg_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
20334         uint32_t ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(arg_conv);
20335         return ret_conv;
20336 }
20337
20338 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(uint32_t orig) {
20339         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(orig & ~1);
20340         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
20341         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
20342         return (uint32_t)ret_conv;
20343 }
20344
20345 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_ok"))) TS_CResult_QueryChannelRangeDecodeErrorZ_ok(uint32_t o) {
20346         LDKQueryChannelRange o_conv;
20347         o_conv.inner = (void*)(o & (~1));
20348         o_conv.is_owned = (o & 1) || (o == 0);
20349         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20350         o_conv = QueryChannelRange_clone(&o_conv);
20351         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
20352         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
20353         return (uint32_t)ret_conv;
20354 }
20355
20356 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_err"))) TS_CResult_QueryChannelRangeDecodeErrorZ_err(uint32_t e) {
20357         LDKDecodeError e_conv;
20358         e_conv.inner = (void*)(e & (~1));
20359         e_conv.is_owned = (e & 1) || (e == 0);
20360         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20361         e_conv = DecodeError_clone(&e_conv);
20362         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
20363         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
20364         return (uint32_t)ret_conv;
20365 }
20366
20367 jboolean  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_is_ok"))) TS_CResult_QueryChannelRangeDecodeErrorZ_is_ok(uint32_t o) {
20368         LDKCResult_QueryChannelRangeDecodeErrorZ* o_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(o & ~1);
20369         jboolean ret_conv = CResult_QueryChannelRangeDecodeErrorZ_is_ok(o_conv);
20370         return ret_conv;
20371 }
20372
20373 void  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_free"))) TS_CResult_QueryChannelRangeDecodeErrorZ_free(uint32_t _res) {
20374         if ((_res & 1) != 0) return;
20375         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20376         CHECK_ACCESS(_res_ptr);
20377         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(_res_ptr);
20378         FREE((void*)_res);
20379         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
20380 }
20381
20382 static inline uintptr_t CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
20383         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
20384         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(arg);
20385         return (uint32_t)ret_conv;
20386 }
20387 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_clone_ptr"))) TS_CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(uint32_t arg) {
20388         LDKCResult_QueryChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
20389         uint32_t ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
20390         return ret_conv;
20391 }
20392
20393 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_clone"))) TS_CResult_QueryChannelRangeDecodeErrorZ_clone(uint32_t orig) {
20394         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(orig & ~1);
20395         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
20396         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
20397         return (uint32_t)ret_conv;
20398 }
20399
20400 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_ok"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_ok(uint32_t o) {
20401         LDKReplyChannelRange o_conv;
20402         o_conv.inner = (void*)(o & (~1));
20403         o_conv.is_owned = (o & 1) || (o == 0);
20404         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20405         o_conv = ReplyChannelRange_clone(&o_conv);
20406         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
20407         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
20408         return (uint32_t)ret_conv;
20409 }
20410
20411 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_err"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_err(uint32_t e) {
20412         LDKDecodeError e_conv;
20413         e_conv.inner = (void*)(e & (~1));
20414         e_conv.is_owned = (e & 1) || (e == 0);
20415         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20416         e_conv = DecodeError_clone(&e_conv);
20417         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
20418         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
20419         return (uint32_t)ret_conv;
20420 }
20421
20422 jboolean  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_is_ok"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_is_ok(uint32_t o) {
20423         LDKCResult_ReplyChannelRangeDecodeErrorZ* o_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(o & ~1);
20424         jboolean ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_is_ok(o_conv);
20425         return ret_conv;
20426 }
20427
20428 void  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_free"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_free(uint32_t _res) {
20429         if ((_res & 1) != 0) return;
20430         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20431         CHECK_ACCESS(_res_ptr);
20432         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(_res_ptr);
20433         FREE((void*)_res);
20434         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
20435 }
20436
20437 static inline uintptr_t CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
20438         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
20439         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(arg);
20440         return (uint32_t)ret_conv;
20441 }
20442 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(uint32_t arg) {
20443         LDKCResult_ReplyChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
20444         uint32_t ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
20445         return ret_conv;
20446 }
20447
20448 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_clone"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_clone(uint32_t orig) {
20449         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(orig & ~1);
20450         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
20451         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
20452         return (uint32_t)ret_conv;
20453 }
20454
20455 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_ok"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_ok(uint32_t o) {
20456         LDKGossipTimestampFilter o_conv;
20457         o_conv.inner = (void*)(o & (~1));
20458         o_conv.is_owned = (o & 1) || (o == 0);
20459         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20460         o_conv = GossipTimestampFilter_clone(&o_conv);
20461         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
20462         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
20463         return (uint32_t)ret_conv;
20464 }
20465
20466 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_err"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_err(uint32_t e) {
20467         LDKDecodeError e_conv;
20468         e_conv.inner = (void*)(e & (~1));
20469         e_conv.is_owned = (e & 1) || (e == 0);
20470         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20471         e_conv = DecodeError_clone(&e_conv);
20472         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
20473         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
20474         return (uint32_t)ret_conv;
20475 }
20476
20477 jboolean  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_is_ok"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_is_ok(uint32_t o) {
20478         LDKCResult_GossipTimestampFilterDecodeErrorZ* o_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(o & ~1);
20479         jboolean ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_is_ok(o_conv);
20480         return ret_conv;
20481 }
20482
20483 void  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_free"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_free(uint32_t _res) {
20484         if ((_res & 1) != 0) return;
20485         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20486         CHECK_ACCESS(_res_ptr);
20487         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(_res_ptr);
20488         FREE((void*)_res);
20489         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
20490 }
20491
20492 static inline uintptr_t CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR arg) {
20493         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
20494         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(arg);
20495         return (uint32_t)ret_conv;
20496 }
20497 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(uint32_t arg) {
20498         LDKCResult_GossipTimestampFilterDecodeErrorZ* arg_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
20499         uint32_t ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(arg_conv);
20500         return ret_conv;
20501 }
20502
20503 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_clone"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_clone(uint32_t orig) {
20504         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(orig & ~1);
20505         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
20506         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
20507         return (uint32_t)ret_conv;
20508 }
20509
20510 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_ok"))) TS_CResult_InvoiceSignOrCreationErrorZ_ok(uint32_t o) {
20511         LDKInvoice o_conv;
20512         o_conv.inner = (void*)(o & (~1));
20513         o_conv.is_owned = (o & 1) || (o == 0);
20514         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20515         o_conv = Invoice_clone(&o_conv);
20516         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
20517         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_ok(o_conv);
20518         return (uint32_t)ret_conv;
20519 }
20520
20521 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_err"))) TS_CResult_InvoiceSignOrCreationErrorZ_err(uint32_t e) {
20522         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
20523         CHECK_ACCESS(e_ptr);
20524         LDKSignOrCreationError e_conv = *(LDKSignOrCreationError*)(e_ptr);
20525         e_conv = SignOrCreationError_clone((LDKSignOrCreationError*)(((uintptr_t)e) & ~1));
20526         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
20527         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_err(e_conv);
20528         return (uint32_t)ret_conv;
20529 }
20530
20531 jboolean  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_is_ok"))) TS_CResult_InvoiceSignOrCreationErrorZ_is_ok(uint32_t o) {
20532         LDKCResult_InvoiceSignOrCreationErrorZ* o_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(o & ~1);
20533         jboolean ret_conv = CResult_InvoiceSignOrCreationErrorZ_is_ok(o_conv);
20534         return ret_conv;
20535 }
20536
20537 void  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_free"))) TS_CResult_InvoiceSignOrCreationErrorZ_free(uint32_t _res) {
20538         if ((_res & 1) != 0) return;
20539         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20540         CHECK_ACCESS(_res_ptr);
20541         LDKCResult_InvoiceSignOrCreationErrorZ _res_conv = *(LDKCResult_InvoiceSignOrCreationErrorZ*)(_res_ptr);
20542         FREE((void*)_res);
20543         CResult_InvoiceSignOrCreationErrorZ_free(_res_conv);
20544 }
20545
20546 static inline uintptr_t CResult_InvoiceSignOrCreationErrorZ_clone_ptr(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR arg) {
20547         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
20548         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(arg);
20549         return (uint32_t)ret_conv;
20550 }
20551 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_clone_ptr"))) TS_CResult_InvoiceSignOrCreationErrorZ_clone_ptr(uint32_t arg) {
20552         LDKCResult_InvoiceSignOrCreationErrorZ* arg_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
20553         uint32_t ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone_ptr(arg_conv);
20554         return ret_conv;
20555 }
20556
20557 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_clone"))) TS_CResult_InvoiceSignOrCreationErrorZ_clone(uint32_t orig) {
20558         LDKCResult_InvoiceSignOrCreationErrorZ* orig_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(orig & ~1);
20559         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
20560         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(orig_conv);
20561         return (uint32_t)ret_conv;
20562 }
20563
20564 uint32_t  __attribute__((export_name("TS_COption_FilterZ_some"))) TS_COption_FilterZ_some(uint32_t o) {
20565         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
20566         CHECK_ACCESS(o_ptr);
20567         LDKFilter o_conv = *(LDKFilter*)(o_ptr);
20568         if (o_conv.free == LDKFilter_JCalls_free) {
20569                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20570                 LDKFilter_JCalls_cloned(&o_conv);
20571         }
20572         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
20573         *ret_copy = COption_FilterZ_some(o_conv);
20574         uint32_t ret_ref = (uintptr_t)ret_copy;
20575         return ret_ref;
20576 }
20577
20578 uint32_t  __attribute__((export_name("TS_COption_FilterZ_none"))) TS_COption_FilterZ_none() {
20579         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
20580         *ret_copy = COption_FilterZ_none();
20581         uint32_t ret_ref = (uintptr_t)ret_copy;
20582         return ret_ref;
20583 }
20584
20585 void  __attribute__((export_name("TS_COption_FilterZ_free"))) TS_COption_FilterZ_free(uint32_t _res) {
20586         if ((_res & 1) != 0) return;
20587         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20588         CHECK_ACCESS(_res_ptr);
20589         LDKCOption_FilterZ _res_conv = *(LDKCOption_FilterZ*)(_res_ptr);
20590         FREE((void*)_res);
20591         COption_FilterZ_free(_res_conv);
20592 }
20593
20594 uint32_t  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_ok"))) TS_CResult_LockedChannelMonitorNoneZ_ok(uint32_t o) {
20595         LDKLockedChannelMonitor o_conv;
20596         o_conv.inner = (void*)(o & (~1));
20597         o_conv.is_owned = (o & 1) || (o == 0);
20598         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20599         // WARNING: we need a move here but no clone is available for LDKLockedChannelMonitor
20600         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
20601         *ret_conv = CResult_LockedChannelMonitorNoneZ_ok(o_conv);
20602         return (uint32_t)ret_conv;
20603 }
20604
20605 uint32_t  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_err"))) TS_CResult_LockedChannelMonitorNoneZ_err() {
20606         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
20607         *ret_conv = CResult_LockedChannelMonitorNoneZ_err();
20608         return (uint32_t)ret_conv;
20609 }
20610
20611 jboolean  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_is_ok"))) TS_CResult_LockedChannelMonitorNoneZ_is_ok(uint32_t o) {
20612         LDKCResult_LockedChannelMonitorNoneZ* o_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(o & ~1);
20613         jboolean ret_conv = CResult_LockedChannelMonitorNoneZ_is_ok(o_conv);
20614         return ret_conv;
20615 }
20616
20617 void  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_free"))) TS_CResult_LockedChannelMonitorNoneZ_free(uint32_t _res) {
20618         if ((_res & 1) != 0) return;
20619         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20620         CHECK_ACCESS(_res_ptr);
20621         LDKCResult_LockedChannelMonitorNoneZ _res_conv = *(LDKCResult_LockedChannelMonitorNoneZ*)(_res_ptr);
20622         FREE((void*)_res);
20623         CResult_LockedChannelMonitorNoneZ_free(_res_conv);
20624 }
20625
20626 void  __attribute__((export_name("TS_CVec_OutPointZ_free"))) TS_CVec_OutPointZ_free(uint32_tArray _res) {
20627         LDKCVec_OutPointZ _res_constr;
20628         _res_constr.datalen = _res->arr_len;
20629         if (_res_constr.datalen > 0)
20630                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKOutPoint), "LDKCVec_OutPointZ Elements");
20631         else
20632                 _res_constr.data = NULL;
20633         uint32_t* _res_vals = _res->elems;
20634         for (size_t k = 0; k < _res_constr.datalen; k++) {
20635                 uint32_t _res_conv_10 = _res_vals[k];
20636                 LDKOutPoint _res_conv_10_conv;
20637                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
20638                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
20639                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
20640                 _res_constr.data[k] = _res_conv_10_conv;
20641         }
20642         FREE(_res);
20643         CVec_OutPointZ_free(_res_constr);
20644 }
20645
20646 void  __attribute__((export_name("TS_PaymentPurpose_free"))) TS_PaymentPurpose_free(uint32_t this_ptr) {
20647         if ((this_ptr & 1) != 0) return;
20648         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
20649         CHECK_ACCESS(this_ptr_ptr);
20650         LDKPaymentPurpose this_ptr_conv = *(LDKPaymentPurpose*)(this_ptr_ptr);
20651         FREE((void*)this_ptr);
20652         PaymentPurpose_free(this_ptr_conv);
20653 }
20654
20655 static inline uintptr_t PaymentPurpose_clone_ptr(LDKPaymentPurpose *NONNULL_PTR arg) {
20656         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
20657         *ret_copy = PaymentPurpose_clone(arg);
20658 uint32_t ret_ref = (uintptr_t)ret_copy;
20659         return ret_ref;
20660 }
20661 uint32_t  __attribute__((export_name("TS_PaymentPurpose_clone_ptr"))) TS_PaymentPurpose_clone_ptr(uint32_t arg) {
20662         LDKPaymentPurpose* arg_conv = (LDKPaymentPurpose*)arg;
20663         uint32_t ret_conv = PaymentPurpose_clone_ptr(arg_conv);
20664         return ret_conv;
20665 }
20666
20667 uint32_t  __attribute__((export_name("TS_PaymentPurpose_clone"))) TS_PaymentPurpose_clone(uint32_t orig) {
20668         LDKPaymentPurpose* orig_conv = (LDKPaymentPurpose*)orig;
20669         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
20670         *ret_copy = PaymentPurpose_clone(orig_conv);
20671         uint32_t ret_ref = (uintptr_t)ret_copy;
20672         return ret_ref;
20673 }
20674
20675 uint32_t  __attribute__((export_name("TS_PaymentPurpose_invoice_payment"))) TS_PaymentPurpose_invoice_payment(int8_tArray payment_preimage, int8_tArray payment_secret) {
20676         LDKThirtyTwoBytes payment_preimage_ref;
20677         CHECK(payment_preimage->arr_len == 32);
20678         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
20679         LDKThirtyTwoBytes payment_secret_ref;
20680         CHECK(payment_secret->arr_len == 32);
20681         memcpy(payment_secret_ref.data, payment_secret->elems, 32); FREE(payment_secret);
20682         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
20683         *ret_copy = PaymentPurpose_invoice_payment(payment_preimage_ref, payment_secret_ref);
20684         uint32_t ret_ref = (uintptr_t)ret_copy;
20685         return ret_ref;
20686 }
20687
20688 uint32_t  __attribute__((export_name("TS_PaymentPurpose_spontaneous_payment"))) TS_PaymentPurpose_spontaneous_payment(int8_tArray a) {
20689         LDKThirtyTwoBytes a_ref;
20690         CHECK(a->arr_len == 32);
20691         memcpy(a_ref.data, a->elems, 32); FREE(a);
20692         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
20693         *ret_copy = PaymentPurpose_spontaneous_payment(a_ref);
20694         uint32_t ret_ref = (uintptr_t)ret_copy;
20695         return ret_ref;
20696 }
20697
20698 int8_tArray  __attribute__((export_name("TS_PaymentPurpose_write"))) TS_PaymentPurpose_write(uint32_t obj) {
20699         LDKPaymentPurpose* obj_conv = (LDKPaymentPurpose*)obj;
20700         LDKCVec_u8Z ret_var = PaymentPurpose_write(obj_conv);
20701         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
20702         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
20703         CVec_u8Z_free(ret_var);
20704         return ret_arr;
20705 }
20706
20707 uint32_t  __attribute__((export_name("TS_PaymentPurpose_read"))) TS_PaymentPurpose_read(int8_tArray ser) {
20708         LDKu8slice ser_ref;
20709         ser_ref.datalen = ser->arr_len;
20710         ser_ref.data = ser->elems;
20711         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
20712         *ret_conv = PaymentPurpose_read(ser_ref);
20713         FREE(ser);
20714         return (uint32_t)ret_conv;
20715 }
20716
20717 void  __attribute__((export_name("TS_ClosureReason_free"))) TS_ClosureReason_free(uint32_t this_ptr) {
20718         if ((this_ptr & 1) != 0) return;
20719         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
20720         CHECK_ACCESS(this_ptr_ptr);
20721         LDKClosureReason this_ptr_conv = *(LDKClosureReason*)(this_ptr_ptr);
20722         FREE((void*)this_ptr);
20723         ClosureReason_free(this_ptr_conv);
20724 }
20725
20726 static inline uintptr_t ClosureReason_clone_ptr(LDKClosureReason *NONNULL_PTR arg) {
20727         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
20728         *ret_copy = ClosureReason_clone(arg);
20729 uint32_t ret_ref = (uintptr_t)ret_copy;
20730         return ret_ref;
20731 }
20732 uint32_t  __attribute__((export_name("TS_ClosureReason_clone_ptr"))) TS_ClosureReason_clone_ptr(uint32_t arg) {
20733         LDKClosureReason* arg_conv = (LDKClosureReason*)arg;
20734         uint32_t ret_conv = ClosureReason_clone_ptr(arg_conv);
20735         return ret_conv;
20736 }
20737
20738 uint32_t  __attribute__((export_name("TS_ClosureReason_clone"))) TS_ClosureReason_clone(uint32_t orig) {
20739         LDKClosureReason* orig_conv = (LDKClosureReason*)orig;
20740         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
20741         *ret_copy = ClosureReason_clone(orig_conv);
20742         uint32_t ret_ref = (uintptr_t)ret_copy;
20743         return ret_ref;
20744 }
20745
20746 uint32_t  __attribute__((export_name("TS_ClosureReason_counterparty_force_closed"))) TS_ClosureReason_counterparty_force_closed(jstring peer_msg) {
20747         LDKStr peer_msg_conv = str_ref_to_owned_c(peer_msg);
20748         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
20749         *ret_copy = ClosureReason_counterparty_force_closed(peer_msg_conv);
20750         uint32_t ret_ref = (uintptr_t)ret_copy;
20751         return ret_ref;
20752 }
20753
20754 uint32_t  __attribute__((export_name("TS_ClosureReason_holder_force_closed"))) TS_ClosureReason_holder_force_closed() {
20755         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
20756         *ret_copy = ClosureReason_holder_force_closed();
20757         uint32_t ret_ref = (uintptr_t)ret_copy;
20758         return ret_ref;
20759 }
20760
20761 uint32_t  __attribute__((export_name("TS_ClosureReason_cooperative_closure"))) TS_ClosureReason_cooperative_closure() {
20762         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
20763         *ret_copy = ClosureReason_cooperative_closure();
20764         uint32_t ret_ref = (uintptr_t)ret_copy;
20765         return ret_ref;
20766 }
20767
20768 uint32_t  __attribute__((export_name("TS_ClosureReason_commitment_tx_confirmed"))) TS_ClosureReason_commitment_tx_confirmed() {
20769         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
20770         *ret_copy = ClosureReason_commitment_tx_confirmed();
20771         uint32_t ret_ref = (uintptr_t)ret_copy;
20772         return ret_ref;
20773 }
20774
20775 uint32_t  __attribute__((export_name("TS_ClosureReason_funding_timed_out"))) TS_ClosureReason_funding_timed_out() {
20776         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
20777         *ret_copy = ClosureReason_funding_timed_out();
20778         uint32_t ret_ref = (uintptr_t)ret_copy;
20779         return ret_ref;
20780 }
20781
20782 uint32_t  __attribute__((export_name("TS_ClosureReason_processing_error"))) TS_ClosureReason_processing_error(jstring err) {
20783         LDKStr err_conv = str_ref_to_owned_c(err);
20784         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
20785         *ret_copy = ClosureReason_processing_error(err_conv);
20786         uint32_t ret_ref = (uintptr_t)ret_copy;
20787         return ret_ref;
20788 }
20789
20790 uint32_t  __attribute__((export_name("TS_ClosureReason_disconnected_peer"))) TS_ClosureReason_disconnected_peer() {
20791         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
20792         *ret_copy = ClosureReason_disconnected_peer();
20793         uint32_t ret_ref = (uintptr_t)ret_copy;
20794         return ret_ref;
20795 }
20796
20797 uint32_t  __attribute__((export_name("TS_ClosureReason_outdated_channel_manager"))) TS_ClosureReason_outdated_channel_manager() {
20798         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
20799         *ret_copy = ClosureReason_outdated_channel_manager();
20800         uint32_t ret_ref = (uintptr_t)ret_copy;
20801         return ret_ref;
20802 }
20803
20804 int8_tArray  __attribute__((export_name("TS_ClosureReason_write"))) TS_ClosureReason_write(uint32_t obj) {
20805         LDKClosureReason* obj_conv = (LDKClosureReason*)obj;
20806         LDKCVec_u8Z ret_var = ClosureReason_write(obj_conv);
20807         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
20808         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
20809         CVec_u8Z_free(ret_var);
20810         return ret_arr;
20811 }
20812
20813 uint32_t  __attribute__((export_name("TS_ClosureReason_read"))) TS_ClosureReason_read(int8_tArray ser) {
20814         LDKu8slice ser_ref;
20815         ser_ref.datalen = ser->arr_len;
20816         ser_ref.data = ser->elems;
20817         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
20818         *ret_conv = ClosureReason_read(ser_ref);
20819         FREE(ser);
20820         return (uint32_t)ret_conv;
20821 }
20822
20823 void  __attribute__((export_name("TS_HTLCDestination_free"))) TS_HTLCDestination_free(uint32_t this_ptr) {
20824         if ((this_ptr & 1) != 0) return;
20825         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
20826         CHECK_ACCESS(this_ptr_ptr);
20827         LDKHTLCDestination this_ptr_conv = *(LDKHTLCDestination*)(this_ptr_ptr);
20828         FREE((void*)this_ptr);
20829         HTLCDestination_free(this_ptr_conv);
20830 }
20831
20832 static inline uintptr_t HTLCDestination_clone_ptr(LDKHTLCDestination *NONNULL_PTR arg) {
20833         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
20834         *ret_copy = HTLCDestination_clone(arg);
20835 uint32_t ret_ref = (uintptr_t)ret_copy;
20836         return ret_ref;
20837 }
20838 uint32_t  __attribute__((export_name("TS_HTLCDestination_clone_ptr"))) TS_HTLCDestination_clone_ptr(uint32_t arg) {
20839         LDKHTLCDestination* arg_conv = (LDKHTLCDestination*)arg;
20840         uint32_t ret_conv = HTLCDestination_clone_ptr(arg_conv);
20841         return ret_conv;
20842 }
20843
20844 uint32_t  __attribute__((export_name("TS_HTLCDestination_clone"))) TS_HTLCDestination_clone(uint32_t orig) {
20845         LDKHTLCDestination* orig_conv = (LDKHTLCDestination*)orig;
20846         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
20847         *ret_copy = HTLCDestination_clone(orig_conv);
20848         uint32_t ret_ref = (uintptr_t)ret_copy;
20849         return ret_ref;
20850 }
20851
20852 uint32_t  __attribute__((export_name("TS_HTLCDestination_next_hop_channel"))) TS_HTLCDestination_next_hop_channel(int8_tArray node_id, int8_tArray channel_id) {
20853         LDKPublicKey node_id_ref;
20854         CHECK(node_id->arr_len == 33);
20855         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20856         LDKThirtyTwoBytes channel_id_ref;
20857         CHECK(channel_id->arr_len == 32);
20858         memcpy(channel_id_ref.data, channel_id->elems, 32); FREE(channel_id);
20859         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
20860         *ret_copy = HTLCDestination_next_hop_channel(node_id_ref, channel_id_ref);
20861         uint32_t ret_ref = (uintptr_t)ret_copy;
20862         return ret_ref;
20863 }
20864
20865 uint32_t  __attribute__((export_name("TS_HTLCDestination_unknown_next_hop"))) TS_HTLCDestination_unknown_next_hop(int64_t requested_forward_scid) {
20866         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
20867         *ret_copy = HTLCDestination_unknown_next_hop(requested_forward_scid);
20868         uint32_t ret_ref = (uintptr_t)ret_copy;
20869         return ret_ref;
20870 }
20871
20872 uint32_t  __attribute__((export_name("TS_HTLCDestination_failed_payment"))) TS_HTLCDestination_failed_payment(int8_tArray payment_hash) {
20873         LDKThirtyTwoBytes payment_hash_ref;
20874         CHECK(payment_hash->arr_len == 32);
20875         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
20876         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
20877         *ret_copy = HTLCDestination_failed_payment(payment_hash_ref);
20878         uint32_t ret_ref = (uintptr_t)ret_copy;
20879         return ret_ref;
20880 }
20881
20882 int8_tArray  __attribute__((export_name("TS_HTLCDestination_write"))) TS_HTLCDestination_write(uint32_t obj) {
20883         LDKHTLCDestination* obj_conv = (LDKHTLCDestination*)obj;
20884         LDKCVec_u8Z ret_var = HTLCDestination_write(obj_conv);
20885         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
20886         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
20887         CVec_u8Z_free(ret_var);
20888         return ret_arr;
20889 }
20890
20891 uint32_t  __attribute__((export_name("TS_HTLCDestination_read"))) TS_HTLCDestination_read(int8_tArray ser) {
20892         LDKu8slice ser_ref;
20893         ser_ref.datalen = ser->arr_len;
20894         ser_ref.data = ser->elems;
20895         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
20896         *ret_conv = HTLCDestination_read(ser_ref);
20897         FREE(ser);
20898         return (uint32_t)ret_conv;
20899 }
20900
20901 void  __attribute__((export_name("TS_Event_free"))) TS_Event_free(uint32_t this_ptr) {
20902         if ((this_ptr & 1) != 0) return;
20903         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
20904         CHECK_ACCESS(this_ptr_ptr);
20905         LDKEvent this_ptr_conv = *(LDKEvent*)(this_ptr_ptr);
20906         FREE((void*)this_ptr);
20907         Event_free(this_ptr_conv);
20908 }
20909
20910 static inline uintptr_t Event_clone_ptr(LDKEvent *NONNULL_PTR arg) {
20911         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20912         *ret_copy = Event_clone(arg);
20913 uint32_t ret_ref = (uintptr_t)ret_copy;
20914         return ret_ref;
20915 }
20916 uint32_t  __attribute__((export_name("TS_Event_clone_ptr"))) TS_Event_clone_ptr(uint32_t arg) {
20917         LDKEvent* arg_conv = (LDKEvent*)arg;
20918         uint32_t ret_conv = Event_clone_ptr(arg_conv);
20919         return ret_conv;
20920 }
20921
20922 uint32_t  __attribute__((export_name("TS_Event_clone"))) TS_Event_clone(uint32_t orig) {
20923         LDKEvent* orig_conv = (LDKEvent*)orig;
20924         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20925         *ret_copy = Event_clone(orig_conv);
20926         uint32_t ret_ref = (uintptr_t)ret_copy;
20927         return ret_ref;
20928 }
20929
20930 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) {
20931         LDKThirtyTwoBytes temporary_channel_id_ref;
20932         CHECK(temporary_channel_id->arr_len == 32);
20933         memcpy(temporary_channel_id_ref.data, temporary_channel_id->elems, 32); FREE(temporary_channel_id);
20934         LDKPublicKey counterparty_node_id_ref;
20935         CHECK(counterparty_node_id->arr_len == 33);
20936         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
20937         LDKCVec_u8Z output_script_ref;
20938         output_script_ref.datalen = output_script->arr_len;
20939         output_script_ref.data = MALLOC(output_script_ref.datalen, "LDKCVec_u8Z Bytes");
20940         memcpy(output_script_ref.data, output_script->elems, output_script_ref.datalen); FREE(output_script);
20941         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20942         *ret_copy = Event_funding_generation_ready(temporary_channel_id_ref, counterparty_node_id_ref, channel_value_satoshis, output_script_ref, user_channel_id);
20943         uint32_t ret_ref = (uintptr_t)ret_copy;
20944         return ret_ref;
20945 }
20946
20947 uint32_t  __attribute__((export_name("TS_Event_payment_received"))) TS_Event_payment_received(int8_tArray payment_hash, int64_t amount_msat, uint32_t purpose) {
20948         LDKThirtyTwoBytes payment_hash_ref;
20949         CHECK(payment_hash->arr_len == 32);
20950         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
20951         void* purpose_ptr = (void*)(((uintptr_t)purpose) & ~1);
20952         CHECK_ACCESS(purpose_ptr);
20953         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
20954         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)(((uintptr_t)purpose) & ~1));
20955         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20956         *ret_copy = Event_payment_received(payment_hash_ref, amount_msat, purpose_conv);
20957         uint32_t ret_ref = (uintptr_t)ret_copy;
20958         return ret_ref;
20959 }
20960
20961 uint32_t  __attribute__((export_name("TS_Event_payment_claimed"))) TS_Event_payment_claimed(int8_tArray payment_hash, int64_t amount_msat, uint32_t purpose) {
20962         LDKThirtyTwoBytes payment_hash_ref;
20963         CHECK(payment_hash->arr_len == 32);
20964         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
20965         void* purpose_ptr = (void*)(((uintptr_t)purpose) & ~1);
20966         CHECK_ACCESS(purpose_ptr);
20967         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
20968         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)(((uintptr_t)purpose) & ~1));
20969         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20970         *ret_copy = Event_payment_claimed(payment_hash_ref, amount_msat, purpose_conv);
20971         uint32_t ret_ref = (uintptr_t)ret_copy;
20972         return ret_ref;
20973 }
20974
20975 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) {
20976         LDKThirtyTwoBytes payment_id_ref;
20977         CHECK(payment_id->arr_len == 32);
20978         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
20979         LDKThirtyTwoBytes payment_preimage_ref;
20980         CHECK(payment_preimage->arr_len == 32);
20981         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
20982         LDKThirtyTwoBytes payment_hash_ref;
20983         CHECK(payment_hash->arr_len == 32);
20984         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
20985         void* fee_paid_msat_ptr = (void*)(((uintptr_t)fee_paid_msat) & ~1);
20986         CHECK_ACCESS(fee_paid_msat_ptr);
20987         LDKCOption_u64Z fee_paid_msat_conv = *(LDKCOption_u64Z*)(fee_paid_msat_ptr);
20988         fee_paid_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)fee_paid_msat) & ~1));
20989         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20990         *ret_copy = Event_payment_sent(payment_id_ref, payment_preimage_ref, payment_hash_ref, fee_paid_msat_conv);
20991         uint32_t ret_ref = (uintptr_t)ret_copy;
20992         return ret_ref;
20993 }
20994
20995 uint32_t  __attribute__((export_name("TS_Event_payment_failed"))) TS_Event_payment_failed(int8_tArray payment_id, int8_tArray payment_hash) {
20996         LDKThirtyTwoBytes payment_id_ref;
20997         CHECK(payment_id->arr_len == 32);
20998         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
20999         LDKThirtyTwoBytes payment_hash_ref;
21000         CHECK(payment_hash->arr_len == 32);
21001         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
21002         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
21003         *ret_copy = Event_payment_failed(payment_id_ref, payment_hash_ref);
21004         uint32_t ret_ref = (uintptr_t)ret_copy;
21005         return ret_ref;
21006 }
21007
21008 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) {
21009         LDKThirtyTwoBytes payment_id_ref;
21010         CHECK(payment_id->arr_len == 32);
21011         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
21012         LDKThirtyTwoBytes payment_hash_ref;
21013         CHECK(payment_hash->arr_len == 32);
21014         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
21015         LDKCVec_RouteHopZ path_constr;
21016         path_constr.datalen = path->arr_len;
21017         if (path_constr.datalen > 0)
21018                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
21019         else
21020                 path_constr.data = NULL;
21021         uint32_t* path_vals = path->elems;
21022         for (size_t k = 0; k < path_constr.datalen; k++) {
21023                 uint32_t path_conv_10 = path_vals[k];
21024                 LDKRouteHop path_conv_10_conv;
21025                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
21026                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
21027                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
21028                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
21029                 path_constr.data[k] = path_conv_10_conv;
21030         }
21031         FREE(path);
21032         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
21033         *ret_copy = Event_payment_path_successful(payment_id_ref, payment_hash_ref, path_constr);
21034         uint32_t ret_ref = (uintptr_t)ret_copy;
21035         return ret_ref;
21036 }
21037
21038 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) {
21039         LDKThirtyTwoBytes payment_id_ref;
21040         CHECK(payment_id->arr_len == 32);
21041         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
21042         LDKThirtyTwoBytes payment_hash_ref;
21043         CHECK(payment_hash->arr_len == 32);
21044         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
21045         void* network_update_ptr = (void*)(((uintptr_t)network_update) & ~1);
21046         CHECK_ACCESS(network_update_ptr);
21047         LDKCOption_NetworkUpdateZ network_update_conv = *(LDKCOption_NetworkUpdateZ*)(network_update_ptr);
21048         network_update_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uintptr_t)network_update) & ~1));
21049         LDKCVec_RouteHopZ path_constr;
21050         path_constr.datalen = path->arr_len;
21051         if (path_constr.datalen > 0)
21052                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
21053         else
21054                 path_constr.data = NULL;
21055         uint32_t* path_vals = path->elems;
21056         for (size_t k = 0; k < path_constr.datalen; k++) {
21057                 uint32_t path_conv_10 = path_vals[k];
21058                 LDKRouteHop path_conv_10_conv;
21059                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
21060                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
21061                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
21062                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
21063                 path_constr.data[k] = path_conv_10_conv;
21064         }
21065         FREE(path);
21066         void* short_channel_id_ptr = (void*)(((uintptr_t)short_channel_id) & ~1);
21067         CHECK_ACCESS(short_channel_id_ptr);
21068         LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(short_channel_id_ptr);
21069         short_channel_id_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id) & ~1));
21070         LDKRouteParameters retry_conv;
21071         retry_conv.inner = (void*)(retry & (~1));
21072         retry_conv.is_owned = (retry & 1) || (retry == 0);
21073         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_conv);
21074         retry_conv = RouteParameters_clone(&retry_conv);
21075         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
21076         *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);
21077         uint32_t ret_ref = (uintptr_t)ret_copy;
21078         return ret_ref;
21079 }
21080
21081 uint32_t  __attribute__((export_name("TS_Event_probe_successful"))) TS_Event_probe_successful(int8_tArray payment_id, int8_tArray payment_hash, uint32_tArray path) {
21082         LDKThirtyTwoBytes payment_id_ref;
21083         CHECK(payment_id->arr_len == 32);
21084         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
21085         LDKThirtyTwoBytes payment_hash_ref;
21086         CHECK(payment_hash->arr_len == 32);
21087         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
21088         LDKCVec_RouteHopZ path_constr;
21089         path_constr.datalen = path->arr_len;
21090         if (path_constr.datalen > 0)
21091                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
21092         else
21093                 path_constr.data = NULL;
21094         uint32_t* path_vals = path->elems;
21095         for (size_t k = 0; k < path_constr.datalen; k++) {
21096                 uint32_t path_conv_10 = path_vals[k];
21097                 LDKRouteHop path_conv_10_conv;
21098                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
21099                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
21100                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
21101                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
21102                 path_constr.data[k] = path_conv_10_conv;
21103         }
21104         FREE(path);
21105         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
21106         *ret_copy = Event_probe_successful(payment_id_ref, payment_hash_ref, path_constr);
21107         uint32_t ret_ref = (uintptr_t)ret_copy;
21108         return ret_ref;
21109 }
21110
21111 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) {
21112         LDKThirtyTwoBytes payment_id_ref;
21113         CHECK(payment_id->arr_len == 32);
21114         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
21115         LDKThirtyTwoBytes payment_hash_ref;
21116         CHECK(payment_hash->arr_len == 32);
21117         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
21118         LDKCVec_RouteHopZ path_constr;
21119         path_constr.datalen = path->arr_len;
21120         if (path_constr.datalen > 0)
21121                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
21122         else
21123                 path_constr.data = NULL;
21124         uint32_t* path_vals = path->elems;
21125         for (size_t k = 0; k < path_constr.datalen; k++) {
21126                 uint32_t path_conv_10 = path_vals[k];
21127                 LDKRouteHop path_conv_10_conv;
21128                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
21129                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
21130                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
21131                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
21132                 path_constr.data[k] = path_conv_10_conv;
21133         }
21134         FREE(path);
21135         void* short_channel_id_ptr = (void*)(((uintptr_t)short_channel_id) & ~1);
21136         CHECK_ACCESS(short_channel_id_ptr);
21137         LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(short_channel_id_ptr);
21138         short_channel_id_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id) & ~1));
21139         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
21140         *ret_copy = Event_probe_failed(payment_id_ref, payment_hash_ref, path_constr, short_channel_id_conv);
21141         uint32_t ret_ref = (uintptr_t)ret_copy;
21142         return ret_ref;
21143 }
21144
21145 uint32_t  __attribute__((export_name("TS_Event_pending_htlcs_forwardable"))) TS_Event_pending_htlcs_forwardable(int64_t time_forwardable) {
21146         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
21147         *ret_copy = Event_pending_htlcs_forwardable(time_forwardable);
21148         uint32_t ret_ref = (uintptr_t)ret_copy;
21149         return ret_ref;
21150 }
21151
21152 uint32_t  __attribute__((export_name("TS_Event_spendable_outputs"))) TS_Event_spendable_outputs(uint32_tArray outputs) {
21153         LDKCVec_SpendableOutputDescriptorZ outputs_constr;
21154         outputs_constr.datalen = outputs->arr_len;
21155         if (outputs_constr.datalen > 0)
21156                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
21157         else
21158                 outputs_constr.data = NULL;
21159         uint32_t* outputs_vals = outputs->elems;
21160         for (size_t b = 0; b < outputs_constr.datalen; b++) {
21161                 uint32_t outputs_conv_27 = outputs_vals[b];
21162                 void* outputs_conv_27_ptr = (void*)(((uintptr_t)outputs_conv_27) & ~1);
21163                 CHECK_ACCESS(outputs_conv_27_ptr);
21164                 LDKSpendableOutputDescriptor outputs_conv_27_conv = *(LDKSpendableOutputDescriptor*)(outputs_conv_27_ptr);
21165                 outputs_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)outputs_conv_27) & ~1));
21166                 outputs_constr.data[b] = outputs_conv_27_conv;
21167         }
21168         FREE(outputs);
21169         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
21170         *ret_copy = Event_spendable_outputs(outputs_constr);
21171         uint32_t ret_ref = (uintptr_t)ret_copy;
21172         return ret_ref;
21173 }
21174
21175 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) {
21176         LDKThirtyTwoBytes prev_channel_id_ref;
21177         CHECK(prev_channel_id->arr_len == 32);
21178         memcpy(prev_channel_id_ref.data, prev_channel_id->elems, 32); FREE(prev_channel_id);
21179         LDKThirtyTwoBytes next_channel_id_ref;
21180         CHECK(next_channel_id->arr_len == 32);
21181         memcpy(next_channel_id_ref.data, next_channel_id->elems, 32); FREE(next_channel_id);
21182         void* fee_earned_msat_ptr = (void*)(((uintptr_t)fee_earned_msat) & ~1);
21183         CHECK_ACCESS(fee_earned_msat_ptr);
21184         LDKCOption_u64Z fee_earned_msat_conv = *(LDKCOption_u64Z*)(fee_earned_msat_ptr);
21185         fee_earned_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)fee_earned_msat) & ~1));
21186         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
21187         *ret_copy = Event_payment_forwarded(prev_channel_id_ref, next_channel_id_ref, fee_earned_msat_conv, claim_from_onchain_tx);
21188         uint32_t ret_ref = (uintptr_t)ret_copy;
21189         return ret_ref;
21190 }
21191
21192 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) {
21193         LDKThirtyTwoBytes channel_id_ref;
21194         CHECK(channel_id->arr_len == 32);
21195         memcpy(channel_id_ref.data, channel_id->elems, 32); FREE(channel_id);
21196         void* reason_ptr = (void*)(((uintptr_t)reason) & ~1);
21197         CHECK_ACCESS(reason_ptr);
21198         LDKClosureReason reason_conv = *(LDKClosureReason*)(reason_ptr);
21199         reason_conv = ClosureReason_clone((LDKClosureReason*)(((uintptr_t)reason) & ~1));
21200         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
21201         *ret_copy = Event_channel_closed(channel_id_ref, user_channel_id, reason_conv);
21202         uint32_t ret_ref = (uintptr_t)ret_copy;
21203         return ret_ref;
21204 }
21205
21206 uint32_t  __attribute__((export_name("TS_Event_discard_funding"))) TS_Event_discard_funding(int8_tArray channel_id, int8_tArray transaction) {
21207         LDKThirtyTwoBytes channel_id_ref;
21208         CHECK(channel_id->arr_len == 32);
21209         memcpy(channel_id_ref.data, channel_id->elems, 32); FREE(channel_id);
21210         LDKTransaction transaction_ref;
21211         transaction_ref.datalen = transaction->arr_len;
21212         transaction_ref.data = MALLOC(transaction_ref.datalen, "LDKTransaction Bytes");
21213         memcpy(transaction_ref.data, transaction->elems, transaction_ref.datalen); FREE(transaction);
21214         transaction_ref.data_is_owned = true;
21215         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
21216         *ret_copy = Event_discard_funding(channel_id_ref, transaction_ref);
21217         uint32_t ret_ref = (uintptr_t)ret_copy;
21218         return ret_ref;
21219 }
21220
21221 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) {
21222         LDKThirtyTwoBytes temporary_channel_id_ref;
21223         CHECK(temporary_channel_id->arr_len == 32);
21224         memcpy(temporary_channel_id_ref.data, temporary_channel_id->elems, 32); FREE(temporary_channel_id);
21225         LDKPublicKey counterparty_node_id_ref;
21226         CHECK(counterparty_node_id->arr_len == 33);
21227         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
21228         LDKChannelTypeFeatures channel_type_conv;
21229         channel_type_conv.inner = (void*)(channel_type & (~1));
21230         channel_type_conv.is_owned = (channel_type & 1) || (channel_type == 0);
21231         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_conv);
21232         channel_type_conv = ChannelTypeFeatures_clone(&channel_type_conv);
21233         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
21234         *ret_copy = Event_open_channel_request(temporary_channel_id_ref, counterparty_node_id_ref, funding_satoshis, push_msat, channel_type_conv);
21235         uint32_t ret_ref = (uintptr_t)ret_copy;
21236         return ret_ref;
21237 }
21238
21239 uint32_t  __attribute__((export_name("TS_Event_htlchandling_failed"))) TS_Event_htlchandling_failed(int8_tArray prev_channel_id, uint32_t failed_next_destination) {
21240         LDKThirtyTwoBytes prev_channel_id_ref;
21241         CHECK(prev_channel_id->arr_len == 32);
21242         memcpy(prev_channel_id_ref.data, prev_channel_id->elems, 32); FREE(prev_channel_id);
21243         void* failed_next_destination_ptr = (void*)(((uintptr_t)failed_next_destination) & ~1);
21244         CHECK_ACCESS(failed_next_destination_ptr);
21245         LDKHTLCDestination failed_next_destination_conv = *(LDKHTLCDestination*)(failed_next_destination_ptr);
21246         failed_next_destination_conv = HTLCDestination_clone((LDKHTLCDestination*)(((uintptr_t)failed_next_destination) & ~1));
21247         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
21248         *ret_copy = Event_htlchandling_failed(prev_channel_id_ref, failed_next_destination_conv);
21249         uint32_t ret_ref = (uintptr_t)ret_copy;
21250         return ret_ref;
21251 }
21252
21253 int8_tArray  __attribute__((export_name("TS_Event_write"))) TS_Event_write(uint32_t obj) {
21254         LDKEvent* obj_conv = (LDKEvent*)obj;
21255         LDKCVec_u8Z ret_var = Event_write(obj_conv);
21256         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
21257         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
21258         CVec_u8Z_free(ret_var);
21259         return ret_arr;
21260 }
21261
21262 uint32_t  __attribute__((export_name("TS_Event_read"))) TS_Event_read(int8_tArray ser) {
21263         LDKu8slice ser_ref;
21264         ser_ref.datalen = ser->arr_len;
21265         ser_ref.data = ser->elems;
21266         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
21267         *ret_conv = Event_read(ser_ref);
21268         FREE(ser);
21269         return (uint32_t)ret_conv;
21270 }
21271
21272 void  __attribute__((export_name("TS_MessageSendEvent_free"))) TS_MessageSendEvent_free(uint32_t this_ptr) {
21273         if ((this_ptr & 1) != 0) return;
21274         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21275         CHECK_ACCESS(this_ptr_ptr);
21276         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(this_ptr_ptr);
21277         FREE((void*)this_ptr);
21278         MessageSendEvent_free(this_ptr_conv);
21279 }
21280
21281 static inline uintptr_t MessageSendEvent_clone_ptr(LDKMessageSendEvent *NONNULL_PTR arg) {
21282         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21283         *ret_copy = MessageSendEvent_clone(arg);
21284 uint32_t ret_ref = (uintptr_t)ret_copy;
21285         return ret_ref;
21286 }
21287 uint32_t  __attribute__((export_name("TS_MessageSendEvent_clone_ptr"))) TS_MessageSendEvent_clone_ptr(uint32_t arg) {
21288         LDKMessageSendEvent* arg_conv = (LDKMessageSendEvent*)arg;
21289         uint32_t ret_conv = MessageSendEvent_clone_ptr(arg_conv);
21290         return ret_conv;
21291 }
21292
21293 uint32_t  __attribute__((export_name("TS_MessageSendEvent_clone"))) TS_MessageSendEvent_clone(uint32_t orig) {
21294         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)orig;
21295         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21296         *ret_copy = MessageSendEvent_clone(orig_conv);
21297         uint32_t ret_ref = (uintptr_t)ret_copy;
21298         return ret_ref;
21299 }
21300
21301 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_accept_channel"))) TS_MessageSendEvent_send_accept_channel(int8_tArray node_id, uint32_t msg) {
21302         LDKPublicKey node_id_ref;
21303         CHECK(node_id->arr_len == 33);
21304         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
21305         LDKAcceptChannel msg_conv;
21306         msg_conv.inner = (void*)(msg & (~1));
21307         msg_conv.is_owned = (msg & 1) || (msg == 0);
21308         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21309         msg_conv = AcceptChannel_clone(&msg_conv);
21310         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21311         *ret_copy = MessageSendEvent_send_accept_channel(node_id_ref, msg_conv);
21312         uint32_t ret_ref = (uintptr_t)ret_copy;
21313         return ret_ref;
21314 }
21315
21316 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_open_channel"))) TS_MessageSendEvent_send_open_channel(int8_tArray node_id, uint32_t msg) {
21317         LDKPublicKey node_id_ref;
21318         CHECK(node_id->arr_len == 33);
21319         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
21320         LDKOpenChannel msg_conv;
21321         msg_conv.inner = (void*)(msg & (~1));
21322         msg_conv.is_owned = (msg & 1) || (msg == 0);
21323         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21324         msg_conv = OpenChannel_clone(&msg_conv);
21325         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21326         *ret_copy = MessageSendEvent_send_open_channel(node_id_ref, msg_conv);
21327         uint32_t ret_ref = (uintptr_t)ret_copy;
21328         return ret_ref;
21329 }
21330
21331 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_funding_created"))) TS_MessageSendEvent_send_funding_created(int8_tArray node_id, uint32_t msg) {
21332         LDKPublicKey node_id_ref;
21333         CHECK(node_id->arr_len == 33);
21334         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
21335         LDKFundingCreated msg_conv;
21336         msg_conv.inner = (void*)(msg & (~1));
21337         msg_conv.is_owned = (msg & 1) || (msg == 0);
21338         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21339         msg_conv = FundingCreated_clone(&msg_conv);
21340         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21341         *ret_copy = MessageSendEvent_send_funding_created(node_id_ref, msg_conv);
21342         uint32_t ret_ref = (uintptr_t)ret_copy;
21343         return ret_ref;
21344 }
21345
21346 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_funding_signed"))) TS_MessageSendEvent_send_funding_signed(int8_tArray node_id, uint32_t msg) {
21347         LDKPublicKey node_id_ref;
21348         CHECK(node_id->arr_len == 33);
21349         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
21350         LDKFundingSigned msg_conv;
21351         msg_conv.inner = (void*)(msg & (~1));
21352         msg_conv.is_owned = (msg & 1) || (msg == 0);
21353         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21354         msg_conv = FundingSigned_clone(&msg_conv);
21355         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21356         *ret_copy = MessageSendEvent_send_funding_signed(node_id_ref, msg_conv);
21357         uint32_t ret_ref = (uintptr_t)ret_copy;
21358         return ret_ref;
21359 }
21360
21361 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_channel_ready"))) TS_MessageSendEvent_send_channel_ready(int8_tArray node_id, uint32_t msg) {
21362         LDKPublicKey node_id_ref;
21363         CHECK(node_id->arr_len == 33);
21364         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
21365         LDKChannelReady msg_conv;
21366         msg_conv.inner = (void*)(msg & (~1));
21367         msg_conv.is_owned = (msg & 1) || (msg == 0);
21368         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21369         msg_conv = ChannelReady_clone(&msg_conv);
21370         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21371         *ret_copy = MessageSendEvent_send_channel_ready(node_id_ref, msg_conv);
21372         uint32_t ret_ref = (uintptr_t)ret_copy;
21373         return ret_ref;
21374 }
21375
21376 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_announcement_signatures"))) TS_MessageSendEvent_send_announcement_signatures(int8_tArray node_id, uint32_t msg) {
21377         LDKPublicKey node_id_ref;
21378         CHECK(node_id->arr_len == 33);
21379         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
21380         LDKAnnouncementSignatures msg_conv;
21381         msg_conv.inner = (void*)(msg & (~1));
21382         msg_conv.is_owned = (msg & 1) || (msg == 0);
21383         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21384         msg_conv = AnnouncementSignatures_clone(&msg_conv);
21385         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21386         *ret_copy = MessageSendEvent_send_announcement_signatures(node_id_ref, msg_conv);
21387         uint32_t ret_ref = (uintptr_t)ret_copy;
21388         return ret_ref;
21389 }
21390
21391 uint32_t  __attribute__((export_name("TS_MessageSendEvent_update_htlcs"))) TS_MessageSendEvent_update_htlcs(int8_tArray node_id, uint32_t updates) {
21392         LDKPublicKey node_id_ref;
21393         CHECK(node_id->arr_len == 33);
21394         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
21395         LDKCommitmentUpdate updates_conv;
21396         updates_conv.inner = (void*)(updates & (~1));
21397         updates_conv.is_owned = (updates & 1) || (updates == 0);
21398         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
21399         updates_conv = CommitmentUpdate_clone(&updates_conv);
21400         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21401         *ret_copy = MessageSendEvent_update_htlcs(node_id_ref, updates_conv);
21402         uint32_t ret_ref = (uintptr_t)ret_copy;
21403         return ret_ref;
21404 }
21405
21406 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_revoke_and_ack"))) TS_MessageSendEvent_send_revoke_and_ack(int8_tArray node_id, uint32_t msg) {
21407         LDKPublicKey node_id_ref;
21408         CHECK(node_id->arr_len == 33);
21409         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
21410         LDKRevokeAndACK msg_conv;
21411         msg_conv.inner = (void*)(msg & (~1));
21412         msg_conv.is_owned = (msg & 1) || (msg == 0);
21413         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21414         msg_conv = RevokeAndACK_clone(&msg_conv);
21415         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21416         *ret_copy = MessageSendEvent_send_revoke_and_ack(node_id_ref, msg_conv);
21417         uint32_t ret_ref = (uintptr_t)ret_copy;
21418         return ret_ref;
21419 }
21420
21421 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_closing_signed"))) TS_MessageSendEvent_send_closing_signed(int8_tArray node_id, uint32_t msg) {
21422         LDKPublicKey node_id_ref;
21423         CHECK(node_id->arr_len == 33);
21424         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
21425         LDKClosingSigned msg_conv;
21426         msg_conv.inner = (void*)(msg & (~1));
21427         msg_conv.is_owned = (msg & 1) || (msg == 0);
21428         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21429         msg_conv = ClosingSigned_clone(&msg_conv);
21430         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21431         *ret_copy = MessageSendEvent_send_closing_signed(node_id_ref, msg_conv);
21432         uint32_t ret_ref = (uintptr_t)ret_copy;
21433         return ret_ref;
21434 }
21435
21436 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_shutdown"))) TS_MessageSendEvent_send_shutdown(int8_tArray node_id, uint32_t msg) {
21437         LDKPublicKey node_id_ref;
21438         CHECK(node_id->arr_len == 33);
21439         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
21440         LDKShutdown msg_conv;
21441         msg_conv.inner = (void*)(msg & (~1));
21442         msg_conv.is_owned = (msg & 1) || (msg == 0);
21443         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21444         msg_conv = Shutdown_clone(&msg_conv);
21445         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21446         *ret_copy = MessageSendEvent_send_shutdown(node_id_ref, msg_conv);
21447         uint32_t ret_ref = (uintptr_t)ret_copy;
21448         return ret_ref;
21449 }
21450
21451 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_channel_reestablish"))) TS_MessageSendEvent_send_channel_reestablish(int8_tArray node_id, uint32_t msg) {
21452         LDKPublicKey node_id_ref;
21453         CHECK(node_id->arr_len == 33);
21454         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
21455         LDKChannelReestablish msg_conv;
21456         msg_conv.inner = (void*)(msg & (~1));
21457         msg_conv.is_owned = (msg & 1) || (msg == 0);
21458         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21459         msg_conv = ChannelReestablish_clone(&msg_conv);
21460         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21461         *ret_copy = MessageSendEvent_send_channel_reestablish(node_id_ref, msg_conv);
21462         uint32_t ret_ref = (uintptr_t)ret_copy;
21463         return ret_ref;
21464 }
21465
21466 uint32_t  __attribute__((export_name("TS_MessageSendEvent_broadcast_channel_announcement"))) TS_MessageSendEvent_broadcast_channel_announcement(uint32_t msg, uint32_t update_msg) {
21467         LDKChannelAnnouncement msg_conv;
21468         msg_conv.inner = (void*)(msg & (~1));
21469         msg_conv.is_owned = (msg & 1) || (msg == 0);
21470         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21471         msg_conv = ChannelAnnouncement_clone(&msg_conv);
21472         LDKChannelUpdate update_msg_conv;
21473         update_msg_conv.inner = (void*)(update_msg & (~1));
21474         update_msg_conv.is_owned = (update_msg & 1) || (update_msg == 0);
21475         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_conv);
21476         update_msg_conv = ChannelUpdate_clone(&update_msg_conv);
21477         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21478         *ret_copy = MessageSendEvent_broadcast_channel_announcement(msg_conv, update_msg_conv);
21479         uint32_t ret_ref = (uintptr_t)ret_copy;
21480         return ret_ref;
21481 }
21482
21483 uint32_t  __attribute__((export_name("TS_MessageSendEvent_broadcast_node_announcement"))) TS_MessageSendEvent_broadcast_node_announcement(uint32_t msg) {
21484         LDKNodeAnnouncement msg_conv;
21485         msg_conv.inner = (void*)(msg & (~1));
21486         msg_conv.is_owned = (msg & 1) || (msg == 0);
21487         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21488         msg_conv = NodeAnnouncement_clone(&msg_conv);
21489         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21490         *ret_copy = MessageSendEvent_broadcast_node_announcement(msg_conv);
21491         uint32_t ret_ref = (uintptr_t)ret_copy;
21492         return ret_ref;
21493 }
21494
21495 uint32_t  __attribute__((export_name("TS_MessageSendEvent_broadcast_channel_update"))) TS_MessageSendEvent_broadcast_channel_update(uint32_t msg) {
21496         LDKChannelUpdate msg_conv;
21497         msg_conv.inner = (void*)(msg & (~1));
21498         msg_conv.is_owned = (msg & 1) || (msg == 0);
21499         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21500         msg_conv = ChannelUpdate_clone(&msg_conv);
21501         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21502         *ret_copy = MessageSendEvent_broadcast_channel_update(msg_conv);
21503         uint32_t ret_ref = (uintptr_t)ret_copy;
21504         return ret_ref;
21505 }
21506
21507 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_channel_update"))) TS_MessageSendEvent_send_channel_update(int8_tArray node_id, uint32_t msg) {
21508         LDKPublicKey node_id_ref;
21509         CHECK(node_id->arr_len == 33);
21510         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
21511         LDKChannelUpdate msg_conv;
21512         msg_conv.inner = (void*)(msg & (~1));
21513         msg_conv.is_owned = (msg & 1) || (msg == 0);
21514         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21515         msg_conv = ChannelUpdate_clone(&msg_conv);
21516         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21517         *ret_copy = MessageSendEvent_send_channel_update(node_id_ref, msg_conv);
21518         uint32_t ret_ref = (uintptr_t)ret_copy;
21519         return ret_ref;
21520 }
21521
21522 uint32_t  __attribute__((export_name("TS_MessageSendEvent_handle_error"))) TS_MessageSendEvent_handle_error(int8_tArray node_id, uint32_t action) {
21523         LDKPublicKey node_id_ref;
21524         CHECK(node_id->arr_len == 33);
21525         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
21526         void* action_ptr = (void*)(((uintptr_t)action) & ~1);
21527         CHECK_ACCESS(action_ptr);
21528         LDKErrorAction action_conv = *(LDKErrorAction*)(action_ptr);
21529         action_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)action) & ~1));
21530         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21531         *ret_copy = MessageSendEvent_handle_error(node_id_ref, action_conv);
21532         uint32_t ret_ref = (uintptr_t)ret_copy;
21533         return ret_ref;
21534 }
21535
21536 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_channel_range_query"))) TS_MessageSendEvent_send_channel_range_query(int8_tArray node_id, uint32_t msg) {
21537         LDKPublicKey node_id_ref;
21538         CHECK(node_id->arr_len == 33);
21539         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
21540         LDKQueryChannelRange msg_conv;
21541         msg_conv.inner = (void*)(msg & (~1));
21542         msg_conv.is_owned = (msg & 1) || (msg == 0);
21543         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21544         msg_conv = QueryChannelRange_clone(&msg_conv);
21545         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21546         *ret_copy = MessageSendEvent_send_channel_range_query(node_id_ref, msg_conv);
21547         uint32_t ret_ref = (uintptr_t)ret_copy;
21548         return ret_ref;
21549 }
21550
21551 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_short_ids_query"))) TS_MessageSendEvent_send_short_ids_query(int8_tArray node_id, uint32_t msg) {
21552         LDKPublicKey node_id_ref;
21553         CHECK(node_id->arr_len == 33);
21554         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
21555         LDKQueryShortChannelIds msg_conv;
21556         msg_conv.inner = (void*)(msg & (~1));
21557         msg_conv.is_owned = (msg & 1) || (msg == 0);
21558         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21559         msg_conv = QueryShortChannelIds_clone(&msg_conv);
21560         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21561         *ret_copy = MessageSendEvent_send_short_ids_query(node_id_ref, msg_conv);
21562         uint32_t ret_ref = (uintptr_t)ret_copy;
21563         return ret_ref;
21564 }
21565
21566 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_reply_channel_range"))) TS_MessageSendEvent_send_reply_channel_range(int8_tArray node_id, uint32_t msg) {
21567         LDKPublicKey node_id_ref;
21568         CHECK(node_id->arr_len == 33);
21569         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
21570         LDKReplyChannelRange msg_conv;
21571         msg_conv.inner = (void*)(msg & (~1));
21572         msg_conv.is_owned = (msg & 1) || (msg == 0);
21573         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21574         msg_conv = ReplyChannelRange_clone(&msg_conv);
21575         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21576         *ret_copy = MessageSendEvent_send_reply_channel_range(node_id_ref, msg_conv);
21577         uint32_t ret_ref = (uintptr_t)ret_copy;
21578         return ret_ref;
21579 }
21580
21581 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_gossip_timestamp_filter"))) TS_MessageSendEvent_send_gossip_timestamp_filter(int8_tArray node_id, uint32_t msg) {
21582         LDKPublicKey node_id_ref;
21583         CHECK(node_id->arr_len == 33);
21584         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
21585         LDKGossipTimestampFilter msg_conv;
21586         msg_conv.inner = (void*)(msg & (~1));
21587         msg_conv.is_owned = (msg & 1) || (msg == 0);
21588         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
21589         msg_conv = GossipTimestampFilter_clone(&msg_conv);
21590         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
21591         *ret_copy = MessageSendEvent_send_gossip_timestamp_filter(node_id_ref, msg_conv);
21592         uint32_t ret_ref = (uintptr_t)ret_copy;
21593         return ret_ref;
21594 }
21595
21596 void  __attribute__((export_name("TS_MessageSendEventsProvider_free"))) TS_MessageSendEventsProvider_free(uint32_t this_ptr) {
21597         if ((this_ptr & 1) != 0) return;
21598         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21599         CHECK_ACCESS(this_ptr_ptr);
21600         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(this_ptr_ptr);
21601         FREE((void*)this_ptr);
21602         MessageSendEventsProvider_free(this_ptr_conv);
21603 }
21604
21605 void  __attribute__((export_name("TS_EventsProvider_free"))) TS_EventsProvider_free(uint32_t this_ptr) {
21606         if ((this_ptr & 1) != 0) return;
21607         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21608         CHECK_ACCESS(this_ptr_ptr);
21609         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(this_ptr_ptr);
21610         FREE((void*)this_ptr);
21611         EventsProvider_free(this_ptr_conv);
21612 }
21613
21614 void  __attribute__((export_name("TS_EventHandler_free"))) TS_EventHandler_free(uint32_t this_ptr) {
21615         if ((this_ptr & 1) != 0) return;
21616         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21617         CHECK_ACCESS(this_ptr_ptr);
21618         LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(this_ptr_ptr);
21619         FREE((void*)this_ptr);
21620         EventHandler_free(this_ptr_conv);
21621 }
21622
21623 void  __attribute__((export_name("TS_APIError_free"))) TS_APIError_free(uint32_t this_ptr) {
21624         if ((this_ptr & 1) != 0) return;
21625         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21626         CHECK_ACCESS(this_ptr_ptr);
21627         LDKAPIError this_ptr_conv = *(LDKAPIError*)(this_ptr_ptr);
21628         FREE((void*)this_ptr);
21629         APIError_free(this_ptr_conv);
21630 }
21631
21632 static inline uintptr_t APIError_clone_ptr(LDKAPIError *NONNULL_PTR arg) {
21633         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
21634         *ret_copy = APIError_clone(arg);
21635 uint32_t ret_ref = (uintptr_t)ret_copy;
21636         return ret_ref;
21637 }
21638 uint32_t  __attribute__((export_name("TS_APIError_clone_ptr"))) TS_APIError_clone_ptr(uint32_t arg) {
21639         LDKAPIError* arg_conv = (LDKAPIError*)arg;
21640         uint32_t ret_conv = APIError_clone_ptr(arg_conv);
21641         return ret_conv;
21642 }
21643
21644 uint32_t  __attribute__((export_name("TS_APIError_clone"))) TS_APIError_clone(uint32_t orig) {
21645         LDKAPIError* orig_conv = (LDKAPIError*)orig;
21646         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
21647         *ret_copy = APIError_clone(orig_conv);
21648         uint32_t ret_ref = (uintptr_t)ret_copy;
21649         return ret_ref;
21650 }
21651
21652 uint32_t  __attribute__((export_name("TS_APIError_apimisuse_error"))) TS_APIError_apimisuse_error(jstring err) {
21653         LDKStr err_conv = str_ref_to_owned_c(err);
21654         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
21655         *ret_copy = APIError_apimisuse_error(err_conv);
21656         uint32_t ret_ref = (uintptr_t)ret_copy;
21657         return ret_ref;
21658 }
21659
21660 uint32_t  __attribute__((export_name("TS_APIError_fee_rate_too_high"))) TS_APIError_fee_rate_too_high(jstring err, int32_t feerate) {
21661         LDKStr err_conv = str_ref_to_owned_c(err);
21662         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
21663         *ret_copy = APIError_fee_rate_too_high(err_conv, feerate);
21664         uint32_t ret_ref = (uintptr_t)ret_copy;
21665         return ret_ref;
21666 }
21667
21668 uint32_t  __attribute__((export_name("TS_APIError_route_error"))) TS_APIError_route_error(jstring err) {
21669         LDKStr err_conv = str_ref_to_owned_c(err);
21670         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
21671         *ret_copy = APIError_route_error(err_conv);
21672         uint32_t ret_ref = (uintptr_t)ret_copy;
21673         return ret_ref;
21674 }
21675
21676 uint32_t  __attribute__((export_name("TS_APIError_channel_unavailable"))) TS_APIError_channel_unavailable(jstring err) {
21677         LDKStr err_conv = str_ref_to_owned_c(err);
21678         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
21679         *ret_copy = APIError_channel_unavailable(err_conv);
21680         uint32_t ret_ref = (uintptr_t)ret_copy;
21681         return ret_ref;
21682 }
21683
21684 uint32_t  __attribute__((export_name("TS_APIError_monitor_update_failed"))) TS_APIError_monitor_update_failed() {
21685         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
21686         *ret_copy = APIError_monitor_update_failed();
21687         uint32_t ret_ref = (uintptr_t)ret_copy;
21688         return ret_ref;
21689 }
21690
21691 uint32_t  __attribute__((export_name("TS_APIError_incompatible_shutdown_script"))) TS_APIError_incompatible_shutdown_script(uint32_t script) {
21692         LDKShutdownScript script_conv;
21693         script_conv.inner = (void*)(script & (~1));
21694         script_conv.is_owned = (script & 1) || (script == 0);
21695         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_conv);
21696         script_conv = ShutdownScript_clone(&script_conv);
21697         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
21698         *ret_copy = APIError_incompatible_shutdown_script(script_conv);
21699         uint32_t ret_ref = (uintptr_t)ret_copy;
21700         return ret_ref;
21701 }
21702
21703 void  __attribute__((export_name("TS_BigSize_free"))) TS_BigSize_free(uint32_t this_obj) {
21704         LDKBigSize this_obj_conv;
21705         this_obj_conv.inner = (void*)(this_obj & (~1));
21706         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21707         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21708         BigSize_free(this_obj_conv);
21709 }
21710
21711 int64_t  __attribute__((export_name("TS_BigSize_get_a"))) TS_BigSize_get_a(uint32_t this_ptr) {
21712         LDKBigSize this_ptr_conv;
21713         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21714         this_ptr_conv.is_owned = false;
21715         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21716         int64_t ret_conv = BigSize_get_a(&this_ptr_conv);
21717         return ret_conv;
21718 }
21719
21720 void  __attribute__((export_name("TS_BigSize_set_a"))) TS_BigSize_set_a(uint32_t this_ptr, int64_t val) {
21721         LDKBigSize this_ptr_conv;
21722         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21723         this_ptr_conv.is_owned = false;
21724         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21725         BigSize_set_a(&this_ptr_conv, val);
21726 }
21727
21728 uint32_t  __attribute__((export_name("TS_BigSize_new"))) TS_BigSize_new(int64_t a_arg) {
21729         LDKBigSize ret_var = BigSize_new(a_arg);
21730         uint32_t ret_ref = 0;
21731         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21732         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21733         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21734         ret_ref = (uintptr_t)ret_var.inner;
21735         if (ret_var.is_owned) {
21736                 ret_ref |= 1;
21737         }
21738         return ret_ref;
21739 }
21740
21741 void  __attribute__((export_name("TS_Hostname_free"))) TS_Hostname_free(uint32_t this_obj) {
21742         LDKHostname this_obj_conv;
21743         this_obj_conv.inner = (void*)(this_obj & (~1));
21744         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21745         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21746         Hostname_free(this_obj_conv);
21747 }
21748
21749 static inline uintptr_t Hostname_clone_ptr(LDKHostname *NONNULL_PTR arg) {
21750         LDKHostname ret_var = Hostname_clone(arg);
21751 uint32_t ret_ref = 0;
21752 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21753 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21754 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21755 ret_ref = (uintptr_t)ret_var.inner;
21756 if (ret_var.is_owned) {
21757         ret_ref |= 1;
21758 }
21759         return ret_ref;
21760 }
21761 uint32_t  __attribute__((export_name("TS_Hostname_clone_ptr"))) TS_Hostname_clone_ptr(uint32_t arg) {
21762         LDKHostname arg_conv;
21763         arg_conv.inner = (void*)(arg & (~1));
21764         arg_conv.is_owned = false;
21765         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21766         uint32_t ret_conv = Hostname_clone_ptr(&arg_conv);
21767         return ret_conv;
21768 }
21769
21770 uint32_t  __attribute__((export_name("TS_Hostname_clone"))) TS_Hostname_clone(uint32_t orig) {
21771         LDKHostname orig_conv;
21772         orig_conv.inner = (void*)(orig & (~1));
21773         orig_conv.is_owned = false;
21774         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21775         LDKHostname ret_var = Hostname_clone(&orig_conv);
21776         uint32_t ret_ref = 0;
21777         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21778         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21779         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21780         ret_ref = (uintptr_t)ret_var.inner;
21781         if (ret_var.is_owned) {
21782                 ret_ref |= 1;
21783         }
21784         return ret_ref;
21785 }
21786
21787 int8_t  __attribute__((export_name("TS_Hostname_len"))) TS_Hostname_len(uint32_t this_arg) {
21788         LDKHostname this_arg_conv;
21789         this_arg_conv.inner = (void*)(this_arg & (~1));
21790         this_arg_conv.is_owned = false;
21791         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21792         int8_t ret_conv = Hostname_len(&this_arg_conv);
21793         return ret_conv;
21794 }
21795
21796 uint32_t  __attribute__((export_name("TS_sign"))) TS_sign(int8_tArray msg, int8_tArray sk) {
21797         LDKu8slice msg_ref;
21798         msg_ref.datalen = msg->arr_len;
21799         msg_ref.data = msg->elems;
21800         unsigned char sk_arr[32];
21801         CHECK(sk->arr_len == 32);
21802         memcpy(sk_arr, sk->elems, 32); FREE(sk);
21803         unsigned char (*sk_ref)[32] = &sk_arr;
21804         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
21805         *ret_conv = sign(msg_ref, sk_ref);
21806         FREE(msg);
21807         return (uint32_t)ret_conv;
21808 }
21809
21810 uint32_t  __attribute__((export_name("TS_recover_pk"))) TS_recover_pk(int8_tArray msg, jstring sig) {
21811         LDKu8slice msg_ref;
21812         msg_ref.datalen = msg->arr_len;
21813         msg_ref.data = msg->elems;
21814         LDKStr sig_conv = str_ref_to_owned_c(sig);
21815         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
21816         *ret_conv = recover_pk(msg_ref, sig_conv);
21817         FREE(msg);
21818         return (uint32_t)ret_conv;
21819 }
21820
21821 jboolean  __attribute__((export_name("TS_verify"))) TS_verify(int8_tArray msg, jstring sig, int8_tArray pk) {
21822         LDKu8slice msg_ref;
21823         msg_ref.datalen = msg->arr_len;
21824         msg_ref.data = msg->elems;
21825         LDKStr sig_conv = str_ref_to_owned_c(sig);
21826         LDKPublicKey pk_ref;
21827         CHECK(pk->arr_len == 33);
21828         memcpy(pk_ref.compressed_form, pk->elems, 33); FREE(pk);
21829         jboolean ret_conv = verify(msg_ref, sig_conv, pk_ref);
21830         FREE(msg);
21831         return ret_conv;
21832 }
21833
21834 int8_tArray  __attribute__((export_name("TS_construct_invoice_preimage"))) TS_construct_invoice_preimage(int8_tArray hrp_bytes, ptrArray data_without_signature) {
21835         LDKu8slice hrp_bytes_ref;
21836         hrp_bytes_ref.datalen = hrp_bytes->arr_len;
21837         hrp_bytes_ref.data = hrp_bytes->elems;
21838         LDKCVec_u5Z data_without_signature_constr;
21839         data_without_signature_constr.datalen = data_without_signature->arr_len;
21840         if (data_without_signature_constr.datalen > 0)
21841                 data_without_signature_constr.data = MALLOC(data_without_signature_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
21842         else
21843                 data_without_signature_constr.data = NULL;
21844         int8_t* data_without_signature_vals = (void*) data_without_signature->elems;
21845         for (size_t h = 0; h < data_without_signature_constr.datalen; h++) {
21846                 int8_t data_without_signature_conv_7 = data_without_signature_vals[h];
21847                 
21848                 data_without_signature_constr.data[h] = (LDKu5){ ._0 = data_without_signature_conv_7 };
21849         }
21850         FREE(data_without_signature);
21851         LDKCVec_u8Z ret_var = construct_invoice_preimage(hrp_bytes_ref, data_without_signature_constr);
21852         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
21853         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
21854         CVec_u8Z_free(ret_var);
21855         FREE(hrp_bytes);
21856         return ret_arr;
21857 }
21858
21859 void  __attribute__((export_name("TS_Persister_free"))) TS_Persister_free(uint32_t this_ptr) {
21860         if ((this_ptr & 1) != 0) return;
21861         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21862         CHECK_ACCESS(this_ptr_ptr);
21863         LDKPersister this_ptr_conv = *(LDKPersister*)(this_ptr_ptr);
21864         FREE((void*)this_ptr);
21865         Persister_free(this_ptr_conv);
21866 }
21867
21868 uint32_t  __attribute__((export_name("TS_Level_clone"))) TS_Level_clone(uint32_t orig) {
21869         LDKLevel* orig_conv = (LDKLevel*)(orig & ~1);
21870         uint32_t ret_conv = LDKLevel_to_js(Level_clone(orig_conv));
21871         return ret_conv;
21872 }
21873
21874 uint32_t  __attribute__((export_name("TS_Level_gossip"))) TS_Level_gossip() {
21875         uint32_t ret_conv = LDKLevel_to_js(Level_gossip());
21876         return ret_conv;
21877 }
21878
21879 uint32_t  __attribute__((export_name("TS_Level_trace"))) TS_Level_trace() {
21880         uint32_t ret_conv = LDKLevel_to_js(Level_trace());
21881         return ret_conv;
21882 }
21883
21884 uint32_t  __attribute__((export_name("TS_Level_debug"))) TS_Level_debug() {
21885         uint32_t ret_conv = LDKLevel_to_js(Level_debug());
21886         return ret_conv;
21887 }
21888
21889 uint32_t  __attribute__((export_name("TS_Level_info"))) TS_Level_info() {
21890         uint32_t ret_conv = LDKLevel_to_js(Level_info());
21891         return ret_conv;
21892 }
21893
21894 uint32_t  __attribute__((export_name("TS_Level_warn"))) TS_Level_warn() {
21895         uint32_t ret_conv = LDKLevel_to_js(Level_warn());
21896         return ret_conv;
21897 }
21898
21899 uint32_t  __attribute__((export_name("TS_Level_error"))) TS_Level_error() {
21900         uint32_t ret_conv = LDKLevel_to_js(Level_error());
21901         return ret_conv;
21902 }
21903
21904 jboolean  __attribute__((export_name("TS_Level_eq"))) TS_Level_eq(uint32_t a, uint32_t b) {
21905         LDKLevel* a_conv = (LDKLevel*)(a & ~1);
21906         LDKLevel* b_conv = (LDKLevel*)(b & ~1);
21907         jboolean ret_conv = Level_eq(a_conv, b_conv);
21908         return ret_conv;
21909 }
21910
21911 int64_t  __attribute__((export_name("TS_Level_hash"))) TS_Level_hash(uint32_t o) {
21912         LDKLevel* o_conv = (LDKLevel*)(o & ~1);
21913         int64_t ret_conv = Level_hash(o_conv);
21914         return ret_conv;
21915 }
21916
21917 uint32_t  __attribute__((export_name("TS_Level_max"))) TS_Level_max() {
21918         uint32_t ret_conv = LDKLevel_to_js(Level_max());
21919         return ret_conv;
21920 }
21921
21922 void  __attribute__((export_name("TS_Record_free"))) TS_Record_free(uint32_t this_obj) {
21923         LDKRecord this_obj_conv;
21924         this_obj_conv.inner = (void*)(this_obj & (~1));
21925         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21926         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21927         Record_free(this_obj_conv);
21928 }
21929
21930 uint32_t  __attribute__((export_name("TS_Record_get_level"))) TS_Record_get_level(uint32_t this_ptr) {
21931         LDKRecord this_ptr_conv;
21932         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21933         this_ptr_conv.is_owned = false;
21934         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21935         uint32_t ret_conv = LDKLevel_to_js(Record_get_level(&this_ptr_conv));
21936         return ret_conv;
21937 }
21938
21939 void  __attribute__((export_name("TS_Record_set_level"))) TS_Record_set_level(uint32_t this_ptr, uint32_t val) {
21940         LDKRecord this_ptr_conv;
21941         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21942         this_ptr_conv.is_owned = false;
21943         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21944         LDKLevel val_conv = LDKLevel_from_js(val);
21945         Record_set_level(&this_ptr_conv, val_conv);
21946 }
21947
21948 jstring  __attribute__((export_name("TS_Record_get_args"))) TS_Record_get_args(uint32_t this_ptr) {
21949         LDKRecord this_ptr_conv;
21950         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21951         this_ptr_conv.is_owned = false;
21952         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21953         LDKStr ret_str = Record_get_args(&this_ptr_conv);
21954         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
21955         Str_free(ret_str);
21956         return ret_conv;
21957 }
21958
21959 void  __attribute__((export_name("TS_Record_set_args"))) TS_Record_set_args(uint32_t this_ptr, jstring val) {
21960         LDKRecord this_ptr_conv;
21961         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21962         this_ptr_conv.is_owned = false;
21963         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21964         LDKStr val_conv = str_ref_to_owned_c(val);
21965         Record_set_args(&this_ptr_conv, val_conv);
21966 }
21967
21968 jstring  __attribute__((export_name("TS_Record_get_module_path"))) TS_Record_get_module_path(uint32_t this_ptr) {
21969         LDKRecord this_ptr_conv;
21970         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21971         this_ptr_conv.is_owned = false;
21972         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21973         LDKStr ret_str = Record_get_module_path(&this_ptr_conv);
21974         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
21975         Str_free(ret_str);
21976         return ret_conv;
21977 }
21978
21979 void  __attribute__((export_name("TS_Record_set_module_path"))) TS_Record_set_module_path(uint32_t this_ptr, jstring val) {
21980         LDKRecord this_ptr_conv;
21981         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21982         this_ptr_conv.is_owned = false;
21983         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21984         LDKStr val_conv = str_ref_to_owned_c(val);
21985         Record_set_module_path(&this_ptr_conv, val_conv);
21986 }
21987
21988 jstring  __attribute__((export_name("TS_Record_get_file"))) TS_Record_get_file(uint32_t this_ptr) {
21989         LDKRecord this_ptr_conv;
21990         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21991         this_ptr_conv.is_owned = false;
21992         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21993         LDKStr ret_str = Record_get_file(&this_ptr_conv);
21994         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
21995         Str_free(ret_str);
21996         return ret_conv;
21997 }
21998
21999 void  __attribute__((export_name("TS_Record_set_file"))) TS_Record_set_file(uint32_t this_ptr, jstring val) {
22000         LDKRecord this_ptr_conv;
22001         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22002         this_ptr_conv.is_owned = false;
22003         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22004         LDKStr val_conv = str_ref_to_owned_c(val);
22005         Record_set_file(&this_ptr_conv, val_conv);
22006 }
22007
22008 int32_t  __attribute__((export_name("TS_Record_get_line"))) TS_Record_get_line(uint32_t this_ptr) {
22009         LDKRecord this_ptr_conv;
22010         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22011         this_ptr_conv.is_owned = false;
22012         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22013         int32_t ret_conv = Record_get_line(&this_ptr_conv);
22014         return ret_conv;
22015 }
22016
22017 void  __attribute__((export_name("TS_Record_set_line"))) TS_Record_set_line(uint32_t this_ptr, int32_t val) {
22018         LDKRecord this_ptr_conv;
22019         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22020         this_ptr_conv.is_owned = false;
22021         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22022         Record_set_line(&this_ptr_conv, val);
22023 }
22024
22025 static inline uintptr_t Record_clone_ptr(LDKRecord *NONNULL_PTR arg) {
22026         LDKRecord ret_var = Record_clone(arg);
22027 uint32_t ret_ref = 0;
22028 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22029 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22030 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22031 ret_ref = (uintptr_t)ret_var.inner;
22032 if (ret_var.is_owned) {
22033         ret_ref |= 1;
22034 }
22035         return ret_ref;
22036 }
22037 uint32_t  __attribute__((export_name("TS_Record_clone_ptr"))) TS_Record_clone_ptr(uint32_t arg) {
22038         LDKRecord arg_conv;
22039         arg_conv.inner = (void*)(arg & (~1));
22040         arg_conv.is_owned = false;
22041         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22042         uint32_t ret_conv = Record_clone_ptr(&arg_conv);
22043         return ret_conv;
22044 }
22045
22046 uint32_t  __attribute__((export_name("TS_Record_clone"))) TS_Record_clone(uint32_t orig) {
22047         LDKRecord orig_conv;
22048         orig_conv.inner = (void*)(orig & (~1));
22049         orig_conv.is_owned = false;
22050         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22051         LDKRecord ret_var = Record_clone(&orig_conv);
22052         uint32_t ret_ref = 0;
22053         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22054         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22055         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22056         ret_ref = (uintptr_t)ret_var.inner;
22057         if (ret_var.is_owned) {
22058                 ret_ref |= 1;
22059         }
22060         return ret_ref;
22061 }
22062
22063 void  __attribute__((export_name("TS_Logger_free"))) TS_Logger_free(uint32_t this_ptr) {
22064         if ((this_ptr & 1) != 0) return;
22065         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
22066         CHECK_ACCESS(this_ptr_ptr);
22067         LDKLogger this_ptr_conv = *(LDKLogger*)(this_ptr_ptr);
22068         FREE((void*)this_ptr);
22069         Logger_free(this_ptr_conv);
22070 }
22071
22072 void  __attribute__((export_name("TS_ChannelHandshakeConfig_free"))) TS_ChannelHandshakeConfig_free(uint32_t this_obj) {
22073         LDKChannelHandshakeConfig this_obj_conv;
22074         this_obj_conv.inner = (void*)(this_obj & (~1));
22075         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22076         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22077         ChannelHandshakeConfig_free(this_obj_conv);
22078 }
22079
22080 int32_t  __attribute__((export_name("TS_ChannelHandshakeConfig_get_minimum_depth"))) TS_ChannelHandshakeConfig_get_minimum_depth(uint32_t this_ptr) {
22081         LDKChannelHandshakeConfig this_ptr_conv;
22082         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22083         this_ptr_conv.is_owned = false;
22084         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22085         int32_t ret_conv = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
22086         return ret_conv;
22087 }
22088
22089 void  __attribute__((export_name("TS_ChannelHandshakeConfig_set_minimum_depth"))) TS_ChannelHandshakeConfig_set_minimum_depth(uint32_t this_ptr, int32_t val) {
22090         LDKChannelHandshakeConfig this_ptr_conv;
22091         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22092         this_ptr_conv.is_owned = false;
22093         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22094         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
22095 }
22096
22097 int16_t  __attribute__((export_name("TS_ChannelHandshakeConfig_get_our_to_self_delay"))) TS_ChannelHandshakeConfig_get_our_to_self_delay(uint32_t this_ptr) {
22098         LDKChannelHandshakeConfig this_ptr_conv;
22099         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22100         this_ptr_conv.is_owned = false;
22101         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22102         int16_t ret_conv = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
22103         return ret_conv;
22104 }
22105
22106 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) {
22107         LDKChannelHandshakeConfig this_ptr_conv;
22108         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22109         this_ptr_conv.is_owned = false;
22110         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22111         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
22112 }
22113
22114 int64_t  __attribute__((export_name("TS_ChannelHandshakeConfig_get_our_htlc_minimum_msat"))) TS_ChannelHandshakeConfig_get_our_htlc_minimum_msat(uint32_t this_ptr) {
22115         LDKChannelHandshakeConfig this_ptr_conv;
22116         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22117         this_ptr_conv.is_owned = false;
22118         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22119         int64_t ret_conv = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
22120         return ret_conv;
22121 }
22122
22123 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) {
22124         LDKChannelHandshakeConfig this_ptr_conv;
22125         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22126         this_ptr_conv.is_owned = false;
22127         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22128         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
22129 }
22130
22131 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) {
22132         LDKChannelHandshakeConfig this_ptr_conv;
22133         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22134         this_ptr_conv.is_owned = false;
22135         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22136         int8_t ret_conv = ChannelHandshakeConfig_get_max_inbound_htlc_value_in_flight_percent_of_channel(&this_ptr_conv);
22137         return ret_conv;
22138 }
22139
22140 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) {
22141         LDKChannelHandshakeConfig this_ptr_conv;
22142         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22143         this_ptr_conv.is_owned = false;
22144         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22145         ChannelHandshakeConfig_set_max_inbound_htlc_value_in_flight_percent_of_channel(&this_ptr_conv, val);
22146 }
22147
22148 jboolean  __attribute__((export_name("TS_ChannelHandshakeConfig_get_negotiate_scid_privacy"))) TS_ChannelHandshakeConfig_get_negotiate_scid_privacy(uint32_t this_ptr) {
22149         LDKChannelHandshakeConfig this_ptr_conv;
22150         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22151         this_ptr_conv.is_owned = false;
22152         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22153         jboolean ret_conv = ChannelHandshakeConfig_get_negotiate_scid_privacy(&this_ptr_conv);
22154         return ret_conv;
22155 }
22156
22157 void  __attribute__((export_name("TS_ChannelHandshakeConfig_set_negotiate_scid_privacy"))) TS_ChannelHandshakeConfig_set_negotiate_scid_privacy(uint32_t this_ptr, jboolean val) {
22158         LDKChannelHandshakeConfig this_ptr_conv;
22159         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22160         this_ptr_conv.is_owned = false;
22161         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22162         ChannelHandshakeConfig_set_negotiate_scid_privacy(&this_ptr_conv, val);
22163 }
22164
22165 jboolean  __attribute__((export_name("TS_ChannelHandshakeConfig_get_announced_channel"))) TS_ChannelHandshakeConfig_get_announced_channel(uint32_t this_ptr) {
22166         LDKChannelHandshakeConfig this_ptr_conv;
22167         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22168         this_ptr_conv.is_owned = false;
22169         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22170         jboolean ret_conv = ChannelHandshakeConfig_get_announced_channel(&this_ptr_conv);
22171         return ret_conv;
22172 }
22173
22174 void  __attribute__((export_name("TS_ChannelHandshakeConfig_set_announced_channel"))) TS_ChannelHandshakeConfig_set_announced_channel(uint32_t this_ptr, jboolean val) {
22175         LDKChannelHandshakeConfig this_ptr_conv;
22176         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22177         this_ptr_conv.is_owned = false;
22178         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22179         ChannelHandshakeConfig_set_announced_channel(&this_ptr_conv, val);
22180 }
22181
22182 jboolean  __attribute__((export_name("TS_ChannelHandshakeConfig_get_commit_upfront_shutdown_pubkey"))) TS_ChannelHandshakeConfig_get_commit_upfront_shutdown_pubkey(uint32_t this_ptr) {
22183         LDKChannelHandshakeConfig this_ptr_conv;
22184         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22185         this_ptr_conv.is_owned = false;
22186         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22187         jboolean ret_conv = ChannelHandshakeConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
22188         return ret_conv;
22189 }
22190
22191 void  __attribute__((export_name("TS_ChannelHandshakeConfig_set_commit_upfront_shutdown_pubkey"))) TS_ChannelHandshakeConfig_set_commit_upfront_shutdown_pubkey(uint32_t this_ptr, jboolean val) {
22192         LDKChannelHandshakeConfig this_ptr_conv;
22193         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22194         this_ptr_conv.is_owned = false;
22195         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22196         ChannelHandshakeConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
22197 }
22198
22199 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) {
22200         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);
22201         uint32_t ret_ref = 0;
22202         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22203         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22204         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22205         ret_ref = (uintptr_t)ret_var.inner;
22206         if (ret_var.is_owned) {
22207                 ret_ref |= 1;
22208         }
22209         return ret_ref;
22210 }
22211
22212 static inline uintptr_t ChannelHandshakeConfig_clone_ptr(LDKChannelHandshakeConfig *NONNULL_PTR arg) {
22213         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(arg);
22214 uint32_t ret_ref = 0;
22215 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22216 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22217 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22218 ret_ref = (uintptr_t)ret_var.inner;
22219 if (ret_var.is_owned) {
22220         ret_ref |= 1;
22221 }
22222         return ret_ref;
22223 }
22224 uint32_t  __attribute__((export_name("TS_ChannelHandshakeConfig_clone_ptr"))) TS_ChannelHandshakeConfig_clone_ptr(uint32_t arg) {
22225         LDKChannelHandshakeConfig arg_conv;
22226         arg_conv.inner = (void*)(arg & (~1));
22227         arg_conv.is_owned = false;
22228         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22229         uint32_t ret_conv = ChannelHandshakeConfig_clone_ptr(&arg_conv);
22230         return ret_conv;
22231 }
22232
22233 uint32_t  __attribute__((export_name("TS_ChannelHandshakeConfig_clone"))) TS_ChannelHandshakeConfig_clone(uint32_t orig) {
22234         LDKChannelHandshakeConfig orig_conv;
22235         orig_conv.inner = (void*)(orig & (~1));
22236         orig_conv.is_owned = false;
22237         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22238         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
22239         uint32_t ret_ref = 0;
22240         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22241         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22242         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22243         ret_ref = (uintptr_t)ret_var.inner;
22244         if (ret_var.is_owned) {
22245                 ret_ref |= 1;
22246         }
22247         return ret_ref;
22248 }
22249
22250 uint32_t  __attribute__((export_name("TS_ChannelHandshakeConfig_default"))) TS_ChannelHandshakeConfig_default() {
22251         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
22252         uint32_t ret_ref = 0;
22253         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22254         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22255         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22256         ret_ref = (uintptr_t)ret_var.inner;
22257         if (ret_var.is_owned) {
22258                 ret_ref |= 1;
22259         }
22260         return ret_ref;
22261 }
22262
22263 void  __attribute__((export_name("TS_ChannelHandshakeLimits_free"))) TS_ChannelHandshakeLimits_free(uint32_t this_obj) {
22264         LDKChannelHandshakeLimits this_obj_conv;
22265         this_obj_conv.inner = (void*)(this_obj & (~1));
22266         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22267         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22268         ChannelHandshakeLimits_free(this_obj_conv);
22269 }
22270
22271 int64_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_min_funding_satoshis"))) TS_ChannelHandshakeLimits_get_min_funding_satoshis(uint32_t this_ptr) {
22272         LDKChannelHandshakeLimits this_ptr_conv;
22273         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22274         this_ptr_conv.is_owned = false;
22275         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22276         int64_t ret_conv = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
22277         return ret_conv;
22278 }
22279
22280 void  __attribute__((export_name("TS_ChannelHandshakeLimits_set_min_funding_satoshis"))) TS_ChannelHandshakeLimits_set_min_funding_satoshis(uint32_t this_ptr, int64_t val) {
22281         LDKChannelHandshakeLimits this_ptr_conv;
22282         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22283         this_ptr_conv.is_owned = false;
22284         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22285         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
22286 }
22287
22288 int64_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_max_funding_satoshis"))) TS_ChannelHandshakeLimits_get_max_funding_satoshis(uint32_t this_ptr) {
22289         LDKChannelHandshakeLimits this_ptr_conv;
22290         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22291         this_ptr_conv.is_owned = false;
22292         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22293         int64_t ret_conv = ChannelHandshakeLimits_get_max_funding_satoshis(&this_ptr_conv);
22294         return ret_conv;
22295 }
22296
22297 void  __attribute__((export_name("TS_ChannelHandshakeLimits_set_max_funding_satoshis"))) TS_ChannelHandshakeLimits_set_max_funding_satoshis(uint32_t this_ptr, int64_t val) {
22298         LDKChannelHandshakeLimits this_ptr_conv;
22299         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22300         this_ptr_conv.is_owned = false;
22301         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22302         ChannelHandshakeLimits_set_max_funding_satoshis(&this_ptr_conv, val);
22303 }
22304
22305 int64_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_max_htlc_minimum_msat"))) TS_ChannelHandshakeLimits_get_max_htlc_minimum_msat(uint32_t this_ptr) {
22306         LDKChannelHandshakeLimits this_ptr_conv;
22307         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22308         this_ptr_conv.is_owned = false;
22309         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22310         int64_t ret_conv = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
22311         return ret_conv;
22312 }
22313
22314 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) {
22315         LDKChannelHandshakeLimits this_ptr_conv;
22316         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22317         this_ptr_conv.is_owned = false;
22318         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22319         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
22320 }
22321
22322 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) {
22323         LDKChannelHandshakeLimits this_ptr_conv;
22324         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22325         this_ptr_conv.is_owned = false;
22326         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22327         int64_t ret_conv = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
22328         return ret_conv;
22329 }
22330
22331 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) {
22332         LDKChannelHandshakeLimits this_ptr_conv;
22333         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22334         this_ptr_conv.is_owned = false;
22335         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22336         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
22337 }
22338
22339 int64_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_max_channel_reserve_satoshis"))) TS_ChannelHandshakeLimits_get_max_channel_reserve_satoshis(uint32_t this_ptr) {
22340         LDKChannelHandshakeLimits this_ptr_conv;
22341         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22342         this_ptr_conv.is_owned = false;
22343         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22344         int64_t ret_conv = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
22345         return ret_conv;
22346 }
22347
22348 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) {
22349         LDKChannelHandshakeLimits this_ptr_conv;
22350         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22351         this_ptr_conv.is_owned = false;
22352         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22353         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
22354 }
22355
22356 int16_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_min_max_accepted_htlcs"))) TS_ChannelHandshakeLimits_get_min_max_accepted_htlcs(uint32_t this_ptr) {
22357         LDKChannelHandshakeLimits this_ptr_conv;
22358         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22359         this_ptr_conv.is_owned = false;
22360         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22361         int16_t ret_conv = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
22362         return ret_conv;
22363 }
22364
22365 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) {
22366         LDKChannelHandshakeLimits this_ptr_conv;
22367         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22368         this_ptr_conv.is_owned = false;
22369         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22370         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
22371 }
22372
22373 int32_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_max_minimum_depth"))) TS_ChannelHandshakeLimits_get_max_minimum_depth(uint32_t this_ptr) {
22374         LDKChannelHandshakeLimits this_ptr_conv;
22375         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22376         this_ptr_conv.is_owned = false;
22377         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22378         int32_t ret_conv = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
22379         return ret_conv;
22380 }
22381
22382 void  __attribute__((export_name("TS_ChannelHandshakeLimits_set_max_minimum_depth"))) TS_ChannelHandshakeLimits_set_max_minimum_depth(uint32_t this_ptr, int32_t val) {
22383         LDKChannelHandshakeLimits this_ptr_conv;
22384         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22385         this_ptr_conv.is_owned = false;
22386         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22387         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
22388 }
22389
22390 jboolean  __attribute__((export_name("TS_ChannelHandshakeLimits_get_trust_own_funding_0conf"))) TS_ChannelHandshakeLimits_get_trust_own_funding_0conf(uint32_t this_ptr) {
22391         LDKChannelHandshakeLimits this_ptr_conv;
22392         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22393         this_ptr_conv.is_owned = false;
22394         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22395         jboolean ret_conv = ChannelHandshakeLimits_get_trust_own_funding_0conf(&this_ptr_conv);
22396         return ret_conv;
22397 }
22398
22399 void  __attribute__((export_name("TS_ChannelHandshakeLimits_set_trust_own_funding_0conf"))) TS_ChannelHandshakeLimits_set_trust_own_funding_0conf(uint32_t this_ptr, jboolean val) {
22400         LDKChannelHandshakeLimits this_ptr_conv;
22401         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22402         this_ptr_conv.is_owned = false;
22403         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22404         ChannelHandshakeLimits_set_trust_own_funding_0conf(&this_ptr_conv, val);
22405 }
22406
22407 jboolean  __attribute__((export_name("TS_ChannelHandshakeLimits_get_force_announced_channel_preference"))) TS_ChannelHandshakeLimits_get_force_announced_channel_preference(uint32_t this_ptr) {
22408         LDKChannelHandshakeLimits this_ptr_conv;
22409         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22410         this_ptr_conv.is_owned = false;
22411         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22412         jboolean ret_conv = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
22413         return ret_conv;
22414 }
22415
22416 void  __attribute__((export_name("TS_ChannelHandshakeLimits_set_force_announced_channel_preference"))) TS_ChannelHandshakeLimits_set_force_announced_channel_preference(uint32_t this_ptr, jboolean val) {
22417         LDKChannelHandshakeLimits this_ptr_conv;
22418         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22419         this_ptr_conv.is_owned = false;
22420         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22421         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
22422 }
22423
22424 int16_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_their_to_self_delay"))) TS_ChannelHandshakeLimits_get_their_to_self_delay(uint32_t this_ptr) {
22425         LDKChannelHandshakeLimits this_ptr_conv;
22426         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22427         this_ptr_conv.is_owned = false;
22428         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22429         int16_t ret_conv = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
22430         return ret_conv;
22431 }
22432
22433 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) {
22434         LDKChannelHandshakeLimits this_ptr_conv;
22435         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22436         this_ptr_conv.is_owned = false;
22437         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22438         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
22439 }
22440
22441 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) {
22442         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);
22443         uint32_t ret_ref = 0;
22444         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22445         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22446         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22447         ret_ref = (uintptr_t)ret_var.inner;
22448         if (ret_var.is_owned) {
22449                 ret_ref |= 1;
22450         }
22451         return ret_ref;
22452 }
22453
22454 static inline uintptr_t ChannelHandshakeLimits_clone_ptr(LDKChannelHandshakeLimits *NONNULL_PTR arg) {
22455         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(arg);
22456 uint32_t ret_ref = 0;
22457 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22458 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22459 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22460 ret_ref = (uintptr_t)ret_var.inner;
22461 if (ret_var.is_owned) {
22462         ret_ref |= 1;
22463 }
22464         return ret_ref;
22465 }
22466 uint32_t  __attribute__((export_name("TS_ChannelHandshakeLimits_clone_ptr"))) TS_ChannelHandshakeLimits_clone_ptr(uint32_t arg) {
22467         LDKChannelHandshakeLimits arg_conv;
22468         arg_conv.inner = (void*)(arg & (~1));
22469         arg_conv.is_owned = false;
22470         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22471         uint32_t ret_conv = ChannelHandshakeLimits_clone_ptr(&arg_conv);
22472         return ret_conv;
22473 }
22474
22475 uint32_t  __attribute__((export_name("TS_ChannelHandshakeLimits_clone"))) TS_ChannelHandshakeLimits_clone(uint32_t orig) {
22476         LDKChannelHandshakeLimits orig_conv;
22477         orig_conv.inner = (void*)(orig & (~1));
22478         orig_conv.is_owned = false;
22479         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22480         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
22481         uint32_t ret_ref = 0;
22482         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22483         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22484         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22485         ret_ref = (uintptr_t)ret_var.inner;
22486         if (ret_var.is_owned) {
22487                 ret_ref |= 1;
22488         }
22489         return ret_ref;
22490 }
22491
22492 uint32_t  __attribute__((export_name("TS_ChannelHandshakeLimits_default"))) TS_ChannelHandshakeLimits_default() {
22493         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
22494         uint32_t ret_ref = 0;
22495         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22496         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22497         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22498         ret_ref = (uintptr_t)ret_var.inner;
22499         if (ret_var.is_owned) {
22500                 ret_ref |= 1;
22501         }
22502         return ret_ref;
22503 }
22504
22505 void  __attribute__((export_name("TS_ChannelConfig_free"))) TS_ChannelConfig_free(uint32_t this_obj) {
22506         LDKChannelConfig this_obj_conv;
22507         this_obj_conv.inner = (void*)(this_obj & (~1));
22508         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22509         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22510         ChannelConfig_free(this_obj_conv);
22511 }
22512
22513 int32_t  __attribute__((export_name("TS_ChannelConfig_get_forwarding_fee_proportional_millionths"))) TS_ChannelConfig_get_forwarding_fee_proportional_millionths(uint32_t this_ptr) {
22514         LDKChannelConfig this_ptr_conv;
22515         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22516         this_ptr_conv.is_owned = false;
22517         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22518         int32_t ret_conv = ChannelConfig_get_forwarding_fee_proportional_millionths(&this_ptr_conv);
22519         return ret_conv;
22520 }
22521
22522 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) {
22523         LDKChannelConfig this_ptr_conv;
22524         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22525         this_ptr_conv.is_owned = false;
22526         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22527         ChannelConfig_set_forwarding_fee_proportional_millionths(&this_ptr_conv, val);
22528 }
22529
22530 int32_t  __attribute__((export_name("TS_ChannelConfig_get_forwarding_fee_base_msat"))) TS_ChannelConfig_get_forwarding_fee_base_msat(uint32_t this_ptr) {
22531         LDKChannelConfig this_ptr_conv;
22532         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22533         this_ptr_conv.is_owned = false;
22534         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22535         int32_t ret_conv = ChannelConfig_get_forwarding_fee_base_msat(&this_ptr_conv);
22536         return ret_conv;
22537 }
22538
22539 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) {
22540         LDKChannelConfig this_ptr_conv;
22541         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22542         this_ptr_conv.is_owned = false;
22543         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22544         ChannelConfig_set_forwarding_fee_base_msat(&this_ptr_conv, val);
22545 }
22546
22547 int16_t  __attribute__((export_name("TS_ChannelConfig_get_cltv_expiry_delta"))) TS_ChannelConfig_get_cltv_expiry_delta(uint32_t this_ptr) {
22548         LDKChannelConfig this_ptr_conv;
22549         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22550         this_ptr_conv.is_owned = false;
22551         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22552         int16_t ret_conv = ChannelConfig_get_cltv_expiry_delta(&this_ptr_conv);
22553         return ret_conv;
22554 }
22555
22556 void  __attribute__((export_name("TS_ChannelConfig_set_cltv_expiry_delta"))) TS_ChannelConfig_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
22557         LDKChannelConfig this_ptr_conv;
22558         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22559         this_ptr_conv.is_owned = false;
22560         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22561         ChannelConfig_set_cltv_expiry_delta(&this_ptr_conv, val);
22562 }
22563
22564 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) {
22565         LDKChannelConfig this_ptr_conv;
22566         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22567         this_ptr_conv.is_owned = false;
22568         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22569         int64_t ret_conv = ChannelConfig_get_max_dust_htlc_exposure_msat(&this_ptr_conv);
22570         return ret_conv;
22571 }
22572
22573 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) {
22574         LDKChannelConfig this_ptr_conv;
22575         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22576         this_ptr_conv.is_owned = false;
22577         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22578         ChannelConfig_set_max_dust_htlc_exposure_msat(&this_ptr_conv, val);
22579 }
22580
22581 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) {
22582         LDKChannelConfig this_ptr_conv;
22583         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22584         this_ptr_conv.is_owned = false;
22585         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22586         int64_t ret_conv = ChannelConfig_get_force_close_avoidance_max_fee_satoshis(&this_ptr_conv);
22587         return ret_conv;
22588 }
22589
22590 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) {
22591         LDKChannelConfig this_ptr_conv;
22592         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22593         this_ptr_conv.is_owned = false;
22594         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22595         ChannelConfig_set_force_close_avoidance_max_fee_satoshis(&this_ptr_conv, val);
22596 }
22597
22598 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) {
22599         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);
22600         uint32_t ret_ref = 0;
22601         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22602         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22603         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22604         ret_ref = (uintptr_t)ret_var.inner;
22605         if (ret_var.is_owned) {
22606                 ret_ref |= 1;
22607         }
22608         return ret_ref;
22609 }
22610
22611 static inline uintptr_t ChannelConfig_clone_ptr(LDKChannelConfig *NONNULL_PTR arg) {
22612         LDKChannelConfig ret_var = ChannelConfig_clone(arg);
22613 uint32_t ret_ref = 0;
22614 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22615 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22616 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22617 ret_ref = (uintptr_t)ret_var.inner;
22618 if (ret_var.is_owned) {
22619         ret_ref |= 1;
22620 }
22621         return ret_ref;
22622 }
22623 uint32_t  __attribute__((export_name("TS_ChannelConfig_clone_ptr"))) TS_ChannelConfig_clone_ptr(uint32_t arg) {
22624         LDKChannelConfig arg_conv;
22625         arg_conv.inner = (void*)(arg & (~1));
22626         arg_conv.is_owned = false;
22627         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22628         uint32_t ret_conv = ChannelConfig_clone_ptr(&arg_conv);
22629         return ret_conv;
22630 }
22631
22632 uint32_t  __attribute__((export_name("TS_ChannelConfig_clone"))) TS_ChannelConfig_clone(uint32_t orig) {
22633         LDKChannelConfig orig_conv;
22634         orig_conv.inner = (void*)(orig & (~1));
22635         orig_conv.is_owned = false;
22636         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22637         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
22638         uint32_t ret_ref = 0;
22639         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22640         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22641         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22642         ret_ref = (uintptr_t)ret_var.inner;
22643         if (ret_var.is_owned) {
22644                 ret_ref |= 1;
22645         }
22646         return ret_ref;
22647 }
22648
22649 uint32_t  __attribute__((export_name("TS_ChannelConfig_default"))) TS_ChannelConfig_default() {
22650         LDKChannelConfig ret_var = ChannelConfig_default();
22651         uint32_t ret_ref = 0;
22652         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22653         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22654         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22655         ret_ref = (uintptr_t)ret_var.inner;
22656         if (ret_var.is_owned) {
22657                 ret_ref |= 1;
22658         }
22659         return ret_ref;
22660 }
22661
22662 int8_tArray  __attribute__((export_name("TS_ChannelConfig_write"))) TS_ChannelConfig_write(uint32_t obj) {
22663         LDKChannelConfig obj_conv;
22664         obj_conv.inner = (void*)(obj & (~1));
22665         obj_conv.is_owned = false;
22666         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
22667         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
22668         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
22669         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
22670         CVec_u8Z_free(ret_var);
22671         return ret_arr;
22672 }
22673
22674 uint32_t  __attribute__((export_name("TS_ChannelConfig_read"))) TS_ChannelConfig_read(int8_tArray ser) {
22675         LDKu8slice ser_ref;
22676         ser_ref.datalen = ser->arr_len;
22677         ser_ref.data = ser->elems;
22678         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
22679         *ret_conv = ChannelConfig_read(ser_ref);
22680         FREE(ser);
22681         return (uint32_t)ret_conv;
22682 }
22683
22684 void  __attribute__((export_name("TS_UserConfig_free"))) TS_UserConfig_free(uint32_t this_obj) {
22685         LDKUserConfig this_obj_conv;
22686         this_obj_conv.inner = (void*)(this_obj & (~1));
22687         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22688         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22689         UserConfig_free(this_obj_conv);
22690 }
22691
22692 uint32_t  __attribute__((export_name("TS_UserConfig_get_channel_handshake_config"))) TS_UserConfig_get_channel_handshake_config(uint32_t this_ptr) {
22693         LDKUserConfig this_ptr_conv;
22694         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22695         this_ptr_conv.is_owned = false;
22696         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22697         LDKChannelHandshakeConfig ret_var = UserConfig_get_channel_handshake_config(&this_ptr_conv);
22698         uint32_t ret_ref = 0;
22699         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22700         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22701         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22702         ret_ref = (uintptr_t)ret_var.inner;
22703         if (ret_var.is_owned) {
22704                 ret_ref |= 1;
22705         }
22706         return ret_ref;
22707 }
22708
22709 void  __attribute__((export_name("TS_UserConfig_set_channel_handshake_config"))) TS_UserConfig_set_channel_handshake_config(uint32_t this_ptr, uint32_t val) {
22710         LDKUserConfig this_ptr_conv;
22711         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22712         this_ptr_conv.is_owned = false;
22713         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22714         LDKChannelHandshakeConfig val_conv;
22715         val_conv.inner = (void*)(val & (~1));
22716         val_conv.is_owned = (val & 1) || (val == 0);
22717         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
22718         val_conv = ChannelHandshakeConfig_clone(&val_conv);
22719         UserConfig_set_channel_handshake_config(&this_ptr_conv, val_conv);
22720 }
22721
22722 uint32_t  __attribute__((export_name("TS_UserConfig_get_channel_handshake_limits"))) TS_UserConfig_get_channel_handshake_limits(uint32_t this_ptr) {
22723         LDKUserConfig this_ptr_conv;
22724         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22725         this_ptr_conv.is_owned = false;
22726         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22727         LDKChannelHandshakeLimits ret_var = UserConfig_get_channel_handshake_limits(&this_ptr_conv);
22728         uint32_t ret_ref = 0;
22729         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22730         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22731         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22732         ret_ref = (uintptr_t)ret_var.inner;
22733         if (ret_var.is_owned) {
22734                 ret_ref |= 1;
22735         }
22736         return ret_ref;
22737 }
22738
22739 void  __attribute__((export_name("TS_UserConfig_set_channel_handshake_limits"))) TS_UserConfig_set_channel_handshake_limits(uint32_t this_ptr, uint32_t val) {
22740         LDKUserConfig this_ptr_conv;
22741         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22742         this_ptr_conv.is_owned = false;
22743         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22744         LDKChannelHandshakeLimits val_conv;
22745         val_conv.inner = (void*)(val & (~1));
22746         val_conv.is_owned = (val & 1) || (val == 0);
22747         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
22748         val_conv = ChannelHandshakeLimits_clone(&val_conv);
22749         UserConfig_set_channel_handshake_limits(&this_ptr_conv, val_conv);
22750 }
22751
22752 uint32_t  __attribute__((export_name("TS_UserConfig_get_channel_config"))) TS_UserConfig_get_channel_config(uint32_t this_ptr) {
22753         LDKUserConfig this_ptr_conv;
22754         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22755         this_ptr_conv.is_owned = false;
22756         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22757         LDKChannelConfig ret_var = UserConfig_get_channel_config(&this_ptr_conv);
22758         uint32_t ret_ref = 0;
22759         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22760         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22761         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22762         ret_ref = (uintptr_t)ret_var.inner;
22763         if (ret_var.is_owned) {
22764                 ret_ref |= 1;
22765         }
22766         return ret_ref;
22767 }
22768
22769 void  __attribute__((export_name("TS_UserConfig_set_channel_config"))) TS_UserConfig_set_channel_config(uint32_t this_ptr, uint32_t val) {
22770         LDKUserConfig this_ptr_conv;
22771         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22772         this_ptr_conv.is_owned = false;
22773         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22774         LDKChannelConfig val_conv;
22775         val_conv.inner = (void*)(val & (~1));
22776         val_conv.is_owned = (val & 1) || (val == 0);
22777         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
22778         val_conv = ChannelConfig_clone(&val_conv);
22779         UserConfig_set_channel_config(&this_ptr_conv, val_conv);
22780 }
22781
22782 jboolean  __attribute__((export_name("TS_UserConfig_get_accept_forwards_to_priv_channels"))) TS_UserConfig_get_accept_forwards_to_priv_channels(uint32_t this_ptr) {
22783         LDKUserConfig this_ptr_conv;
22784         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22785         this_ptr_conv.is_owned = false;
22786         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22787         jboolean ret_conv = UserConfig_get_accept_forwards_to_priv_channels(&this_ptr_conv);
22788         return ret_conv;
22789 }
22790
22791 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) {
22792         LDKUserConfig this_ptr_conv;
22793         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22794         this_ptr_conv.is_owned = false;
22795         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22796         UserConfig_set_accept_forwards_to_priv_channels(&this_ptr_conv, val);
22797 }
22798
22799 jboolean  __attribute__((export_name("TS_UserConfig_get_accept_inbound_channels"))) TS_UserConfig_get_accept_inbound_channels(uint32_t this_ptr) {
22800         LDKUserConfig this_ptr_conv;
22801         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22802         this_ptr_conv.is_owned = false;
22803         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22804         jboolean ret_conv = UserConfig_get_accept_inbound_channels(&this_ptr_conv);
22805         return ret_conv;
22806 }
22807
22808 void  __attribute__((export_name("TS_UserConfig_set_accept_inbound_channels"))) TS_UserConfig_set_accept_inbound_channels(uint32_t this_ptr, jboolean val) {
22809         LDKUserConfig this_ptr_conv;
22810         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22811         this_ptr_conv.is_owned = false;
22812         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22813         UserConfig_set_accept_inbound_channels(&this_ptr_conv, val);
22814 }
22815
22816 jboolean  __attribute__((export_name("TS_UserConfig_get_manually_accept_inbound_channels"))) TS_UserConfig_get_manually_accept_inbound_channels(uint32_t this_ptr) {
22817         LDKUserConfig this_ptr_conv;
22818         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22819         this_ptr_conv.is_owned = false;
22820         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22821         jboolean ret_conv = UserConfig_get_manually_accept_inbound_channels(&this_ptr_conv);
22822         return ret_conv;
22823 }
22824
22825 void  __attribute__((export_name("TS_UserConfig_set_manually_accept_inbound_channels"))) TS_UserConfig_set_manually_accept_inbound_channels(uint32_t this_ptr, jboolean val) {
22826         LDKUserConfig this_ptr_conv;
22827         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22828         this_ptr_conv.is_owned = false;
22829         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22830         UserConfig_set_manually_accept_inbound_channels(&this_ptr_conv, val);
22831 }
22832
22833 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) {
22834         LDKChannelHandshakeConfig channel_handshake_config_arg_conv;
22835         channel_handshake_config_arg_conv.inner = (void*)(channel_handshake_config_arg & (~1));
22836         channel_handshake_config_arg_conv.is_owned = (channel_handshake_config_arg & 1) || (channel_handshake_config_arg == 0);
22837         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_handshake_config_arg_conv);
22838         channel_handshake_config_arg_conv = ChannelHandshakeConfig_clone(&channel_handshake_config_arg_conv);
22839         LDKChannelHandshakeLimits channel_handshake_limits_arg_conv;
22840         channel_handshake_limits_arg_conv.inner = (void*)(channel_handshake_limits_arg & (~1));
22841         channel_handshake_limits_arg_conv.is_owned = (channel_handshake_limits_arg & 1) || (channel_handshake_limits_arg == 0);
22842         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_handshake_limits_arg_conv);
22843         channel_handshake_limits_arg_conv = ChannelHandshakeLimits_clone(&channel_handshake_limits_arg_conv);
22844         LDKChannelConfig channel_config_arg_conv;
22845         channel_config_arg_conv.inner = (void*)(channel_config_arg & (~1));
22846         channel_config_arg_conv.is_owned = (channel_config_arg & 1) || (channel_config_arg == 0);
22847         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_config_arg_conv);
22848         channel_config_arg_conv = ChannelConfig_clone(&channel_config_arg_conv);
22849         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);
22850         uint32_t ret_ref = 0;
22851         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22852         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22853         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22854         ret_ref = (uintptr_t)ret_var.inner;
22855         if (ret_var.is_owned) {
22856                 ret_ref |= 1;
22857         }
22858         return ret_ref;
22859 }
22860
22861 static inline uintptr_t UserConfig_clone_ptr(LDKUserConfig *NONNULL_PTR arg) {
22862         LDKUserConfig ret_var = UserConfig_clone(arg);
22863 uint32_t ret_ref = 0;
22864 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22865 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22866 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22867 ret_ref = (uintptr_t)ret_var.inner;
22868 if (ret_var.is_owned) {
22869         ret_ref |= 1;
22870 }
22871         return ret_ref;
22872 }
22873 uint32_t  __attribute__((export_name("TS_UserConfig_clone_ptr"))) TS_UserConfig_clone_ptr(uint32_t arg) {
22874         LDKUserConfig arg_conv;
22875         arg_conv.inner = (void*)(arg & (~1));
22876         arg_conv.is_owned = false;
22877         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22878         uint32_t ret_conv = UserConfig_clone_ptr(&arg_conv);
22879         return ret_conv;
22880 }
22881
22882 uint32_t  __attribute__((export_name("TS_UserConfig_clone"))) TS_UserConfig_clone(uint32_t orig) {
22883         LDKUserConfig orig_conv;
22884         orig_conv.inner = (void*)(orig & (~1));
22885         orig_conv.is_owned = false;
22886         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22887         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
22888         uint32_t ret_ref = 0;
22889         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22890         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22891         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22892         ret_ref = (uintptr_t)ret_var.inner;
22893         if (ret_var.is_owned) {
22894                 ret_ref |= 1;
22895         }
22896         return ret_ref;
22897 }
22898
22899 uint32_t  __attribute__((export_name("TS_UserConfig_default"))) TS_UserConfig_default() {
22900         LDKUserConfig ret_var = UserConfig_default();
22901         uint32_t ret_ref = 0;
22902         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22903         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22904         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22905         ret_ref = (uintptr_t)ret_var.inner;
22906         if (ret_var.is_owned) {
22907                 ret_ref |= 1;
22908         }
22909         return ret_ref;
22910 }
22911
22912 void  __attribute__((export_name("TS_BestBlock_free"))) TS_BestBlock_free(uint32_t this_obj) {
22913         LDKBestBlock this_obj_conv;
22914         this_obj_conv.inner = (void*)(this_obj & (~1));
22915         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22916         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22917         BestBlock_free(this_obj_conv);
22918 }
22919
22920 static inline uintptr_t BestBlock_clone_ptr(LDKBestBlock *NONNULL_PTR arg) {
22921         LDKBestBlock ret_var = BestBlock_clone(arg);
22922 uint32_t ret_ref = 0;
22923 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22924 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22925 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22926 ret_ref = (uintptr_t)ret_var.inner;
22927 if (ret_var.is_owned) {
22928         ret_ref |= 1;
22929 }
22930         return ret_ref;
22931 }
22932 uint32_t  __attribute__((export_name("TS_BestBlock_clone_ptr"))) TS_BestBlock_clone_ptr(uint32_t arg) {
22933         LDKBestBlock arg_conv;
22934         arg_conv.inner = (void*)(arg & (~1));
22935         arg_conv.is_owned = false;
22936         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22937         uint32_t ret_conv = BestBlock_clone_ptr(&arg_conv);
22938         return ret_conv;
22939 }
22940
22941 uint32_t  __attribute__((export_name("TS_BestBlock_clone"))) TS_BestBlock_clone(uint32_t orig) {
22942         LDKBestBlock orig_conv;
22943         orig_conv.inner = (void*)(orig & (~1));
22944         orig_conv.is_owned = false;
22945         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22946         LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
22947         uint32_t ret_ref = 0;
22948         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22949         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22950         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22951         ret_ref = (uintptr_t)ret_var.inner;
22952         if (ret_var.is_owned) {
22953                 ret_ref |= 1;
22954         }
22955         return ret_ref;
22956 }
22957
22958 uint32_t  __attribute__((export_name("TS_BestBlock_from_genesis"))) TS_BestBlock_from_genesis(uint32_t network) {
22959         LDKNetwork network_conv = LDKNetwork_from_js(network);
22960         LDKBestBlock ret_var = BestBlock_from_genesis(network_conv);
22961         uint32_t ret_ref = 0;
22962         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22963         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22964         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22965         ret_ref = (uintptr_t)ret_var.inner;
22966         if (ret_var.is_owned) {
22967                 ret_ref |= 1;
22968         }
22969         return ret_ref;
22970 }
22971
22972 uint32_t  __attribute__((export_name("TS_BestBlock_new"))) TS_BestBlock_new(int8_tArray block_hash, int32_t height) {
22973         LDKThirtyTwoBytes block_hash_ref;
22974         CHECK(block_hash->arr_len == 32);
22975         memcpy(block_hash_ref.data, block_hash->elems, 32); FREE(block_hash);
22976         LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
22977         uint32_t ret_ref = 0;
22978         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22979         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22980         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22981         ret_ref = (uintptr_t)ret_var.inner;
22982         if (ret_var.is_owned) {
22983                 ret_ref |= 1;
22984         }
22985         return ret_ref;
22986 }
22987
22988 int8_tArray  __attribute__((export_name("TS_BestBlock_block_hash"))) TS_BestBlock_block_hash(uint32_t this_arg) {
22989         LDKBestBlock this_arg_conv;
22990         this_arg_conv.inner = (void*)(this_arg & (~1));
22991         this_arg_conv.is_owned = false;
22992         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22993         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
22994         memcpy(ret_arr->elems, BestBlock_block_hash(&this_arg_conv).data, 32);
22995         return ret_arr;
22996 }
22997
22998 int32_t  __attribute__((export_name("TS_BestBlock_height"))) TS_BestBlock_height(uint32_t this_arg) {
22999         LDKBestBlock this_arg_conv;
23000         this_arg_conv.inner = (void*)(this_arg & (~1));
23001         this_arg_conv.is_owned = false;
23002         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23003         int32_t ret_conv = BestBlock_height(&this_arg_conv);
23004         return ret_conv;
23005 }
23006
23007 uint32_t  __attribute__((export_name("TS_AccessError_clone"))) TS_AccessError_clone(uint32_t orig) {
23008         LDKAccessError* orig_conv = (LDKAccessError*)(orig & ~1);
23009         uint32_t ret_conv = LDKAccessError_to_js(AccessError_clone(orig_conv));
23010         return ret_conv;
23011 }
23012
23013 uint32_t  __attribute__((export_name("TS_AccessError_unknown_chain"))) TS_AccessError_unknown_chain() {
23014         uint32_t ret_conv = LDKAccessError_to_js(AccessError_unknown_chain());
23015         return ret_conv;
23016 }
23017
23018 uint32_t  __attribute__((export_name("TS_AccessError_unknown_tx"))) TS_AccessError_unknown_tx() {
23019         uint32_t ret_conv = LDKAccessError_to_js(AccessError_unknown_tx());
23020         return ret_conv;
23021 }
23022
23023 void  __attribute__((export_name("TS_Access_free"))) TS_Access_free(uint32_t this_ptr) {
23024         if ((this_ptr & 1) != 0) return;
23025         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23026         CHECK_ACCESS(this_ptr_ptr);
23027         LDKAccess this_ptr_conv = *(LDKAccess*)(this_ptr_ptr);
23028         FREE((void*)this_ptr);
23029         Access_free(this_ptr_conv);
23030 }
23031
23032 void  __attribute__((export_name("TS_Listen_free"))) TS_Listen_free(uint32_t this_ptr) {
23033         if ((this_ptr & 1) != 0) return;
23034         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23035         CHECK_ACCESS(this_ptr_ptr);
23036         LDKListen this_ptr_conv = *(LDKListen*)(this_ptr_ptr);
23037         FREE((void*)this_ptr);
23038         Listen_free(this_ptr_conv);
23039 }
23040
23041 void  __attribute__((export_name("TS_Confirm_free"))) TS_Confirm_free(uint32_t this_ptr) {
23042         if ((this_ptr & 1) != 0) return;
23043         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23044         CHECK_ACCESS(this_ptr_ptr);
23045         LDKConfirm this_ptr_conv = *(LDKConfirm*)(this_ptr_ptr);
23046         FREE((void*)this_ptr);
23047         Confirm_free(this_ptr_conv);
23048 }
23049
23050 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdateErr_clone"))) TS_ChannelMonitorUpdateErr_clone(uint32_t orig) {
23051         LDKChannelMonitorUpdateErr* orig_conv = (LDKChannelMonitorUpdateErr*)(orig & ~1);
23052         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_clone(orig_conv));
23053         return ret_conv;
23054 }
23055
23056 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdateErr_temporary_failure"))) TS_ChannelMonitorUpdateErr_temporary_failure() {
23057         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_temporary_failure());
23058         return ret_conv;
23059 }
23060
23061 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdateErr_permanent_failure"))) TS_ChannelMonitorUpdateErr_permanent_failure() {
23062         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_permanent_failure());
23063         return ret_conv;
23064 }
23065
23066 void  __attribute__((export_name("TS_Watch_free"))) TS_Watch_free(uint32_t this_ptr) {
23067         if ((this_ptr & 1) != 0) return;
23068         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23069         CHECK_ACCESS(this_ptr_ptr);
23070         LDKWatch this_ptr_conv = *(LDKWatch*)(this_ptr_ptr);
23071         FREE((void*)this_ptr);
23072         Watch_free(this_ptr_conv);
23073 }
23074
23075 void  __attribute__((export_name("TS_Filter_free"))) TS_Filter_free(uint32_t this_ptr) {
23076         if ((this_ptr & 1) != 0) return;
23077         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23078         CHECK_ACCESS(this_ptr_ptr);
23079         LDKFilter this_ptr_conv = *(LDKFilter*)(this_ptr_ptr);
23080         FREE((void*)this_ptr);
23081         Filter_free(this_ptr_conv);
23082 }
23083
23084 void  __attribute__((export_name("TS_WatchedOutput_free"))) TS_WatchedOutput_free(uint32_t this_obj) {
23085         LDKWatchedOutput this_obj_conv;
23086         this_obj_conv.inner = (void*)(this_obj & (~1));
23087         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23088         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23089         WatchedOutput_free(this_obj_conv);
23090 }
23091
23092 int8_tArray  __attribute__((export_name("TS_WatchedOutput_get_block_hash"))) TS_WatchedOutput_get_block_hash(uint32_t this_ptr) {
23093         LDKWatchedOutput this_ptr_conv;
23094         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23095         this_ptr_conv.is_owned = false;
23096         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23097         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
23098         memcpy(ret_arr->elems, WatchedOutput_get_block_hash(&this_ptr_conv).data, 32);
23099         return ret_arr;
23100 }
23101
23102 void  __attribute__((export_name("TS_WatchedOutput_set_block_hash"))) TS_WatchedOutput_set_block_hash(uint32_t this_ptr, int8_tArray val) {
23103         LDKWatchedOutput this_ptr_conv;
23104         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23105         this_ptr_conv.is_owned = false;
23106         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23107         LDKThirtyTwoBytes val_ref;
23108         CHECK(val->arr_len == 32);
23109         memcpy(val_ref.data, val->elems, 32); FREE(val);
23110         WatchedOutput_set_block_hash(&this_ptr_conv, val_ref);
23111 }
23112
23113 uint32_t  __attribute__((export_name("TS_WatchedOutput_get_outpoint"))) TS_WatchedOutput_get_outpoint(uint32_t this_ptr) {
23114         LDKWatchedOutput this_ptr_conv;
23115         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23116         this_ptr_conv.is_owned = false;
23117         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23118         LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
23119         uint32_t ret_ref = 0;
23120         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23121         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23122         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23123         ret_ref = (uintptr_t)ret_var.inner;
23124         if (ret_var.is_owned) {
23125                 ret_ref |= 1;
23126         }
23127         return ret_ref;
23128 }
23129
23130 void  __attribute__((export_name("TS_WatchedOutput_set_outpoint"))) TS_WatchedOutput_set_outpoint(uint32_t this_ptr, uint32_t val) {
23131         LDKWatchedOutput this_ptr_conv;
23132         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23133         this_ptr_conv.is_owned = false;
23134         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23135         LDKOutPoint val_conv;
23136         val_conv.inner = (void*)(val & (~1));
23137         val_conv.is_owned = (val & 1) || (val == 0);
23138         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
23139         val_conv = OutPoint_clone(&val_conv);
23140         WatchedOutput_set_outpoint(&this_ptr_conv, val_conv);
23141 }
23142
23143 int8_tArray  __attribute__((export_name("TS_WatchedOutput_get_script_pubkey"))) TS_WatchedOutput_get_script_pubkey(uint32_t this_ptr) {
23144         LDKWatchedOutput this_ptr_conv;
23145         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23146         this_ptr_conv.is_owned = false;
23147         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23148         LDKu8slice ret_var = WatchedOutput_get_script_pubkey(&this_ptr_conv);
23149         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
23150         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
23151         return ret_arr;
23152 }
23153
23154 void  __attribute__((export_name("TS_WatchedOutput_set_script_pubkey"))) TS_WatchedOutput_set_script_pubkey(uint32_t this_ptr, int8_tArray val) {
23155         LDKWatchedOutput this_ptr_conv;
23156         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23157         this_ptr_conv.is_owned = false;
23158         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23159         LDKCVec_u8Z val_ref;
23160         val_ref.datalen = val->arr_len;
23161         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
23162         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
23163         WatchedOutput_set_script_pubkey(&this_ptr_conv, val_ref);
23164 }
23165
23166 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) {
23167         LDKThirtyTwoBytes block_hash_arg_ref;
23168         CHECK(block_hash_arg->arr_len == 32);
23169         memcpy(block_hash_arg_ref.data, block_hash_arg->elems, 32); FREE(block_hash_arg);
23170         LDKOutPoint outpoint_arg_conv;
23171         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
23172         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
23173         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
23174         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
23175         LDKCVec_u8Z script_pubkey_arg_ref;
23176         script_pubkey_arg_ref.datalen = script_pubkey_arg->arr_len;
23177         script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
23178         memcpy(script_pubkey_arg_ref.data, script_pubkey_arg->elems, script_pubkey_arg_ref.datalen); FREE(script_pubkey_arg);
23179         LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
23180         uint32_t ret_ref = 0;
23181         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23182         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23183         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23184         ret_ref = (uintptr_t)ret_var.inner;
23185         if (ret_var.is_owned) {
23186                 ret_ref |= 1;
23187         }
23188         return ret_ref;
23189 }
23190
23191 static inline uintptr_t WatchedOutput_clone_ptr(LDKWatchedOutput *NONNULL_PTR arg) {
23192         LDKWatchedOutput ret_var = WatchedOutput_clone(arg);
23193 uint32_t ret_ref = 0;
23194 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23195 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23196 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23197 ret_ref = (uintptr_t)ret_var.inner;
23198 if (ret_var.is_owned) {
23199         ret_ref |= 1;
23200 }
23201         return ret_ref;
23202 }
23203 uint32_t  __attribute__((export_name("TS_WatchedOutput_clone_ptr"))) TS_WatchedOutput_clone_ptr(uint32_t arg) {
23204         LDKWatchedOutput arg_conv;
23205         arg_conv.inner = (void*)(arg & (~1));
23206         arg_conv.is_owned = false;
23207         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23208         uint32_t ret_conv = WatchedOutput_clone_ptr(&arg_conv);
23209         return ret_conv;
23210 }
23211
23212 uint32_t  __attribute__((export_name("TS_WatchedOutput_clone"))) TS_WatchedOutput_clone(uint32_t orig) {
23213         LDKWatchedOutput orig_conv;
23214         orig_conv.inner = (void*)(orig & (~1));
23215         orig_conv.is_owned = false;
23216         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23217         LDKWatchedOutput ret_var = WatchedOutput_clone(&orig_conv);
23218         uint32_t ret_ref = 0;
23219         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23220         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23221         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23222         ret_ref = (uintptr_t)ret_var.inner;
23223         if (ret_var.is_owned) {
23224                 ret_ref |= 1;
23225         }
23226         return ret_ref;
23227 }
23228
23229 int64_t  __attribute__((export_name("TS_WatchedOutput_hash"))) TS_WatchedOutput_hash(uint32_t o) {
23230         LDKWatchedOutput o_conv;
23231         o_conv.inner = (void*)(o & (~1));
23232         o_conv.is_owned = false;
23233         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23234         int64_t ret_conv = WatchedOutput_hash(&o_conv);
23235         return ret_conv;
23236 }
23237
23238 void  __attribute__((export_name("TS_BroadcasterInterface_free"))) TS_BroadcasterInterface_free(uint32_t this_ptr) {
23239         if ((this_ptr & 1) != 0) return;
23240         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23241         CHECK_ACCESS(this_ptr_ptr);
23242         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(this_ptr_ptr);
23243         FREE((void*)this_ptr);
23244         BroadcasterInterface_free(this_ptr_conv);
23245 }
23246
23247 uint32_t  __attribute__((export_name("TS_ConfirmationTarget_clone"))) TS_ConfirmationTarget_clone(uint32_t orig) {
23248         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)(orig & ~1);
23249         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_clone(orig_conv));
23250         return ret_conv;
23251 }
23252
23253 uint32_t  __attribute__((export_name("TS_ConfirmationTarget_background"))) TS_ConfirmationTarget_background() {
23254         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_background());
23255         return ret_conv;
23256 }
23257
23258 uint32_t  __attribute__((export_name("TS_ConfirmationTarget_normal"))) TS_ConfirmationTarget_normal() {
23259         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_normal());
23260         return ret_conv;
23261 }
23262
23263 uint32_t  __attribute__((export_name("TS_ConfirmationTarget_high_priority"))) TS_ConfirmationTarget_high_priority() {
23264         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_high_priority());
23265         return ret_conv;
23266 }
23267
23268 jboolean  __attribute__((export_name("TS_ConfirmationTarget_eq"))) TS_ConfirmationTarget_eq(uint32_t a, uint32_t b) {
23269         LDKConfirmationTarget* a_conv = (LDKConfirmationTarget*)(a & ~1);
23270         LDKConfirmationTarget* b_conv = (LDKConfirmationTarget*)(b & ~1);
23271         jboolean ret_conv = ConfirmationTarget_eq(a_conv, b_conv);
23272         return ret_conv;
23273 }
23274
23275 void  __attribute__((export_name("TS_FeeEstimator_free"))) TS_FeeEstimator_free(uint32_t this_ptr) {
23276         if ((this_ptr & 1) != 0) return;
23277         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23278         CHECK_ACCESS(this_ptr_ptr);
23279         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(this_ptr_ptr);
23280         FREE((void*)this_ptr);
23281         FeeEstimator_free(this_ptr_conv);
23282 }
23283
23284 void  __attribute__((export_name("TS_MonitorUpdateId_free"))) TS_MonitorUpdateId_free(uint32_t this_obj) {
23285         LDKMonitorUpdateId this_obj_conv;
23286         this_obj_conv.inner = (void*)(this_obj & (~1));
23287         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23288         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23289         MonitorUpdateId_free(this_obj_conv);
23290 }
23291
23292 static inline uintptr_t MonitorUpdateId_clone_ptr(LDKMonitorUpdateId *NONNULL_PTR arg) {
23293         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(arg);
23294 uint32_t ret_ref = 0;
23295 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23296 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23297 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23298 ret_ref = (uintptr_t)ret_var.inner;
23299 if (ret_var.is_owned) {
23300         ret_ref |= 1;
23301 }
23302         return ret_ref;
23303 }
23304 uint32_t  __attribute__((export_name("TS_MonitorUpdateId_clone_ptr"))) TS_MonitorUpdateId_clone_ptr(uint32_t arg) {
23305         LDKMonitorUpdateId arg_conv;
23306         arg_conv.inner = (void*)(arg & (~1));
23307         arg_conv.is_owned = false;
23308         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23309         uint32_t ret_conv = MonitorUpdateId_clone_ptr(&arg_conv);
23310         return ret_conv;
23311 }
23312
23313 uint32_t  __attribute__((export_name("TS_MonitorUpdateId_clone"))) TS_MonitorUpdateId_clone(uint32_t orig) {
23314         LDKMonitorUpdateId orig_conv;
23315         orig_conv.inner = (void*)(orig & (~1));
23316         orig_conv.is_owned = false;
23317         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23318         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(&orig_conv);
23319         uint32_t ret_ref = 0;
23320         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23321         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23322         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23323         ret_ref = (uintptr_t)ret_var.inner;
23324         if (ret_var.is_owned) {
23325                 ret_ref |= 1;
23326         }
23327         return ret_ref;
23328 }
23329
23330 int64_t  __attribute__((export_name("TS_MonitorUpdateId_hash"))) TS_MonitorUpdateId_hash(uint32_t o) {
23331         LDKMonitorUpdateId o_conv;
23332         o_conv.inner = (void*)(o & (~1));
23333         o_conv.is_owned = false;
23334         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23335         int64_t ret_conv = MonitorUpdateId_hash(&o_conv);
23336         return ret_conv;
23337 }
23338
23339 jboolean  __attribute__((export_name("TS_MonitorUpdateId_eq"))) TS_MonitorUpdateId_eq(uint32_t a, uint32_t b) {
23340         LDKMonitorUpdateId a_conv;
23341         a_conv.inner = (void*)(a & (~1));
23342         a_conv.is_owned = false;
23343         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
23344         LDKMonitorUpdateId b_conv;
23345         b_conv.inner = (void*)(b & (~1));
23346         b_conv.is_owned = false;
23347         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
23348         jboolean ret_conv = MonitorUpdateId_eq(&a_conv, &b_conv);
23349         return ret_conv;
23350 }
23351
23352 void  __attribute__((export_name("TS_Persist_free"))) TS_Persist_free(uint32_t this_ptr) {
23353         if ((this_ptr & 1) != 0) return;
23354         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23355         CHECK_ACCESS(this_ptr_ptr);
23356         LDKPersist this_ptr_conv = *(LDKPersist*)(this_ptr_ptr);
23357         FREE((void*)this_ptr);
23358         Persist_free(this_ptr_conv);
23359 }
23360
23361 void  __attribute__((export_name("TS_LockedChannelMonitor_free"))) TS_LockedChannelMonitor_free(uint32_t this_obj) {
23362         LDKLockedChannelMonitor this_obj_conv;
23363         this_obj_conv.inner = (void*)(this_obj & (~1));
23364         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23365         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23366         LockedChannelMonitor_free(this_obj_conv);
23367 }
23368
23369 void  __attribute__((export_name("TS_ChainMonitor_free"))) TS_ChainMonitor_free(uint32_t this_obj) {
23370         LDKChainMonitor this_obj_conv;
23371         this_obj_conv.inner = (void*)(this_obj & (~1));
23372         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23373         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23374         ChainMonitor_free(this_obj_conv);
23375 }
23376
23377 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) {
23378         void* chain_source_ptr = (void*)(((uintptr_t)chain_source) & ~1);
23379         CHECK_ACCESS(chain_source_ptr);
23380         LDKCOption_FilterZ chain_source_conv = *(LDKCOption_FilterZ*)(chain_source_ptr);
23381         // WARNING: we may need a move here but no clone is available for LDKCOption_FilterZ
23382         if (chain_source_conv.tag == LDKCOption_FilterZ_Some) {
23383                 // Manually implement clone for Java trait instances
23384                 if (chain_source_conv.some.free == LDKFilter_JCalls_free) {
23385                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23386                         LDKFilter_JCalls_cloned(&chain_source_conv.some);
23387                 }
23388         }
23389         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
23390         CHECK_ACCESS(broadcaster_ptr);
23391         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
23392         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
23393                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23394                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
23395         }
23396         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
23397         CHECK_ACCESS(logger_ptr);
23398         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
23399         if (logger_conv.free == LDKLogger_JCalls_free) {
23400                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23401                 LDKLogger_JCalls_cloned(&logger_conv);
23402         }
23403         void* feeest_ptr = (void*)(((uintptr_t)feeest) & ~1);
23404         CHECK_ACCESS(feeest_ptr);
23405         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(feeest_ptr);
23406         if (feeest_conv.free == LDKFeeEstimator_JCalls_free) {
23407                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23408                 LDKFeeEstimator_JCalls_cloned(&feeest_conv);
23409         }
23410         void* persister_ptr = (void*)(((uintptr_t)persister) & ~1);
23411         CHECK_ACCESS(persister_ptr);
23412         LDKPersist persister_conv = *(LDKPersist*)(persister_ptr);
23413         if (persister_conv.free == LDKPersist_JCalls_free) {
23414                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23415                 LDKPersist_JCalls_cloned(&persister_conv);
23416         }
23417         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
23418         uint32_t ret_ref = 0;
23419         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23420         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23421         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23422         ret_ref = (uintptr_t)ret_var.inner;
23423         if (ret_var.is_owned) {
23424                 ret_ref |= 1;
23425         }
23426         return ret_ref;
23427 }
23428
23429 uint32_tArray  __attribute__((export_name("TS_ChainMonitor_get_claimable_balances"))) TS_ChainMonitor_get_claimable_balances(uint32_t this_arg, uint32_tArray ignored_channels) {
23430         LDKChainMonitor this_arg_conv;
23431         this_arg_conv.inner = (void*)(this_arg & (~1));
23432         this_arg_conv.is_owned = false;
23433         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23434         LDKCVec_ChannelDetailsZ ignored_channels_constr;
23435         ignored_channels_constr.datalen = ignored_channels->arr_len;
23436         if (ignored_channels_constr.datalen > 0)
23437                 ignored_channels_constr.data = MALLOC(ignored_channels_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
23438         else
23439                 ignored_channels_constr.data = NULL;
23440         uint32_t* ignored_channels_vals = ignored_channels->elems;
23441         for (size_t q = 0; q < ignored_channels_constr.datalen; q++) {
23442                 uint32_t ignored_channels_conv_16 = ignored_channels_vals[q];
23443                 LDKChannelDetails ignored_channels_conv_16_conv;
23444                 ignored_channels_conv_16_conv.inner = (void*)(ignored_channels_conv_16 & (~1));
23445                 ignored_channels_conv_16_conv.is_owned = (ignored_channels_conv_16 & 1) || (ignored_channels_conv_16 == 0);
23446                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ignored_channels_conv_16_conv);
23447                 ignored_channels_conv_16_conv = ChannelDetails_clone(&ignored_channels_conv_16_conv);
23448                 ignored_channels_constr.data[q] = ignored_channels_conv_16_conv;
23449         }
23450         FREE(ignored_channels);
23451         LDKCVec_BalanceZ ret_var = ChainMonitor_get_claimable_balances(&this_arg_conv, ignored_channels_constr);
23452         uint32_tArray ret_arr = NULL;
23453         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
23454         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 8);
23455         for (size_t j = 0; j < ret_var.datalen; j++) {
23456                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
23457                 *ret_conv_9_copy = ret_var.data[j];
23458                 uint32_t ret_conv_9_ref = (uintptr_t)ret_conv_9_copy;
23459                 ret_arr_ptr[j] = ret_conv_9_ref;
23460         }
23461         
23462         FREE(ret_var.data);
23463         return ret_arr;
23464 }
23465
23466 uint32_t  __attribute__((export_name("TS_ChainMonitor_get_monitor"))) TS_ChainMonitor_get_monitor(uint32_t this_arg, uint32_t funding_txo) {
23467         LDKChainMonitor this_arg_conv;
23468         this_arg_conv.inner = (void*)(this_arg & (~1));
23469         this_arg_conv.is_owned = false;
23470         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23471         LDKOutPoint funding_txo_conv;
23472         funding_txo_conv.inner = (void*)(funding_txo & (~1));
23473         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
23474         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
23475         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
23476         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
23477         *ret_conv = ChainMonitor_get_monitor(&this_arg_conv, funding_txo_conv);
23478         return (uint32_t)ret_conv;
23479 }
23480
23481 uint32_tArray  __attribute__((export_name("TS_ChainMonitor_list_monitors"))) TS_ChainMonitor_list_monitors(uint32_t this_arg) {
23482         LDKChainMonitor this_arg_conv;
23483         this_arg_conv.inner = (void*)(this_arg & (~1));
23484         this_arg_conv.is_owned = false;
23485         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23486         LDKCVec_OutPointZ ret_var = ChainMonitor_list_monitors(&this_arg_conv);
23487         uint32_tArray ret_arr = NULL;
23488         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
23489         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 8);
23490         for (size_t k = 0; k < ret_var.datalen; k++) {
23491                 LDKOutPoint ret_conv_10_var = ret_var.data[k];
23492                 uint32_t ret_conv_10_ref = 0;
23493                 CHECK((((uintptr_t)ret_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23494                 CHECK((((uintptr_t)&ret_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23495                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_10_var);
23496                 ret_conv_10_ref = (uintptr_t)ret_conv_10_var.inner;
23497                 if (ret_conv_10_var.is_owned) {
23498                         ret_conv_10_ref |= 1;
23499                 }
23500                 ret_arr_ptr[k] = ret_conv_10_ref;
23501         }
23502         
23503         FREE(ret_var.data);
23504         return ret_arr;
23505 }
23506
23507 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) {
23508         LDKChainMonitor this_arg_conv;
23509         this_arg_conv.inner = (void*)(this_arg & (~1));
23510         this_arg_conv.is_owned = false;
23511         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23512         LDKOutPoint funding_txo_conv;
23513         funding_txo_conv.inner = (void*)(funding_txo & (~1));
23514         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
23515         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
23516         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
23517         LDKMonitorUpdateId completed_update_id_conv;
23518         completed_update_id_conv.inner = (void*)(completed_update_id & (~1));
23519         completed_update_id_conv.is_owned = (completed_update_id & 1) || (completed_update_id == 0);
23520         CHECK_INNER_FIELD_ACCESS_OR_NULL(completed_update_id_conv);
23521         completed_update_id_conv = MonitorUpdateId_clone(&completed_update_id_conv);
23522         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
23523         *ret_conv = ChainMonitor_channel_monitor_updated(&this_arg_conv, funding_txo_conv, completed_update_id_conv);
23524         return (uint32_t)ret_conv;
23525 }
23526
23527 uint32_t  __attribute__((export_name("TS_ChainMonitor_as_Listen"))) TS_ChainMonitor_as_Listen(uint32_t this_arg) {
23528         LDKChainMonitor this_arg_conv;
23529         this_arg_conv.inner = (void*)(this_arg & (~1));
23530         this_arg_conv.is_owned = false;
23531         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23532         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
23533         *ret_ret = ChainMonitor_as_Listen(&this_arg_conv);
23534         return (uint32_t)ret_ret;
23535 }
23536
23537 uint32_t  __attribute__((export_name("TS_ChainMonitor_as_Confirm"))) TS_ChainMonitor_as_Confirm(uint32_t this_arg) {
23538         LDKChainMonitor this_arg_conv;
23539         this_arg_conv.inner = (void*)(this_arg & (~1));
23540         this_arg_conv.is_owned = false;
23541         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23542         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
23543         *ret_ret = ChainMonitor_as_Confirm(&this_arg_conv);
23544         return (uint32_t)ret_ret;
23545 }
23546
23547 uint32_t  __attribute__((export_name("TS_ChainMonitor_as_Watch"))) TS_ChainMonitor_as_Watch(uint32_t this_arg) {
23548         LDKChainMonitor this_arg_conv;
23549         this_arg_conv.inner = (void*)(this_arg & (~1));
23550         this_arg_conv.is_owned = false;
23551         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23552         LDKWatch* ret_ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
23553         *ret_ret = ChainMonitor_as_Watch(&this_arg_conv);
23554         return (uint32_t)ret_ret;
23555 }
23556
23557 uint32_t  __attribute__((export_name("TS_ChainMonitor_as_EventsProvider"))) TS_ChainMonitor_as_EventsProvider(uint32_t this_arg) {
23558         LDKChainMonitor this_arg_conv;
23559         this_arg_conv.inner = (void*)(this_arg & (~1));
23560         this_arg_conv.is_owned = false;
23561         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23562         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
23563         *ret_ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
23564         return (uint32_t)ret_ret;
23565 }
23566
23567 void  __attribute__((export_name("TS_ChannelMonitorUpdate_free"))) TS_ChannelMonitorUpdate_free(uint32_t this_obj) {
23568         LDKChannelMonitorUpdate this_obj_conv;
23569         this_obj_conv.inner = (void*)(this_obj & (~1));
23570         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23571         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23572         ChannelMonitorUpdate_free(this_obj_conv);
23573 }
23574
23575 int64_t  __attribute__((export_name("TS_ChannelMonitorUpdate_get_update_id"))) TS_ChannelMonitorUpdate_get_update_id(uint32_t this_ptr) {
23576         LDKChannelMonitorUpdate this_ptr_conv;
23577         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23578         this_ptr_conv.is_owned = false;
23579         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23580         int64_t ret_conv = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
23581         return ret_conv;
23582 }
23583
23584 void  __attribute__((export_name("TS_ChannelMonitorUpdate_set_update_id"))) TS_ChannelMonitorUpdate_set_update_id(uint32_t this_ptr, int64_t val) {
23585         LDKChannelMonitorUpdate this_ptr_conv;
23586         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23587         this_ptr_conv.is_owned = false;
23588         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23589         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
23590 }
23591
23592 static inline uintptr_t ChannelMonitorUpdate_clone_ptr(LDKChannelMonitorUpdate *NONNULL_PTR arg) {
23593         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(arg);
23594 uint32_t ret_ref = 0;
23595 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23596 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23597 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23598 ret_ref = (uintptr_t)ret_var.inner;
23599 if (ret_var.is_owned) {
23600         ret_ref |= 1;
23601 }
23602         return ret_ref;
23603 }
23604 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdate_clone_ptr"))) TS_ChannelMonitorUpdate_clone_ptr(uint32_t arg) {
23605         LDKChannelMonitorUpdate arg_conv;
23606         arg_conv.inner = (void*)(arg & (~1));
23607         arg_conv.is_owned = false;
23608         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23609         uint32_t ret_conv = ChannelMonitorUpdate_clone_ptr(&arg_conv);
23610         return ret_conv;
23611 }
23612
23613 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdate_clone"))) TS_ChannelMonitorUpdate_clone(uint32_t orig) {
23614         LDKChannelMonitorUpdate orig_conv;
23615         orig_conv.inner = (void*)(orig & (~1));
23616         orig_conv.is_owned = false;
23617         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23618         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
23619         uint32_t ret_ref = 0;
23620         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23621         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23622         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23623         ret_ref = (uintptr_t)ret_var.inner;
23624         if (ret_var.is_owned) {
23625                 ret_ref |= 1;
23626         }
23627         return ret_ref;
23628 }
23629
23630 int8_tArray  __attribute__((export_name("TS_ChannelMonitorUpdate_write"))) TS_ChannelMonitorUpdate_write(uint32_t obj) {
23631         LDKChannelMonitorUpdate obj_conv;
23632         obj_conv.inner = (void*)(obj & (~1));
23633         obj_conv.is_owned = false;
23634         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
23635         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
23636         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
23637         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
23638         CVec_u8Z_free(ret_var);
23639         return ret_arr;
23640 }
23641
23642 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdate_read"))) TS_ChannelMonitorUpdate_read(int8_tArray ser) {
23643         LDKu8slice ser_ref;
23644         ser_ref.datalen = ser->arr_len;
23645         ser_ref.data = ser->elems;
23646         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
23647         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
23648         FREE(ser);
23649         return (uint32_t)ret_conv;
23650 }
23651
23652 void  __attribute__((export_name("TS_MonitorEvent_free"))) TS_MonitorEvent_free(uint32_t this_ptr) {
23653         if ((this_ptr & 1) != 0) return;
23654         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23655         CHECK_ACCESS(this_ptr_ptr);
23656         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(this_ptr_ptr);
23657         FREE((void*)this_ptr);
23658         MonitorEvent_free(this_ptr_conv);
23659 }
23660
23661 static inline uintptr_t MonitorEvent_clone_ptr(LDKMonitorEvent *NONNULL_PTR arg) {
23662         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
23663         *ret_copy = MonitorEvent_clone(arg);
23664 uint32_t ret_ref = (uintptr_t)ret_copy;
23665         return ret_ref;
23666 }
23667 uint32_t  __attribute__((export_name("TS_MonitorEvent_clone_ptr"))) TS_MonitorEvent_clone_ptr(uint32_t arg) {
23668         LDKMonitorEvent* arg_conv = (LDKMonitorEvent*)arg;
23669         uint32_t ret_conv = MonitorEvent_clone_ptr(arg_conv);
23670         return ret_conv;
23671 }
23672
23673 uint32_t  __attribute__((export_name("TS_MonitorEvent_clone"))) TS_MonitorEvent_clone(uint32_t orig) {
23674         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)orig;
23675         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
23676         *ret_copy = MonitorEvent_clone(orig_conv);
23677         uint32_t ret_ref = (uintptr_t)ret_copy;
23678         return ret_ref;
23679 }
23680
23681 uint32_t  __attribute__((export_name("TS_MonitorEvent_htlcevent"))) TS_MonitorEvent_htlcevent(uint32_t a) {
23682         LDKHTLCUpdate a_conv;
23683         a_conv.inner = (void*)(a & (~1));
23684         a_conv.is_owned = (a & 1) || (a == 0);
23685         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
23686         a_conv = HTLCUpdate_clone(&a_conv);
23687         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
23688         *ret_copy = MonitorEvent_htlcevent(a_conv);
23689         uint32_t ret_ref = (uintptr_t)ret_copy;
23690         return ret_ref;
23691 }
23692
23693 uint32_t  __attribute__((export_name("TS_MonitorEvent_commitment_tx_confirmed"))) TS_MonitorEvent_commitment_tx_confirmed(uint32_t a) {
23694         LDKOutPoint a_conv;
23695         a_conv.inner = (void*)(a & (~1));
23696         a_conv.is_owned = (a & 1) || (a == 0);
23697         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
23698         a_conv = OutPoint_clone(&a_conv);
23699         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
23700         *ret_copy = MonitorEvent_commitment_tx_confirmed(a_conv);
23701         uint32_t ret_ref = (uintptr_t)ret_copy;
23702         return ret_ref;
23703 }
23704
23705 uint32_t  __attribute__((export_name("TS_MonitorEvent_update_completed"))) TS_MonitorEvent_update_completed(uint32_t funding_txo, int64_t monitor_update_id) {
23706         LDKOutPoint funding_txo_conv;
23707         funding_txo_conv.inner = (void*)(funding_txo & (~1));
23708         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
23709         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
23710         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
23711         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
23712         *ret_copy = MonitorEvent_update_completed(funding_txo_conv, monitor_update_id);
23713         uint32_t ret_ref = (uintptr_t)ret_copy;
23714         return ret_ref;
23715 }
23716
23717 uint32_t  __attribute__((export_name("TS_MonitorEvent_update_failed"))) TS_MonitorEvent_update_failed(uint32_t a) {
23718         LDKOutPoint a_conv;
23719         a_conv.inner = (void*)(a & (~1));
23720         a_conv.is_owned = (a & 1) || (a == 0);
23721         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
23722         a_conv = OutPoint_clone(&a_conv);
23723         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
23724         *ret_copy = MonitorEvent_update_failed(a_conv);
23725         uint32_t ret_ref = (uintptr_t)ret_copy;
23726         return ret_ref;
23727 }
23728
23729 int8_tArray  __attribute__((export_name("TS_MonitorEvent_write"))) TS_MonitorEvent_write(uint32_t obj) {
23730         LDKMonitorEvent* obj_conv = (LDKMonitorEvent*)obj;
23731         LDKCVec_u8Z ret_var = MonitorEvent_write(obj_conv);
23732         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
23733         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
23734         CVec_u8Z_free(ret_var);
23735         return ret_arr;
23736 }
23737
23738 uint32_t  __attribute__((export_name("TS_MonitorEvent_read"))) TS_MonitorEvent_read(int8_tArray ser) {
23739         LDKu8slice ser_ref;
23740         ser_ref.datalen = ser->arr_len;
23741         ser_ref.data = ser->elems;
23742         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
23743         *ret_conv = MonitorEvent_read(ser_ref);
23744         FREE(ser);
23745         return (uint32_t)ret_conv;
23746 }
23747
23748 void  __attribute__((export_name("TS_HTLCUpdate_free"))) TS_HTLCUpdate_free(uint32_t this_obj) {
23749         LDKHTLCUpdate this_obj_conv;
23750         this_obj_conv.inner = (void*)(this_obj & (~1));
23751         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23752         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23753         HTLCUpdate_free(this_obj_conv);
23754 }
23755
23756 static inline uintptr_t HTLCUpdate_clone_ptr(LDKHTLCUpdate *NONNULL_PTR arg) {
23757         LDKHTLCUpdate ret_var = HTLCUpdate_clone(arg);
23758 uint32_t ret_ref = 0;
23759 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23760 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23761 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23762 ret_ref = (uintptr_t)ret_var.inner;
23763 if (ret_var.is_owned) {
23764         ret_ref |= 1;
23765 }
23766         return ret_ref;
23767 }
23768 uint32_t  __attribute__((export_name("TS_HTLCUpdate_clone_ptr"))) TS_HTLCUpdate_clone_ptr(uint32_t arg) {
23769         LDKHTLCUpdate arg_conv;
23770         arg_conv.inner = (void*)(arg & (~1));
23771         arg_conv.is_owned = false;
23772         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23773         uint32_t ret_conv = HTLCUpdate_clone_ptr(&arg_conv);
23774         return ret_conv;
23775 }
23776
23777 uint32_t  __attribute__((export_name("TS_HTLCUpdate_clone"))) TS_HTLCUpdate_clone(uint32_t orig) {
23778         LDKHTLCUpdate orig_conv;
23779         orig_conv.inner = (void*)(orig & (~1));
23780         orig_conv.is_owned = false;
23781         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23782         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
23783         uint32_t ret_ref = 0;
23784         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23785         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23786         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23787         ret_ref = (uintptr_t)ret_var.inner;
23788         if (ret_var.is_owned) {
23789                 ret_ref |= 1;
23790         }
23791         return ret_ref;
23792 }
23793
23794 int8_tArray  __attribute__((export_name("TS_HTLCUpdate_write"))) TS_HTLCUpdate_write(uint32_t obj) {
23795         LDKHTLCUpdate obj_conv;
23796         obj_conv.inner = (void*)(obj & (~1));
23797         obj_conv.is_owned = false;
23798         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
23799         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
23800         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
23801         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
23802         CVec_u8Z_free(ret_var);
23803         return ret_arr;
23804 }
23805
23806 uint32_t  __attribute__((export_name("TS_HTLCUpdate_read"))) TS_HTLCUpdate_read(int8_tArray ser) {
23807         LDKu8slice ser_ref;
23808         ser_ref.datalen = ser->arr_len;
23809         ser_ref.data = ser->elems;
23810         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
23811         *ret_conv = HTLCUpdate_read(ser_ref);
23812         FREE(ser);
23813         return (uint32_t)ret_conv;
23814 }
23815
23816 void  __attribute__((export_name("TS_Balance_free"))) TS_Balance_free(uint32_t this_ptr) {
23817         if ((this_ptr & 1) != 0) return;
23818         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23819         CHECK_ACCESS(this_ptr_ptr);
23820         LDKBalance this_ptr_conv = *(LDKBalance*)(this_ptr_ptr);
23821         FREE((void*)this_ptr);
23822         Balance_free(this_ptr_conv);
23823 }
23824
23825 static inline uintptr_t Balance_clone_ptr(LDKBalance *NONNULL_PTR arg) {
23826         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
23827         *ret_copy = Balance_clone(arg);
23828 uint32_t ret_ref = (uintptr_t)ret_copy;
23829         return ret_ref;
23830 }
23831 uint32_t  __attribute__((export_name("TS_Balance_clone_ptr"))) TS_Balance_clone_ptr(uint32_t arg) {
23832         LDKBalance* arg_conv = (LDKBalance*)arg;
23833         uint32_t ret_conv = Balance_clone_ptr(arg_conv);
23834         return ret_conv;
23835 }
23836
23837 uint32_t  __attribute__((export_name("TS_Balance_clone"))) TS_Balance_clone(uint32_t orig) {
23838         LDKBalance* orig_conv = (LDKBalance*)orig;
23839         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
23840         *ret_copy = Balance_clone(orig_conv);
23841         uint32_t ret_ref = (uintptr_t)ret_copy;
23842         return ret_ref;
23843 }
23844
23845 uint32_t  __attribute__((export_name("TS_Balance_claimable_on_channel_close"))) TS_Balance_claimable_on_channel_close(int64_t claimable_amount_satoshis) {
23846         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
23847         *ret_copy = Balance_claimable_on_channel_close(claimable_amount_satoshis);
23848         uint32_t ret_ref = (uintptr_t)ret_copy;
23849         return ret_ref;
23850 }
23851
23852 uint32_t  __attribute__((export_name("TS_Balance_claimable_awaiting_confirmations"))) TS_Balance_claimable_awaiting_confirmations(int64_t claimable_amount_satoshis, int32_t confirmation_height) {
23853         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
23854         *ret_copy = Balance_claimable_awaiting_confirmations(claimable_amount_satoshis, confirmation_height);
23855         uint32_t ret_ref = (uintptr_t)ret_copy;
23856         return ret_ref;
23857 }
23858
23859 uint32_t  __attribute__((export_name("TS_Balance_contentious_claimable"))) TS_Balance_contentious_claimable(int64_t claimable_amount_satoshis, int32_t timeout_height) {
23860         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
23861         *ret_copy = Balance_contentious_claimable(claimable_amount_satoshis, timeout_height);
23862         uint32_t ret_ref = (uintptr_t)ret_copy;
23863         return ret_ref;
23864 }
23865
23866 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) {
23867         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
23868         *ret_copy = Balance_maybe_claimable_htlcawaiting_timeout(claimable_amount_satoshis, claimable_height);
23869         uint32_t ret_ref = (uintptr_t)ret_copy;
23870         return ret_ref;
23871 }
23872
23873 jboolean  __attribute__((export_name("TS_Balance_eq"))) TS_Balance_eq(uint32_t a, uint32_t b) {
23874         LDKBalance* a_conv = (LDKBalance*)a;
23875         LDKBalance* b_conv = (LDKBalance*)b;
23876         jboolean ret_conv = Balance_eq(a_conv, b_conv);
23877         return ret_conv;
23878 }
23879
23880 void  __attribute__((export_name("TS_ChannelMonitor_free"))) TS_ChannelMonitor_free(uint32_t this_obj) {
23881         LDKChannelMonitor this_obj_conv;
23882         this_obj_conv.inner = (void*)(this_obj & (~1));
23883         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23884         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23885         ChannelMonitor_free(this_obj_conv);
23886 }
23887
23888 static inline uintptr_t ChannelMonitor_clone_ptr(LDKChannelMonitor *NONNULL_PTR arg) {
23889         LDKChannelMonitor ret_var = ChannelMonitor_clone(arg);
23890 uint32_t ret_ref = 0;
23891 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23892 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23893 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23894 ret_ref = (uintptr_t)ret_var.inner;
23895 if (ret_var.is_owned) {
23896         ret_ref |= 1;
23897 }
23898         return ret_ref;
23899 }
23900 uint32_t  __attribute__((export_name("TS_ChannelMonitor_clone_ptr"))) TS_ChannelMonitor_clone_ptr(uint32_t arg) {
23901         LDKChannelMonitor arg_conv;
23902         arg_conv.inner = (void*)(arg & (~1));
23903         arg_conv.is_owned = false;
23904         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23905         uint32_t ret_conv = ChannelMonitor_clone_ptr(&arg_conv);
23906         return ret_conv;
23907 }
23908
23909 uint32_t  __attribute__((export_name("TS_ChannelMonitor_clone"))) TS_ChannelMonitor_clone(uint32_t orig) {
23910         LDKChannelMonitor orig_conv;
23911         orig_conv.inner = (void*)(orig & (~1));
23912         orig_conv.is_owned = false;
23913         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23914         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
23915         uint32_t ret_ref = 0;
23916         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23917         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23918         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23919         ret_ref = (uintptr_t)ret_var.inner;
23920         if (ret_var.is_owned) {
23921                 ret_ref |= 1;
23922         }
23923         return ret_ref;
23924 }
23925
23926 int8_tArray  __attribute__((export_name("TS_ChannelMonitor_write"))) TS_ChannelMonitor_write(uint32_t obj) {
23927         LDKChannelMonitor obj_conv;
23928         obj_conv.inner = (void*)(obj & (~1));
23929         obj_conv.is_owned = false;
23930         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
23931         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
23932         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
23933         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
23934         CVec_u8Z_free(ret_var);
23935         return ret_arr;
23936 }
23937
23938 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) {
23939         LDKChannelMonitor this_arg_conv;
23940         this_arg_conv.inner = (void*)(this_arg & (~1));
23941         this_arg_conv.is_owned = false;
23942         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23943         LDKChannelMonitorUpdate updates_conv;
23944         updates_conv.inner = (void*)(updates & (~1));
23945         updates_conv.is_owned = false;
23946         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
23947         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
23948         if (!(broadcaster & 1)) { CHECK_ACCESS(broadcaster_ptr); }
23949         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)broadcaster_ptr;
23950         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
23951         CHECK_ACCESS(fee_estimator_ptr);
23952         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
23953         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
23954                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23955                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
23956         }
23957         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
23958         if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
23959         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
23960         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
23961         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
23962         return (uint32_t)ret_conv;
23963 }
23964
23965 int64_t  __attribute__((export_name("TS_ChannelMonitor_get_latest_update_id"))) TS_ChannelMonitor_get_latest_update_id(uint32_t this_arg) {
23966         LDKChannelMonitor this_arg_conv;
23967         this_arg_conv.inner = (void*)(this_arg & (~1));
23968         this_arg_conv.is_owned = false;
23969         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23970         int64_t ret_conv = ChannelMonitor_get_latest_update_id(&this_arg_conv);
23971         return ret_conv;
23972 }
23973
23974 uint32_t  __attribute__((export_name("TS_ChannelMonitor_get_funding_txo"))) TS_ChannelMonitor_get_funding_txo(uint32_t this_arg) {
23975         LDKChannelMonitor this_arg_conv;
23976         this_arg_conv.inner = (void*)(this_arg & (~1));
23977         this_arg_conv.is_owned = false;
23978         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23979         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
23980         *ret_conv = ChannelMonitor_get_funding_txo(&this_arg_conv);
23981         return ((uint32_t)ret_conv);
23982 }
23983
23984 uint32_tArray  __attribute__((export_name("TS_ChannelMonitor_get_outputs_to_watch"))) TS_ChannelMonitor_get_outputs_to_watch(uint32_t this_arg) {
23985         LDKChannelMonitor this_arg_conv;
23986         this_arg_conv.inner = (void*)(this_arg & (~1));
23987         this_arg_conv.is_owned = false;
23988         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23989         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
23990         uint32_tArray ret_arr = NULL;
23991         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
23992         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 8);
23993         for (size_t o = 0; o < ret_var.datalen; o++) {
23994                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_40_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
23995                 *ret_conv_40_conv = ret_var.data[o];
23996                 ret_arr_ptr[o] = ((uint32_t)ret_conv_40_conv);
23997         }
23998         
23999         FREE(ret_var.data);
24000         return ret_arr;
24001 }
24002
24003 void  __attribute__((export_name("TS_ChannelMonitor_load_outputs_to_watch"))) TS_ChannelMonitor_load_outputs_to_watch(uint32_t this_arg, uint32_t filter) {
24004         LDKChannelMonitor this_arg_conv;
24005         this_arg_conv.inner = (void*)(this_arg & (~1));
24006         this_arg_conv.is_owned = false;
24007         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24008         void* filter_ptr = (void*)(((uintptr_t)filter) & ~1);
24009         if (!(filter & 1)) { CHECK_ACCESS(filter_ptr); }
24010         LDKFilter* filter_conv = (LDKFilter*)filter_ptr;
24011         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
24012 }
24013
24014 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) {
24015         LDKChannelMonitor this_arg_conv;
24016         this_arg_conv.inner = (void*)(this_arg & (~1));
24017         this_arg_conv.is_owned = false;
24018         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24019         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
24020         uint32_tArray ret_arr = NULL;
24021         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
24022         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 8);
24023         for (size_t o = 0; o < ret_var.datalen; o++) {
24024                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
24025                 *ret_conv_14_copy = ret_var.data[o];
24026                 uint32_t ret_conv_14_ref = (uintptr_t)ret_conv_14_copy;
24027                 ret_arr_ptr[o] = ret_conv_14_ref;
24028         }
24029         
24030         FREE(ret_var.data);
24031         return ret_arr;
24032 }
24033
24034 uint32_tArray  __attribute__((export_name("TS_ChannelMonitor_get_and_clear_pending_events"))) TS_ChannelMonitor_get_and_clear_pending_events(uint32_t this_arg) {
24035         LDKChannelMonitor this_arg_conv;
24036         this_arg_conv.inner = (void*)(this_arg & (~1));
24037         this_arg_conv.is_owned = false;
24038         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24039         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
24040         uint32_tArray ret_arr = NULL;
24041         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
24042         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 8);
24043         for (size_t h = 0; h < ret_var.datalen; h++) {
24044                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24045                 *ret_conv_7_copy = ret_var.data[h];
24046                 uint32_t ret_conv_7_ref = (uintptr_t)ret_conv_7_copy;
24047                 ret_arr_ptr[h] = ret_conv_7_ref;
24048         }
24049         
24050         FREE(ret_var.data);
24051         return ret_arr;
24052 }
24053
24054 int8_tArray  __attribute__((export_name("TS_ChannelMonitor_get_counterparty_node_id"))) TS_ChannelMonitor_get_counterparty_node_id(uint32_t this_arg) {
24055         LDKChannelMonitor this_arg_conv;
24056         this_arg_conv.inner = (void*)(this_arg & (~1));
24057         this_arg_conv.is_owned = false;
24058         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24059         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
24060         memcpy(ret_arr->elems, ChannelMonitor_get_counterparty_node_id(&this_arg_conv).compressed_form, 33);
24061         return ret_arr;
24062 }
24063
24064 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) {
24065         LDKChannelMonitor this_arg_conv;
24066         this_arg_conv.inner = (void*)(this_arg & (~1));
24067         this_arg_conv.is_owned = false;
24068         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24069         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
24070         if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
24071         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
24072         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
24073         ptrArray ret_arr = NULL;
24074         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
24075         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 8);
24076         for (size_t m = 0; m < ret_var.datalen; m++) {
24077                 LDKTransaction ret_conv_12_var = ret_var.data[m];
24078                 int8_tArray ret_conv_12_arr = init_int8_tArray(ret_conv_12_var.datalen, __LINE__);
24079                 memcpy(ret_conv_12_arr->elems, ret_conv_12_var.data, ret_conv_12_var.datalen);
24080                 Transaction_free(ret_conv_12_var);
24081                 ret_arr_ptr[m] = ret_conv_12_arr;
24082         }
24083         
24084         FREE(ret_var.data);
24085         return ret_arr;
24086 }
24087
24088 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) {
24089         LDKChannelMonitor this_arg_conv;
24090         this_arg_conv.inner = (void*)(this_arg & (~1));
24091         this_arg_conv.is_owned = false;
24092         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24093         unsigned char header_arr[80];
24094         CHECK(header->arr_len == 80);
24095         memcpy(header_arr, header->elems, 80); FREE(header);
24096         unsigned char (*header_ref)[80] = &header_arr;
24097         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
24098         txdata_constr.datalen = txdata->arr_len;
24099         if (txdata_constr.datalen > 0)
24100                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
24101         else
24102                 txdata_constr.data = NULL;
24103         uint32_t* txdata_vals = txdata->elems;
24104         for (size_t c = 0; c < txdata_constr.datalen; c++) {
24105                 uint32_t txdata_conv_28 = txdata_vals[c];
24106                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
24107                 CHECK_ACCESS(txdata_conv_28_ptr);
24108                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
24109                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
24110                 txdata_constr.data[c] = txdata_conv_28_conv;
24111         }
24112         FREE(txdata);
24113         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
24114         CHECK_ACCESS(broadcaster_ptr);
24115         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
24116         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
24117                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24118                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
24119         }
24120         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
24121         CHECK_ACCESS(fee_estimator_ptr);
24122         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
24123         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
24124                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24125                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
24126         }
24127         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
24128         CHECK_ACCESS(logger_ptr);
24129         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
24130         if (logger_conv.free == LDKLogger_JCalls_free) {
24131                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24132                 LDKLogger_JCalls_cloned(&logger_conv);
24133         }
24134         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);
24135         uint32_tArray ret_arr = NULL;
24136         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
24137         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 8);
24138         for (size_t n = 0; n < ret_var.datalen; n++) {
24139                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
24140                 *ret_conv_39_conv = ret_var.data[n];
24141                 ret_arr_ptr[n] = ((uint32_t)ret_conv_39_conv);
24142         }
24143         
24144         FREE(ret_var.data);
24145         return ret_arr;
24146 }
24147
24148 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) {
24149         LDKChannelMonitor this_arg_conv;
24150         this_arg_conv.inner = (void*)(this_arg & (~1));
24151         this_arg_conv.is_owned = false;
24152         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24153         unsigned char header_arr[80];
24154         CHECK(header->arr_len == 80);
24155         memcpy(header_arr, header->elems, 80); FREE(header);
24156         unsigned char (*header_ref)[80] = &header_arr;
24157         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
24158         CHECK_ACCESS(broadcaster_ptr);
24159         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
24160         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
24161                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24162                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
24163         }
24164         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
24165         CHECK_ACCESS(fee_estimator_ptr);
24166         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
24167         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
24168                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24169                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
24170         }
24171         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
24172         CHECK_ACCESS(logger_ptr);
24173         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
24174         if (logger_conv.free == LDKLogger_JCalls_free) {
24175                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24176                 LDKLogger_JCalls_cloned(&logger_conv);
24177         }
24178         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
24179 }
24180
24181 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) {
24182         LDKChannelMonitor this_arg_conv;
24183         this_arg_conv.inner = (void*)(this_arg & (~1));
24184         this_arg_conv.is_owned = false;
24185         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24186         unsigned char header_arr[80];
24187         CHECK(header->arr_len == 80);
24188         memcpy(header_arr, header->elems, 80); FREE(header);
24189         unsigned char (*header_ref)[80] = &header_arr;
24190         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
24191         txdata_constr.datalen = txdata->arr_len;
24192         if (txdata_constr.datalen > 0)
24193                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
24194         else
24195                 txdata_constr.data = NULL;
24196         uint32_t* txdata_vals = txdata->elems;
24197         for (size_t c = 0; c < txdata_constr.datalen; c++) {
24198                 uint32_t txdata_conv_28 = txdata_vals[c];
24199                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
24200                 CHECK_ACCESS(txdata_conv_28_ptr);
24201                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
24202                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
24203                 txdata_constr.data[c] = txdata_conv_28_conv;
24204         }
24205         FREE(txdata);
24206         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
24207         CHECK_ACCESS(broadcaster_ptr);
24208         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
24209         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
24210                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24211                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
24212         }
24213         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
24214         CHECK_ACCESS(fee_estimator_ptr);
24215         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
24216         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
24217                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24218                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
24219         }
24220         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
24221         CHECK_ACCESS(logger_ptr);
24222         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
24223         if (logger_conv.free == LDKLogger_JCalls_free) {
24224                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24225                 LDKLogger_JCalls_cloned(&logger_conv);
24226         }
24227         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);
24228         uint32_tArray ret_arr = NULL;
24229         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
24230         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 8);
24231         for (size_t n = 0; n < ret_var.datalen; n++) {
24232                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
24233                 *ret_conv_39_conv = ret_var.data[n];
24234                 ret_arr_ptr[n] = ((uint32_t)ret_conv_39_conv);
24235         }
24236         
24237         FREE(ret_var.data);
24238         return ret_arr;
24239 }
24240
24241 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) {
24242         LDKChannelMonitor this_arg_conv;
24243         this_arg_conv.inner = (void*)(this_arg & (~1));
24244         this_arg_conv.is_owned = false;
24245         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24246         unsigned char txid_arr[32];
24247         CHECK(txid->arr_len == 32);
24248         memcpy(txid_arr, txid->elems, 32); FREE(txid);
24249         unsigned char (*txid_ref)[32] = &txid_arr;
24250         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
24251         CHECK_ACCESS(broadcaster_ptr);
24252         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
24253         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
24254                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24255                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
24256         }
24257         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
24258         CHECK_ACCESS(fee_estimator_ptr);
24259         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
24260         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
24261                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24262                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
24263         }
24264         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
24265         CHECK_ACCESS(logger_ptr);
24266         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
24267         if (logger_conv.free == LDKLogger_JCalls_free) {
24268                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24269                 LDKLogger_JCalls_cloned(&logger_conv);
24270         }
24271         ChannelMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref, broadcaster_conv, fee_estimator_conv, logger_conv);
24272 }
24273
24274 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) {
24275         LDKChannelMonitor this_arg_conv;
24276         this_arg_conv.inner = (void*)(this_arg & (~1));
24277         this_arg_conv.is_owned = false;
24278         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24279         unsigned char header_arr[80];
24280         CHECK(header->arr_len == 80);
24281         memcpy(header_arr, header->elems, 80); FREE(header);
24282         unsigned char (*header_ref)[80] = &header_arr;
24283         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
24284         CHECK_ACCESS(broadcaster_ptr);
24285         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
24286         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
24287                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24288                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
24289         }
24290         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
24291         CHECK_ACCESS(fee_estimator_ptr);
24292         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
24293         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
24294                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24295                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
24296         }
24297         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
24298         CHECK_ACCESS(logger_ptr);
24299         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
24300         if (logger_conv.free == LDKLogger_JCalls_free) {
24301                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24302                 LDKLogger_JCalls_cloned(&logger_conv);
24303         }
24304         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_best_block_updated(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
24305         uint32_tArray ret_arr = NULL;
24306         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
24307         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 8);
24308         for (size_t n = 0; n < ret_var.datalen; n++) {
24309                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
24310                 *ret_conv_39_conv = ret_var.data[n];
24311                 ret_arr_ptr[n] = ((uint32_t)ret_conv_39_conv);
24312         }
24313         
24314         FREE(ret_var.data);
24315         return ret_arr;
24316 }
24317
24318 ptrArray  __attribute__((export_name("TS_ChannelMonitor_get_relevant_txids"))) TS_ChannelMonitor_get_relevant_txids(uint32_t this_arg) {
24319         LDKChannelMonitor this_arg_conv;
24320         this_arg_conv.inner = (void*)(this_arg & (~1));
24321         this_arg_conv.is_owned = false;
24322         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24323         LDKCVec_TxidZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_conv);
24324         ptrArray ret_arr = NULL;
24325         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
24326         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 8);
24327         for (size_t m = 0; m < ret_var.datalen; m++) {
24328                 int8_tArray ret_conv_12_arr = init_int8_tArray(32, __LINE__);
24329                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].data, 32);
24330                 ret_arr_ptr[m] = ret_conv_12_arr;
24331         }
24332         
24333         FREE(ret_var.data);
24334         return ret_arr;
24335 }
24336
24337 uint32_t  __attribute__((export_name("TS_ChannelMonitor_current_best_block"))) TS_ChannelMonitor_current_best_block(uint32_t this_arg) {
24338         LDKChannelMonitor this_arg_conv;
24339         this_arg_conv.inner = (void*)(this_arg & (~1));
24340         this_arg_conv.is_owned = false;
24341         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24342         LDKBestBlock ret_var = ChannelMonitor_current_best_block(&this_arg_conv);
24343         uint32_t ret_ref = 0;
24344         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24345         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24346         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24347         ret_ref = (uintptr_t)ret_var.inner;
24348         if (ret_var.is_owned) {
24349                 ret_ref |= 1;
24350         }
24351         return ret_ref;
24352 }
24353
24354 uint32_tArray  __attribute__((export_name("TS_ChannelMonitor_get_claimable_balances"))) TS_ChannelMonitor_get_claimable_balances(uint32_t this_arg) {
24355         LDKChannelMonitor this_arg_conv;
24356         this_arg_conv.inner = (void*)(this_arg & (~1));
24357         this_arg_conv.is_owned = false;
24358         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24359         LDKCVec_BalanceZ ret_var = ChannelMonitor_get_claimable_balances(&this_arg_conv);
24360         uint32_tArray ret_arr = NULL;
24361         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
24362         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 8);
24363         for (size_t j = 0; j < ret_var.datalen; j++) {
24364                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
24365                 *ret_conv_9_copy = ret_var.data[j];
24366                 uint32_t ret_conv_9_ref = (uintptr_t)ret_conv_9_copy;
24367                 ret_arr_ptr[j] = ret_conv_9_ref;
24368         }
24369         
24370         FREE(ret_var.data);
24371         return ret_arr;
24372 }
24373
24374 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_read"))) TS_C2Tuple_BlockHashChannelMonitorZ_read(int8_tArray ser, uint32_t arg) {
24375         LDKu8slice ser_ref;
24376         ser_ref.datalen = ser->arr_len;
24377         ser_ref.data = ser->elems;
24378         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
24379         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
24380         LDKKeysInterface* arg_conv = (LDKKeysInterface*)arg_ptr;
24381         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
24382         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
24383         FREE(ser);
24384         return (uint32_t)ret_conv;
24385 }
24386
24387 void  __attribute__((export_name("TS_OutPoint_free"))) TS_OutPoint_free(uint32_t this_obj) {
24388         LDKOutPoint this_obj_conv;
24389         this_obj_conv.inner = (void*)(this_obj & (~1));
24390         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24391         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24392         OutPoint_free(this_obj_conv);
24393 }
24394
24395 int8_tArray  __attribute__((export_name("TS_OutPoint_get_txid"))) TS_OutPoint_get_txid(uint32_t this_ptr) {
24396         LDKOutPoint this_ptr_conv;
24397         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24398         this_ptr_conv.is_owned = false;
24399         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24400         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
24401         memcpy(ret_arr->elems, *OutPoint_get_txid(&this_ptr_conv), 32);
24402         return ret_arr;
24403 }
24404
24405 void  __attribute__((export_name("TS_OutPoint_set_txid"))) TS_OutPoint_set_txid(uint32_t this_ptr, int8_tArray val) {
24406         LDKOutPoint this_ptr_conv;
24407         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24408         this_ptr_conv.is_owned = false;
24409         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24410         LDKThirtyTwoBytes val_ref;
24411         CHECK(val->arr_len == 32);
24412         memcpy(val_ref.data, val->elems, 32); FREE(val);
24413         OutPoint_set_txid(&this_ptr_conv, val_ref);
24414 }
24415
24416 int16_t  __attribute__((export_name("TS_OutPoint_get_index"))) TS_OutPoint_get_index(uint32_t this_ptr) {
24417         LDKOutPoint this_ptr_conv;
24418         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24419         this_ptr_conv.is_owned = false;
24420         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24421         int16_t ret_conv = OutPoint_get_index(&this_ptr_conv);
24422         return ret_conv;
24423 }
24424
24425 void  __attribute__((export_name("TS_OutPoint_set_index"))) TS_OutPoint_set_index(uint32_t this_ptr, int16_t val) {
24426         LDKOutPoint this_ptr_conv;
24427         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24428         this_ptr_conv.is_owned = false;
24429         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24430         OutPoint_set_index(&this_ptr_conv, val);
24431 }
24432
24433 uint32_t  __attribute__((export_name("TS_OutPoint_new"))) TS_OutPoint_new(int8_tArray txid_arg, int16_t index_arg) {
24434         LDKThirtyTwoBytes txid_arg_ref;
24435         CHECK(txid_arg->arr_len == 32);
24436         memcpy(txid_arg_ref.data, txid_arg->elems, 32); FREE(txid_arg);
24437         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
24438         uint32_t ret_ref = 0;
24439         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24440         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24441         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24442         ret_ref = (uintptr_t)ret_var.inner;
24443         if (ret_var.is_owned) {
24444                 ret_ref |= 1;
24445         }
24446         return ret_ref;
24447 }
24448
24449 static inline uintptr_t OutPoint_clone_ptr(LDKOutPoint *NONNULL_PTR arg) {
24450         LDKOutPoint ret_var = OutPoint_clone(arg);
24451 uint32_t ret_ref = 0;
24452 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24453 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24454 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24455 ret_ref = (uintptr_t)ret_var.inner;
24456 if (ret_var.is_owned) {
24457         ret_ref |= 1;
24458 }
24459         return ret_ref;
24460 }
24461 uint32_t  __attribute__((export_name("TS_OutPoint_clone_ptr"))) TS_OutPoint_clone_ptr(uint32_t arg) {
24462         LDKOutPoint arg_conv;
24463         arg_conv.inner = (void*)(arg & (~1));
24464         arg_conv.is_owned = false;
24465         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24466         uint32_t ret_conv = OutPoint_clone_ptr(&arg_conv);
24467         return ret_conv;
24468 }
24469
24470 uint32_t  __attribute__((export_name("TS_OutPoint_clone"))) TS_OutPoint_clone(uint32_t orig) {
24471         LDKOutPoint orig_conv;
24472         orig_conv.inner = (void*)(orig & (~1));
24473         orig_conv.is_owned = false;
24474         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24475         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
24476         uint32_t ret_ref = 0;
24477         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24478         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24479         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24480         ret_ref = (uintptr_t)ret_var.inner;
24481         if (ret_var.is_owned) {
24482                 ret_ref |= 1;
24483         }
24484         return ret_ref;
24485 }
24486
24487 jboolean  __attribute__((export_name("TS_OutPoint_eq"))) TS_OutPoint_eq(uint32_t a, uint32_t b) {
24488         LDKOutPoint a_conv;
24489         a_conv.inner = (void*)(a & (~1));
24490         a_conv.is_owned = false;
24491         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
24492         LDKOutPoint b_conv;
24493         b_conv.inner = (void*)(b & (~1));
24494         b_conv.is_owned = false;
24495         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
24496         jboolean ret_conv = OutPoint_eq(&a_conv, &b_conv);
24497         return ret_conv;
24498 }
24499
24500 int64_t  __attribute__((export_name("TS_OutPoint_hash"))) TS_OutPoint_hash(uint32_t o) {
24501         LDKOutPoint o_conv;
24502         o_conv.inner = (void*)(o & (~1));
24503         o_conv.is_owned = false;
24504         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24505         int64_t ret_conv = OutPoint_hash(&o_conv);
24506         return ret_conv;
24507 }
24508
24509 int8_tArray  __attribute__((export_name("TS_OutPoint_to_channel_id"))) TS_OutPoint_to_channel_id(uint32_t this_arg) {
24510         LDKOutPoint this_arg_conv;
24511         this_arg_conv.inner = (void*)(this_arg & (~1));
24512         this_arg_conv.is_owned = false;
24513         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24514         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
24515         memcpy(ret_arr->elems, OutPoint_to_channel_id(&this_arg_conv).data, 32);
24516         return ret_arr;
24517 }
24518
24519 int8_tArray  __attribute__((export_name("TS_OutPoint_write"))) TS_OutPoint_write(uint32_t obj) {
24520         LDKOutPoint obj_conv;
24521         obj_conv.inner = (void*)(obj & (~1));
24522         obj_conv.is_owned = false;
24523         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
24524         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
24525         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
24526         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
24527         CVec_u8Z_free(ret_var);
24528         return ret_arr;
24529 }
24530
24531 uint32_t  __attribute__((export_name("TS_OutPoint_read"))) TS_OutPoint_read(int8_tArray ser) {
24532         LDKu8slice ser_ref;
24533         ser_ref.datalen = ser->arr_len;
24534         ser_ref.data = ser->elems;
24535         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
24536         *ret_conv = OutPoint_read(ser_ref);
24537         FREE(ser);
24538         return (uint32_t)ret_conv;
24539 }
24540
24541 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_free"))) TS_DelayedPaymentOutputDescriptor_free(uint32_t this_obj) {
24542         LDKDelayedPaymentOutputDescriptor this_obj_conv;
24543         this_obj_conv.inner = (void*)(this_obj & (~1));
24544         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24545         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24546         DelayedPaymentOutputDescriptor_free(this_obj_conv);
24547 }
24548
24549 uint32_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_outpoint"))) TS_DelayedPaymentOutputDescriptor_get_outpoint(uint32_t this_ptr) {
24550         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24551         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24552         this_ptr_conv.is_owned = false;
24553         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24554         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
24555         uint32_t ret_ref = 0;
24556         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24557         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24558         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24559         ret_ref = (uintptr_t)ret_var.inner;
24560         if (ret_var.is_owned) {
24561                 ret_ref |= 1;
24562         }
24563         return ret_ref;
24564 }
24565
24566 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_outpoint"))) TS_DelayedPaymentOutputDescriptor_set_outpoint(uint32_t this_ptr, uint32_t val) {
24567         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24568         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24569         this_ptr_conv.is_owned = false;
24570         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24571         LDKOutPoint val_conv;
24572         val_conv.inner = (void*)(val & (~1));
24573         val_conv.is_owned = (val & 1) || (val == 0);
24574         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
24575         val_conv = OutPoint_clone(&val_conv);
24576         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
24577 }
24578
24579 int8_tArray  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_per_commitment_point"))) TS_DelayedPaymentOutputDescriptor_get_per_commitment_point(uint32_t this_ptr) {
24580         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24581         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24582         this_ptr_conv.is_owned = false;
24583         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24584         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
24585         memcpy(ret_arr->elems, DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form, 33);
24586         return ret_arr;
24587 }
24588
24589 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_per_commitment_point"))) TS_DelayedPaymentOutputDescriptor_set_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
24590         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24591         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24592         this_ptr_conv.is_owned = false;
24593         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24594         LDKPublicKey val_ref;
24595         CHECK(val->arr_len == 33);
24596         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
24597         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
24598 }
24599
24600 int16_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_to_self_delay"))) TS_DelayedPaymentOutputDescriptor_get_to_self_delay(uint32_t this_ptr) {
24601         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24602         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24603         this_ptr_conv.is_owned = false;
24604         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24605         int16_t ret_conv = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
24606         return ret_conv;
24607 }
24608
24609 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_to_self_delay"))) TS_DelayedPaymentOutputDescriptor_set_to_self_delay(uint32_t this_ptr, int16_t val) {
24610         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24611         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24612         this_ptr_conv.is_owned = false;
24613         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24614         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
24615 }
24616
24617 uint32_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_output"))) TS_DelayedPaymentOutputDescriptor_get_output(uint32_t this_ptr) {
24618         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24619         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24620         this_ptr_conv.is_owned = false;
24621         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24622         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
24623         *ret_ref = DelayedPaymentOutputDescriptor_get_output(&this_ptr_conv);
24624         return (uint32_t)ret_ref;
24625 }
24626
24627 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_output"))) TS_DelayedPaymentOutputDescriptor_set_output(uint32_t this_ptr, uint32_t val) {
24628         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24629         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24630         this_ptr_conv.is_owned = false;
24631         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24632         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
24633         CHECK_ACCESS(val_ptr);
24634         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
24635         val_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)val) & ~1));
24636         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
24637 }
24638
24639 int8_tArray  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_revocation_pubkey"))) TS_DelayedPaymentOutputDescriptor_get_revocation_pubkey(uint32_t this_ptr) {
24640         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24641         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24642         this_ptr_conv.is_owned = false;
24643         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24644         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
24645         memcpy(ret_arr->elems, DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form, 33);
24646         return ret_arr;
24647 }
24648
24649 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_revocation_pubkey"))) TS_DelayedPaymentOutputDescriptor_set_revocation_pubkey(uint32_t this_ptr, int8_tArray val) {
24650         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24651         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24652         this_ptr_conv.is_owned = false;
24653         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24654         LDKPublicKey val_ref;
24655         CHECK(val->arr_len == 33);
24656         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
24657         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
24658 }
24659
24660 int8_tArray  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_channel_keys_id"))) TS_DelayedPaymentOutputDescriptor_get_channel_keys_id(uint32_t this_ptr) {
24661         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24662         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24663         this_ptr_conv.is_owned = false;
24664         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24665         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
24666         memcpy(ret_arr->elems, *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv), 32);
24667         return ret_arr;
24668 }
24669
24670 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_channel_keys_id"))) TS_DelayedPaymentOutputDescriptor_set_channel_keys_id(uint32_t this_ptr, int8_tArray val) {
24671         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24672         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24673         this_ptr_conv.is_owned = false;
24674         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24675         LDKThirtyTwoBytes val_ref;
24676         CHECK(val->arr_len == 32);
24677         memcpy(val_ref.data, val->elems, 32); FREE(val);
24678         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
24679 }
24680
24681 int64_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_channel_value_satoshis"))) TS_DelayedPaymentOutputDescriptor_get_channel_value_satoshis(uint32_t this_ptr) {
24682         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24683         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24684         this_ptr_conv.is_owned = false;
24685         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24686         int64_t ret_conv = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
24687         return ret_conv;
24688 }
24689
24690 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_channel_value_satoshis"))) TS_DelayedPaymentOutputDescriptor_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
24691         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
24692         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24693         this_ptr_conv.is_owned = false;
24694         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24695         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
24696 }
24697
24698 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) {
24699         LDKOutPoint outpoint_arg_conv;
24700         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
24701         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
24702         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
24703         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
24704         LDKPublicKey per_commitment_point_arg_ref;
24705         CHECK(per_commitment_point_arg->arr_len == 33);
24706         memcpy(per_commitment_point_arg_ref.compressed_form, per_commitment_point_arg->elems, 33); FREE(per_commitment_point_arg);
24707         void* output_arg_ptr = (void*)(((uintptr_t)output_arg) & ~1);
24708         CHECK_ACCESS(output_arg_ptr);
24709         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
24710         output_arg_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output_arg) & ~1));
24711         LDKPublicKey revocation_pubkey_arg_ref;
24712         CHECK(revocation_pubkey_arg->arr_len == 33);
24713         memcpy(revocation_pubkey_arg_ref.compressed_form, revocation_pubkey_arg->elems, 33); FREE(revocation_pubkey_arg);
24714         LDKThirtyTwoBytes channel_keys_id_arg_ref;
24715         CHECK(channel_keys_id_arg->arr_len == 32);
24716         memcpy(channel_keys_id_arg_ref.data, channel_keys_id_arg->elems, 32); FREE(channel_keys_id_arg);
24717         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);
24718         uint32_t ret_ref = 0;
24719         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24720         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24721         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24722         ret_ref = (uintptr_t)ret_var.inner;
24723         if (ret_var.is_owned) {
24724                 ret_ref |= 1;
24725         }
24726         return ret_ref;
24727 }
24728
24729 static inline uintptr_t DelayedPaymentOutputDescriptor_clone_ptr(LDKDelayedPaymentOutputDescriptor *NONNULL_PTR arg) {
24730         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(arg);
24731 uint32_t ret_ref = 0;
24732 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24733 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24734 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24735 ret_ref = (uintptr_t)ret_var.inner;
24736 if (ret_var.is_owned) {
24737         ret_ref |= 1;
24738 }
24739         return ret_ref;
24740 }
24741 uint32_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_clone_ptr"))) TS_DelayedPaymentOutputDescriptor_clone_ptr(uint32_t arg) {
24742         LDKDelayedPaymentOutputDescriptor arg_conv;
24743         arg_conv.inner = (void*)(arg & (~1));
24744         arg_conv.is_owned = false;
24745         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24746         uint32_t ret_conv = DelayedPaymentOutputDescriptor_clone_ptr(&arg_conv);
24747         return ret_conv;
24748 }
24749
24750 uint32_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_clone"))) TS_DelayedPaymentOutputDescriptor_clone(uint32_t orig) {
24751         LDKDelayedPaymentOutputDescriptor orig_conv;
24752         orig_conv.inner = (void*)(orig & (~1));
24753         orig_conv.is_owned = false;
24754         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24755         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
24756         uint32_t ret_ref = 0;
24757         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24758         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24759         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24760         ret_ref = (uintptr_t)ret_var.inner;
24761         if (ret_var.is_owned) {
24762                 ret_ref |= 1;
24763         }
24764         return ret_ref;
24765 }
24766
24767 int8_tArray  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_write"))) TS_DelayedPaymentOutputDescriptor_write(uint32_t obj) {
24768         LDKDelayedPaymentOutputDescriptor obj_conv;
24769         obj_conv.inner = (void*)(obj & (~1));
24770         obj_conv.is_owned = false;
24771         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
24772         LDKCVec_u8Z ret_var = DelayedPaymentOutputDescriptor_write(&obj_conv);
24773         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
24774         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
24775         CVec_u8Z_free(ret_var);
24776         return ret_arr;
24777 }
24778
24779 uint32_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_read"))) TS_DelayedPaymentOutputDescriptor_read(int8_tArray ser) {
24780         LDKu8slice ser_ref;
24781         ser_ref.datalen = ser->arr_len;
24782         ser_ref.data = ser->elems;
24783         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
24784         *ret_conv = DelayedPaymentOutputDescriptor_read(ser_ref);
24785         FREE(ser);
24786         return (uint32_t)ret_conv;
24787 }
24788
24789 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_free"))) TS_StaticPaymentOutputDescriptor_free(uint32_t this_obj) {
24790         LDKStaticPaymentOutputDescriptor this_obj_conv;
24791         this_obj_conv.inner = (void*)(this_obj & (~1));
24792         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24793         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24794         StaticPaymentOutputDescriptor_free(this_obj_conv);
24795 }
24796
24797 uint32_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_get_outpoint"))) TS_StaticPaymentOutputDescriptor_get_outpoint(uint32_t this_ptr) {
24798         LDKStaticPaymentOutputDescriptor this_ptr_conv;
24799         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24800         this_ptr_conv.is_owned = false;
24801         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24802         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
24803         uint32_t ret_ref = 0;
24804         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24805         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24806         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24807         ret_ref = (uintptr_t)ret_var.inner;
24808         if (ret_var.is_owned) {
24809                 ret_ref |= 1;
24810         }
24811         return ret_ref;
24812 }
24813
24814 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_set_outpoint"))) TS_StaticPaymentOutputDescriptor_set_outpoint(uint32_t this_ptr, uint32_t val) {
24815         LDKStaticPaymentOutputDescriptor this_ptr_conv;
24816         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24817         this_ptr_conv.is_owned = false;
24818         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24819         LDKOutPoint val_conv;
24820         val_conv.inner = (void*)(val & (~1));
24821         val_conv.is_owned = (val & 1) || (val == 0);
24822         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
24823         val_conv = OutPoint_clone(&val_conv);
24824         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
24825 }
24826
24827 uint32_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_get_output"))) TS_StaticPaymentOutputDescriptor_get_output(uint32_t this_ptr) {
24828         LDKStaticPaymentOutputDescriptor this_ptr_conv;
24829         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24830         this_ptr_conv.is_owned = false;
24831         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24832         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
24833         *ret_ref = StaticPaymentOutputDescriptor_get_output(&this_ptr_conv);
24834         return (uint32_t)ret_ref;
24835 }
24836
24837 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_set_output"))) TS_StaticPaymentOutputDescriptor_set_output(uint32_t this_ptr, uint32_t val) {
24838         LDKStaticPaymentOutputDescriptor this_ptr_conv;
24839         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24840         this_ptr_conv.is_owned = false;
24841         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24842         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
24843         CHECK_ACCESS(val_ptr);
24844         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
24845         val_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)val) & ~1));
24846         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
24847 }
24848
24849 int8_tArray  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_get_channel_keys_id"))) TS_StaticPaymentOutputDescriptor_get_channel_keys_id(uint32_t this_ptr) {
24850         LDKStaticPaymentOutputDescriptor this_ptr_conv;
24851         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24852         this_ptr_conv.is_owned = false;
24853         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24854         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
24855         memcpy(ret_arr->elems, *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv), 32);
24856         return ret_arr;
24857 }
24858
24859 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_set_channel_keys_id"))) TS_StaticPaymentOutputDescriptor_set_channel_keys_id(uint32_t this_ptr, int8_tArray val) {
24860         LDKStaticPaymentOutputDescriptor this_ptr_conv;
24861         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24862         this_ptr_conv.is_owned = false;
24863         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24864         LDKThirtyTwoBytes val_ref;
24865         CHECK(val->arr_len == 32);
24866         memcpy(val_ref.data, val->elems, 32); FREE(val);
24867         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
24868 }
24869
24870 int64_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_get_channel_value_satoshis"))) TS_StaticPaymentOutputDescriptor_get_channel_value_satoshis(uint32_t this_ptr) {
24871         LDKStaticPaymentOutputDescriptor this_ptr_conv;
24872         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24873         this_ptr_conv.is_owned = false;
24874         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24875         int64_t ret_conv = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
24876         return ret_conv;
24877 }
24878
24879 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_set_channel_value_satoshis"))) TS_StaticPaymentOutputDescriptor_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
24880         LDKStaticPaymentOutputDescriptor this_ptr_conv;
24881         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24882         this_ptr_conv.is_owned = false;
24883         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24884         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
24885 }
24886
24887 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) {
24888         LDKOutPoint outpoint_arg_conv;
24889         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
24890         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
24891         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
24892         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
24893         void* output_arg_ptr = (void*)(((uintptr_t)output_arg) & ~1);
24894         CHECK_ACCESS(output_arg_ptr);
24895         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
24896         output_arg_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output_arg) & ~1));
24897         LDKThirtyTwoBytes channel_keys_id_arg_ref;
24898         CHECK(channel_keys_id_arg->arr_len == 32);
24899         memcpy(channel_keys_id_arg_ref.data, channel_keys_id_arg->elems, 32); FREE(channel_keys_id_arg);
24900         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
24901         uint32_t ret_ref = 0;
24902         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24903         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24904         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24905         ret_ref = (uintptr_t)ret_var.inner;
24906         if (ret_var.is_owned) {
24907                 ret_ref |= 1;
24908         }
24909         return ret_ref;
24910 }
24911
24912 static inline uintptr_t StaticPaymentOutputDescriptor_clone_ptr(LDKStaticPaymentOutputDescriptor *NONNULL_PTR arg) {
24913         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(arg);
24914 uint32_t ret_ref = 0;
24915 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24916 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24917 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24918 ret_ref = (uintptr_t)ret_var.inner;
24919 if (ret_var.is_owned) {
24920         ret_ref |= 1;
24921 }
24922         return ret_ref;
24923 }
24924 uint32_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_clone_ptr"))) TS_StaticPaymentOutputDescriptor_clone_ptr(uint32_t arg) {
24925         LDKStaticPaymentOutputDescriptor arg_conv;
24926         arg_conv.inner = (void*)(arg & (~1));
24927         arg_conv.is_owned = false;
24928         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24929         uint32_t ret_conv = StaticPaymentOutputDescriptor_clone_ptr(&arg_conv);
24930         return ret_conv;
24931 }
24932
24933 uint32_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_clone"))) TS_StaticPaymentOutputDescriptor_clone(uint32_t orig) {
24934         LDKStaticPaymentOutputDescriptor orig_conv;
24935         orig_conv.inner = (void*)(orig & (~1));
24936         orig_conv.is_owned = false;
24937         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24938         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
24939         uint32_t ret_ref = 0;
24940         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24941         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24942         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24943         ret_ref = (uintptr_t)ret_var.inner;
24944         if (ret_var.is_owned) {
24945                 ret_ref |= 1;
24946         }
24947         return ret_ref;
24948 }
24949
24950 int8_tArray  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_write"))) TS_StaticPaymentOutputDescriptor_write(uint32_t obj) {
24951         LDKStaticPaymentOutputDescriptor obj_conv;
24952         obj_conv.inner = (void*)(obj & (~1));
24953         obj_conv.is_owned = false;
24954         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
24955         LDKCVec_u8Z ret_var = StaticPaymentOutputDescriptor_write(&obj_conv);
24956         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
24957         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
24958         CVec_u8Z_free(ret_var);
24959         return ret_arr;
24960 }
24961
24962 uint32_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_read"))) TS_StaticPaymentOutputDescriptor_read(int8_tArray ser) {
24963         LDKu8slice ser_ref;
24964         ser_ref.datalen = ser->arr_len;
24965         ser_ref.data = ser->elems;
24966         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
24967         *ret_conv = StaticPaymentOutputDescriptor_read(ser_ref);
24968         FREE(ser);
24969         return (uint32_t)ret_conv;
24970 }
24971
24972 void  __attribute__((export_name("TS_SpendableOutputDescriptor_free"))) TS_SpendableOutputDescriptor_free(uint32_t this_ptr) {
24973         if ((this_ptr & 1) != 0) return;
24974         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
24975         CHECK_ACCESS(this_ptr_ptr);
24976         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(this_ptr_ptr);
24977         FREE((void*)this_ptr);
24978         SpendableOutputDescriptor_free(this_ptr_conv);
24979 }
24980
24981 static inline uintptr_t SpendableOutputDescriptor_clone_ptr(LDKSpendableOutputDescriptor *NONNULL_PTR arg) {
24982         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
24983         *ret_copy = SpendableOutputDescriptor_clone(arg);
24984 uint32_t ret_ref = (uintptr_t)ret_copy;
24985         return ret_ref;
24986 }
24987 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_clone_ptr"))) TS_SpendableOutputDescriptor_clone_ptr(uint32_t arg) {
24988         LDKSpendableOutputDescriptor* arg_conv = (LDKSpendableOutputDescriptor*)arg;
24989         uint32_t ret_conv = SpendableOutputDescriptor_clone_ptr(arg_conv);
24990         return ret_conv;
24991 }
24992
24993 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_clone"))) TS_SpendableOutputDescriptor_clone(uint32_t orig) {
24994         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)orig;
24995         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
24996         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
24997         uint32_t ret_ref = (uintptr_t)ret_copy;
24998         return ret_ref;
24999 }
25000
25001 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_static_output"))) TS_SpendableOutputDescriptor_static_output(uint32_t outpoint, uint32_t output) {
25002         LDKOutPoint outpoint_conv;
25003         outpoint_conv.inner = (void*)(outpoint & (~1));
25004         outpoint_conv.is_owned = (outpoint & 1) || (outpoint == 0);
25005         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_conv);
25006         outpoint_conv = OutPoint_clone(&outpoint_conv);
25007         void* output_ptr = (void*)(((uintptr_t)output) & ~1);
25008         CHECK_ACCESS(output_ptr);
25009         LDKTxOut output_conv = *(LDKTxOut*)(output_ptr);
25010         output_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output) & ~1));
25011         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
25012         *ret_copy = SpendableOutputDescriptor_static_output(outpoint_conv, output_conv);
25013         uint32_t ret_ref = (uintptr_t)ret_copy;
25014         return ret_ref;
25015 }
25016
25017 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_delayed_payment_output"))) TS_SpendableOutputDescriptor_delayed_payment_output(uint32_t a) {
25018         LDKDelayedPaymentOutputDescriptor a_conv;
25019         a_conv.inner = (void*)(a & (~1));
25020         a_conv.is_owned = (a & 1) || (a == 0);
25021         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
25022         a_conv = DelayedPaymentOutputDescriptor_clone(&a_conv);
25023         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
25024         *ret_copy = SpendableOutputDescriptor_delayed_payment_output(a_conv);
25025         uint32_t ret_ref = (uintptr_t)ret_copy;
25026         return ret_ref;
25027 }
25028
25029 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_static_payment_output"))) TS_SpendableOutputDescriptor_static_payment_output(uint32_t a) {
25030         LDKStaticPaymentOutputDescriptor a_conv;
25031         a_conv.inner = (void*)(a & (~1));
25032         a_conv.is_owned = (a & 1) || (a == 0);
25033         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
25034         a_conv = StaticPaymentOutputDescriptor_clone(&a_conv);
25035         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
25036         *ret_copy = SpendableOutputDescriptor_static_payment_output(a_conv);
25037         uint32_t ret_ref = (uintptr_t)ret_copy;
25038         return ret_ref;
25039 }
25040
25041 int8_tArray  __attribute__((export_name("TS_SpendableOutputDescriptor_write"))) TS_SpendableOutputDescriptor_write(uint32_t obj) {
25042         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)obj;
25043         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
25044         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
25045         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
25046         CVec_u8Z_free(ret_var);
25047         return ret_arr;
25048 }
25049
25050 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_read"))) TS_SpendableOutputDescriptor_read(int8_tArray ser) {
25051         LDKu8slice ser_ref;
25052         ser_ref.datalen = ser->arr_len;
25053         ser_ref.data = ser->elems;
25054         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
25055         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
25056         FREE(ser);
25057         return (uint32_t)ret_conv;
25058 }
25059
25060 void  __attribute__((export_name("TS_BaseSign_free"))) TS_BaseSign_free(uint32_t this_ptr) {
25061         if ((this_ptr & 1) != 0) return;
25062         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
25063         CHECK_ACCESS(this_ptr_ptr);
25064         LDKBaseSign this_ptr_conv = *(LDKBaseSign*)(this_ptr_ptr);
25065         FREE((void*)this_ptr);
25066         BaseSign_free(this_ptr_conv);
25067 }
25068
25069 static inline uintptr_t Sign_clone_ptr(LDKSign *NONNULL_PTR arg) {
25070         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
25071         *ret_ret = Sign_clone(arg);
25072         return (uint32_t)ret_ret;
25073 }
25074 uint32_t  __attribute__((export_name("TS_Sign_clone_ptr"))) TS_Sign_clone_ptr(uint32_t arg) {
25075         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
25076         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
25077         LDKSign* arg_conv = (LDKSign*)arg_ptr;
25078         uint32_t ret_conv = Sign_clone_ptr(arg_conv);
25079         return ret_conv;
25080 }
25081
25082 uint32_t  __attribute__((export_name("TS_Sign_clone"))) TS_Sign_clone(uint32_t orig) {
25083         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
25084         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
25085         LDKSign* orig_conv = (LDKSign*)orig_ptr;
25086         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
25087         *ret_ret = Sign_clone(orig_conv);
25088         return (uint32_t)ret_ret;
25089 }
25090
25091 void  __attribute__((export_name("TS_Sign_free"))) TS_Sign_free(uint32_t this_ptr) {
25092         if ((this_ptr & 1) != 0) return;
25093         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
25094         CHECK_ACCESS(this_ptr_ptr);
25095         LDKSign this_ptr_conv = *(LDKSign*)(this_ptr_ptr);
25096         FREE((void*)this_ptr);
25097         Sign_free(this_ptr_conv);
25098 }
25099
25100 uint32_t  __attribute__((export_name("TS_Recipient_clone"))) TS_Recipient_clone(uint32_t orig) {
25101         LDKRecipient* orig_conv = (LDKRecipient*)(orig & ~1);
25102         uint32_t ret_conv = LDKRecipient_to_js(Recipient_clone(orig_conv));
25103         return ret_conv;
25104 }
25105
25106 uint32_t  __attribute__((export_name("TS_Recipient_node"))) TS_Recipient_node() {
25107         uint32_t ret_conv = LDKRecipient_to_js(Recipient_node());
25108         return ret_conv;
25109 }
25110
25111 uint32_t  __attribute__((export_name("TS_Recipient_phantom_node"))) TS_Recipient_phantom_node() {
25112         uint32_t ret_conv = LDKRecipient_to_js(Recipient_phantom_node());
25113         return ret_conv;
25114 }
25115
25116 void  __attribute__((export_name("TS_KeysInterface_free"))) TS_KeysInterface_free(uint32_t this_ptr) {
25117         if ((this_ptr & 1) != 0) return;
25118         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
25119         CHECK_ACCESS(this_ptr_ptr);
25120         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(this_ptr_ptr);
25121         FREE((void*)this_ptr);
25122         KeysInterface_free(this_ptr_conv);
25123 }
25124
25125 void  __attribute__((export_name("TS_InMemorySigner_free"))) TS_InMemorySigner_free(uint32_t this_obj) {
25126         LDKInMemorySigner this_obj_conv;
25127         this_obj_conv.inner = (void*)(this_obj & (~1));
25128         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25129         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25130         InMemorySigner_free(this_obj_conv);
25131 }
25132
25133 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_funding_key"))) TS_InMemorySigner_get_funding_key(uint32_t this_ptr) {
25134         LDKInMemorySigner this_ptr_conv;
25135         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25136         this_ptr_conv.is_owned = false;
25137         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25138         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
25139         memcpy(ret_arr->elems, *InMemorySigner_get_funding_key(&this_ptr_conv), 32);
25140         return ret_arr;
25141 }
25142
25143 void  __attribute__((export_name("TS_InMemorySigner_set_funding_key"))) TS_InMemorySigner_set_funding_key(uint32_t this_ptr, int8_tArray val) {
25144         LDKInMemorySigner this_ptr_conv;
25145         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25146         this_ptr_conv.is_owned = false;
25147         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25148         LDKSecretKey val_ref;
25149         CHECK(val->arr_len == 32);
25150         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
25151         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
25152 }
25153
25154 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_revocation_base_key"))) TS_InMemorySigner_get_revocation_base_key(uint32_t this_ptr) {
25155         LDKInMemorySigner this_ptr_conv;
25156         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25157         this_ptr_conv.is_owned = false;
25158         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25159         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
25160         memcpy(ret_arr->elems, *InMemorySigner_get_revocation_base_key(&this_ptr_conv), 32);
25161         return ret_arr;
25162 }
25163
25164 void  __attribute__((export_name("TS_InMemorySigner_set_revocation_base_key"))) TS_InMemorySigner_set_revocation_base_key(uint32_t this_ptr, int8_tArray val) {
25165         LDKInMemorySigner this_ptr_conv;
25166         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25167         this_ptr_conv.is_owned = false;
25168         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25169         LDKSecretKey val_ref;
25170         CHECK(val->arr_len == 32);
25171         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
25172         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
25173 }
25174
25175 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_payment_key"))) TS_InMemorySigner_get_payment_key(uint32_t this_ptr) {
25176         LDKInMemorySigner this_ptr_conv;
25177         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25178         this_ptr_conv.is_owned = false;
25179         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25180         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
25181         memcpy(ret_arr->elems, *InMemorySigner_get_payment_key(&this_ptr_conv), 32);
25182         return ret_arr;
25183 }
25184
25185 void  __attribute__((export_name("TS_InMemorySigner_set_payment_key"))) TS_InMemorySigner_set_payment_key(uint32_t this_ptr, int8_tArray val) {
25186         LDKInMemorySigner this_ptr_conv;
25187         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25188         this_ptr_conv.is_owned = false;
25189         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25190         LDKSecretKey val_ref;
25191         CHECK(val->arr_len == 32);
25192         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
25193         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
25194 }
25195
25196 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_delayed_payment_base_key"))) TS_InMemorySigner_get_delayed_payment_base_key(uint32_t this_ptr) {
25197         LDKInMemorySigner this_ptr_conv;
25198         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25199         this_ptr_conv.is_owned = false;
25200         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25201         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
25202         memcpy(ret_arr->elems, *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv), 32);
25203         return ret_arr;
25204 }
25205
25206 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) {
25207         LDKInMemorySigner this_ptr_conv;
25208         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25209         this_ptr_conv.is_owned = false;
25210         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25211         LDKSecretKey val_ref;
25212         CHECK(val->arr_len == 32);
25213         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
25214         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
25215 }
25216
25217 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_htlc_base_key"))) TS_InMemorySigner_get_htlc_base_key(uint32_t this_ptr) {
25218         LDKInMemorySigner this_ptr_conv;
25219         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25220         this_ptr_conv.is_owned = false;
25221         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25222         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
25223         memcpy(ret_arr->elems, *InMemorySigner_get_htlc_base_key(&this_ptr_conv), 32);
25224         return ret_arr;
25225 }
25226
25227 void  __attribute__((export_name("TS_InMemorySigner_set_htlc_base_key"))) TS_InMemorySigner_set_htlc_base_key(uint32_t this_ptr, int8_tArray val) {
25228         LDKInMemorySigner this_ptr_conv;
25229         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25230         this_ptr_conv.is_owned = false;
25231         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25232         LDKSecretKey val_ref;
25233         CHECK(val->arr_len == 32);
25234         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
25235         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
25236 }
25237
25238 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_commitment_seed"))) TS_InMemorySigner_get_commitment_seed(uint32_t this_ptr) {
25239         LDKInMemorySigner this_ptr_conv;
25240         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25241         this_ptr_conv.is_owned = false;
25242         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25243         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
25244         memcpy(ret_arr->elems, *InMemorySigner_get_commitment_seed(&this_ptr_conv), 32);
25245         return ret_arr;
25246 }
25247
25248 void  __attribute__((export_name("TS_InMemorySigner_set_commitment_seed"))) TS_InMemorySigner_set_commitment_seed(uint32_t this_ptr, int8_tArray val) {
25249         LDKInMemorySigner this_ptr_conv;
25250         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25251         this_ptr_conv.is_owned = false;
25252         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25253         LDKThirtyTwoBytes val_ref;
25254         CHECK(val->arr_len == 32);
25255         memcpy(val_ref.data, val->elems, 32); FREE(val);
25256         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
25257 }
25258
25259 static inline uintptr_t InMemorySigner_clone_ptr(LDKInMemorySigner *NONNULL_PTR arg) {
25260         LDKInMemorySigner ret_var = InMemorySigner_clone(arg);
25261 uint32_t ret_ref = 0;
25262 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25263 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25264 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25265 ret_ref = (uintptr_t)ret_var.inner;
25266 if (ret_var.is_owned) {
25267         ret_ref |= 1;
25268 }
25269         return ret_ref;
25270 }
25271 uint32_t  __attribute__((export_name("TS_InMemorySigner_clone_ptr"))) TS_InMemorySigner_clone_ptr(uint32_t arg) {
25272         LDKInMemorySigner arg_conv;
25273         arg_conv.inner = (void*)(arg & (~1));
25274         arg_conv.is_owned = false;
25275         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25276         uint32_t ret_conv = InMemorySigner_clone_ptr(&arg_conv);
25277         return ret_conv;
25278 }
25279
25280 uint32_t  __attribute__((export_name("TS_InMemorySigner_clone"))) TS_InMemorySigner_clone(uint32_t orig) {
25281         LDKInMemorySigner orig_conv;
25282         orig_conv.inner = (void*)(orig & (~1));
25283         orig_conv.is_owned = false;
25284         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25285         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
25286         uint32_t ret_ref = 0;
25287         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25288         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25289         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25290         ret_ref = (uintptr_t)ret_var.inner;
25291         if (ret_var.is_owned) {
25292                 ret_ref |= 1;
25293         }
25294         return ret_ref;
25295 }
25296
25297 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) {
25298         LDKSecretKey node_secret_ref;
25299         CHECK(node_secret->arr_len == 32);
25300         memcpy(node_secret_ref.bytes, node_secret->elems, 32); FREE(node_secret);
25301         LDKSecretKey funding_key_ref;
25302         CHECK(funding_key->arr_len == 32);
25303         memcpy(funding_key_ref.bytes, funding_key->elems, 32); FREE(funding_key);
25304         LDKSecretKey revocation_base_key_ref;
25305         CHECK(revocation_base_key->arr_len == 32);
25306         memcpy(revocation_base_key_ref.bytes, revocation_base_key->elems, 32); FREE(revocation_base_key);
25307         LDKSecretKey payment_key_ref;
25308         CHECK(payment_key->arr_len == 32);
25309         memcpy(payment_key_ref.bytes, payment_key->elems, 32); FREE(payment_key);
25310         LDKSecretKey delayed_payment_base_key_ref;
25311         CHECK(delayed_payment_base_key->arr_len == 32);
25312         memcpy(delayed_payment_base_key_ref.bytes, delayed_payment_base_key->elems, 32); FREE(delayed_payment_base_key);
25313         LDKSecretKey htlc_base_key_ref;
25314         CHECK(htlc_base_key->arr_len == 32);
25315         memcpy(htlc_base_key_ref.bytes, htlc_base_key->elems, 32); FREE(htlc_base_key);
25316         LDKThirtyTwoBytes commitment_seed_ref;
25317         CHECK(commitment_seed->arr_len == 32);
25318         memcpy(commitment_seed_ref.data, commitment_seed->elems, 32); FREE(commitment_seed);
25319         LDKThirtyTwoBytes channel_keys_id_ref;
25320         CHECK(channel_keys_id->arr_len == 32);
25321         memcpy(channel_keys_id_ref.data, channel_keys_id->elems, 32); FREE(channel_keys_id);
25322         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);
25323         uint32_t ret_ref = 0;
25324         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25325         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25326         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25327         ret_ref = (uintptr_t)ret_var.inner;
25328         if (ret_var.is_owned) {
25329                 ret_ref |= 1;
25330         }
25331         return ret_ref;
25332 }
25333
25334 uint32_t  __attribute__((export_name("TS_InMemorySigner_counterparty_pubkeys"))) TS_InMemorySigner_counterparty_pubkeys(uint32_t this_arg) {
25335         LDKInMemorySigner this_arg_conv;
25336         this_arg_conv.inner = (void*)(this_arg & (~1));
25337         this_arg_conv.is_owned = false;
25338         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25339         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
25340         uint32_t ret_ref = 0;
25341         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25342         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25343         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25344         ret_ref = (uintptr_t)ret_var.inner;
25345         if (ret_var.is_owned) {
25346                 ret_ref |= 1;
25347         }
25348         return ret_ref;
25349 }
25350
25351 int16_t  __attribute__((export_name("TS_InMemorySigner_counterparty_selected_contest_delay"))) TS_InMemorySigner_counterparty_selected_contest_delay(uint32_t this_arg) {
25352         LDKInMemorySigner this_arg_conv;
25353         this_arg_conv.inner = (void*)(this_arg & (~1));
25354         this_arg_conv.is_owned = false;
25355         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25356         int16_t ret_conv = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
25357         return ret_conv;
25358 }
25359
25360 int16_t  __attribute__((export_name("TS_InMemorySigner_holder_selected_contest_delay"))) TS_InMemorySigner_holder_selected_contest_delay(uint32_t this_arg) {
25361         LDKInMemorySigner this_arg_conv;
25362         this_arg_conv.inner = (void*)(this_arg & (~1));
25363         this_arg_conv.is_owned = false;
25364         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25365         int16_t ret_conv = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
25366         return ret_conv;
25367 }
25368
25369 jboolean  __attribute__((export_name("TS_InMemorySigner_is_outbound"))) TS_InMemorySigner_is_outbound(uint32_t this_arg) {
25370         LDKInMemorySigner this_arg_conv;
25371         this_arg_conv.inner = (void*)(this_arg & (~1));
25372         this_arg_conv.is_owned = false;
25373         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25374         jboolean ret_conv = InMemorySigner_is_outbound(&this_arg_conv);
25375         return ret_conv;
25376 }
25377
25378 uint32_t  __attribute__((export_name("TS_InMemorySigner_funding_outpoint"))) TS_InMemorySigner_funding_outpoint(uint32_t this_arg) {
25379         LDKInMemorySigner this_arg_conv;
25380         this_arg_conv.inner = (void*)(this_arg & (~1));
25381         this_arg_conv.is_owned = false;
25382         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25383         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
25384         uint32_t ret_ref = 0;
25385         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25386         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25387         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25388         ret_ref = (uintptr_t)ret_var.inner;
25389         if (ret_var.is_owned) {
25390                 ret_ref |= 1;
25391         }
25392         return ret_ref;
25393 }
25394
25395 uint32_t  __attribute__((export_name("TS_InMemorySigner_get_channel_parameters"))) TS_InMemorySigner_get_channel_parameters(uint32_t this_arg) {
25396         LDKInMemorySigner this_arg_conv;
25397         this_arg_conv.inner = (void*)(this_arg & (~1));
25398         this_arg_conv.is_owned = false;
25399         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25400         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
25401         uint32_t ret_ref = 0;
25402         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25403         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25404         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25405         ret_ref = (uintptr_t)ret_var.inner;
25406         if (ret_var.is_owned) {
25407                 ret_ref |= 1;
25408         }
25409         return ret_ref;
25410 }
25411
25412 jboolean  __attribute__((export_name("TS_InMemorySigner_opt_anchors"))) TS_InMemorySigner_opt_anchors(uint32_t this_arg) {
25413         LDKInMemorySigner this_arg_conv;
25414         this_arg_conv.inner = (void*)(this_arg & (~1));
25415         this_arg_conv.is_owned = false;
25416         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25417         jboolean ret_conv = InMemorySigner_opt_anchors(&this_arg_conv);
25418         return ret_conv;
25419 }
25420
25421 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) {
25422         LDKInMemorySigner this_arg_conv;
25423         this_arg_conv.inner = (void*)(this_arg & (~1));
25424         this_arg_conv.is_owned = false;
25425         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25426         LDKTransaction spend_tx_ref;
25427         spend_tx_ref.datalen = spend_tx->arr_len;
25428         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
25429         memcpy(spend_tx_ref.data, spend_tx->elems, spend_tx_ref.datalen); FREE(spend_tx);
25430         spend_tx_ref.data_is_owned = true;
25431         LDKStaticPaymentOutputDescriptor descriptor_conv;
25432         descriptor_conv.inner = (void*)(descriptor & (~1));
25433         descriptor_conv.is_owned = false;
25434         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
25435         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
25436         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
25437         return (uint32_t)ret_conv;
25438 }
25439
25440 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) {
25441         LDKInMemorySigner this_arg_conv;
25442         this_arg_conv.inner = (void*)(this_arg & (~1));
25443         this_arg_conv.is_owned = false;
25444         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25445         LDKTransaction spend_tx_ref;
25446         spend_tx_ref.datalen = spend_tx->arr_len;
25447         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
25448         memcpy(spend_tx_ref.data, spend_tx->elems, spend_tx_ref.datalen); FREE(spend_tx);
25449         spend_tx_ref.data_is_owned = true;
25450         LDKDelayedPaymentOutputDescriptor descriptor_conv;
25451         descriptor_conv.inner = (void*)(descriptor & (~1));
25452         descriptor_conv.is_owned = false;
25453         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
25454         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
25455         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
25456         return (uint32_t)ret_conv;
25457 }
25458
25459 uint32_t  __attribute__((export_name("TS_InMemorySigner_as_BaseSign"))) TS_InMemorySigner_as_BaseSign(uint32_t this_arg) {
25460         LDKInMemorySigner this_arg_conv;
25461         this_arg_conv.inner = (void*)(this_arg & (~1));
25462         this_arg_conv.is_owned = false;
25463         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25464         LDKBaseSign* ret_ret = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
25465         *ret_ret = InMemorySigner_as_BaseSign(&this_arg_conv);
25466         return (uint32_t)ret_ret;
25467 }
25468
25469 uint32_t  __attribute__((export_name("TS_InMemorySigner_as_Sign"))) TS_InMemorySigner_as_Sign(uint32_t this_arg) {
25470         LDKInMemorySigner this_arg_conv;
25471         this_arg_conv.inner = (void*)(this_arg & (~1));
25472         this_arg_conv.is_owned = false;
25473         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25474         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
25475         *ret_ret = InMemorySigner_as_Sign(&this_arg_conv);
25476         return (uint32_t)ret_ret;
25477 }
25478
25479 int8_tArray  __attribute__((export_name("TS_InMemorySigner_write"))) TS_InMemorySigner_write(uint32_t obj) {
25480         LDKInMemorySigner obj_conv;
25481         obj_conv.inner = (void*)(obj & (~1));
25482         obj_conv.is_owned = false;
25483         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
25484         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
25485         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
25486         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
25487         CVec_u8Z_free(ret_var);
25488         return ret_arr;
25489 }
25490
25491 uint32_t  __attribute__((export_name("TS_InMemorySigner_read"))) TS_InMemorySigner_read(int8_tArray ser, int8_tArray arg) {
25492         LDKu8slice ser_ref;
25493         ser_ref.datalen = ser->arr_len;
25494         ser_ref.data = ser->elems;
25495         LDKSecretKey arg_ref;
25496         CHECK(arg->arr_len == 32);
25497         memcpy(arg_ref.bytes, arg->elems, 32); FREE(arg);
25498         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
25499         *ret_conv = InMemorySigner_read(ser_ref, arg_ref);
25500         FREE(ser);
25501         return (uint32_t)ret_conv;
25502 }
25503
25504 void  __attribute__((export_name("TS_KeysManager_free"))) TS_KeysManager_free(uint32_t this_obj) {
25505         LDKKeysManager this_obj_conv;
25506         this_obj_conv.inner = (void*)(this_obj & (~1));
25507         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25508         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25509         KeysManager_free(this_obj_conv);
25510 }
25511
25512 uint32_t  __attribute__((export_name("TS_KeysManager_new"))) TS_KeysManager_new(int8_tArray seed, int64_t starting_time_secs, int32_t starting_time_nanos) {
25513         unsigned char seed_arr[32];
25514         CHECK(seed->arr_len == 32);
25515         memcpy(seed_arr, seed->elems, 32); FREE(seed);
25516         unsigned char (*seed_ref)[32] = &seed_arr;
25517         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
25518         uint32_t ret_ref = 0;
25519         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25520         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25521         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25522         ret_ref = (uintptr_t)ret_var.inner;
25523         if (ret_var.is_owned) {
25524                 ret_ref |= 1;
25525         }
25526         return ret_ref;
25527 }
25528
25529 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) {
25530         LDKKeysManager this_arg_conv;
25531         this_arg_conv.inner = (void*)(this_arg & (~1));
25532         this_arg_conv.is_owned = false;
25533         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25534         unsigned char params_arr[32];
25535         CHECK(params->arr_len == 32);
25536         memcpy(params_arr, params->elems, 32); FREE(params);
25537         unsigned char (*params_ref)[32] = &params_arr;
25538         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
25539         uint32_t ret_ref = 0;
25540         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25541         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25542         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25543         ret_ref = (uintptr_t)ret_var.inner;
25544         if (ret_var.is_owned) {
25545                 ret_ref |= 1;
25546         }
25547         return ret_ref;
25548 }
25549
25550 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) {
25551         LDKKeysManager this_arg_conv;
25552         this_arg_conv.inner = (void*)(this_arg & (~1));
25553         this_arg_conv.is_owned = false;
25554         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25555         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
25556         descriptors_constr.datalen = descriptors->arr_len;
25557         if (descriptors_constr.datalen > 0)
25558                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
25559         else
25560                 descriptors_constr.data = NULL;
25561         uint32_t* descriptors_vals = descriptors->elems;
25562         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
25563                 uint32_t descriptors_conv_27 = descriptors_vals[b];
25564                 void* descriptors_conv_27_ptr = (void*)(((uintptr_t)descriptors_conv_27) & ~1);
25565                 CHECK_ACCESS(descriptors_conv_27_ptr);
25566                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
25567                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)descriptors_conv_27) & ~1));
25568                 descriptors_constr.data[b] = descriptors_conv_27_conv;
25569         }
25570         FREE(descriptors);
25571         LDKCVec_TxOutZ outputs_constr;
25572         outputs_constr.datalen = outputs->arr_len;
25573         if (outputs_constr.datalen > 0)
25574                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
25575         else
25576                 outputs_constr.data = NULL;
25577         uint32_t* outputs_vals = outputs->elems;
25578         for (size_t h = 0; h < outputs_constr.datalen; h++) {
25579                 uint32_t outputs_conv_7 = outputs_vals[h];
25580                 void* outputs_conv_7_ptr = (void*)(((uintptr_t)outputs_conv_7) & ~1);
25581                 CHECK_ACCESS(outputs_conv_7_ptr);
25582                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
25583                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)outputs_conv_7) & ~1));
25584                 outputs_constr.data[h] = outputs_conv_7_conv;
25585         }
25586         FREE(outputs);
25587         LDKCVec_u8Z change_destination_script_ref;
25588         change_destination_script_ref.datalen = change_destination_script->arr_len;
25589         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
25590         memcpy(change_destination_script_ref.data, change_destination_script->elems, change_destination_script_ref.datalen); FREE(change_destination_script);
25591         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
25592         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
25593         return (uint32_t)ret_conv;
25594 }
25595
25596 uint32_t  __attribute__((export_name("TS_KeysManager_as_KeysInterface"))) TS_KeysManager_as_KeysInterface(uint32_t this_arg) {
25597         LDKKeysManager this_arg_conv;
25598         this_arg_conv.inner = (void*)(this_arg & (~1));
25599         this_arg_conv.is_owned = false;
25600         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25601         LDKKeysInterface* ret_ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
25602         *ret_ret = KeysManager_as_KeysInterface(&this_arg_conv);
25603         return (uint32_t)ret_ret;
25604 }
25605
25606 void  __attribute__((export_name("TS_PhantomKeysManager_free"))) TS_PhantomKeysManager_free(uint32_t this_obj) {
25607         LDKPhantomKeysManager this_obj_conv;
25608         this_obj_conv.inner = (void*)(this_obj & (~1));
25609         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25610         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25611         PhantomKeysManager_free(this_obj_conv);
25612 }
25613
25614 uint32_t  __attribute__((export_name("TS_PhantomKeysManager_as_KeysInterface"))) TS_PhantomKeysManager_as_KeysInterface(uint32_t this_arg) {
25615         LDKPhantomKeysManager this_arg_conv;
25616         this_arg_conv.inner = (void*)(this_arg & (~1));
25617         this_arg_conv.is_owned = false;
25618         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25619         LDKKeysInterface* ret_ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
25620         *ret_ret = PhantomKeysManager_as_KeysInterface(&this_arg_conv);
25621         return (uint32_t)ret_ret;
25622 }
25623
25624 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) {
25625         unsigned char seed_arr[32];
25626         CHECK(seed->arr_len == 32);
25627         memcpy(seed_arr, seed->elems, 32); FREE(seed);
25628         unsigned char (*seed_ref)[32] = &seed_arr;
25629         unsigned char cross_node_seed_arr[32];
25630         CHECK(cross_node_seed->arr_len == 32);
25631         memcpy(cross_node_seed_arr, cross_node_seed->elems, 32); FREE(cross_node_seed);
25632         unsigned char (*cross_node_seed_ref)[32] = &cross_node_seed_arr;
25633         LDKPhantomKeysManager ret_var = PhantomKeysManager_new(seed_ref, starting_time_secs, starting_time_nanos, cross_node_seed_ref);
25634         uint32_t ret_ref = 0;
25635         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25636         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25637         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25638         ret_ref = (uintptr_t)ret_var.inner;
25639         if (ret_var.is_owned) {
25640                 ret_ref |= 1;
25641         }
25642         return ret_ref;
25643 }
25644
25645 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) {
25646         LDKPhantomKeysManager this_arg_conv;
25647         this_arg_conv.inner = (void*)(this_arg & (~1));
25648         this_arg_conv.is_owned = false;
25649         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25650         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
25651         descriptors_constr.datalen = descriptors->arr_len;
25652         if (descriptors_constr.datalen > 0)
25653                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
25654         else
25655                 descriptors_constr.data = NULL;
25656         uint32_t* descriptors_vals = descriptors->elems;
25657         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
25658                 uint32_t descriptors_conv_27 = descriptors_vals[b];
25659                 void* descriptors_conv_27_ptr = (void*)(((uintptr_t)descriptors_conv_27) & ~1);
25660                 CHECK_ACCESS(descriptors_conv_27_ptr);
25661                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
25662                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)descriptors_conv_27) & ~1));
25663                 descriptors_constr.data[b] = descriptors_conv_27_conv;
25664         }
25665         FREE(descriptors);
25666         LDKCVec_TxOutZ outputs_constr;
25667         outputs_constr.datalen = outputs->arr_len;
25668         if (outputs_constr.datalen > 0)
25669                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
25670         else
25671                 outputs_constr.data = NULL;
25672         uint32_t* outputs_vals = outputs->elems;
25673         for (size_t h = 0; h < outputs_constr.datalen; h++) {
25674                 uint32_t outputs_conv_7 = outputs_vals[h];
25675                 void* outputs_conv_7_ptr = (void*)(((uintptr_t)outputs_conv_7) & ~1);
25676                 CHECK_ACCESS(outputs_conv_7_ptr);
25677                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
25678                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)outputs_conv_7) & ~1));
25679                 outputs_constr.data[h] = outputs_conv_7_conv;
25680         }
25681         FREE(outputs);
25682         LDKCVec_u8Z change_destination_script_ref;
25683         change_destination_script_ref.datalen = change_destination_script->arr_len;
25684         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
25685         memcpy(change_destination_script_ref.data, change_destination_script->elems, change_destination_script_ref.datalen); FREE(change_destination_script);
25686         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
25687         *ret_conv = PhantomKeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
25688         return (uint32_t)ret_conv;
25689 }
25690
25691 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) {
25692         LDKPhantomKeysManager this_arg_conv;
25693         this_arg_conv.inner = (void*)(this_arg & (~1));
25694         this_arg_conv.is_owned = false;
25695         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25696         unsigned char params_arr[32];
25697         CHECK(params->arr_len == 32);
25698         memcpy(params_arr, params->elems, 32); FREE(params);
25699         unsigned char (*params_ref)[32] = &params_arr;
25700         LDKInMemorySigner ret_var = PhantomKeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
25701         uint32_t ret_ref = 0;
25702         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25703         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25704         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25705         ret_ref = (uintptr_t)ret_var.inner;
25706         if (ret_var.is_owned) {
25707                 ret_ref |= 1;
25708         }
25709         return ret_ref;
25710 }
25711
25712 void  __attribute__((export_name("TS_ChannelManager_free"))) TS_ChannelManager_free(uint32_t this_obj) {
25713         LDKChannelManager this_obj_conv;
25714         this_obj_conv.inner = (void*)(this_obj & (~1));
25715         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25716         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25717         ChannelManager_free(this_obj_conv);
25718 }
25719
25720 void  __attribute__((export_name("TS_ChainParameters_free"))) TS_ChainParameters_free(uint32_t this_obj) {
25721         LDKChainParameters this_obj_conv;
25722         this_obj_conv.inner = (void*)(this_obj & (~1));
25723         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25724         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25725         ChainParameters_free(this_obj_conv);
25726 }
25727
25728 uint32_t  __attribute__((export_name("TS_ChainParameters_get_network"))) TS_ChainParameters_get_network(uint32_t this_ptr) {
25729         LDKChainParameters this_ptr_conv;
25730         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25731         this_ptr_conv.is_owned = false;
25732         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25733         uint32_t ret_conv = LDKNetwork_to_js(ChainParameters_get_network(&this_ptr_conv));
25734         return ret_conv;
25735 }
25736
25737 void  __attribute__((export_name("TS_ChainParameters_set_network"))) TS_ChainParameters_set_network(uint32_t this_ptr, uint32_t val) {
25738         LDKChainParameters this_ptr_conv;
25739         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25740         this_ptr_conv.is_owned = false;
25741         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25742         LDKNetwork val_conv = LDKNetwork_from_js(val);
25743         ChainParameters_set_network(&this_ptr_conv, val_conv);
25744 }
25745
25746 uint32_t  __attribute__((export_name("TS_ChainParameters_get_best_block"))) TS_ChainParameters_get_best_block(uint32_t this_ptr) {
25747         LDKChainParameters this_ptr_conv;
25748         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25749         this_ptr_conv.is_owned = false;
25750         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25751         LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
25752         uint32_t ret_ref = 0;
25753         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25754         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25755         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25756         ret_ref = (uintptr_t)ret_var.inner;
25757         if (ret_var.is_owned) {
25758                 ret_ref |= 1;
25759         }
25760         return ret_ref;
25761 }
25762
25763 void  __attribute__((export_name("TS_ChainParameters_set_best_block"))) TS_ChainParameters_set_best_block(uint32_t this_ptr, uint32_t val) {
25764         LDKChainParameters this_ptr_conv;
25765         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25766         this_ptr_conv.is_owned = false;
25767         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25768         LDKBestBlock val_conv;
25769         val_conv.inner = (void*)(val & (~1));
25770         val_conv.is_owned = (val & 1) || (val == 0);
25771         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
25772         val_conv = BestBlock_clone(&val_conv);
25773         ChainParameters_set_best_block(&this_ptr_conv, val_conv);
25774 }
25775
25776 uint32_t  __attribute__((export_name("TS_ChainParameters_new"))) TS_ChainParameters_new(uint32_t network_arg, uint32_t best_block_arg) {
25777         LDKNetwork network_arg_conv = LDKNetwork_from_js(network_arg);
25778         LDKBestBlock best_block_arg_conv;
25779         best_block_arg_conv.inner = (void*)(best_block_arg & (~1));
25780         best_block_arg_conv.is_owned = (best_block_arg & 1) || (best_block_arg == 0);
25781         CHECK_INNER_FIELD_ACCESS_OR_NULL(best_block_arg_conv);
25782         best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
25783         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
25784         uint32_t ret_ref = 0;
25785         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25786         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25787         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25788         ret_ref = (uintptr_t)ret_var.inner;
25789         if (ret_var.is_owned) {
25790                 ret_ref |= 1;
25791         }
25792         return ret_ref;
25793 }
25794
25795 static inline uintptr_t ChainParameters_clone_ptr(LDKChainParameters *NONNULL_PTR arg) {
25796         LDKChainParameters ret_var = ChainParameters_clone(arg);
25797 uint32_t ret_ref = 0;
25798 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25799 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25800 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25801 ret_ref = (uintptr_t)ret_var.inner;
25802 if (ret_var.is_owned) {
25803         ret_ref |= 1;
25804 }
25805         return ret_ref;
25806 }
25807 uint32_t  __attribute__((export_name("TS_ChainParameters_clone_ptr"))) TS_ChainParameters_clone_ptr(uint32_t arg) {
25808         LDKChainParameters arg_conv;
25809         arg_conv.inner = (void*)(arg & (~1));
25810         arg_conv.is_owned = false;
25811         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25812         uint32_t ret_conv = ChainParameters_clone_ptr(&arg_conv);
25813         return ret_conv;
25814 }
25815
25816 uint32_t  __attribute__((export_name("TS_ChainParameters_clone"))) TS_ChainParameters_clone(uint32_t orig) {
25817         LDKChainParameters orig_conv;
25818         orig_conv.inner = (void*)(orig & (~1));
25819         orig_conv.is_owned = false;
25820         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25821         LDKChainParameters ret_var = ChainParameters_clone(&orig_conv);
25822         uint32_t ret_ref = 0;
25823         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25824         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25825         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25826         ret_ref = (uintptr_t)ret_var.inner;
25827         if (ret_var.is_owned) {
25828                 ret_ref |= 1;
25829         }
25830         return ret_ref;
25831 }
25832
25833 void  __attribute__((export_name("TS_CounterpartyForwardingInfo_free"))) TS_CounterpartyForwardingInfo_free(uint32_t this_obj) {
25834         LDKCounterpartyForwardingInfo this_obj_conv;
25835         this_obj_conv.inner = (void*)(this_obj & (~1));
25836         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25837         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25838         CounterpartyForwardingInfo_free(this_obj_conv);
25839 }
25840
25841 int32_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_get_fee_base_msat"))) TS_CounterpartyForwardingInfo_get_fee_base_msat(uint32_t this_ptr) {
25842         LDKCounterpartyForwardingInfo this_ptr_conv;
25843         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25844         this_ptr_conv.is_owned = false;
25845         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25846         int32_t ret_conv = CounterpartyForwardingInfo_get_fee_base_msat(&this_ptr_conv);
25847         return ret_conv;
25848 }
25849
25850 void  __attribute__((export_name("TS_CounterpartyForwardingInfo_set_fee_base_msat"))) TS_CounterpartyForwardingInfo_set_fee_base_msat(uint32_t this_ptr, int32_t val) {
25851         LDKCounterpartyForwardingInfo this_ptr_conv;
25852         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25853         this_ptr_conv.is_owned = false;
25854         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25855         CounterpartyForwardingInfo_set_fee_base_msat(&this_ptr_conv, val);
25856 }
25857
25858 int32_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_get_fee_proportional_millionths"))) TS_CounterpartyForwardingInfo_get_fee_proportional_millionths(uint32_t this_ptr) {
25859         LDKCounterpartyForwardingInfo this_ptr_conv;
25860         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25861         this_ptr_conv.is_owned = false;
25862         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25863         int32_t ret_conv = CounterpartyForwardingInfo_get_fee_proportional_millionths(&this_ptr_conv);
25864         return ret_conv;
25865 }
25866
25867 void  __attribute__((export_name("TS_CounterpartyForwardingInfo_set_fee_proportional_millionths"))) TS_CounterpartyForwardingInfo_set_fee_proportional_millionths(uint32_t this_ptr, int32_t val) {
25868         LDKCounterpartyForwardingInfo this_ptr_conv;
25869         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25870         this_ptr_conv.is_owned = false;
25871         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25872         CounterpartyForwardingInfo_set_fee_proportional_millionths(&this_ptr_conv, val);
25873 }
25874
25875 int16_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_get_cltv_expiry_delta"))) TS_CounterpartyForwardingInfo_get_cltv_expiry_delta(uint32_t this_ptr) {
25876         LDKCounterpartyForwardingInfo this_ptr_conv;
25877         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25878         this_ptr_conv.is_owned = false;
25879         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25880         int16_t ret_conv = CounterpartyForwardingInfo_get_cltv_expiry_delta(&this_ptr_conv);
25881         return ret_conv;
25882 }
25883
25884 void  __attribute__((export_name("TS_CounterpartyForwardingInfo_set_cltv_expiry_delta"))) TS_CounterpartyForwardingInfo_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
25885         LDKCounterpartyForwardingInfo this_ptr_conv;
25886         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25887         this_ptr_conv.is_owned = false;
25888         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25889         CounterpartyForwardingInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
25890 }
25891
25892 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) {
25893         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_new(fee_base_msat_arg, fee_proportional_millionths_arg, cltv_expiry_delta_arg);
25894         uint32_t ret_ref = 0;
25895         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25896         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25897         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25898         ret_ref = (uintptr_t)ret_var.inner;
25899         if (ret_var.is_owned) {
25900                 ret_ref |= 1;
25901         }
25902         return ret_ref;
25903 }
25904
25905 static inline uintptr_t CounterpartyForwardingInfo_clone_ptr(LDKCounterpartyForwardingInfo *NONNULL_PTR arg) {
25906         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(arg);
25907 uint32_t ret_ref = 0;
25908 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25909 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25910 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25911 ret_ref = (uintptr_t)ret_var.inner;
25912 if (ret_var.is_owned) {
25913         ret_ref |= 1;
25914 }
25915         return ret_ref;
25916 }
25917 uint32_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_clone_ptr"))) TS_CounterpartyForwardingInfo_clone_ptr(uint32_t arg) {
25918         LDKCounterpartyForwardingInfo arg_conv;
25919         arg_conv.inner = (void*)(arg & (~1));
25920         arg_conv.is_owned = false;
25921         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25922         uint32_t ret_conv = CounterpartyForwardingInfo_clone_ptr(&arg_conv);
25923         return ret_conv;
25924 }
25925
25926 uint32_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_clone"))) TS_CounterpartyForwardingInfo_clone(uint32_t orig) {
25927         LDKCounterpartyForwardingInfo orig_conv;
25928         orig_conv.inner = (void*)(orig & (~1));
25929         orig_conv.is_owned = false;
25930         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25931         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(&orig_conv);
25932         uint32_t ret_ref = 0;
25933         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25934         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25935         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25936         ret_ref = (uintptr_t)ret_var.inner;
25937         if (ret_var.is_owned) {
25938                 ret_ref |= 1;
25939         }
25940         return ret_ref;
25941 }
25942
25943 void  __attribute__((export_name("TS_ChannelCounterparty_free"))) TS_ChannelCounterparty_free(uint32_t this_obj) {
25944         LDKChannelCounterparty this_obj_conv;
25945         this_obj_conv.inner = (void*)(this_obj & (~1));
25946         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25947         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25948         ChannelCounterparty_free(this_obj_conv);
25949 }
25950
25951 int8_tArray  __attribute__((export_name("TS_ChannelCounterparty_get_node_id"))) TS_ChannelCounterparty_get_node_id(uint32_t this_ptr) {
25952         LDKChannelCounterparty this_ptr_conv;
25953         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25954         this_ptr_conv.is_owned = false;
25955         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25956         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
25957         memcpy(ret_arr->elems, ChannelCounterparty_get_node_id(&this_ptr_conv).compressed_form, 33);
25958         return ret_arr;
25959 }
25960
25961 void  __attribute__((export_name("TS_ChannelCounterparty_set_node_id"))) TS_ChannelCounterparty_set_node_id(uint32_t this_ptr, int8_tArray val) {
25962         LDKChannelCounterparty this_ptr_conv;
25963         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25964         this_ptr_conv.is_owned = false;
25965         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25966         LDKPublicKey val_ref;
25967         CHECK(val->arr_len == 33);
25968         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
25969         ChannelCounterparty_set_node_id(&this_ptr_conv, val_ref);
25970 }
25971
25972 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_get_features"))) TS_ChannelCounterparty_get_features(uint32_t this_ptr) {
25973         LDKChannelCounterparty this_ptr_conv;
25974         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25975         this_ptr_conv.is_owned = false;
25976         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25977         LDKInitFeatures ret_var = ChannelCounterparty_get_features(&this_ptr_conv);
25978         uint32_t ret_ref = 0;
25979         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25980         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25981         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25982         ret_ref = (uintptr_t)ret_var.inner;
25983         if (ret_var.is_owned) {
25984                 ret_ref |= 1;
25985         }
25986         return ret_ref;
25987 }
25988
25989 void  __attribute__((export_name("TS_ChannelCounterparty_set_features"))) TS_ChannelCounterparty_set_features(uint32_t this_ptr, uint32_t val) {
25990         LDKChannelCounterparty this_ptr_conv;
25991         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25992         this_ptr_conv.is_owned = false;
25993         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25994         LDKInitFeatures val_conv;
25995         val_conv.inner = (void*)(val & (~1));
25996         val_conv.is_owned = (val & 1) || (val == 0);
25997         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
25998         val_conv = InitFeatures_clone(&val_conv);
25999         ChannelCounterparty_set_features(&this_ptr_conv, val_conv);
26000 }
26001
26002 int64_t  __attribute__((export_name("TS_ChannelCounterparty_get_unspendable_punishment_reserve"))) TS_ChannelCounterparty_get_unspendable_punishment_reserve(uint32_t this_ptr) {
26003         LDKChannelCounterparty this_ptr_conv;
26004         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26005         this_ptr_conv.is_owned = false;
26006         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26007         int64_t ret_conv = ChannelCounterparty_get_unspendable_punishment_reserve(&this_ptr_conv);
26008         return ret_conv;
26009 }
26010
26011 void  __attribute__((export_name("TS_ChannelCounterparty_set_unspendable_punishment_reserve"))) TS_ChannelCounterparty_set_unspendable_punishment_reserve(uint32_t this_ptr, int64_t val) {
26012         LDKChannelCounterparty this_ptr_conv;
26013         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26014         this_ptr_conv.is_owned = false;
26015         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26016         ChannelCounterparty_set_unspendable_punishment_reserve(&this_ptr_conv, val);
26017 }
26018
26019 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_get_forwarding_info"))) TS_ChannelCounterparty_get_forwarding_info(uint32_t this_ptr) {
26020         LDKChannelCounterparty this_ptr_conv;
26021         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26022         this_ptr_conv.is_owned = false;
26023         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26024         LDKCounterpartyForwardingInfo ret_var = ChannelCounterparty_get_forwarding_info(&this_ptr_conv);
26025         uint32_t ret_ref = 0;
26026         if ((uintptr_t)ret_var.inner > 4096) {
26027                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26028                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26029         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26030                 ret_ref = (uintptr_t)ret_var.inner;
26031                 if (ret_var.is_owned) {
26032                         ret_ref |= 1;
26033                 }
26034         }
26035         return ret_ref;
26036 }
26037
26038 void  __attribute__((export_name("TS_ChannelCounterparty_set_forwarding_info"))) TS_ChannelCounterparty_set_forwarding_info(uint32_t this_ptr, uint32_t val) {
26039         LDKChannelCounterparty this_ptr_conv;
26040         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26041         this_ptr_conv.is_owned = false;
26042         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26043         LDKCounterpartyForwardingInfo val_conv;
26044         val_conv.inner = (void*)(val & (~1));
26045         val_conv.is_owned = (val & 1) || (val == 0);
26046         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26047         val_conv = CounterpartyForwardingInfo_clone(&val_conv);
26048         ChannelCounterparty_set_forwarding_info(&this_ptr_conv, val_conv);
26049 }
26050
26051 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_get_outbound_htlc_minimum_msat"))) TS_ChannelCounterparty_get_outbound_htlc_minimum_msat(uint32_t this_ptr) {
26052         LDKChannelCounterparty this_ptr_conv;
26053         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26054         this_ptr_conv.is_owned = false;
26055         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26056         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
26057         *ret_copy = ChannelCounterparty_get_outbound_htlc_minimum_msat(&this_ptr_conv);
26058         uint32_t ret_ref = (uintptr_t)ret_copy;
26059         return ret_ref;
26060 }
26061
26062 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) {
26063         LDKChannelCounterparty this_ptr_conv;
26064         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26065         this_ptr_conv.is_owned = false;
26066         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26067         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
26068         CHECK_ACCESS(val_ptr);
26069         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
26070         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
26071         ChannelCounterparty_set_outbound_htlc_minimum_msat(&this_ptr_conv, val_conv);
26072 }
26073
26074 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_get_outbound_htlc_maximum_msat"))) TS_ChannelCounterparty_get_outbound_htlc_maximum_msat(uint32_t this_ptr) {
26075         LDKChannelCounterparty this_ptr_conv;
26076         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26077         this_ptr_conv.is_owned = false;
26078         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26079         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
26080         *ret_copy = ChannelCounterparty_get_outbound_htlc_maximum_msat(&this_ptr_conv);
26081         uint32_t ret_ref = (uintptr_t)ret_copy;
26082         return ret_ref;
26083 }
26084
26085 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) {
26086         LDKChannelCounterparty this_ptr_conv;
26087         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26088         this_ptr_conv.is_owned = false;
26089         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26090         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
26091         CHECK_ACCESS(val_ptr);
26092         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
26093         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
26094         ChannelCounterparty_set_outbound_htlc_maximum_msat(&this_ptr_conv, val_conv);
26095 }
26096
26097 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) {
26098         LDKPublicKey node_id_arg_ref;
26099         CHECK(node_id_arg->arr_len == 33);
26100         memcpy(node_id_arg_ref.compressed_form, node_id_arg->elems, 33); FREE(node_id_arg);
26101         LDKInitFeatures features_arg_conv;
26102         features_arg_conv.inner = (void*)(features_arg & (~1));
26103         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
26104         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
26105         features_arg_conv = InitFeatures_clone(&features_arg_conv);
26106         LDKCounterpartyForwardingInfo forwarding_info_arg_conv;
26107         forwarding_info_arg_conv.inner = (void*)(forwarding_info_arg & (~1));
26108         forwarding_info_arg_conv.is_owned = (forwarding_info_arg & 1) || (forwarding_info_arg == 0);
26109         CHECK_INNER_FIELD_ACCESS_OR_NULL(forwarding_info_arg_conv);
26110         forwarding_info_arg_conv = CounterpartyForwardingInfo_clone(&forwarding_info_arg_conv);
26111         void* outbound_htlc_minimum_msat_arg_ptr = (void*)(((uintptr_t)outbound_htlc_minimum_msat_arg) & ~1);
26112         CHECK_ACCESS(outbound_htlc_minimum_msat_arg_ptr);
26113         LDKCOption_u64Z outbound_htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(outbound_htlc_minimum_msat_arg_ptr);
26114         outbound_htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)outbound_htlc_minimum_msat_arg) & ~1));
26115         void* outbound_htlc_maximum_msat_arg_ptr = (void*)(((uintptr_t)outbound_htlc_maximum_msat_arg) & ~1);
26116         CHECK_ACCESS(outbound_htlc_maximum_msat_arg_ptr);
26117         LDKCOption_u64Z outbound_htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(outbound_htlc_maximum_msat_arg_ptr);
26118         outbound_htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)outbound_htlc_maximum_msat_arg) & ~1));
26119         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);
26120         uint32_t ret_ref = 0;
26121         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26122         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26123         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26124         ret_ref = (uintptr_t)ret_var.inner;
26125         if (ret_var.is_owned) {
26126                 ret_ref |= 1;
26127         }
26128         return ret_ref;
26129 }
26130
26131 static inline uintptr_t ChannelCounterparty_clone_ptr(LDKChannelCounterparty *NONNULL_PTR arg) {
26132         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(arg);
26133 uint32_t ret_ref = 0;
26134 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26135 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26136 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26137 ret_ref = (uintptr_t)ret_var.inner;
26138 if (ret_var.is_owned) {
26139         ret_ref |= 1;
26140 }
26141         return ret_ref;
26142 }
26143 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_clone_ptr"))) TS_ChannelCounterparty_clone_ptr(uint32_t arg) {
26144         LDKChannelCounterparty arg_conv;
26145         arg_conv.inner = (void*)(arg & (~1));
26146         arg_conv.is_owned = false;
26147         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26148         uint32_t ret_conv = ChannelCounterparty_clone_ptr(&arg_conv);
26149         return ret_conv;
26150 }
26151
26152 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_clone"))) TS_ChannelCounterparty_clone(uint32_t orig) {
26153         LDKChannelCounterparty orig_conv;
26154         orig_conv.inner = (void*)(orig & (~1));
26155         orig_conv.is_owned = false;
26156         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26157         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(&orig_conv);
26158         uint32_t ret_ref = 0;
26159         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26160         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26161         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26162         ret_ref = (uintptr_t)ret_var.inner;
26163         if (ret_var.is_owned) {
26164                 ret_ref |= 1;
26165         }
26166         return ret_ref;
26167 }
26168
26169 void  __attribute__((export_name("TS_ChannelDetails_free"))) TS_ChannelDetails_free(uint32_t this_obj) {
26170         LDKChannelDetails this_obj_conv;
26171         this_obj_conv.inner = (void*)(this_obj & (~1));
26172         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26173         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26174         ChannelDetails_free(this_obj_conv);
26175 }
26176
26177 int8_tArray  __attribute__((export_name("TS_ChannelDetails_get_channel_id"))) TS_ChannelDetails_get_channel_id(uint32_t this_ptr) {
26178         LDKChannelDetails this_ptr_conv;
26179         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26180         this_ptr_conv.is_owned = false;
26181         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26182         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
26183         memcpy(ret_arr->elems, *ChannelDetails_get_channel_id(&this_ptr_conv), 32);
26184         return ret_arr;
26185 }
26186
26187 void  __attribute__((export_name("TS_ChannelDetails_set_channel_id"))) TS_ChannelDetails_set_channel_id(uint32_t this_ptr, int8_tArray val) {
26188         LDKChannelDetails this_ptr_conv;
26189         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26190         this_ptr_conv.is_owned = false;
26191         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26192         LDKThirtyTwoBytes val_ref;
26193         CHECK(val->arr_len == 32);
26194         memcpy(val_ref.data, val->elems, 32); FREE(val);
26195         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
26196 }
26197
26198 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_counterparty"))) TS_ChannelDetails_get_counterparty(uint32_t this_ptr) {
26199         LDKChannelDetails this_ptr_conv;
26200         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26201         this_ptr_conv.is_owned = false;
26202         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26203         LDKChannelCounterparty ret_var = ChannelDetails_get_counterparty(&this_ptr_conv);
26204         uint32_t ret_ref = 0;
26205         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26206         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26207         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26208         ret_ref = (uintptr_t)ret_var.inner;
26209         if (ret_var.is_owned) {
26210                 ret_ref |= 1;
26211         }
26212         return ret_ref;
26213 }
26214
26215 void  __attribute__((export_name("TS_ChannelDetails_set_counterparty"))) TS_ChannelDetails_set_counterparty(uint32_t this_ptr, uint32_t val) {
26216         LDKChannelDetails this_ptr_conv;
26217         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26218         this_ptr_conv.is_owned = false;
26219         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26220         LDKChannelCounterparty val_conv;
26221         val_conv.inner = (void*)(val & (~1));
26222         val_conv.is_owned = (val & 1) || (val == 0);
26223         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26224         val_conv = ChannelCounterparty_clone(&val_conv);
26225         ChannelDetails_set_counterparty(&this_ptr_conv, val_conv);
26226 }
26227
26228 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_funding_txo"))) TS_ChannelDetails_get_funding_txo(uint32_t this_ptr) {
26229         LDKChannelDetails this_ptr_conv;
26230         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26231         this_ptr_conv.is_owned = false;
26232         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26233         LDKOutPoint ret_var = ChannelDetails_get_funding_txo(&this_ptr_conv);
26234         uint32_t ret_ref = 0;
26235         if ((uintptr_t)ret_var.inner > 4096) {
26236                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26237                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26238         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26239                 ret_ref = (uintptr_t)ret_var.inner;
26240                 if (ret_var.is_owned) {
26241                         ret_ref |= 1;
26242                 }
26243         }
26244         return ret_ref;
26245 }
26246
26247 void  __attribute__((export_name("TS_ChannelDetails_set_funding_txo"))) TS_ChannelDetails_set_funding_txo(uint32_t this_ptr, uint32_t val) {
26248         LDKChannelDetails this_ptr_conv;
26249         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26250         this_ptr_conv.is_owned = false;
26251         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26252         LDKOutPoint val_conv;
26253         val_conv.inner = (void*)(val & (~1));
26254         val_conv.is_owned = (val & 1) || (val == 0);
26255         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26256         val_conv = OutPoint_clone(&val_conv);
26257         ChannelDetails_set_funding_txo(&this_ptr_conv, val_conv);
26258 }
26259
26260 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_channel_type"))) TS_ChannelDetails_get_channel_type(uint32_t this_ptr) {
26261         LDKChannelDetails this_ptr_conv;
26262         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26263         this_ptr_conv.is_owned = false;
26264         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26265         LDKChannelTypeFeatures ret_var = ChannelDetails_get_channel_type(&this_ptr_conv);
26266         uint32_t ret_ref = 0;
26267         if ((uintptr_t)ret_var.inner > 4096) {
26268                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26269                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26270         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26271                 ret_ref = (uintptr_t)ret_var.inner;
26272                 if (ret_var.is_owned) {
26273                         ret_ref |= 1;
26274                 }
26275         }
26276         return ret_ref;
26277 }
26278
26279 void  __attribute__((export_name("TS_ChannelDetails_set_channel_type"))) TS_ChannelDetails_set_channel_type(uint32_t this_ptr, uint32_t val) {
26280         LDKChannelDetails this_ptr_conv;
26281         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26282         this_ptr_conv.is_owned = false;
26283         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26284         LDKChannelTypeFeatures val_conv;
26285         val_conv.inner = (void*)(val & (~1));
26286         val_conv.is_owned = (val & 1) || (val == 0);
26287         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26288         val_conv = ChannelTypeFeatures_clone(&val_conv);
26289         ChannelDetails_set_channel_type(&this_ptr_conv, val_conv);
26290 }
26291
26292 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_short_channel_id"))) TS_ChannelDetails_get_short_channel_id(uint32_t this_ptr) {
26293         LDKChannelDetails this_ptr_conv;
26294         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26295         this_ptr_conv.is_owned = false;
26296         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26297         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
26298         *ret_copy = ChannelDetails_get_short_channel_id(&this_ptr_conv);
26299         uint32_t ret_ref = (uintptr_t)ret_copy;
26300         return ret_ref;
26301 }
26302
26303 void  __attribute__((export_name("TS_ChannelDetails_set_short_channel_id"))) TS_ChannelDetails_set_short_channel_id(uint32_t this_ptr, uint32_t val) {
26304         LDKChannelDetails this_ptr_conv;
26305         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26306         this_ptr_conv.is_owned = false;
26307         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26308         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
26309         CHECK_ACCESS(val_ptr);
26310         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
26311         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
26312         ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
26313 }
26314
26315 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_outbound_scid_alias"))) TS_ChannelDetails_get_outbound_scid_alias(uint32_t this_ptr) {
26316         LDKChannelDetails this_ptr_conv;
26317         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26318         this_ptr_conv.is_owned = false;
26319         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26320         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
26321         *ret_copy = ChannelDetails_get_outbound_scid_alias(&this_ptr_conv);
26322         uint32_t ret_ref = (uintptr_t)ret_copy;
26323         return ret_ref;
26324 }
26325
26326 void  __attribute__((export_name("TS_ChannelDetails_set_outbound_scid_alias"))) TS_ChannelDetails_set_outbound_scid_alias(uint32_t this_ptr, uint32_t val) {
26327         LDKChannelDetails this_ptr_conv;
26328         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26329         this_ptr_conv.is_owned = false;
26330         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26331         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
26332         CHECK_ACCESS(val_ptr);
26333         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
26334         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
26335         ChannelDetails_set_outbound_scid_alias(&this_ptr_conv, val_conv);
26336 }
26337
26338 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_inbound_scid_alias"))) TS_ChannelDetails_get_inbound_scid_alias(uint32_t this_ptr) {
26339         LDKChannelDetails this_ptr_conv;
26340         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26341         this_ptr_conv.is_owned = false;
26342         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26343         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
26344         *ret_copy = ChannelDetails_get_inbound_scid_alias(&this_ptr_conv);
26345         uint32_t ret_ref = (uintptr_t)ret_copy;
26346         return ret_ref;
26347 }
26348
26349 void  __attribute__((export_name("TS_ChannelDetails_set_inbound_scid_alias"))) TS_ChannelDetails_set_inbound_scid_alias(uint32_t this_ptr, uint32_t val) {
26350         LDKChannelDetails this_ptr_conv;
26351         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26352         this_ptr_conv.is_owned = false;
26353         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26354         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
26355         CHECK_ACCESS(val_ptr);
26356         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
26357         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
26358         ChannelDetails_set_inbound_scid_alias(&this_ptr_conv, val_conv);
26359 }
26360
26361 int64_t  __attribute__((export_name("TS_ChannelDetails_get_channel_value_satoshis"))) TS_ChannelDetails_get_channel_value_satoshis(uint32_t this_ptr) {
26362         LDKChannelDetails this_ptr_conv;
26363         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26364         this_ptr_conv.is_owned = false;
26365         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26366         int64_t ret_conv = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
26367         return ret_conv;
26368 }
26369
26370 void  __attribute__((export_name("TS_ChannelDetails_set_channel_value_satoshis"))) TS_ChannelDetails_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
26371         LDKChannelDetails this_ptr_conv;
26372         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26373         this_ptr_conv.is_owned = false;
26374         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26375         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
26376 }
26377
26378 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_unspendable_punishment_reserve"))) TS_ChannelDetails_get_unspendable_punishment_reserve(uint32_t this_ptr) {
26379         LDKChannelDetails this_ptr_conv;
26380         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26381         this_ptr_conv.is_owned = false;
26382         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26383         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
26384         *ret_copy = ChannelDetails_get_unspendable_punishment_reserve(&this_ptr_conv);
26385         uint32_t ret_ref = (uintptr_t)ret_copy;
26386         return ret_ref;
26387 }
26388
26389 void  __attribute__((export_name("TS_ChannelDetails_set_unspendable_punishment_reserve"))) TS_ChannelDetails_set_unspendable_punishment_reserve(uint32_t this_ptr, uint32_t val) {
26390         LDKChannelDetails this_ptr_conv;
26391         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26392         this_ptr_conv.is_owned = false;
26393         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26394         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
26395         CHECK_ACCESS(val_ptr);
26396         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
26397         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
26398         ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv);
26399 }
26400
26401 int64_t  __attribute__((export_name("TS_ChannelDetails_get_user_channel_id"))) TS_ChannelDetails_get_user_channel_id(uint32_t this_ptr) {
26402         LDKChannelDetails this_ptr_conv;
26403         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26404         this_ptr_conv.is_owned = false;
26405         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26406         int64_t ret_conv = ChannelDetails_get_user_channel_id(&this_ptr_conv);
26407         return ret_conv;
26408 }
26409
26410 void  __attribute__((export_name("TS_ChannelDetails_set_user_channel_id"))) TS_ChannelDetails_set_user_channel_id(uint32_t this_ptr, int64_t val) {
26411         LDKChannelDetails this_ptr_conv;
26412         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26413         this_ptr_conv.is_owned = false;
26414         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26415         ChannelDetails_set_user_channel_id(&this_ptr_conv, val);
26416 }
26417
26418 int64_t  __attribute__((export_name("TS_ChannelDetails_get_balance_msat"))) TS_ChannelDetails_get_balance_msat(uint32_t this_ptr) {
26419         LDKChannelDetails this_ptr_conv;
26420         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26421         this_ptr_conv.is_owned = false;
26422         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26423         int64_t ret_conv = ChannelDetails_get_balance_msat(&this_ptr_conv);
26424         return ret_conv;
26425 }
26426
26427 void  __attribute__((export_name("TS_ChannelDetails_set_balance_msat"))) TS_ChannelDetails_set_balance_msat(uint32_t this_ptr, int64_t val) {
26428         LDKChannelDetails this_ptr_conv;
26429         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26430         this_ptr_conv.is_owned = false;
26431         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26432         ChannelDetails_set_balance_msat(&this_ptr_conv, val);
26433 }
26434
26435 int64_t  __attribute__((export_name("TS_ChannelDetails_get_outbound_capacity_msat"))) TS_ChannelDetails_get_outbound_capacity_msat(uint32_t this_ptr) {
26436         LDKChannelDetails this_ptr_conv;
26437         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26438         this_ptr_conv.is_owned = false;
26439         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26440         int64_t ret_conv = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
26441         return ret_conv;
26442 }
26443
26444 void  __attribute__((export_name("TS_ChannelDetails_set_outbound_capacity_msat"))) TS_ChannelDetails_set_outbound_capacity_msat(uint32_t this_ptr, int64_t val) {
26445         LDKChannelDetails this_ptr_conv;
26446         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26447         this_ptr_conv.is_owned = false;
26448         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26449         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
26450 }
26451
26452 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) {
26453         LDKChannelDetails this_ptr_conv;
26454         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26455         this_ptr_conv.is_owned = false;
26456         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26457         int64_t ret_conv = ChannelDetails_get_next_outbound_htlc_limit_msat(&this_ptr_conv);
26458         return ret_conv;
26459 }
26460
26461 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) {
26462         LDKChannelDetails this_ptr_conv;
26463         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26464         this_ptr_conv.is_owned = false;
26465         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26466         ChannelDetails_set_next_outbound_htlc_limit_msat(&this_ptr_conv, val);
26467 }
26468
26469 int64_t  __attribute__((export_name("TS_ChannelDetails_get_inbound_capacity_msat"))) TS_ChannelDetails_get_inbound_capacity_msat(uint32_t this_ptr) {
26470         LDKChannelDetails this_ptr_conv;
26471         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26472         this_ptr_conv.is_owned = false;
26473         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26474         int64_t ret_conv = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
26475         return ret_conv;
26476 }
26477
26478 void  __attribute__((export_name("TS_ChannelDetails_set_inbound_capacity_msat"))) TS_ChannelDetails_set_inbound_capacity_msat(uint32_t this_ptr, int64_t val) {
26479         LDKChannelDetails this_ptr_conv;
26480         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26481         this_ptr_conv.is_owned = false;
26482         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26483         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
26484 }
26485
26486 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_confirmations_required"))) TS_ChannelDetails_get_confirmations_required(uint32_t this_ptr) {
26487         LDKChannelDetails this_ptr_conv;
26488         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26489         this_ptr_conv.is_owned = false;
26490         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26491         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
26492         *ret_copy = ChannelDetails_get_confirmations_required(&this_ptr_conv);
26493         uint32_t ret_ref = (uintptr_t)ret_copy;
26494         return ret_ref;
26495 }
26496
26497 void  __attribute__((export_name("TS_ChannelDetails_set_confirmations_required"))) TS_ChannelDetails_set_confirmations_required(uint32_t this_ptr, uint32_t val) {
26498         LDKChannelDetails this_ptr_conv;
26499         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26500         this_ptr_conv.is_owned = false;
26501         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26502         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
26503         CHECK_ACCESS(val_ptr);
26504         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
26505         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)val) & ~1));
26506         ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv);
26507 }
26508
26509 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_force_close_spend_delay"))) TS_ChannelDetails_get_force_close_spend_delay(uint32_t this_ptr) {
26510         LDKChannelDetails this_ptr_conv;
26511         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26512         this_ptr_conv.is_owned = false;
26513         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26514         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
26515         *ret_copy = ChannelDetails_get_force_close_spend_delay(&this_ptr_conv);
26516         uint32_t ret_ref = (uintptr_t)ret_copy;
26517         return ret_ref;
26518 }
26519
26520 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) {
26521         LDKChannelDetails this_ptr_conv;
26522         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26523         this_ptr_conv.is_owned = false;
26524         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26525         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
26526         CHECK_ACCESS(val_ptr);
26527         LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(val_ptr);
26528         val_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uintptr_t)val) & ~1));
26529         ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv);
26530 }
26531
26532 jboolean  __attribute__((export_name("TS_ChannelDetails_get_is_outbound"))) TS_ChannelDetails_get_is_outbound(uint32_t this_ptr) {
26533         LDKChannelDetails this_ptr_conv;
26534         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26535         this_ptr_conv.is_owned = false;
26536         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26537         jboolean ret_conv = ChannelDetails_get_is_outbound(&this_ptr_conv);
26538         return ret_conv;
26539 }
26540
26541 void  __attribute__((export_name("TS_ChannelDetails_set_is_outbound"))) TS_ChannelDetails_set_is_outbound(uint32_t this_ptr, jboolean val) {
26542         LDKChannelDetails this_ptr_conv;
26543         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26544         this_ptr_conv.is_owned = false;
26545         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26546         ChannelDetails_set_is_outbound(&this_ptr_conv, val);
26547 }
26548
26549 jboolean  __attribute__((export_name("TS_ChannelDetails_get_is_channel_ready"))) TS_ChannelDetails_get_is_channel_ready(uint32_t this_ptr) {
26550         LDKChannelDetails this_ptr_conv;
26551         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26552         this_ptr_conv.is_owned = false;
26553         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26554         jboolean ret_conv = ChannelDetails_get_is_channel_ready(&this_ptr_conv);
26555         return ret_conv;
26556 }
26557
26558 void  __attribute__((export_name("TS_ChannelDetails_set_is_channel_ready"))) TS_ChannelDetails_set_is_channel_ready(uint32_t this_ptr, jboolean val) {
26559         LDKChannelDetails this_ptr_conv;
26560         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26561         this_ptr_conv.is_owned = false;
26562         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26563         ChannelDetails_set_is_channel_ready(&this_ptr_conv, val);
26564 }
26565
26566 jboolean  __attribute__((export_name("TS_ChannelDetails_get_is_usable"))) TS_ChannelDetails_get_is_usable(uint32_t this_ptr) {
26567         LDKChannelDetails this_ptr_conv;
26568         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26569         this_ptr_conv.is_owned = false;
26570         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26571         jboolean ret_conv = ChannelDetails_get_is_usable(&this_ptr_conv);
26572         return ret_conv;
26573 }
26574
26575 void  __attribute__((export_name("TS_ChannelDetails_set_is_usable"))) TS_ChannelDetails_set_is_usable(uint32_t this_ptr, jboolean val) {
26576         LDKChannelDetails this_ptr_conv;
26577         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26578         this_ptr_conv.is_owned = false;
26579         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26580         ChannelDetails_set_is_usable(&this_ptr_conv, val);
26581 }
26582
26583 jboolean  __attribute__((export_name("TS_ChannelDetails_get_is_public"))) TS_ChannelDetails_get_is_public(uint32_t this_ptr) {
26584         LDKChannelDetails this_ptr_conv;
26585         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26586         this_ptr_conv.is_owned = false;
26587         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26588         jboolean ret_conv = ChannelDetails_get_is_public(&this_ptr_conv);
26589         return ret_conv;
26590 }
26591
26592 void  __attribute__((export_name("TS_ChannelDetails_set_is_public"))) TS_ChannelDetails_set_is_public(uint32_t this_ptr, jboolean val) {
26593         LDKChannelDetails this_ptr_conv;
26594         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26595         this_ptr_conv.is_owned = false;
26596         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26597         ChannelDetails_set_is_public(&this_ptr_conv, val);
26598 }
26599
26600 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_inbound_htlc_minimum_msat"))) TS_ChannelDetails_get_inbound_htlc_minimum_msat(uint32_t this_ptr) {
26601         LDKChannelDetails this_ptr_conv;
26602         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26603         this_ptr_conv.is_owned = false;
26604         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26605         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
26606         *ret_copy = ChannelDetails_get_inbound_htlc_minimum_msat(&this_ptr_conv);
26607         uint32_t ret_ref = (uintptr_t)ret_copy;
26608         return ret_ref;
26609 }
26610
26611 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) {
26612         LDKChannelDetails this_ptr_conv;
26613         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26614         this_ptr_conv.is_owned = false;
26615         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26616         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
26617         CHECK_ACCESS(val_ptr);
26618         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
26619         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
26620         ChannelDetails_set_inbound_htlc_minimum_msat(&this_ptr_conv, val_conv);
26621 }
26622
26623 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_inbound_htlc_maximum_msat"))) TS_ChannelDetails_get_inbound_htlc_maximum_msat(uint32_t this_ptr) {
26624         LDKChannelDetails this_ptr_conv;
26625         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26626         this_ptr_conv.is_owned = false;
26627         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26628         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
26629         *ret_copy = ChannelDetails_get_inbound_htlc_maximum_msat(&this_ptr_conv);
26630         uint32_t ret_ref = (uintptr_t)ret_copy;
26631         return ret_ref;
26632 }
26633
26634 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) {
26635         LDKChannelDetails this_ptr_conv;
26636         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26637         this_ptr_conv.is_owned = false;
26638         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26639         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
26640         CHECK_ACCESS(val_ptr);
26641         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
26642         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
26643         ChannelDetails_set_inbound_htlc_maximum_msat(&this_ptr_conv, val_conv);
26644 }
26645
26646 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_config"))) TS_ChannelDetails_get_config(uint32_t this_ptr) {
26647         LDKChannelDetails this_ptr_conv;
26648         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26649         this_ptr_conv.is_owned = false;
26650         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26651         LDKChannelConfig ret_var = ChannelDetails_get_config(&this_ptr_conv);
26652         uint32_t ret_ref = 0;
26653         if ((uintptr_t)ret_var.inner > 4096) {
26654                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26655                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26656         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26657                 ret_ref = (uintptr_t)ret_var.inner;
26658                 if (ret_var.is_owned) {
26659                         ret_ref |= 1;
26660                 }
26661         }
26662         return ret_ref;
26663 }
26664
26665 void  __attribute__((export_name("TS_ChannelDetails_set_config"))) TS_ChannelDetails_set_config(uint32_t this_ptr, uint32_t val) {
26666         LDKChannelDetails this_ptr_conv;
26667         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26668         this_ptr_conv.is_owned = false;
26669         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26670         LDKChannelConfig val_conv;
26671         val_conv.inner = (void*)(val & (~1));
26672         val_conv.is_owned = (val & 1) || (val == 0);
26673         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26674         val_conv = ChannelConfig_clone(&val_conv);
26675         ChannelDetails_set_config(&this_ptr_conv, val_conv);
26676 }
26677
26678 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) {
26679         LDKThirtyTwoBytes channel_id_arg_ref;
26680         CHECK(channel_id_arg->arr_len == 32);
26681         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
26682         LDKChannelCounterparty counterparty_arg_conv;
26683         counterparty_arg_conv.inner = (void*)(counterparty_arg & (~1));
26684         counterparty_arg_conv.is_owned = (counterparty_arg & 1) || (counterparty_arg == 0);
26685         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_arg_conv);
26686         counterparty_arg_conv = ChannelCounterparty_clone(&counterparty_arg_conv);
26687         LDKOutPoint funding_txo_arg_conv;
26688         funding_txo_arg_conv.inner = (void*)(funding_txo_arg & (~1));
26689         funding_txo_arg_conv.is_owned = (funding_txo_arg & 1) || (funding_txo_arg == 0);
26690         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_arg_conv);
26691         funding_txo_arg_conv = OutPoint_clone(&funding_txo_arg_conv);
26692         LDKChannelTypeFeatures channel_type_arg_conv;
26693         channel_type_arg_conv.inner = (void*)(channel_type_arg & (~1));
26694         channel_type_arg_conv.is_owned = (channel_type_arg & 1) || (channel_type_arg == 0);
26695         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_arg_conv);
26696         channel_type_arg_conv = ChannelTypeFeatures_clone(&channel_type_arg_conv);
26697         void* short_channel_id_arg_ptr = (void*)(((uintptr_t)short_channel_id_arg) & ~1);
26698         CHECK_ACCESS(short_channel_id_arg_ptr);
26699         LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_arg_ptr);
26700         short_channel_id_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id_arg) & ~1));
26701         void* outbound_scid_alias_arg_ptr = (void*)(((uintptr_t)outbound_scid_alias_arg) & ~1);
26702         CHECK_ACCESS(outbound_scid_alias_arg_ptr);
26703         LDKCOption_u64Z outbound_scid_alias_arg_conv = *(LDKCOption_u64Z*)(outbound_scid_alias_arg_ptr);
26704         outbound_scid_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)outbound_scid_alias_arg) & ~1));
26705         void* inbound_scid_alias_arg_ptr = (void*)(((uintptr_t)inbound_scid_alias_arg) & ~1);
26706         CHECK_ACCESS(inbound_scid_alias_arg_ptr);
26707         LDKCOption_u64Z inbound_scid_alias_arg_conv = *(LDKCOption_u64Z*)(inbound_scid_alias_arg_ptr);
26708         inbound_scid_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)inbound_scid_alias_arg) & ~1));
26709         void* unspendable_punishment_reserve_arg_ptr = (void*)(((uintptr_t)unspendable_punishment_reserve_arg) & ~1);
26710         CHECK_ACCESS(unspendable_punishment_reserve_arg_ptr);
26711         LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(unspendable_punishment_reserve_arg_ptr);
26712         void* confirmations_required_arg_ptr = (void*)(((uintptr_t)confirmations_required_arg) & ~1);
26713         CHECK_ACCESS(confirmations_required_arg_ptr);
26714         LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(confirmations_required_arg_ptr);
26715         confirmations_required_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)confirmations_required_arg) & ~1));
26716         void* force_close_spend_delay_arg_ptr = (void*)(((uintptr_t)force_close_spend_delay_arg) & ~1);
26717         CHECK_ACCESS(force_close_spend_delay_arg_ptr);
26718         LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(force_close_spend_delay_arg_ptr);
26719         force_close_spend_delay_arg_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uintptr_t)force_close_spend_delay_arg) & ~1));
26720         void* inbound_htlc_minimum_msat_arg_ptr = (void*)(((uintptr_t)inbound_htlc_minimum_msat_arg) & ~1);
26721         CHECK_ACCESS(inbound_htlc_minimum_msat_arg_ptr);
26722         LDKCOption_u64Z inbound_htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(inbound_htlc_minimum_msat_arg_ptr);
26723         inbound_htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)inbound_htlc_minimum_msat_arg) & ~1));
26724         void* inbound_htlc_maximum_msat_arg_ptr = (void*)(((uintptr_t)inbound_htlc_maximum_msat_arg) & ~1);
26725         CHECK_ACCESS(inbound_htlc_maximum_msat_arg_ptr);
26726         LDKCOption_u64Z inbound_htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(inbound_htlc_maximum_msat_arg_ptr);
26727         inbound_htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)inbound_htlc_maximum_msat_arg) & ~1));
26728         LDKChannelConfig config_arg_conv;
26729         config_arg_conv.inner = (void*)(config_arg & (~1));
26730         config_arg_conv.is_owned = (config_arg & 1) || (config_arg == 0);
26731         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_arg_conv);
26732         config_arg_conv = ChannelConfig_clone(&config_arg_conv);
26733         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);
26734         uint32_t ret_ref = 0;
26735         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26736         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26737         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26738         ret_ref = (uintptr_t)ret_var.inner;
26739         if (ret_var.is_owned) {
26740                 ret_ref |= 1;
26741         }
26742         return ret_ref;
26743 }
26744
26745 static inline uintptr_t ChannelDetails_clone_ptr(LDKChannelDetails *NONNULL_PTR arg) {
26746         LDKChannelDetails ret_var = ChannelDetails_clone(arg);
26747 uint32_t ret_ref = 0;
26748 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26749 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26750 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26751 ret_ref = (uintptr_t)ret_var.inner;
26752 if (ret_var.is_owned) {
26753         ret_ref |= 1;
26754 }
26755         return ret_ref;
26756 }
26757 uint32_t  __attribute__((export_name("TS_ChannelDetails_clone_ptr"))) TS_ChannelDetails_clone_ptr(uint32_t arg) {
26758         LDKChannelDetails arg_conv;
26759         arg_conv.inner = (void*)(arg & (~1));
26760         arg_conv.is_owned = false;
26761         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26762         uint32_t ret_conv = ChannelDetails_clone_ptr(&arg_conv);
26763         return ret_conv;
26764 }
26765
26766 uint32_t  __attribute__((export_name("TS_ChannelDetails_clone"))) TS_ChannelDetails_clone(uint32_t orig) {
26767         LDKChannelDetails orig_conv;
26768         orig_conv.inner = (void*)(orig & (~1));
26769         orig_conv.is_owned = false;
26770         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26771         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
26772         uint32_t ret_ref = 0;
26773         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26774         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26775         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26776         ret_ref = (uintptr_t)ret_var.inner;
26777         if (ret_var.is_owned) {
26778                 ret_ref |= 1;
26779         }
26780         return ret_ref;
26781 }
26782
26783 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_inbound_payment_scid"))) TS_ChannelDetails_get_inbound_payment_scid(uint32_t this_arg) {
26784         LDKChannelDetails this_arg_conv;
26785         this_arg_conv.inner = (void*)(this_arg & (~1));
26786         this_arg_conv.is_owned = false;
26787         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26788         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
26789         *ret_copy = ChannelDetails_get_inbound_payment_scid(&this_arg_conv);
26790         uint32_t ret_ref = (uintptr_t)ret_copy;
26791         return ret_ref;
26792 }
26793
26794 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_outbound_payment_scid"))) TS_ChannelDetails_get_outbound_payment_scid(uint32_t this_arg) {
26795         LDKChannelDetails this_arg_conv;
26796         this_arg_conv.inner = (void*)(this_arg & (~1));
26797         this_arg_conv.is_owned = false;
26798         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26799         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
26800         *ret_copy = ChannelDetails_get_outbound_payment_scid(&this_arg_conv);
26801         uint32_t ret_ref = (uintptr_t)ret_copy;
26802         return ret_ref;
26803 }
26804
26805 void  __attribute__((export_name("TS_PaymentSendFailure_free"))) TS_PaymentSendFailure_free(uint32_t this_ptr) {
26806         if ((this_ptr & 1) != 0) return;
26807         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
26808         CHECK_ACCESS(this_ptr_ptr);
26809         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(this_ptr_ptr);
26810         FREE((void*)this_ptr);
26811         PaymentSendFailure_free(this_ptr_conv);
26812 }
26813
26814 static inline uintptr_t PaymentSendFailure_clone_ptr(LDKPaymentSendFailure *NONNULL_PTR arg) {
26815         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
26816         *ret_copy = PaymentSendFailure_clone(arg);
26817 uint32_t ret_ref = (uintptr_t)ret_copy;
26818         return ret_ref;
26819 }
26820 uint32_t  __attribute__((export_name("TS_PaymentSendFailure_clone_ptr"))) TS_PaymentSendFailure_clone_ptr(uint32_t arg) {
26821         LDKPaymentSendFailure* arg_conv = (LDKPaymentSendFailure*)arg;
26822         uint32_t ret_conv = PaymentSendFailure_clone_ptr(arg_conv);
26823         return ret_conv;
26824 }
26825
26826 uint32_t  __attribute__((export_name("TS_PaymentSendFailure_clone"))) TS_PaymentSendFailure_clone(uint32_t orig) {
26827         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)orig;
26828         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
26829         *ret_copy = PaymentSendFailure_clone(orig_conv);
26830         uint32_t ret_ref = (uintptr_t)ret_copy;
26831         return ret_ref;
26832 }
26833
26834 uint32_t  __attribute__((export_name("TS_PaymentSendFailure_parameter_error"))) TS_PaymentSendFailure_parameter_error(uint32_t a) {
26835         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
26836         CHECK_ACCESS(a_ptr);
26837         LDKAPIError a_conv = *(LDKAPIError*)(a_ptr);
26838         a_conv = APIError_clone((LDKAPIError*)(((uintptr_t)a) & ~1));
26839         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
26840         *ret_copy = PaymentSendFailure_parameter_error(a_conv);
26841         uint32_t ret_ref = (uintptr_t)ret_copy;
26842         return ret_ref;
26843 }
26844
26845 uint32_t  __attribute__((export_name("TS_PaymentSendFailure_path_parameter_error"))) TS_PaymentSendFailure_path_parameter_error(uint32_tArray a) {
26846         LDKCVec_CResult_NoneAPIErrorZZ a_constr;
26847         a_constr.datalen = a->arr_len;
26848         if (a_constr.datalen > 0)
26849                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
26850         else
26851                 a_constr.data = NULL;
26852         uint32_t* a_vals = a->elems;
26853         for (size_t w = 0; w < a_constr.datalen; w++) {
26854                 uint32_t a_conv_22 = a_vals[w];
26855                 void* a_conv_22_ptr = (void*)(((uintptr_t)a_conv_22) & ~1);
26856                 CHECK_ACCESS(a_conv_22_ptr);
26857                 LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(a_conv_22_ptr);
26858                 a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uintptr_t)a_conv_22) & ~1));
26859                 a_constr.data[w] = a_conv_22_conv;
26860         }
26861         FREE(a);
26862         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
26863         *ret_copy = PaymentSendFailure_path_parameter_error(a_constr);
26864         uint32_t ret_ref = (uintptr_t)ret_copy;
26865         return ret_ref;
26866 }
26867
26868 uint32_t  __attribute__((export_name("TS_PaymentSendFailure_all_failed_retry_safe"))) TS_PaymentSendFailure_all_failed_retry_safe(uint32_tArray a) {
26869         LDKCVec_APIErrorZ a_constr;
26870         a_constr.datalen = a->arr_len;
26871         if (a_constr.datalen > 0)
26872                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
26873         else
26874                 a_constr.data = NULL;
26875         uint32_t* a_vals = a->elems;
26876         for (size_t k = 0; k < a_constr.datalen; k++) {
26877                 uint32_t a_conv_10 = a_vals[k];
26878                 void* a_conv_10_ptr = (void*)(((uintptr_t)a_conv_10) & ~1);
26879                 CHECK_ACCESS(a_conv_10_ptr);
26880                 LDKAPIError a_conv_10_conv = *(LDKAPIError*)(a_conv_10_ptr);
26881                 a_conv_10_conv = APIError_clone((LDKAPIError*)(((uintptr_t)a_conv_10) & ~1));
26882                 a_constr.data[k] = a_conv_10_conv;
26883         }
26884         FREE(a);
26885         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
26886         *ret_copy = PaymentSendFailure_all_failed_retry_safe(a_constr);
26887         uint32_t ret_ref = (uintptr_t)ret_copy;
26888         return ret_ref;
26889 }
26890
26891 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) {
26892         LDKCVec_CResult_NoneAPIErrorZZ results_constr;
26893         results_constr.datalen = results->arr_len;
26894         if (results_constr.datalen > 0)
26895                 results_constr.data = MALLOC(results_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
26896         else
26897                 results_constr.data = NULL;
26898         uint32_t* results_vals = results->elems;
26899         for (size_t w = 0; w < results_constr.datalen; w++) {
26900                 uint32_t results_conv_22 = results_vals[w];
26901                 void* results_conv_22_ptr = (void*)(((uintptr_t)results_conv_22) & ~1);
26902                 CHECK_ACCESS(results_conv_22_ptr);
26903                 LDKCResult_NoneAPIErrorZ results_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(results_conv_22_ptr);
26904                 results_constr.data[w] = results_conv_22_conv;
26905         }
26906         FREE(results);
26907         LDKRouteParameters failed_paths_retry_conv;
26908         failed_paths_retry_conv.inner = (void*)(failed_paths_retry & (~1));
26909         failed_paths_retry_conv.is_owned = (failed_paths_retry & 1) || (failed_paths_retry == 0);
26910         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_conv);
26911         failed_paths_retry_conv = RouteParameters_clone(&failed_paths_retry_conv);
26912         LDKThirtyTwoBytes payment_id_ref;
26913         CHECK(payment_id->arr_len == 32);
26914         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
26915         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
26916         *ret_copy = PaymentSendFailure_partial_failure(results_constr, failed_paths_retry_conv, payment_id_ref);
26917         uint32_t ret_ref = (uintptr_t)ret_copy;
26918         return ret_ref;
26919 }
26920
26921 void  __attribute__((export_name("TS_PhantomRouteHints_free"))) TS_PhantomRouteHints_free(uint32_t this_obj) {
26922         LDKPhantomRouteHints this_obj_conv;
26923         this_obj_conv.inner = (void*)(this_obj & (~1));
26924         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26925         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26926         PhantomRouteHints_free(this_obj_conv);
26927 }
26928
26929 uint32_tArray  __attribute__((export_name("TS_PhantomRouteHints_get_channels"))) TS_PhantomRouteHints_get_channels(uint32_t this_ptr) {
26930         LDKPhantomRouteHints this_ptr_conv;
26931         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26932         this_ptr_conv.is_owned = false;
26933         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26934         LDKCVec_ChannelDetailsZ ret_var = PhantomRouteHints_get_channels(&this_ptr_conv);
26935         uint32_tArray ret_arr = NULL;
26936         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
26937         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 8);
26938         for (size_t q = 0; q < ret_var.datalen; q++) {
26939                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
26940                 uint32_t ret_conv_16_ref = 0;
26941                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26942                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26943                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
26944                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
26945                 if (ret_conv_16_var.is_owned) {
26946                         ret_conv_16_ref |= 1;
26947                 }
26948                 ret_arr_ptr[q] = ret_conv_16_ref;
26949         }
26950         
26951         FREE(ret_var.data);
26952         return ret_arr;
26953 }
26954
26955 void  __attribute__((export_name("TS_PhantomRouteHints_set_channels"))) TS_PhantomRouteHints_set_channels(uint32_t this_ptr, uint32_tArray val) {
26956         LDKPhantomRouteHints this_ptr_conv;
26957         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26958         this_ptr_conv.is_owned = false;
26959         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26960         LDKCVec_ChannelDetailsZ val_constr;
26961         val_constr.datalen = val->arr_len;
26962         if (val_constr.datalen > 0)
26963                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
26964         else
26965                 val_constr.data = NULL;
26966         uint32_t* val_vals = val->elems;
26967         for (size_t q = 0; q < val_constr.datalen; q++) {
26968                 uint32_t val_conv_16 = val_vals[q];
26969                 LDKChannelDetails val_conv_16_conv;
26970                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
26971                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
26972                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
26973                 val_conv_16_conv = ChannelDetails_clone(&val_conv_16_conv);
26974                 val_constr.data[q] = val_conv_16_conv;
26975         }
26976         FREE(val);
26977         PhantomRouteHints_set_channels(&this_ptr_conv, val_constr);
26978 }
26979
26980 int64_t  __attribute__((export_name("TS_PhantomRouteHints_get_phantom_scid"))) TS_PhantomRouteHints_get_phantom_scid(uint32_t this_ptr) {
26981         LDKPhantomRouteHints this_ptr_conv;
26982         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26983         this_ptr_conv.is_owned = false;
26984         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26985         int64_t ret_conv = PhantomRouteHints_get_phantom_scid(&this_ptr_conv);
26986         return ret_conv;
26987 }
26988
26989 void  __attribute__((export_name("TS_PhantomRouteHints_set_phantom_scid"))) TS_PhantomRouteHints_set_phantom_scid(uint32_t this_ptr, int64_t val) {
26990         LDKPhantomRouteHints this_ptr_conv;
26991         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26992         this_ptr_conv.is_owned = false;
26993         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26994         PhantomRouteHints_set_phantom_scid(&this_ptr_conv, val);
26995 }
26996
26997 int8_tArray  __attribute__((export_name("TS_PhantomRouteHints_get_real_node_pubkey"))) TS_PhantomRouteHints_get_real_node_pubkey(uint32_t this_ptr) {
26998         LDKPhantomRouteHints this_ptr_conv;
26999         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27000         this_ptr_conv.is_owned = false;
27001         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27002         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
27003         memcpy(ret_arr->elems, PhantomRouteHints_get_real_node_pubkey(&this_ptr_conv).compressed_form, 33);
27004         return ret_arr;
27005 }
27006
27007 void  __attribute__((export_name("TS_PhantomRouteHints_set_real_node_pubkey"))) TS_PhantomRouteHints_set_real_node_pubkey(uint32_t this_ptr, int8_tArray val) {
27008         LDKPhantomRouteHints this_ptr_conv;
27009         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27010         this_ptr_conv.is_owned = false;
27011         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27012         LDKPublicKey val_ref;
27013         CHECK(val->arr_len == 33);
27014         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
27015         PhantomRouteHints_set_real_node_pubkey(&this_ptr_conv, val_ref);
27016 }
27017
27018 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) {
27019         LDKCVec_ChannelDetailsZ channels_arg_constr;
27020         channels_arg_constr.datalen = channels_arg->arr_len;
27021         if (channels_arg_constr.datalen > 0)
27022                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
27023         else
27024                 channels_arg_constr.data = NULL;
27025         uint32_t* channels_arg_vals = channels_arg->elems;
27026         for (size_t q = 0; q < channels_arg_constr.datalen; q++) {
27027                 uint32_t channels_arg_conv_16 = channels_arg_vals[q];
27028                 LDKChannelDetails channels_arg_conv_16_conv;
27029                 channels_arg_conv_16_conv.inner = (void*)(channels_arg_conv_16 & (~1));
27030                 channels_arg_conv_16_conv.is_owned = (channels_arg_conv_16 & 1) || (channels_arg_conv_16 == 0);
27031                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channels_arg_conv_16_conv);
27032                 channels_arg_conv_16_conv = ChannelDetails_clone(&channels_arg_conv_16_conv);
27033                 channels_arg_constr.data[q] = channels_arg_conv_16_conv;
27034         }
27035         FREE(channels_arg);
27036         LDKPublicKey real_node_pubkey_arg_ref;
27037         CHECK(real_node_pubkey_arg->arr_len == 33);
27038         memcpy(real_node_pubkey_arg_ref.compressed_form, real_node_pubkey_arg->elems, 33); FREE(real_node_pubkey_arg);
27039         LDKPhantomRouteHints ret_var = PhantomRouteHints_new(channels_arg_constr, phantom_scid_arg, real_node_pubkey_arg_ref);
27040         uint32_t ret_ref = 0;
27041         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27042         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27043         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27044         ret_ref = (uintptr_t)ret_var.inner;
27045         if (ret_var.is_owned) {
27046                 ret_ref |= 1;
27047         }
27048         return ret_ref;
27049 }
27050
27051 static inline uintptr_t PhantomRouteHints_clone_ptr(LDKPhantomRouteHints *NONNULL_PTR arg) {
27052         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(arg);
27053 uint32_t ret_ref = 0;
27054 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27055 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27056 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27057 ret_ref = (uintptr_t)ret_var.inner;
27058 if (ret_var.is_owned) {
27059         ret_ref |= 1;
27060 }
27061         return ret_ref;
27062 }
27063 uint32_t  __attribute__((export_name("TS_PhantomRouteHints_clone_ptr"))) TS_PhantomRouteHints_clone_ptr(uint32_t arg) {
27064         LDKPhantomRouteHints arg_conv;
27065         arg_conv.inner = (void*)(arg & (~1));
27066         arg_conv.is_owned = false;
27067         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27068         uint32_t ret_conv = PhantomRouteHints_clone_ptr(&arg_conv);
27069         return ret_conv;
27070 }
27071
27072 uint32_t  __attribute__((export_name("TS_PhantomRouteHints_clone"))) TS_PhantomRouteHints_clone(uint32_t orig) {
27073         LDKPhantomRouteHints orig_conv;
27074         orig_conv.inner = (void*)(orig & (~1));
27075         orig_conv.is_owned = false;
27076         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27077         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(&orig_conv);
27078         uint32_t ret_ref = 0;
27079         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27080         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27081         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27082         ret_ref = (uintptr_t)ret_var.inner;
27083         if (ret_var.is_owned) {
27084                 ret_ref |= 1;
27085         }
27086         return ret_ref;
27087 }
27088
27089 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) {
27090         void* fee_est_ptr = (void*)(((uintptr_t)fee_est) & ~1);
27091         CHECK_ACCESS(fee_est_ptr);
27092         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(fee_est_ptr);
27093         if (fee_est_conv.free == LDKFeeEstimator_JCalls_free) {
27094                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27095                 LDKFeeEstimator_JCalls_cloned(&fee_est_conv);
27096         }
27097         void* chain_monitor_ptr = (void*)(((uintptr_t)chain_monitor) & ~1);
27098         CHECK_ACCESS(chain_monitor_ptr);
27099         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
27100         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
27101                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27102                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
27103         }
27104         void* tx_broadcaster_ptr = (void*)(((uintptr_t)tx_broadcaster) & ~1);
27105         CHECK_ACCESS(tx_broadcaster_ptr);
27106         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
27107         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
27108                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27109                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
27110         }
27111         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
27112         CHECK_ACCESS(logger_ptr);
27113         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
27114         if (logger_conv.free == LDKLogger_JCalls_free) {
27115                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27116                 LDKLogger_JCalls_cloned(&logger_conv);
27117         }
27118         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
27119         CHECK_ACCESS(keys_manager_ptr);
27120         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
27121         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
27122                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27123                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
27124         }
27125         LDKUserConfig config_conv;
27126         config_conv.inner = (void*)(config & (~1));
27127         config_conv.is_owned = (config & 1) || (config == 0);
27128         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_conv);
27129         config_conv = UserConfig_clone(&config_conv);
27130         LDKChainParameters params_conv;
27131         params_conv.inner = (void*)(params & (~1));
27132         params_conv.is_owned = (params & 1) || (params == 0);
27133         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
27134         params_conv = ChainParameters_clone(&params_conv);
27135         LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, params_conv);
27136         uint32_t ret_ref = 0;
27137         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27138         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27139         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27140         ret_ref = (uintptr_t)ret_var.inner;
27141         if (ret_var.is_owned) {
27142                 ret_ref |= 1;
27143         }
27144         return ret_ref;
27145 }
27146
27147 uint32_t  __attribute__((export_name("TS_ChannelManager_get_current_default_configuration"))) TS_ChannelManager_get_current_default_configuration(uint32_t this_arg) {
27148         LDKChannelManager this_arg_conv;
27149         this_arg_conv.inner = (void*)(this_arg & (~1));
27150         this_arg_conv.is_owned = false;
27151         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27152         LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
27153         uint32_t ret_ref = 0;
27154         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27155         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27156         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27157         ret_ref = (uintptr_t)ret_var.inner;
27158         if (ret_var.is_owned) {
27159                 ret_ref |= 1;
27160         }
27161         return ret_ref;
27162 }
27163
27164 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) {
27165         LDKChannelManager this_arg_conv;
27166         this_arg_conv.inner = (void*)(this_arg & (~1));
27167         this_arg_conv.is_owned = false;
27168         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27169         LDKPublicKey their_network_key_ref;
27170         CHECK(their_network_key->arr_len == 33);
27171         memcpy(their_network_key_ref.compressed_form, their_network_key->elems, 33); FREE(their_network_key);
27172         LDKUserConfig override_config_conv;
27173         override_config_conv.inner = (void*)(override_config & (~1));
27174         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
27175         CHECK_INNER_FIELD_ACCESS_OR_NULL(override_config_conv);
27176         override_config_conv = UserConfig_clone(&override_config_conv);
27177         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
27178         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_channel_id, override_config_conv);
27179         return (uint32_t)ret_conv;
27180 }
27181
27182 uint32_tArray  __attribute__((export_name("TS_ChannelManager_list_channels"))) TS_ChannelManager_list_channels(uint32_t this_arg) {
27183         LDKChannelManager this_arg_conv;
27184         this_arg_conv.inner = (void*)(this_arg & (~1));
27185         this_arg_conv.is_owned = false;
27186         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27187         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
27188         uint32_tArray ret_arr = NULL;
27189         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
27190         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 8);
27191         for (size_t q = 0; q < ret_var.datalen; q++) {
27192                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
27193                 uint32_t ret_conv_16_ref = 0;
27194                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27195                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27196                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
27197                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
27198                 if (ret_conv_16_var.is_owned) {
27199                         ret_conv_16_ref |= 1;
27200                 }
27201                 ret_arr_ptr[q] = ret_conv_16_ref;
27202         }
27203         
27204         FREE(ret_var.data);
27205         return ret_arr;
27206 }
27207
27208 uint32_tArray  __attribute__((export_name("TS_ChannelManager_list_usable_channels"))) TS_ChannelManager_list_usable_channels(uint32_t this_arg) {
27209         LDKChannelManager this_arg_conv;
27210         this_arg_conv.inner = (void*)(this_arg & (~1));
27211         this_arg_conv.is_owned = false;
27212         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27213         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
27214         uint32_tArray ret_arr = NULL;
27215         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
27216         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 8);
27217         for (size_t q = 0; q < ret_var.datalen; q++) {
27218                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
27219                 uint32_t ret_conv_16_ref = 0;
27220                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27221                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27222                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
27223                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
27224                 if (ret_conv_16_var.is_owned) {
27225                         ret_conv_16_ref |= 1;
27226                 }
27227                 ret_arr_ptr[q] = ret_conv_16_ref;
27228         }
27229         
27230         FREE(ret_var.data);
27231         return ret_arr;
27232 }
27233
27234 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) {
27235         LDKChannelManager this_arg_conv;
27236         this_arg_conv.inner = (void*)(this_arg & (~1));
27237         this_arg_conv.is_owned = false;
27238         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27239         unsigned char channel_id_arr[32];
27240         CHECK(channel_id->arr_len == 32);
27241         memcpy(channel_id_arr, channel_id->elems, 32); FREE(channel_id);
27242         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
27243         LDKPublicKey counterparty_node_id_ref;
27244         CHECK(counterparty_node_id->arr_len == 33);
27245         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
27246         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
27247         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
27248         return (uint32_t)ret_conv;
27249 }
27250
27251 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) {
27252         LDKChannelManager this_arg_conv;
27253         this_arg_conv.inner = (void*)(this_arg & (~1));
27254         this_arg_conv.is_owned = false;
27255         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27256         unsigned char channel_id_arr[32];
27257         CHECK(channel_id->arr_len == 32);
27258         memcpy(channel_id_arr, channel_id->elems, 32); FREE(channel_id);
27259         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
27260         LDKPublicKey counterparty_node_id_ref;
27261         CHECK(counterparty_node_id->arr_len == 33);
27262         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
27263         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
27264         *ret_conv = ChannelManager_close_channel_with_target_feerate(&this_arg_conv, channel_id_ref, counterparty_node_id_ref, target_feerate_sats_per_1000_weight);
27265         return (uint32_t)ret_conv;
27266 }
27267
27268 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) {
27269         LDKChannelManager this_arg_conv;
27270         this_arg_conv.inner = (void*)(this_arg & (~1));
27271         this_arg_conv.is_owned = false;
27272         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27273         unsigned char channel_id_arr[32];
27274         CHECK(channel_id->arr_len == 32);
27275         memcpy(channel_id_arr, channel_id->elems, 32); FREE(channel_id);
27276         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
27277         LDKPublicKey counterparty_node_id_ref;
27278         CHECK(counterparty_node_id->arr_len == 33);
27279         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
27280         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
27281         *ret_conv = ChannelManager_force_close_broadcasting_latest_txn(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
27282         return (uint32_t)ret_conv;
27283 }
27284
27285 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) {
27286         LDKChannelManager this_arg_conv;
27287         this_arg_conv.inner = (void*)(this_arg & (~1));
27288         this_arg_conv.is_owned = false;
27289         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27290         unsigned char channel_id_arr[32];
27291         CHECK(channel_id->arr_len == 32);
27292         memcpy(channel_id_arr, channel_id->elems, 32); FREE(channel_id);
27293         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
27294         LDKPublicKey counterparty_node_id_ref;
27295         CHECK(counterparty_node_id->arr_len == 33);
27296         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
27297         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
27298         *ret_conv = ChannelManager_force_close_without_broadcasting_txn(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
27299         return (uint32_t)ret_conv;
27300 }
27301
27302 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) {
27303         LDKChannelManager this_arg_conv;
27304         this_arg_conv.inner = (void*)(this_arg & (~1));
27305         this_arg_conv.is_owned = false;
27306         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27307         ChannelManager_force_close_all_channels_broadcasting_latest_txn(&this_arg_conv);
27308 }
27309
27310 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) {
27311         LDKChannelManager this_arg_conv;
27312         this_arg_conv.inner = (void*)(this_arg & (~1));
27313         this_arg_conv.is_owned = false;
27314         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27315         ChannelManager_force_close_all_channels_without_broadcasting_txn(&this_arg_conv);
27316 }
27317
27318 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) {
27319         LDKChannelManager this_arg_conv;
27320         this_arg_conv.inner = (void*)(this_arg & (~1));
27321         this_arg_conv.is_owned = false;
27322         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27323         LDKRoute route_conv;
27324         route_conv.inner = (void*)(route & (~1));
27325         route_conv.is_owned = false;
27326         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
27327         LDKThirtyTwoBytes payment_hash_ref;
27328         CHECK(payment_hash->arr_len == 32);
27329         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
27330         LDKThirtyTwoBytes payment_secret_ref;
27331         CHECK(payment_secret->arr_len == 32);
27332         memcpy(payment_secret_ref.data, payment_secret->elems, 32); FREE(payment_secret);
27333         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
27334         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
27335         return (uint32_t)ret_conv;
27336 }
27337
27338 uint32_t  __attribute__((export_name("TS_ChannelManager_retry_payment"))) TS_ChannelManager_retry_payment(uint32_t this_arg, uint32_t route, int8_tArray payment_id) {
27339         LDKChannelManager this_arg_conv;
27340         this_arg_conv.inner = (void*)(this_arg & (~1));
27341         this_arg_conv.is_owned = false;
27342         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27343         LDKRoute route_conv;
27344         route_conv.inner = (void*)(route & (~1));
27345         route_conv.is_owned = false;
27346         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
27347         LDKThirtyTwoBytes payment_id_ref;
27348         CHECK(payment_id->arr_len == 32);
27349         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
27350         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
27351         *ret_conv = ChannelManager_retry_payment(&this_arg_conv, &route_conv, payment_id_ref);
27352         return (uint32_t)ret_conv;
27353 }
27354
27355 void  __attribute__((export_name("TS_ChannelManager_abandon_payment"))) TS_ChannelManager_abandon_payment(uint32_t this_arg, int8_tArray payment_id) {
27356         LDKChannelManager this_arg_conv;
27357         this_arg_conv.inner = (void*)(this_arg & (~1));
27358         this_arg_conv.is_owned = false;
27359         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27360         LDKThirtyTwoBytes payment_id_ref;
27361         CHECK(payment_id->arr_len == 32);
27362         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
27363         ChannelManager_abandon_payment(&this_arg_conv, payment_id_ref);
27364 }
27365
27366 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) {
27367         LDKChannelManager this_arg_conv;
27368         this_arg_conv.inner = (void*)(this_arg & (~1));
27369         this_arg_conv.is_owned = false;
27370         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27371         LDKRoute route_conv;
27372         route_conv.inner = (void*)(route & (~1));
27373         route_conv.is_owned = false;
27374         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
27375         LDKThirtyTwoBytes payment_preimage_ref;
27376         CHECK(payment_preimage->arr_len == 32);
27377         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
27378         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
27379         *ret_conv = ChannelManager_send_spontaneous_payment(&this_arg_conv, &route_conv, payment_preimage_ref);
27380         return (uint32_t)ret_conv;
27381 }
27382
27383 uint32_t  __attribute__((export_name("TS_ChannelManager_send_probe"))) TS_ChannelManager_send_probe(uint32_t this_arg, uint32_tArray hops) {
27384         LDKChannelManager this_arg_conv;
27385         this_arg_conv.inner = (void*)(this_arg & (~1));
27386         this_arg_conv.is_owned = false;
27387         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27388         LDKCVec_RouteHopZ hops_constr;
27389         hops_constr.datalen = hops->arr_len;
27390         if (hops_constr.datalen > 0)
27391                 hops_constr.data = MALLOC(hops_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
27392         else
27393                 hops_constr.data = NULL;
27394         uint32_t* hops_vals = hops->elems;
27395         for (size_t k = 0; k < hops_constr.datalen; k++) {
27396                 uint32_t hops_conv_10 = hops_vals[k];
27397                 LDKRouteHop hops_conv_10_conv;
27398                 hops_conv_10_conv.inner = (void*)(hops_conv_10 & (~1));
27399                 hops_conv_10_conv.is_owned = (hops_conv_10 & 1) || (hops_conv_10 == 0);
27400                 CHECK_INNER_FIELD_ACCESS_OR_NULL(hops_conv_10_conv);
27401                 hops_conv_10_conv = RouteHop_clone(&hops_conv_10_conv);
27402                 hops_constr.data[k] = hops_conv_10_conv;
27403         }
27404         FREE(hops);
27405         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
27406         *ret_conv = ChannelManager_send_probe(&this_arg_conv, hops_constr);
27407         return (uint32_t)ret_conv;
27408 }
27409
27410 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) {
27411         LDKChannelManager this_arg_conv;
27412         this_arg_conv.inner = (void*)(this_arg & (~1));
27413         this_arg_conv.is_owned = false;
27414         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27415         unsigned char temporary_channel_id_arr[32];
27416         CHECK(temporary_channel_id->arr_len == 32);
27417         memcpy(temporary_channel_id_arr, temporary_channel_id->elems, 32); FREE(temporary_channel_id);
27418         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
27419         LDKPublicKey counterparty_node_id_ref;
27420         CHECK(counterparty_node_id->arr_len == 33);
27421         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
27422         LDKTransaction funding_transaction_ref;
27423         funding_transaction_ref.datalen = funding_transaction->arr_len;
27424         funding_transaction_ref.data = MALLOC(funding_transaction_ref.datalen, "LDKTransaction Bytes");
27425         memcpy(funding_transaction_ref.data, funding_transaction->elems, funding_transaction_ref.datalen); FREE(funding_transaction);
27426         funding_transaction_ref.data_is_owned = true;
27427         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
27428         *ret_conv = ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, counterparty_node_id_ref, funding_transaction_ref);
27429         return (uint32_t)ret_conv;
27430 }
27431
27432 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) {
27433         LDKChannelManager this_arg_conv;
27434         this_arg_conv.inner = (void*)(this_arg & (~1));
27435         this_arg_conv.is_owned = false;
27436         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27437         LDKThreeBytes rgb_ref;
27438         CHECK(rgb->arr_len == 3);
27439         memcpy(rgb_ref.data, rgb->elems, 3); FREE(rgb);
27440         LDKThirtyTwoBytes alias_ref;
27441         CHECK(alias->arr_len == 32);
27442         memcpy(alias_ref.data, alias->elems, 32); FREE(alias);
27443         LDKCVec_NetAddressZ addresses_constr;
27444         addresses_constr.datalen = addresses->arr_len;
27445         if (addresses_constr.datalen > 0)
27446                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
27447         else
27448                 addresses_constr.data = NULL;
27449         uint32_t* addresses_vals = addresses->elems;
27450         for (size_t m = 0; m < addresses_constr.datalen; m++) {
27451                 uint32_t addresses_conv_12 = addresses_vals[m];
27452                 void* addresses_conv_12_ptr = (void*)(((uintptr_t)addresses_conv_12) & ~1);
27453                 CHECK_ACCESS(addresses_conv_12_ptr);
27454                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(addresses_conv_12_ptr);
27455                 addresses_constr.data[m] = addresses_conv_12_conv;
27456         }
27457         FREE(addresses);
27458         ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
27459 }
27460
27461 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) {
27462         LDKChannelManager this_arg_conv;
27463         this_arg_conv.inner = (void*)(this_arg & (~1));
27464         this_arg_conv.is_owned = false;
27465         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27466         LDKPublicKey counterparty_node_id_ref;
27467         CHECK(counterparty_node_id->arr_len == 33);
27468         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
27469         LDKCVec_ThirtyTwoBytesZ channel_ids_constr;
27470         channel_ids_constr.datalen = channel_ids->arr_len;
27471         if (channel_ids_constr.datalen > 0)
27472                 channel_ids_constr.data = MALLOC(channel_ids_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_ThirtyTwoBytesZ Elements");
27473         else
27474                 channel_ids_constr.data = NULL;
27475         int8_tArray* channel_ids_vals = (void*) channel_ids->elems;
27476         for (size_t m = 0; m < channel_ids_constr.datalen; m++) {
27477                 int8_tArray channel_ids_conv_12 = channel_ids_vals[m];
27478                 LDKThirtyTwoBytes channel_ids_conv_12_ref;
27479                 CHECK(channel_ids_conv_12->arr_len == 32);
27480                 memcpy(channel_ids_conv_12_ref.data, channel_ids_conv_12->elems, 32); FREE(channel_ids_conv_12);
27481                 channel_ids_constr.data[m] = channel_ids_conv_12_ref;
27482         }
27483         FREE(channel_ids);
27484         LDKChannelConfig config_conv;
27485         config_conv.inner = (void*)(config & (~1));
27486         config_conv.is_owned = false;
27487         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_conv);
27488         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
27489         *ret_conv = ChannelManager_update_channel_config(&this_arg_conv, counterparty_node_id_ref, channel_ids_constr, &config_conv);
27490         return (uint32_t)ret_conv;
27491 }
27492
27493 void  __attribute__((export_name("TS_ChannelManager_process_pending_htlc_forwards"))) TS_ChannelManager_process_pending_htlc_forwards(uint32_t this_arg) {
27494         LDKChannelManager this_arg_conv;
27495         this_arg_conv.inner = (void*)(this_arg & (~1));
27496         this_arg_conv.is_owned = false;
27497         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27498         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
27499 }
27500
27501 void  __attribute__((export_name("TS_ChannelManager_timer_tick_occurred"))) TS_ChannelManager_timer_tick_occurred(uint32_t this_arg) {
27502         LDKChannelManager this_arg_conv;
27503         this_arg_conv.inner = (void*)(this_arg & (~1));
27504         this_arg_conv.is_owned = false;
27505         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27506         ChannelManager_timer_tick_occurred(&this_arg_conv);
27507 }
27508
27509 void  __attribute__((export_name("TS_ChannelManager_fail_htlc_backwards"))) TS_ChannelManager_fail_htlc_backwards(uint32_t this_arg, int8_tArray payment_hash) {
27510         LDKChannelManager this_arg_conv;
27511         this_arg_conv.inner = (void*)(this_arg & (~1));
27512         this_arg_conv.is_owned = false;
27513         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27514         unsigned char payment_hash_arr[32];
27515         CHECK(payment_hash->arr_len == 32);
27516         memcpy(payment_hash_arr, payment_hash->elems, 32); FREE(payment_hash);
27517         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
27518         ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref);
27519 }
27520
27521 void  __attribute__((export_name("TS_ChannelManager_claim_funds"))) TS_ChannelManager_claim_funds(uint32_t this_arg, int8_tArray payment_preimage) {
27522         LDKChannelManager this_arg_conv;
27523         this_arg_conv.inner = (void*)(this_arg & (~1));
27524         this_arg_conv.is_owned = false;
27525         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27526         LDKThirtyTwoBytes payment_preimage_ref;
27527         CHECK(payment_preimage->arr_len == 32);
27528         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
27529         ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref);
27530 }
27531
27532 int8_tArray  __attribute__((export_name("TS_ChannelManager_get_our_node_id"))) TS_ChannelManager_get_our_node_id(uint32_t this_arg) {
27533         LDKChannelManager this_arg_conv;
27534         this_arg_conv.inner = (void*)(this_arg & (~1));
27535         this_arg_conv.is_owned = false;
27536         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27537         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
27538         memcpy(ret_arr->elems, ChannelManager_get_our_node_id(&this_arg_conv).compressed_form, 33);
27539         return ret_arr;
27540 }
27541
27542 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) {
27543         LDKChannelManager this_arg_conv;
27544         this_arg_conv.inner = (void*)(this_arg & (~1));
27545         this_arg_conv.is_owned = false;
27546         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27547         unsigned char temporary_channel_id_arr[32];
27548         CHECK(temporary_channel_id->arr_len == 32);
27549         memcpy(temporary_channel_id_arr, temporary_channel_id->elems, 32); FREE(temporary_channel_id);
27550         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
27551         LDKPublicKey counterparty_node_id_ref;
27552         CHECK(counterparty_node_id->arr_len == 33);
27553         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
27554         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
27555         *ret_conv = ChannelManager_accept_inbound_channel(&this_arg_conv, temporary_channel_id_ref, counterparty_node_id_ref, user_channel_id);
27556         return (uint32_t)ret_conv;
27557 }
27558
27559 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) {
27560         LDKChannelManager this_arg_conv;
27561         this_arg_conv.inner = (void*)(this_arg & (~1));
27562         this_arg_conv.is_owned = false;
27563         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27564         unsigned char temporary_channel_id_arr[32];
27565         CHECK(temporary_channel_id->arr_len == 32);
27566         memcpy(temporary_channel_id_arr, temporary_channel_id->elems, 32); FREE(temporary_channel_id);
27567         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
27568         LDKPublicKey counterparty_node_id_ref;
27569         CHECK(counterparty_node_id->arr_len == 33);
27570         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
27571         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
27572         *ret_conv = ChannelManager_accept_inbound_channel_from_trusted_peer_0conf(&this_arg_conv, temporary_channel_id_ref, counterparty_node_id_ref, user_channel_id);
27573         return (uint32_t)ret_conv;
27574 }
27575
27576 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) {
27577         LDKChannelManager this_arg_conv;
27578         this_arg_conv.inner = (void*)(this_arg & (~1));
27579         this_arg_conv.is_owned = false;
27580         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27581         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
27582         CHECK_ACCESS(min_value_msat_ptr);
27583         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
27584         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
27585         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
27586         *ret_conv = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
27587         return (uint32_t)ret_conv;
27588 }
27589
27590 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) {
27591         LDKChannelManager this_arg_conv;
27592         this_arg_conv.inner = (void*)(this_arg & (~1));
27593         this_arg_conv.is_owned = false;
27594         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27595         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
27596         CHECK_ACCESS(min_value_msat_ptr);
27597         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
27598         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
27599         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
27600         *ret_conv = ChannelManager_create_inbound_payment_legacy(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
27601         return (uint32_t)ret_conv;
27602 }
27603
27604 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) {
27605         LDKChannelManager this_arg_conv;
27606         this_arg_conv.inner = (void*)(this_arg & (~1));
27607         this_arg_conv.is_owned = false;
27608         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27609         LDKThirtyTwoBytes payment_hash_ref;
27610         CHECK(payment_hash->arr_len == 32);
27611         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
27612         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
27613         CHECK_ACCESS(min_value_msat_ptr);
27614         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
27615         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
27616         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
27617         *ret_conv = ChannelManager_create_inbound_payment_for_hash(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
27618         return (uint32_t)ret_conv;
27619 }
27620
27621 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) {
27622         LDKChannelManager this_arg_conv;
27623         this_arg_conv.inner = (void*)(this_arg & (~1));
27624         this_arg_conv.is_owned = false;
27625         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27626         LDKThirtyTwoBytes payment_hash_ref;
27627         CHECK(payment_hash->arr_len == 32);
27628         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
27629         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
27630         CHECK_ACCESS(min_value_msat_ptr);
27631         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
27632         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
27633         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
27634         *ret_conv = ChannelManager_create_inbound_payment_for_hash_legacy(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
27635         return (uint32_t)ret_conv;
27636 }
27637
27638 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) {
27639         LDKChannelManager this_arg_conv;
27640         this_arg_conv.inner = (void*)(this_arg & (~1));
27641         this_arg_conv.is_owned = false;
27642         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27643         LDKThirtyTwoBytes payment_hash_ref;
27644         CHECK(payment_hash->arr_len == 32);
27645         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
27646         LDKThirtyTwoBytes payment_secret_ref;
27647         CHECK(payment_secret->arr_len == 32);
27648         memcpy(payment_secret_ref.data, payment_secret->elems, 32); FREE(payment_secret);
27649         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
27650         *ret_conv = ChannelManager_get_payment_preimage(&this_arg_conv, payment_hash_ref, payment_secret_ref);
27651         return (uint32_t)ret_conv;
27652 }
27653
27654 int64_t  __attribute__((export_name("TS_ChannelManager_get_phantom_scid"))) TS_ChannelManager_get_phantom_scid(uint32_t this_arg) {
27655         LDKChannelManager this_arg_conv;
27656         this_arg_conv.inner = (void*)(this_arg & (~1));
27657         this_arg_conv.is_owned = false;
27658         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27659         int64_t ret_conv = ChannelManager_get_phantom_scid(&this_arg_conv);
27660         return ret_conv;
27661 }
27662
27663 uint32_t  __attribute__((export_name("TS_ChannelManager_get_phantom_route_hints"))) TS_ChannelManager_get_phantom_route_hints(uint32_t this_arg) {
27664         LDKChannelManager this_arg_conv;
27665         this_arg_conv.inner = (void*)(this_arg & (~1));
27666         this_arg_conv.is_owned = false;
27667         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27668         LDKPhantomRouteHints ret_var = ChannelManager_get_phantom_route_hints(&this_arg_conv);
27669         uint32_t ret_ref = 0;
27670         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27671         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27672         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27673         ret_ref = (uintptr_t)ret_var.inner;
27674         if (ret_var.is_owned) {
27675                 ret_ref |= 1;
27676         }
27677         return ret_ref;
27678 }
27679
27680 uint32_t  __attribute__((export_name("TS_ChannelManager_as_MessageSendEventsProvider"))) TS_ChannelManager_as_MessageSendEventsProvider(uint32_t this_arg) {
27681         LDKChannelManager this_arg_conv;
27682         this_arg_conv.inner = (void*)(this_arg & (~1));
27683         this_arg_conv.is_owned = false;
27684         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27685         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
27686         *ret_ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
27687         return (uint32_t)ret_ret;
27688 }
27689
27690 uint32_t  __attribute__((export_name("TS_ChannelManager_as_EventsProvider"))) TS_ChannelManager_as_EventsProvider(uint32_t this_arg) {
27691         LDKChannelManager this_arg_conv;
27692         this_arg_conv.inner = (void*)(this_arg & (~1));
27693         this_arg_conv.is_owned = false;
27694         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27695         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
27696         *ret_ret = ChannelManager_as_EventsProvider(&this_arg_conv);
27697         return (uint32_t)ret_ret;
27698 }
27699
27700 uint32_t  __attribute__((export_name("TS_ChannelManager_as_Listen"))) TS_ChannelManager_as_Listen(uint32_t this_arg) {
27701         LDKChannelManager this_arg_conv;
27702         this_arg_conv.inner = (void*)(this_arg & (~1));
27703         this_arg_conv.is_owned = false;
27704         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27705         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
27706         *ret_ret = ChannelManager_as_Listen(&this_arg_conv);
27707         return (uint32_t)ret_ret;
27708 }
27709
27710 uint32_t  __attribute__((export_name("TS_ChannelManager_as_Confirm"))) TS_ChannelManager_as_Confirm(uint32_t this_arg) {
27711         LDKChannelManager this_arg_conv;
27712         this_arg_conv.inner = (void*)(this_arg & (~1));
27713         this_arg_conv.is_owned = false;
27714         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27715         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
27716         *ret_ret = ChannelManager_as_Confirm(&this_arg_conv);
27717         return (uint32_t)ret_ret;
27718 }
27719
27720 void  __attribute__((export_name("TS_ChannelManager_await_persistable_update"))) TS_ChannelManager_await_persistable_update(uint32_t this_arg) {
27721         LDKChannelManager this_arg_conv;
27722         this_arg_conv.inner = (void*)(this_arg & (~1));
27723         this_arg_conv.is_owned = false;
27724         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27725         ChannelManager_await_persistable_update(&this_arg_conv);
27726 }
27727
27728 uint32_t  __attribute__((export_name("TS_ChannelManager_current_best_block"))) TS_ChannelManager_current_best_block(uint32_t this_arg) {
27729         LDKChannelManager this_arg_conv;
27730         this_arg_conv.inner = (void*)(this_arg & (~1));
27731         this_arg_conv.is_owned = false;
27732         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27733         LDKBestBlock ret_var = ChannelManager_current_best_block(&this_arg_conv);
27734         uint32_t ret_ref = 0;
27735         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27736         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27737         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27738         ret_ref = (uintptr_t)ret_var.inner;
27739         if (ret_var.is_owned) {
27740                 ret_ref |= 1;
27741         }
27742         return ret_ref;
27743 }
27744
27745 uint32_t  __attribute__((export_name("TS_ChannelManager_as_ChannelMessageHandler"))) TS_ChannelManager_as_ChannelMessageHandler(uint32_t this_arg) {
27746         LDKChannelManager this_arg_conv;
27747         this_arg_conv.inner = (void*)(this_arg & (~1));
27748         this_arg_conv.is_owned = false;
27749         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27750         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
27751         *ret_ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
27752         return (uint32_t)ret_ret;
27753 }
27754
27755 int8_tArray  __attribute__((export_name("TS_CounterpartyForwardingInfo_write"))) TS_CounterpartyForwardingInfo_write(uint32_t obj) {
27756         LDKCounterpartyForwardingInfo obj_conv;
27757         obj_conv.inner = (void*)(obj & (~1));
27758         obj_conv.is_owned = false;
27759         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27760         LDKCVec_u8Z ret_var = CounterpartyForwardingInfo_write(&obj_conv);
27761         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
27762         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27763         CVec_u8Z_free(ret_var);
27764         return ret_arr;
27765 }
27766
27767 uint32_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_read"))) TS_CounterpartyForwardingInfo_read(int8_tArray ser) {
27768         LDKu8slice ser_ref;
27769         ser_ref.datalen = ser->arr_len;
27770         ser_ref.data = ser->elems;
27771         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
27772         *ret_conv = CounterpartyForwardingInfo_read(ser_ref);
27773         FREE(ser);
27774         return (uint32_t)ret_conv;
27775 }
27776
27777 int8_tArray  __attribute__((export_name("TS_ChannelCounterparty_write"))) TS_ChannelCounterparty_write(uint32_t obj) {
27778         LDKChannelCounterparty obj_conv;
27779         obj_conv.inner = (void*)(obj & (~1));
27780         obj_conv.is_owned = false;
27781         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27782         LDKCVec_u8Z ret_var = ChannelCounterparty_write(&obj_conv);
27783         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
27784         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27785         CVec_u8Z_free(ret_var);
27786         return ret_arr;
27787 }
27788
27789 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_read"))) TS_ChannelCounterparty_read(int8_tArray ser) {
27790         LDKu8slice ser_ref;
27791         ser_ref.datalen = ser->arr_len;
27792         ser_ref.data = ser->elems;
27793         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
27794         *ret_conv = ChannelCounterparty_read(ser_ref);
27795         FREE(ser);
27796         return (uint32_t)ret_conv;
27797 }
27798
27799 int8_tArray  __attribute__((export_name("TS_ChannelDetails_write"))) TS_ChannelDetails_write(uint32_t obj) {
27800         LDKChannelDetails obj_conv;
27801         obj_conv.inner = (void*)(obj & (~1));
27802         obj_conv.is_owned = false;
27803         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27804         LDKCVec_u8Z ret_var = ChannelDetails_write(&obj_conv);
27805         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
27806         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27807         CVec_u8Z_free(ret_var);
27808         return ret_arr;
27809 }
27810
27811 uint32_t  __attribute__((export_name("TS_ChannelDetails_read"))) TS_ChannelDetails_read(int8_tArray ser) {
27812         LDKu8slice ser_ref;
27813         ser_ref.datalen = ser->arr_len;
27814         ser_ref.data = ser->elems;
27815         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
27816         *ret_conv = ChannelDetails_read(ser_ref);
27817         FREE(ser);
27818         return (uint32_t)ret_conv;
27819 }
27820
27821 int8_tArray  __attribute__((export_name("TS_PhantomRouteHints_write"))) TS_PhantomRouteHints_write(uint32_t obj) {
27822         LDKPhantomRouteHints obj_conv;
27823         obj_conv.inner = (void*)(obj & (~1));
27824         obj_conv.is_owned = false;
27825         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27826         LDKCVec_u8Z ret_var = PhantomRouteHints_write(&obj_conv);
27827         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
27828         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27829         CVec_u8Z_free(ret_var);
27830         return ret_arr;
27831 }
27832
27833 uint32_t  __attribute__((export_name("TS_PhantomRouteHints_read"))) TS_PhantomRouteHints_read(int8_tArray ser) {
27834         LDKu8slice ser_ref;
27835         ser_ref.datalen = ser->arr_len;
27836         ser_ref.data = ser->elems;
27837         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
27838         *ret_conv = PhantomRouteHints_read(ser_ref);
27839         FREE(ser);
27840         return (uint32_t)ret_conv;
27841 }
27842
27843 int8_tArray  __attribute__((export_name("TS_ChannelManager_write"))) TS_ChannelManager_write(uint32_t obj) {
27844         LDKChannelManager obj_conv;
27845         obj_conv.inner = (void*)(obj & (~1));
27846         obj_conv.is_owned = false;
27847         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27848         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
27849         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
27850         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27851         CVec_u8Z_free(ret_var);
27852         return ret_arr;
27853 }
27854
27855 void  __attribute__((export_name("TS_ChannelManagerReadArgs_free"))) TS_ChannelManagerReadArgs_free(uint32_t this_obj) {
27856         LDKChannelManagerReadArgs this_obj_conv;
27857         this_obj_conv.inner = (void*)(this_obj & (~1));
27858         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27859         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27860         ChannelManagerReadArgs_free(this_obj_conv);
27861 }
27862
27863 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_keys_manager"))) TS_ChannelManagerReadArgs_get_keys_manager(uint32_t this_ptr) {
27864         LDKChannelManagerReadArgs this_ptr_conv;
27865         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27866         this_ptr_conv.is_owned = false;
27867         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27868         // WARNING: This object doesn't live past this scope, needs clone!
27869         uint32_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv)) | 1;
27870         return ret_ret;
27871 }
27872
27873 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_keys_manager"))) TS_ChannelManagerReadArgs_set_keys_manager(uint32_t this_ptr, uint32_t val) {
27874         LDKChannelManagerReadArgs this_ptr_conv;
27875         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27876         this_ptr_conv.is_owned = false;
27877         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27878         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
27879         CHECK_ACCESS(val_ptr);
27880         LDKKeysInterface val_conv = *(LDKKeysInterface*)(val_ptr);
27881         if (val_conv.free == LDKKeysInterface_JCalls_free) {
27882                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27883                 LDKKeysInterface_JCalls_cloned(&val_conv);
27884         }
27885         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
27886 }
27887
27888 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_fee_estimator"))) TS_ChannelManagerReadArgs_get_fee_estimator(uint32_t this_ptr) {
27889         LDKChannelManagerReadArgs this_ptr_conv;
27890         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27891         this_ptr_conv.is_owned = false;
27892         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27893         // WARNING: This object doesn't live past this scope, needs clone!
27894         uint32_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv)) | 1;
27895         return ret_ret;
27896 }
27897
27898 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_fee_estimator"))) TS_ChannelManagerReadArgs_set_fee_estimator(uint32_t this_ptr, uint32_t val) {
27899         LDKChannelManagerReadArgs this_ptr_conv;
27900         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27901         this_ptr_conv.is_owned = false;
27902         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27903         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
27904         CHECK_ACCESS(val_ptr);
27905         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(val_ptr);
27906         if (val_conv.free == LDKFeeEstimator_JCalls_free) {
27907                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27908                 LDKFeeEstimator_JCalls_cloned(&val_conv);
27909         }
27910         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
27911 }
27912
27913 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_chain_monitor"))) TS_ChannelManagerReadArgs_get_chain_monitor(uint32_t this_ptr) {
27914         LDKChannelManagerReadArgs this_ptr_conv;
27915         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27916         this_ptr_conv.is_owned = false;
27917         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27918         // WARNING: This object doesn't live past this scope, needs clone!
27919         uint32_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv)) | 1;
27920         return ret_ret;
27921 }
27922
27923 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_chain_monitor"))) TS_ChannelManagerReadArgs_set_chain_monitor(uint32_t this_ptr, uint32_t val) {
27924         LDKChannelManagerReadArgs this_ptr_conv;
27925         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27926         this_ptr_conv.is_owned = false;
27927         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27928         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
27929         CHECK_ACCESS(val_ptr);
27930         LDKWatch val_conv = *(LDKWatch*)(val_ptr);
27931         if (val_conv.free == LDKWatch_JCalls_free) {
27932                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27933                 LDKWatch_JCalls_cloned(&val_conv);
27934         }
27935         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
27936 }
27937
27938 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_tx_broadcaster"))) TS_ChannelManagerReadArgs_get_tx_broadcaster(uint32_t this_ptr) {
27939         LDKChannelManagerReadArgs this_ptr_conv;
27940         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27941         this_ptr_conv.is_owned = false;
27942         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27943         // WARNING: This object doesn't live past this scope, needs clone!
27944         uint32_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv)) | 1;
27945         return ret_ret;
27946 }
27947
27948 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_tx_broadcaster"))) TS_ChannelManagerReadArgs_set_tx_broadcaster(uint32_t this_ptr, uint32_t val) {
27949         LDKChannelManagerReadArgs this_ptr_conv;
27950         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27951         this_ptr_conv.is_owned = false;
27952         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27953         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
27954         CHECK_ACCESS(val_ptr);
27955         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(val_ptr);
27956         if (val_conv.free == LDKBroadcasterInterface_JCalls_free) {
27957                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27958                 LDKBroadcasterInterface_JCalls_cloned(&val_conv);
27959         }
27960         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
27961 }
27962
27963 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_logger"))) TS_ChannelManagerReadArgs_get_logger(uint32_t this_ptr) {
27964         LDKChannelManagerReadArgs this_ptr_conv;
27965         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27966         this_ptr_conv.is_owned = false;
27967         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27968         // WARNING: This object doesn't live past this scope, needs clone!
27969         uint32_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_logger(&this_ptr_conv)) | 1;
27970         return ret_ret;
27971 }
27972
27973 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_logger"))) TS_ChannelManagerReadArgs_set_logger(uint32_t this_ptr, uint32_t val) {
27974         LDKChannelManagerReadArgs this_ptr_conv;
27975         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27976         this_ptr_conv.is_owned = false;
27977         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27978         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
27979         CHECK_ACCESS(val_ptr);
27980         LDKLogger val_conv = *(LDKLogger*)(val_ptr);
27981         if (val_conv.free == LDKLogger_JCalls_free) {
27982                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27983                 LDKLogger_JCalls_cloned(&val_conv);
27984         }
27985         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
27986 }
27987
27988 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_default_config"))) TS_ChannelManagerReadArgs_get_default_config(uint32_t this_ptr) {
27989         LDKChannelManagerReadArgs this_ptr_conv;
27990         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27991         this_ptr_conv.is_owned = false;
27992         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27993         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
27994         uint32_t ret_ref = 0;
27995         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27996         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27997         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27998         ret_ref = (uintptr_t)ret_var.inner;
27999         if (ret_var.is_owned) {
28000                 ret_ref |= 1;
28001         }
28002         return ret_ref;
28003 }
28004
28005 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_default_config"))) TS_ChannelManagerReadArgs_set_default_config(uint32_t this_ptr, uint32_t val) {
28006         LDKChannelManagerReadArgs this_ptr_conv;
28007         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28008         this_ptr_conv.is_owned = false;
28009         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28010         LDKUserConfig val_conv;
28011         val_conv.inner = (void*)(val & (~1));
28012         val_conv.is_owned = (val & 1) || (val == 0);
28013         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28014         val_conv = UserConfig_clone(&val_conv);
28015         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
28016 }
28017
28018 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) {
28019         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
28020         CHECK_ACCESS(keys_manager_ptr);
28021         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
28022         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
28023                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28024                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
28025         }
28026         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
28027         CHECK_ACCESS(fee_estimator_ptr);
28028         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
28029         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
28030                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28031                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
28032         }
28033         void* chain_monitor_ptr = (void*)(((uintptr_t)chain_monitor) & ~1);
28034         CHECK_ACCESS(chain_monitor_ptr);
28035         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
28036         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
28037                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28038                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
28039         }
28040         void* tx_broadcaster_ptr = (void*)(((uintptr_t)tx_broadcaster) & ~1);
28041         CHECK_ACCESS(tx_broadcaster_ptr);
28042         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
28043         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
28044                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28045                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
28046         }
28047         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
28048         CHECK_ACCESS(logger_ptr);
28049         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
28050         if (logger_conv.free == LDKLogger_JCalls_free) {
28051                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28052                 LDKLogger_JCalls_cloned(&logger_conv);
28053         }
28054         LDKUserConfig default_config_conv;
28055         default_config_conv.inner = (void*)(default_config & (~1));
28056         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
28057         CHECK_INNER_FIELD_ACCESS_OR_NULL(default_config_conv);
28058         default_config_conv = UserConfig_clone(&default_config_conv);
28059         LDKCVec_ChannelMonitorZ channel_monitors_constr;
28060         channel_monitors_constr.datalen = channel_monitors->arr_len;
28061         if (channel_monitors_constr.datalen > 0)
28062                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
28063         else
28064                 channel_monitors_constr.data = NULL;
28065         uint32_t* channel_monitors_vals = channel_monitors->elems;
28066         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
28067                 uint32_t channel_monitors_conv_16 = channel_monitors_vals[q];
28068                 LDKChannelMonitor channel_monitors_conv_16_conv;
28069                 channel_monitors_conv_16_conv.inner = (void*)(channel_monitors_conv_16 & (~1));
28070                 channel_monitors_conv_16_conv.is_owned = (channel_monitors_conv_16 & 1) || (channel_monitors_conv_16 == 0);
28071                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_monitors_conv_16_conv);
28072                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
28073         }
28074         FREE(channel_monitors);
28075         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);
28076         uint32_t ret_ref = 0;
28077         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28078         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28079         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28080         ret_ref = (uintptr_t)ret_var.inner;
28081         if (ret_var.is_owned) {
28082                 ret_ref |= 1;
28083         }
28084         return ret_ref;
28085 }
28086
28087 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_read"))) TS_C2Tuple_BlockHashChannelManagerZ_read(int8_tArray ser, uint32_t arg) {
28088         LDKu8slice ser_ref;
28089         ser_ref.datalen = ser->arr_len;
28090         ser_ref.data = ser->elems;
28091         LDKChannelManagerReadArgs arg_conv;
28092         arg_conv.inner = (void*)(arg & (~1));
28093         arg_conv.is_owned = (arg & 1) || (arg == 0);
28094         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28095         // WARNING: we need a move here but no clone is available for LDKChannelManagerReadArgs
28096         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
28097         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
28098         FREE(ser);
28099         return (uint32_t)ret_conv;
28100 }
28101
28102 void  __attribute__((export_name("TS_ExpandedKey_free"))) TS_ExpandedKey_free(uint32_t this_obj) {
28103         LDKExpandedKey this_obj_conv;
28104         this_obj_conv.inner = (void*)(this_obj & (~1));
28105         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28106         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28107         ExpandedKey_free(this_obj_conv);
28108 }
28109
28110 uint32_t  __attribute__((export_name("TS_ExpandedKey_new"))) TS_ExpandedKey_new(int8_tArray key_material) {
28111         unsigned char key_material_arr[32];
28112         CHECK(key_material->arr_len == 32);
28113         memcpy(key_material_arr, key_material->elems, 32); FREE(key_material);
28114         unsigned char (*key_material_ref)[32] = &key_material_arr;
28115         LDKExpandedKey ret_var = ExpandedKey_new(key_material_ref);
28116         uint32_t ret_ref = 0;
28117         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28118         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28119         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28120         ret_ref = (uintptr_t)ret_var.inner;
28121         if (ret_var.is_owned) {
28122                 ret_ref |= 1;
28123         }
28124         return ret_ref;
28125 }
28126
28127 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) {
28128         LDKExpandedKey keys_conv;
28129         keys_conv.inner = (void*)(keys & (~1));
28130         keys_conv.is_owned = false;
28131         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
28132         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
28133         CHECK_ACCESS(min_value_msat_ptr);
28134         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
28135         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
28136         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
28137         if (!(keys_manager & 1)) { CHECK_ACCESS(keys_manager_ptr); }
28138         LDKKeysInterface* keys_manager_conv = (LDKKeysInterface*)keys_manager_ptr;
28139         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
28140         *ret_conv = create(&keys_conv, min_value_msat_conv, invoice_expiry_delta_secs, keys_manager_conv, current_time);
28141         return (uint32_t)ret_conv;
28142 }
28143
28144 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) {
28145         LDKExpandedKey keys_conv;
28146         keys_conv.inner = (void*)(keys & (~1));
28147         keys_conv.is_owned = false;
28148         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
28149         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
28150         CHECK_ACCESS(min_value_msat_ptr);
28151         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
28152         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
28153         LDKThirtyTwoBytes payment_hash_ref;
28154         CHECK(payment_hash->arr_len == 32);
28155         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
28156         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
28157         *ret_conv = create_from_hash(&keys_conv, min_value_msat_conv, payment_hash_ref, invoice_expiry_delta_secs, current_time);
28158         return (uint32_t)ret_conv;
28159 }
28160
28161 void  __attribute__((export_name("TS_DecodeError_free"))) TS_DecodeError_free(uint32_t this_obj) {
28162         LDKDecodeError this_obj_conv;
28163         this_obj_conv.inner = (void*)(this_obj & (~1));
28164         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28165         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28166         DecodeError_free(this_obj_conv);
28167 }
28168
28169 static inline uintptr_t DecodeError_clone_ptr(LDKDecodeError *NONNULL_PTR arg) {
28170         LDKDecodeError ret_var = DecodeError_clone(arg);
28171 uint32_t ret_ref = 0;
28172 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28173 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28174 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28175 ret_ref = (uintptr_t)ret_var.inner;
28176 if (ret_var.is_owned) {
28177         ret_ref |= 1;
28178 }
28179         return ret_ref;
28180 }
28181 uint32_t  __attribute__((export_name("TS_DecodeError_clone_ptr"))) TS_DecodeError_clone_ptr(uint32_t arg) {
28182         LDKDecodeError arg_conv;
28183         arg_conv.inner = (void*)(arg & (~1));
28184         arg_conv.is_owned = false;
28185         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28186         uint32_t ret_conv = DecodeError_clone_ptr(&arg_conv);
28187         return ret_conv;
28188 }
28189
28190 uint32_t  __attribute__((export_name("TS_DecodeError_clone"))) TS_DecodeError_clone(uint32_t orig) {
28191         LDKDecodeError orig_conv;
28192         orig_conv.inner = (void*)(orig & (~1));
28193         orig_conv.is_owned = false;
28194         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28195         LDKDecodeError ret_var = DecodeError_clone(&orig_conv);
28196         uint32_t ret_ref = 0;
28197         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28198         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28199         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28200         ret_ref = (uintptr_t)ret_var.inner;
28201         if (ret_var.is_owned) {
28202                 ret_ref |= 1;
28203         }
28204         return ret_ref;
28205 }
28206
28207 void  __attribute__((export_name("TS_Init_free"))) TS_Init_free(uint32_t this_obj) {
28208         LDKInit this_obj_conv;
28209         this_obj_conv.inner = (void*)(this_obj & (~1));
28210         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28211         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28212         Init_free(this_obj_conv);
28213 }
28214
28215 uint32_t  __attribute__((export_name("TS_Init_get_features"))) TS_Init_get_features(uint32_t this_ptr) {
28216         LDKInit this_ptr_conv;
28217         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28218         this_ptr_conv.is_owned = false;
28219         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28220         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
28221         uint32_t ret_ref = 0;
28222         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28223         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28224         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28225         ret_ref = (uintptr_t)ret_var.inner;
28226         if (ret_var.is_owned) {
28227                 ret_ref |= 1;
28228         }
28229         return ret_ref;
28230 }
28231
28232 void  __attribute__((export_name("TS_Init_set_features"))) TS_Init_set_features(uint32_t this_ptr, uint32_t val) {
28233         LDKInit this_ptr_conv;
28234         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28235         this_ptr_conv.is_owned = false;
28236         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28237         LDKInitFeatures val_conv;
28238         val_conv.inner = (void*)(val & (~1));
28239         val_conv.is_owned = (val & 1) || (val == 0);
28240         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28241         val_conv = InitFeatures_clone(&val_conv);
28242         Init_set_features(&this_ptr_conv, val_conv);
28243 }
28244
28245 uint32_t  __attribute__((export_name("TS_Init_get_remote_network_address"))) TS_Init_get_remote_network_address(uint32_t this_ptr) {
28246         LDKInit this_ptr_conv;
28247         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28248         this_ptr_conv.is_owned = false;
28249         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28250         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
28251         *ret_copy = Init_get_remote_network_address(&this_ptr_conv);
28252         uint32_t ret_ref = (uintptr_t)ret_copy;
28253         return ret_ref;
28254 }
28255
28256 void  __attribute__((export_name("TS_Init_set_remote_network_address"))) TS_Init_set_remote_network_address(uint32_t this_ptr, uint32_t val) {
28257         LDKInit this_ptr_conv;
28258         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28259         this_ptr_conv.is_owned = false;
28260         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28261         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
28262         CHECK_ACCESS(val_ptr);
28263         LDKCOption_NetAddressZ val_conv = *(LDKCOption_NetAddressZ*)(val_ptr);
28264         val_conv = COption_NetAddressZ_clone((LDKCOption_NetAddressZ*)(((uintptr_t)val) & ~1));
28265         Init_set_remote_network_address(&this_ptr_conv, val_conv);
28266 }
28267
28268 uint32_t  __attribute__((export_name("TS_Init_new"))) TS_Init_new(uint32_t features_arg, uint32_t remote_network_address_arg) {
28269         LDKInitFeatures features_arg_conv;
28270         features_arg_conv.inner = (void*)(features_arg & (~1));
28271         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
28272         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
28273         features_arg_conv = InitFeatures_clone(&features_arg_conv);
28274         void* remote_network_address_arg_ptr = (void*)(((uintptr_t)remote_network_address_arg) & ~1);
28275         CHECK_ACCESS(remote_network_address_arg_ptr);
28276         LDKCOption_NetAddressZ remote_network_address_arg_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_arg_ptr);
28277         LDKInit ret_var = Init_new(features_arg_conv, remote_network_address_arg_conv);
28278         uint32_t ret_ref = 0;
28279         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28280         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28281         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28282         ret_ref = (uintptr_t)ret_var.inner;
28283         if (ret_var.is_owned) {
28284                 ret_ref |= 1;
28285         }
28286         return ret_ref;
28287 }
28288
28289 static inline uintptr_t Init_clone_ptr(LDKInit *NONNULL_PTR arg) {
28290         LDKInit ret_var = Init_clone(arg);
28291 uint32_t ret_ref = 0;
28292 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28293 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28294 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28295 ret_ref = (uintptr_t)ret_var.inner;
28296 if (ret_var.is_owned) {
28297         ret_ref |= 1;
28298 }
28299         return ret_ref;
28300 }
28301 uint32_t  __attribute__((export_name("TS_Init_clone_ptr"))) TS_Init_clone_ptr(uint32_t arg) {
28302         LDKInit arg_conv;
28303         arg_conv.inner = (void*)(arg & (~1));
28304         arg_conv.is_owned = false;
28305         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28306         uint32_t ret_conv = Init_clone_ptr(&arg_conv);
28307         return ret_conv;
28308 }
28309
28310 uint32_t  __attribute__((export_name("TS_Init_clone"))) TS_Init_clone(uint32_t orig) {
28311         LDKInit orig_conv;
28312         orig_conv.inner = (void*)(orig & (~1));
28313         orig_conv.is_owned = false;
28314         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28315         LDKInit ret_var = Init_clone(&orig_conv);
28316         uint32_t ret_ref = 0;
28317         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28318         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28319         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28320         ret_ref = (uintptr_t)ret_var.inner;
28321         if (ret_var.is_owned) {
28322                 ret_ref |= 1;
28323         }
28324         return ret_ref;
28325 }
28326
28327 void  __attribute__((export_name("TS_ErrorMessage_free"))) TS_ErrorMessage_free(uint32_t this_obj) {
28328         LDKErrorMessage this_obj_conv;
28329         this_obj_conv.inner = (void*)(this_obj & (~1));
28330         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28331         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28332         ErrorMessage_free(this_obj_conv);
28333 }
28334
28335 int8_tArray  __attribute__((export_name("TS_ErrorMessage_get_channel_id"))) TS_ErrorMessage_get_channel_id(uint32_t this_ptr) {
28336         LDKErrorMessage this_ptr_conv;
28337         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28338         this_ptr_conv.is_owned = false;
28339         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28340         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28341         memcpy(ret_arr->elems, *ErrorMessage_get_channel_id(&this_ptr_conv), 32);
28342         return ret_arr;
28343 }
28344
28345 void  __attribute__((export_name("TS_ErrorMessage_set_channel_id"))) TS_ErrorMessage_set_channel_id(uint32_t this_ptr, int8_tArray val) {
28346         LDKErrorMessage this_ptr_conv;
28347         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28348         this_ptr_conv.is_owned = false;
28349         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28350         LDKThirtyTwoBytes val_ref;
28351         CHECK(val->arr_len == 32);
28352         memcpy(val_ref.data, val->elems, 32); FREE(val);
28353         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
28354 }
28355
28356 jstring  __attribute__((export_name("TS_ErrorMessage_get_data"))) TS_ErrorMessage_get_data(uint32_t this_ptr) {
28357         LDKErrorMessage this_ptr_conv;
28358         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28359         this_ptr_conv.is_owned = false;
28360         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28361         LDKStr ret_str = ErrorMessage_get_data(&this_ptr_conv);
28362         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
28363         Str_free(ret_str);
28364         return ret_conv;
28365 }
28366
28367 void  __attribute__((export_name("TS_ErrorMessage_set_data"))) TS_ErrorMessage_set_data(uint32_t this_ptr, jstring val) {
28368         LDKErrorMessage this_ptr_conv;
28369         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28370         this_ptr_conv.is_owned = false;
28371         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28372         LDKStr val_conv = str_ref_to_owned_c(val);
28373         ErrorMessage_set_data(&this_ptr_conv, val_conv);
28374 }
28375
28376 uint32_t  __attribute__((export_name("TS_ErrorMessage_new"))) TS_ErrorMessage_new(int8_tArray channel_id_arg, jstring data_arg) {
28377         LDKThirtyTwoBytes channel_id_arg_ref;
28378         CHECK(channel_id_arg->arr_len == 32);
28379         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
28380         LDKStr data_arg_conv = str_ref_to_owned_c(data_arg);
28381         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
28382         uint32_t ret_ref = 0;
28383         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28384         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28385         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28386         ret_ref = (uintptr_t)ret_var.inner;
28387         if (ret_var.is_owned) {
28388                 ret_ref |= 1;
28389         }
28390         return ret_ref;
28391 }
28392
28393 static inline uintptr_t ErrorMessage_clone_ptr(LDKErrorMessage *NONNULL_PTR arg) {
28394         LDKErrorMessage ret_var = ErrorMessage_clone(arg);
28395 uint32_t ret_ref = 0;
28396 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28397 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28398 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28399 ret_ref = (uintptr_t)ret_var.inner;
28400 if (ret_var.is_owned) {
28401         ret_ref |= 1;
28402 }
28403         return ret_ref;
28404 }
28405 uint32_t  __attribute__((export_name("TS_ErrorMessage_clone_ptr"))) TS_ErrorMessage_clone_ptr(uint32_t arg) {
28406         LDKErrorMessage arg_conv;
28407         arg_conv.inner = (void*)(arg & (~1));
28408         arg_conv.is_owned = false;
28409         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28410         uint32_t ret_conv = ErrorMessage_clone_ptr(&arg_conv);
28411         return ret_conv;
28412 }
28413
28414 uint32_t  __attribute__((export_name("TS_ErrorMessage_clone"))) TS_ErrorMessage_clone(uint32_t orig) {
28415         LDKErrorMessage orig_conv;
28416         orig_conv.inner = (void*)(orig & (~1));
28417         orig_conv.is_owned = false;
28418         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28419         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
28420         uint32_t ret_ref = 0;
28421         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28422         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28423         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28424         ret_ref = (uintptr_t)ret_var.inner;
28425         if (ret_var.is_owned) {
28426                 ret_ref |= 1;
28427         }
28428         return ret_ref;
28429 }
28430
28431 void  __attribute__((export_name("TS_WarningMessage_free"))) TS_WarningMessage_free(uint32_t this_obj) {
28432         LDKWarningMessage this_obj_conv;
28433         this_obj_conv.inner = (void*)(this_obj & (~1));
28434         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28435         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28436         WarningMessage_free(this_obj_conv);
28437 }
28438
28439 int8_tArray  __attribute__((export_name("TS_WarningMessage_get_channel_id"))) TS_WarningMessage_get_channel_id(uint32_t this_ptr) {
28440         LDKWarningMessage this_ptr_conv;
28441         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28442         this_ptr_conv.is_owned = false;
28443         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28444         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28445         memcpy(ret_arr->elems, *WarningMessage_get_channel_id(&this_ptr_conv), 32);
28446         return ret_arr;
28447 }
28448
28449 void  __attribute__((export_name("TS_WarningMessage_set_channel_id"))) TS_WarningMessage_set_channel_id(uint32_t this_ptr, int8_tArray val) {
28450         LDKWarningMessage this_ptr_conv;
28451         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28452         this_ptr_conv.is_owned = false;
28453         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28454         LDKThirtyTwoBytes val_ref;
28455         CHECK(val->arr_len == 32);
28456         memcpy(val_ref.data, val->elems, 32); FREE(val);
28457         WarningMessage_set_channel_id(&this_ptr_conv, val_ref);
28458 }
28459
28460 jstring  __attribute__((export_name("TS_WarningMessage_get_data"))) TS_WarningMessage_get_data(uint32_t this_ptr) {
28461         LDKWarningMessage this_ptr_conv;
28462         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28463         this_ptr_conv.is_owned = false;
28464         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28465         LDKStr ret_str = WarningMessage_get_data(&this_ptr_conv);
28466         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
28467         Str_free(ret_str);
28468         return ret_conv;
28469 }
28470
28471 void  __attribute__((export_name("TS_WarningMessage_set_data"))) TS_WarningMessage_set_data(uint32_t this_ptr, jstring val) {
28472         LDKWarningMessage this_ptr_conv;
28473         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28474         this_ptr_conv.is_owned = false;
28475         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28476         LDKStr val_conv = str_ref_to_owned_c(val);
28477         WarningMessage_set_data(&this_ptr_conv, val_conv);
28478 }
28479
28480 uint32_t  __attribute__((export_name("TS_WarningMessage_new"))) TS_WarningMessage_new(int8_tArray channel_id_arg, jstring data_arg) {
28481         LDKThirtyTwoBytes channel_id_arg_ref;
28482         CHECK(channel_id_arg->arr_len == 32);
28483         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
28484         LDKStr data_arg_conv = str_ref_to_owned_c(data_arg);
28485         LDKWarningMessage ret_var = WarningMessage_new(channel_id_arg_ref, data_arg_conv);
28486         uint32_t ret_ref = 0;
28487         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28488         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28489         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28490         ret_ref = (uintptr_t)ret_var.inner;
28491         if (ret_var.is_owned) {
28492                 ret_ref |= 1;
28493         }
28494         return ret_ref;
28495 }
28496
28497 static inline uintptr_t WarningMessage_clone_ptr(LDKWarningMessage *NONNULL_PTR arg) {
28498         LDKWarningMessage ret_var = WarningMessage_clone(arg);
28499 uint32_t ret_ref = 0;
28500 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28501 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28502 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28503 ret_ref = (uintptr_t)ret_var.inner;
28504 if (ret_var.is_owned) {
28505         ret_ref |= 1;
28506 }
28507         return ret_ref;
28508 }
28509 uint32_t  __attribute__((export_name("TS_WarningMessage_clone_ptr"))) TS_WarningMessage_clone_ptr(uint32_t arg) {
28510         LDKWarningMessage arg_conv;
28511         arg_conv.inner = (void*)(arg & (~1));
28512         arg_conv.is_owned = false;
28513         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28514         uint32_t ret_conv = WarningMessage_clone_ptr(&arg_conv);
28515         return ret_conv;
28516 }
28517
28518 uint32_t  __attribute__((export_name("TS_WarningMessage_clone"))) TS_WarningMessage_clone(uint32_t orig) {
28519         LDKWarningMessage orig_conv;
28520         orig_conv.inner = (void*)(orig & (~1));
28521         orig_conv.is_owned = false;
28522         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28523         LDKWarningMessage ret_var = WarningMessage_clone(&orig_conv);
28524         uint32_t ret_ref = 0;
28525         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28526         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28527         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28528         ret_ref = (uintptr_t)ret_var.inner;
28529         if (ret_var.is_owned) {
28530                 ret_ref |= 1;
28531         }
28532         return ret_ref;
28533 }
28534
28535 void  __attribute__((export_name("TS_Ping_free"))) TS_Ping_free(uint32_t this_obj) {
28536         LDKPing this_obj_conv;
28537         this_obj_conv.inner = (void*)(this_obj & (~1));
28538         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28539         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28540         Ping_free(this_obj_conv);
28541 }
28542
28543 int16_t  __attribute__((export_name("TS_Ping_get_ponglen"))) TS_Ping_get_ponglen(uint32_t this_ptr) {
28544         LDKPing this_ptr_conv;
28545         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28546         this_ptr_conv.is_owned = false;
28547         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28548         int16_t ret_conv = Ping_get_ponglen(&this_ptr_conv);
28549         return ret_conv;
28550 }
28551
28552 void  __attribute__((export_name("TS_Ping_set_ponglen"))) TS_Ping_set_ponglen(uint32_t this_ptr, int16_t val) {
28553         LDKPing this_ptr_conv;
28554         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28555         this_ptr_conv.is_owned = false;
28556         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28557         Ping_set_ponglen(&this_ptr_conv, val);
28558 }
28559
28560 int16_t  __attribute__((export_name("TS_Ping_get_byteslen"))) TS_Ping_get_byteslen(uint32_t this_ptr) {
28561         LDKPing this_ptr_conv;
28562         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28563         this_ptr_conv.is_owned = false;
28564         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28565         int16_t ret_conv = Ping_get_byteslen(&this_ptr_conv);
28566         return ret_conv;
28567 }
28568
28569 void  __attribute__((export_name("TS_Ping_set_byteslen"))) TS_Ping_set_byteslen(uint32_t this_ptr, int16_t val) {
28570         LDKPing this_ptr_conv;
28571         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28572         this_ptr_conv.is_owned = false;
28573         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28574         Ping_set_byteslen(&this_ptr_conv, val);
28575 }
28576
28577 uint32_t  __attribute__((export_name("TS_Ping_new"))) TS_Ping_new(int16_t ponglen_arg, int16_t byteslen_arg) {
28578         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
28579         uint32_t ret_ref = 0;
28580         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28581         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28582         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28583         ret_ref = (uintptr_t)ret_var.inner;
28584         if (ret_var.is_owned) {
28585                 ret_ref |= 1;
28586         }
28587         return ret_ref;
28588 }
28589
28590 static inline uintptr_t Ping_clone_ptr(LDKPing *NONNULL_PTR arg) {
28591         LDKPing ret_var = Ping_clone(arg);
28592 uint32_t ret_ref = 0;
28593 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28594 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28595 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28596 ret_ref = (uintptr_t)ret_var.inner;
28597 if (ret_var.is_owned) {
28598         ret_ref |= 1;
28599 }
28600         return ret_ref;
28601 }
28602 uint32_t  __attribute__((export_name("TS_Ping_clone_ptr"))) TS_Ping_clone_ptr(uint32_t arg) {
28603         LDKPing arg_conv;
28604         arg_conv.inner = (void*)(arg & (~1));
28605         arg_conv.is_owned = false;
28606         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28607         uint32_t ret_conv = Ping_clone_ptr(&arg_conv);
28608         return ret_conv;
28609 }
28610
28611 uint32_t  __attribute__((export_name("TS_Ping_clone"))) TS_Ping_clone(uint32_t orig) {
28612         LDKPing orig_conv;
28613         orig_conv.inner = (void*)(orig & (~1));
28614         orig_conv.is_owned = false;
28615         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28616         LDKPing ret_var = Ping_clone(&orig_conv);
28617         uint32_t ret_ref = 0;
28618         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28619         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28620         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28621         ret_ref = (uintptr_t)ret_var.inner;
28622         if (ret_var.is_owned) {
28623                 ret_ref |= 1;
28624         }
28625         return ret_ref;
28626 }
28627
28628 void  __attribute__((export_name("TS_Pong_free"))) TS_Pong_free(uint32_t this_obj) {
28629         LDKPong this_obj_conv;
28630         this_obj_conv.inner = (void*)(this_obj & (~1));
28631         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28632         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28633         Pong_free(this_obj_conv);
28634 }
28635
28636 int16_t  __attribute__((export_name("TS_Pong_get_byteslen"))) TS_Pong_get_byteslen(uint32_t this_ptr) {
28637         LDKPong this_ptr_conv;
28638         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28639         this_ptr_conv.is_owned = false;
28640         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28641         int16_t ret_conv = Pong_get_byteslen(&this_ptr_conv);
28642         return ret_conv;
28643 }
28644
28645 void  __attribute__((export_name("TS_Pong_set_byteslen"))) TS_Pong_set_byteslen(uint32_t this_ptr, int16_t val) {
28646         LDKPong this_ptr_conv;
28647         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28648         this_ptr_conv.is_owned = false;
28649         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28650         Pong_set_byteslen(&this_ptr_conv, val);
28651 }
28652
28653 uint32_t  __attribute__((export_name("TS_Pong_new"))) TS_Pong_new(int16_t byteslen_arg) {
28654         LDKPong ret_var = Pong_new(byteslen_arg);
28655         uint32_t ret_ref = 0;
28656         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28657         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28658         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28659         ret_ref = (uintptr_t)ret_var.inner;
28660         if (ret_var.is_owned) {
28661                 ret_ref |= 1;
28662         }
28663         return ret_ref;
28664 }
28665
28666 static inline uintptr_t Pong_clone_ptr(LDKPong *NONNULL_PTR arg) {
28667         LDKPong ret_var = Pong_clone(arg);
28668 uint32_t ret_ref = 0;
28669 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28670 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28671 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28672 ret_ref = (uintptr_t)ret_var.inner;
28673 if (ret_var.is_owned) {
28674         ret_ref |= 1;
28675 }
28676         return ret_ref;
28677 }
28678 uint32_t  __attribute__((export_name("TS_Pong_clone_ptr"))) TS_Pong_clone_ptr(uint32_t arg) {
28679         LDKPong arg_conv;
28680         arg_conv.inner = (void*)(arg & (~1));
28681         arg_conv.is_owned = false;
28682         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28683         uint32_t ret_conv = Pong_clone_ptr(&arg_conv);
28684         return ret_conv;
28685 }
28686
28687 uint32_t  __attribute__((export_name("TS_Pong_clone"))) TS_Pong_clone(uint32_t orig) {
28688         LDKPong orig_conv;
28689         orig_conv.inner = (void*)(orig & (~1));
28690         orig_conv.is_owned = false;
28691         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28692         LDKPong ret_var = Pong_clone(&orig_conv);
28693         uint32_t ret_ref = 0;
28694         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28695         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28696         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28697         ret_ref = (uintptr_t)ret_var.inner;
28698         if (ret_var.is_owned) {
28699                 ret_ref |= 1;
28700         }
28701         return ret_ref;
28702 }
28703
28704 void  __attribute__((export_name("TS_OpenChannel_free"))) TS_OpenChannel_free(uint32_t this_obj) {
28705         LDKOpenChannel this_obj_conv;
28706         this_obj_conv.inner = (void*)(this_obj & (~1));
28707         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28708         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28709         OpenChannel_free(this_obj_conv);
28710 }
28711
28712 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_chain_hash"))) TS_OpenChannel_get_chain_hash(uint32_t this_ptr) {
28713         LDKOpenChannel this_ptr_conv;
28714         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28715         this_ptr_conv.is_owned = false;
28716         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28717         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28718         memcpy(ret_arr->elems, *OpenChannel_get_chain_hash(&this_ptr_conv), 32);
28719         return ret_arr;
28720 }
28721
28722 void  __attribute__((export_name("TS_OpenChannel_set_chain_hash"))) TS_OpenChannel_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
28723         LDKOpenChannel this_ptr_conv;
28724         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28725         this_ptr_conv.is_owned = false;
28726         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28727         LDKThirtyTwoBytes val_ref;
28728         CHECK(val->arr_len == 32);
28729         memcpy(val_ref.data, val->elems, 32); FREE(val);
28730         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
28731 }
28732
28733 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_temporary_channel_id"))) TS_OpenChannel_get_temporary_channel_id(uint32_t this_ptr) {
28734         LDKOpenChannel this_ptr_conv;
28735         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28736         this_ptr_conv.is_owned = false;
28737         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28738         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28739         memcpy(ret_arr->elems, *OpenChannel_get_temporary_channel_id(&this_ptr_conv), 32);
28740         return ret_arr;
28741 }
28742
28743 void  __attribute__((export_name("TS_OpenChannel_set_temporary_channel_id"))) TS_OpenChannel_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
28744         LDKOpenChannel this_ptr_conv;
28745         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28746         this_ptr_conv.is_owned = false;
28747         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28748         LDKThirtyTwoBytes val_ref;
28749         CHECK(val->arr_len == 32);
28750         memcpy(val_ref.data, val->elems, 32); FREE(val);
28751         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
28752 }
28753
28754 int64_t  __attribute__((export_name("TS_OpenChannel_get_funding_satoshis"))) TS_OpenChannel_get_funding_satoshis(uint32_t this_ptr) {
28755         LDKOpenChannel this_ptr_conv;
28756         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28757         this_ptr_conv.is_owned = false;
28758         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28759         int64_t ret_conv = OpenChannel_get_funding_satoshis(&this_ptr_conv);
28760         return ret_conv;
28761 }
28762
28763 void  __attribute__((export_name("TS_OpenChannel_set_funding_satoshis"))) TS_OpenChannel_set_funding_satoshis(uint32_t this_ptr, int64_t val) {
28764         LDKOpenChannel this_ptr_conv;
28765         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28766         this_ptr_conv.is_owned = false;
28767         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28768         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
28769 }
28770
28771 int64_t  __attribute__((export_name("TS_OpenChannel_get_push_msat"))) TS_OpenChannel_get_push_msat(uint32_t this_ptr) {
28772         LDKOpenChannel this_ptr_conv;
28773         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28774         this_ptr_conv.is_owned = false;
28775         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28776         int64_t ret_conv = OpenChannel_get_push_msat(&this_ptr_conv);
28777         return ret_conv;
28778 }
28779
28780 void  __attribute__((export_name("TS_OpenChannel_set_push_msat"))) TS_OpenChannel_set_push_msat(uint32_t this_ptr, int64_t val) {
28781         LDKOpenChannel this_ptr_conv;
28782         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28783         this_ptr_conv.is_owned = false;
28784         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28785         OpenChannel_set_push_msat(&this_ptr_conv, val);
28786 }
28787
28788 int64_t  __attribute__((export_name("TS_OpenChannel_get_dust_limit_satoshis"))) TS_OpenChannel_get_dust_limit_satoshis(uint32_t this_ptr) {
28789         LDKOpenChannel this_ptr_conv;
28790         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28791         this_ptr_conv.is_owned = false;
28792         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28793         int64_t ret_conv = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
28794         return ret_conv;
28795 }
28796
28797 void  __attribute__((export_name("TS_OpenChannel_set_dust_limit_satoshis"))) TS_OpenChannel_set_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
28798         LDKOpenChannel this_ptr_conv;
28799         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28800         this_ptr_conv.is_owned = false;
28801         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28802         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
28803 }
28804
28805 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) {
28806         LDKOpenChannel this_ptr_conv;
28807         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28808         this_ptr_conv.is_owned = false;
28809         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28810         int64_t ret_conv = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
28811         return ret_conv;
28812 }
28813
28814 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) {
28815         LDKOpenChannel this_ptr_conv;
28816         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28817         this_ptr_conv.is_owned = false;
28818         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28819         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
28820 }
28821
28822 int64_t  __attribute__((export_name("TS_OpenChannel_get_channel_reserve_satoshis"))) TS_OpenChannel_get_channel_reserve_satoshis(uint32_t this_ptr) {
28823         LDKOpenChannel this_ptr_conv;
28824         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28825         this_ptr_conv.is_owned = false;
28826         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28827         int64_t ret_conv = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
28828         return ret_conv;
28829 }
28830
28831 void  __attribute__((export_name("TS_OpenChannel_set_channel_reserve_satoshis"))) TS_OpenChannel_set_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
28832         LDKOpenChannel this_ptr_conv;
28833         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28834         this_ptr_conv.is_owned = false;
28835         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28836         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
28837 }
28838
28839 int64_t  __attribute__((export_name("TS_OpenChannel_get_htlc_minimum_msat"))) TS_OpenChannel_get_htlc_minimum_msat(uint32_t this_ptr) {
28840         LDKOpenChannel this_ptr_conv;
28841         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28842         this_ptr_conv.is_owned = false;
28843         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28844         int64_t ret_conv = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
28845         return ret_conv;
28846 }
28847
28848 void  __attribute__((export_name("TS_OpenChannel_set_htlc_minimum_msat"))) TS_OpenChannel_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
28849         LDKOpenChannel this_ptr_conv;
28850         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28851         this_ptr_conv.is_owned = false;
28852         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28853         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
28854 }
28855
28856 int32_t  __attribute__((export_name("TS_OpenChannel_get_feerate_per_kw"))) TS_OpenChannel_get_feerate_per_kw(uint32_t this_ptr) {
28857         LDKOpenChannel this_ptr_conv;
28858         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28859         this_ptr_conv.is_owned = false;
28860         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28861         int32_t ret_conv = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
28862         return ret_conv;
28863 }
28864
28865 void  __attribute__((export_name("TS_OpenChannel_set_feerate_per_kw"))) TS_OpenChannel_set_feerate_per_kw(uint32_t this_ptr, int32_t val) {
28866         LDKOpenChannel this_ptr_conv;
28867         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28868         this_ptr_conv.is_owned = false;
28869         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28870         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
28871 }
28872
28873 int16_t  __attribute__((export_name("TS_OpenChannel_get_to_self_delay"))) TS_OpenChannel_get_to_self_delay(uint32_t this_ptr) {
28874         LDKOpenChannel this_ptr_conv;
28875         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28876         this_ptr_conv.is_owned = false;
28877         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28878         int16_t ret_conv = OpenChannel_get_to_self_delay(&this_ptr_conv);
28879         return ret_conv;
28880 }
28881
28882 void  __attribute__((export_name("TS_OpenChannel_set_to_self_delay"))) TS_OpenChannel_set_to_self_delay(uint32_t this_ptr, int16_t val) {
28883         LDKOpenChannel this_ptr_conv;
28884         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28885         this_ptr_conv.is_owned = false;
28886         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28887         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
28888 }
28889
28890 int16_t  __attribute__((export_name("TS_OpenChannel_get_max_accepted_htlcs"))) TS_OpenChannel_get_max_accepted_htlcs(uint32_t this_ptr) {
28891         LDKOpenChannel this_ptr_conv;
28892         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28893         this_ptr_conv.is_owned = false;
28894         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28895         int16_t ret_conv = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
28896         return ret_conv;
28897 }
28898
28899 void  __attribute__((export_name("TS_OpenChannel_set_max_accepted_htlcs"))) TS_OpenChannel_set_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
28900         LDKOpenChannel this_ptr_conv;
28901         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28902         this_ptr_conv.is_owned = false;
28903         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28904         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
28905 }
28906
28907 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_funding_pubkey"))) TS_OpenChannel_get_funding_pubkey(uint32_t this_ptr) {
28908         LDKOpenChannel this_ptr_conv;
28909         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28910         this_ptr_conv.is_owned = false;
28911         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28912         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
28913         memcpy(ret_arr->elems, OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
28914         return ret_arr;
28915 }
28916
28917 void  __attribute__((export_name("TS_OpenChannel_set_funding_pubkey"))) TS_OpenChannel_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
28918         LDKOpenChannel this_ptr_conv;
28919         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28920         this_ptr_conv.is_owned = false;
28921         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28922         LDKPublicKey val_ref;
28923         CHECK(val->arr_len == 33);
28924         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
28925         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
28926 }
28927
28928 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_revocation_basepoint"))) TS_OpenChannel_get_revocation_basepoint(uint32_t this_ptr) {
28929         LDKOpenChannel this_ptr_conv;
28930         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28931         this_ptr_conv.is_owned = false;
28932         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28933         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
28934         memcpy(ret_arr->elems, OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
28935         return ret_arr;
28936 }
28937
28938 void  __attribute__((export_name("TS_OpenChannel_set_revocation_basepoint"))) TS_OpenChannel_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
28939         LDKOpenChannel this_ptr_conv;
28940         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28941         this_ptr_conv.is_owned = false;
28942         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28943         LDKPublicKey val_ref;
28944         CHECK(val->arr_len == 33);
28945         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
28946         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
28947 }
28948
28949 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_payment_point"))) TS_OpenChannel_get_payment_point(uint32_t this_ptr) {
28950         LDKOpenChannel this_ptr_conv;
28951         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28952         this_ptr_conv.is_owned = false;
28953         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28954         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
28955         memcpy(ret_arr->elems, OpenChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
28956         return ret_arr;
28957 }
28958
28959 void  __attribute__((export_name("TS_OpenChannel_set_payment_point"))) TS_OpenChannel_set_payment_point(uint32_t this_ptr, int8_tArray val) {
28960         LDKOpenChannel this_ptr_conv;
28961         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28962         this_ptr_conv.is_owned = false;
28963         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28964         LDKPublicKey val_ref;
28965         CHECK(val->arr_len == 33);
28966         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
28967         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
28968 }
28969
28970 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_delayed_payment_basepoint"))) TS_OpenChannel_get_delayed_payment_basepoint(uint32_t this_ptr) {
28971         LDKOpenChannel this_ptr_conv;
28972         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28973         this_ptr_conv.is_owned = false;
28974         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28975         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
28976         memcpy(ret_arr->elems, OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
28977         return ret_arr;
28978 }
28979
28980 void  __attribute__((export_name("TS_OpenChannel_set_delayed_payment_basepoint"))) TS_OpenChannel_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
28981         LDKOpenChannel this_ptr_conv;
28982         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28983         this_ptr_conv.is_owned = false;
28984         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28985         LDKPublicKey val_ref;
28986         CHECK(val->arr_len == 33);
28987         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
28988         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
28989 }
28990
28991 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_htlc_basepoint"))) TS_OpenChannel_get_htlc_basepoint(uint32_t this_ptr) {
28992         LDKOpenChannel this_ptr_conv;
28993         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28994         this_ptr_conv.is_owned = false;
28995         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28996         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
28997         memcpy(ret_arr->elems, OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
28998         return ret_arr;
28999 }
29000
29001 void  __attribute__((export_name("TS_OpenChannel_set_htlc_basepoint"))) TS_OpenChannel_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
29002         LDKOpenChannel this_ptr_conv;
29003         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29004         this_ptr_conv.is_owned = false;
29005         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29006         LDKPublicKey val_ref;
29007         CHECK(val->arr_len == 33);
29008         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29009         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
29010 }
29011
29012 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_first_per_commitment_point"))) TS_OpenChannel_get_first_per_commitment_point(uint32_t this_ptr) {
29013         LDKOpenChannel this_ptr_conv;
29014         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29015         this_ptr_conv.is_owned = false;
29016         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29017         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29018         memcpy(ret_arr->elems, OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
29019         return ret_arr;
29020 }
29021
29022 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) {
29023         LDKOpenChannel this_ptr_conv;
29024         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29025         this_ptr_conv.is_owned = false;
29026         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29027         LDKPublicKey val_ref;
29028         CHECK(val->arr_len == 33);
29029         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29030         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
29031 }
29032
29033 int8_t  __attribute__((export_name("TS_OpenChannel_get_channel_flags"))) TS_OpenChannel_get_channel_flags(uint32_t this_ptr) {
29034         LDKOpenChannel this_ptr_conv;
29035         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29036         this_ptr_conv.is_owned = false;
29037         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29038         int8_t ret_conv = OpenChannel_get_channel_flags(&this_ptr_conv);
29039         return ret_conv;
29040 }
29041
29042 void  __attribute__((export_name("TS_OpenChannel_set_channel_flags"))) TS_OpenChannel_set_channel_flags(uint32_t this_ptr, int8_t val) {
29043         LDKOpenChannel this_ptr_conv;
29044         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29045         this_ptr_conv.is_owned = false;
29046         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29047         OpenChannel_set_channel_flags(&this_ptr_conv, val);
29048 }
29049
29050 uint32_t  __attribute__((export_name("TS_OpenChannel_get_channel_type"))) TS_OpenChannel_get_channel_type(uint32_t this_ptr) {
29051         LDKOpenChannel this_ptr_conv;
29052         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29053         this_ptr_conv.is_owned = false;
29054         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29055         LDKChannelTypeFeatures ret_var = OpenChannel_get_channel_type(&this_ptr_conv);
29056         uint32_t ret_ref = 0;
29057         if ((uintptr_t)ret_var.inner > 4096) {
29058                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29059                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29060         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29061                 ret_ref = (uintptr_t)ret_var.inner;
29062                 if (ret_var.is_owned) {
29063                         ret_ref |= 1;
29064                 }
29065         }
29066         return ret_ref;
29067 }
29068
29069 void  __attribute__((export_name("TS_OpenChannel_set_channel_type"))) TS_OpenChannel_set_channel_type(uint32_t this_ptr, uint32_t val) {
29070         LDKOpenChannel this_ptr_conv;
29071         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29072         this_ptr_conv.is_owned = false;
29073         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29074         LDKChannelTypeFeatures val_conv;
29075         val_conv.inner = (void*)(val & (~1));
29076         val_conv.is_owned = (val & 1) || (val == 0);
29077         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29078         val_conv = ChannelTypeFeatures_clone(&val_conv);
29079         OpenChannel_set_channel_type(&this_ptr_conv, val_conv);
29080 }
29081
29082 static inline uintptr_t OpenChannel_clone_ptr(LDKOpenChannel *NONNULL_PTR arg) {
29083         LDKOpenChannel ret_var = OpenChannel_clone(arg);
29084 uint32_t ret_ref = 0;
29085 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29086 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29087 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29088 ret_ref = (uintptr_t)ret_var.inner;
29089 if (ret_var.is_owned) {
29090         ret_ref |= 1;
29091 }
29092         return ret_ref;
29093 }
29094 uint32_t  __attribute__((export_name("TS_OpenChannel_clone_ptr"))) TS_OpenChannel_clone_ptr(uint32_t arg) {
29095         LDKOpenChannel arg_conv;
29096         arg_conv.inner = (void*)(arg & (~1));
29097         arg_conv.is_owned = false;
29098         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29099         uint32_t ret_conv = OpenChannel_clone_ptr(&arg_conv);
29100         return ret_conv;
29101 }
29102
29103 uint32_t  __attribute__((export_name("TS_OpenChannel_clone"))) TS_OpenChannel_clone(uint32_t orig) {
29104         LDKOpenChannel orig_conv;
29105         orig_conv.inner = (void*)(orig & (~1));
29106         orig_conv.is_owned = false;
29107         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29108         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
29109         uint32_t ret_ref = 0;
29110         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29111         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29112         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29113         ret_ref = (uintptr_t)ret_var.inner;
29114         if (ret_var.is_owned) {
29115                 ret_ref |= 1;
29116         }
29117         return ret_ref;
29118 }
29119
29120 void  __attribute__((export_name("TS_AcceptChannel_free"))) TS_AcceptChannel_free(uint32_t this_obj) {
29121         LDKAcceptChannel this_obj_conv;
29122         this_obj_conv.inner = (void*)(this_obj & (~1));
29123         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29124         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29125         AcceptChannel_free(this_obj_conv);
29126 }
29127
29128 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_temporary_channel_id"))) TS_AcceptChannel_get_temporary_channel_id(uint32_t this_ptr) {
29129         LDKAcceptChannel this_ptr_conv;
29130         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29131         this_ptr_conv.is_owned = false;
29132         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29133         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29134         memcpy(ret_arr->elems, *AcceptChannel_get_temporary_channel_id(&this_ptr_conv), 32);
29135         return ret_arr;
29136 }
29137
29138 void  __attribute__((export_name("TS_AcceptChannel_set_temporary_channel_id"))) TS_AcceptChannel_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
29139         LDKAcceptChannel this_ptr_conv;
29140         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29141         this_ptr_conv.is_owned = false;
29142         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29143         LDKThirtyTwoBytes val_ref;
29144         CHECK(val->arr_len == 32);
29145         memcpy(val_ref.data, val->elems, 32); FREE(val);
29146         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
29147 }
29148
29149 int64_t  __attribute__((export_name("TS_AcceptChannel_get_dust_limit_satoshis"))) TS_AcceptChannel_get_dust_limit_satoshis(uint32_t this_ptr) {
29150         LDKAcceptChannel this_ptr_conv;
29151         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29152         this_ptr_conv.is_owned = false;
29153         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29154         int64_t ret_conv = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
29155         return ret_conv;
29156 }
29157
29158 void  __attribute__((export_name("TS_AcceptChannel_set_dust_limit_satoshis"))) TS_AcceptChannel_set_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
29159         LDKAcceptChannel this_ptr_conv;
29160         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29161         this_ptr_conv.is_owned = false;
29162         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29163         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
29164 }
29165
29166 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) {
29167         LDKAcceptChannel this_ptr_conv;
29168         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29169         this_ptr_conv.is_owned = false;
29170         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29171         int64_t ret_conv = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
29172         return ret_conv;
29173 }
29174
29175 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) {
29176         LDKAcceptChannel this_ptr_conv;
29177         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29178         this_ptr_conv.is_owned = false;
29179         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29180         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
29181 }
29182
29183 int64_t  __attribute__((export_name("TS_AcceptChannel_get_channel_reserve_satoshis"))) TS_AcceptChannel_get_channel_reserve_satoshis(uint32_t this_ptr) {
29184         LDKAcceptChannel this_ptr_conv;
29185         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29186         this_ptr_conv.is_owned = false;
29187         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29188         int64_t ret_conv = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
29189         return ret_conv;
29190 }
29191
29192 void  __attribute__((export_name("TS_AcceptChannel_set_channel_reserve_satoshis"))) TS_AcceptChannel_set_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
29193         LDKAcceptChannel this_ptr_conv;
29194         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29195         this_ptr_conv.is_owned = false;
29196         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29197         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
29198 }
29199
29200 int64_t  __attribute__((export_name("TS_AcceptChannel_get_htlc_minimum_msat"))) TS_AcceptChannel_get_htlc_minimum_msat(uint32_t this_ptr) {
29201         LDKAcceptChannel this_ptr_conv;
29202         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29203         this_ptr_conv.is_owned = false;
29204         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29205         int64_t ret_conv = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
29206         return ret_conv;
29207 }
29208
29209 void  __attribute__((export_name("TS_AcceptChannel_set_htlc_minimum_msat"))) TS_AcceptChannel_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
29210         LDKAcceptChannel this_ptr_conv;
29211         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29212         this_ptr_conv.is_owned = false;
29213         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29214         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
29215 }
29216
29217 int32_t  __attribute__((export_name("TS_AcceptChannel_get_minimum_depth"))) TS_AcceptChannel_get_minimum_depth(uint32_t this_ptr) {
29218         LDKAcceptChannel this_ptr_conv;
29219         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29220         this_ptr_conv.is_owned = false;
29221         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29222         int32_t ret_conv = AcceptChannel_get_minimum_depth(&this_ptr_conv);
29223         return ret_conv;
29224 }
29225
29226 void  __attribute__((export_name("TS_AcceptChannel_set_minimum_depth"))) TS_AcceptChannel_set_minimum_depth(uint32_t this_ptr, int32_t val) {
29227         LDKAcceptChannel this_ptr_conv;
29228         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29229         this_ptr_conv.is_owned = false;
29230         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29231         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
29232 }
29233
29234 int16_t  __attribute__((export_name("TS_AcceptChannel_get_to_self_delay"))) TS_AcceptChannel_get_to_self_delay(uint32_t this_ptr) {
29235         LDKAcceptChannel this_ptr_conv;
29236         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29237         this_ptr_conv.is_owned = false;
29238         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29239         int16_t ret_conv = AcceptChannel_get_to_self_delay(&this_ptr_conv);
29240         return ret_conv;
29241 }
29242
29243 void  __attribute__((export_name("TS_AcceptChannel_set_to_self_delay"))) TS_AcceptChannel_set_to_self_delay(uint32_t this_ptr, int16_t val) {
29244         LDKAcceptChannel this_ptr_conv;
29245         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29246         this_ptr_conv.is_owned = false;
29247         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29248         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
29249 }
29250
29251 int16_t  __attribute__((export_name("TS_AcceptChannel_get_max_accepted_htlcs"))) TS_AcceptChannel_get_max_accepted_htlcs(uint32_t this_ptr) {
29252         LDKAcceptChannel this_ptr_conv;
29253         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29254         this_ptr_conv.is_owned = false;
29255         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29256         int16_t ret_conv = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
29257         return ret_conv;
29258 }
29259
29260 void  __attribute__((export_name("TS_AcceptChannel_set_max_accepted_htlcs"))) TS_AcceptChannel_set_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
29261         LDKAcceptChannel this_ptr_conv;
29262         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29263         this_ptr_conv.is_owned = false;
29264         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29265         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
29266 }
29267
29268 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_funding_pubkey"))) TS_AcceptChannel_get_funding_pubkey(uint32_t this_ptr) {
29269         LDKAcceptChannel this_ptr_conv;
29270         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29271         this_ptr_conv.is_owned = false;
29272         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29273         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29274         memcpy(ret_arr->elems, AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
29275         return ret_arr;
29276 }
29277
29278 void  __attribute__((export_name("TS_AcceptChannel_set_funding_pubkey"))) TS_AcceptChannel_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
29279         LDKAcceptChannel this_ptr_conv;
29280         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29281         this_ptr_conv.is_owned = false;
29282         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29283         LDKPublicKey val_ref;
29284         CHECK(val->arr_len == 33);
29285         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29286         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
29287 }
29288
29289 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_revocation_basepoint"))) TS_AcceptChannel_get_revocation_basepoint(uint32_t this_ptr) {
29290         LDKAcceptChannel this_ptr_conv;
29291         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29292         this_ptr_conv.is_owned = false;
29293         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29294         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29295         memcpy(ret_arr->elems, AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
29296         return ret_arr;
29297 }
29298
29299 void  __attribute__((export_name("TS_AcceptChannel_set_revocation_basepoint"))) TS_AcceptChannel_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
29300         LDKAcceptChannel this_ptr_conv;
29301         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29302         this_ptr_conv.is_owned = false;
29303         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29304         LDKPublicKey val_ref;
29305         CHECK(val->arr_len == 33);
29306         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29307         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
29308 }
29309
29310 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_payment_point"))) TS_AcceptChannel_get_payment_point(uint32_t this_ptr) {
29311         LDKAcceptChannel this_ptr_conv;
29312         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29313         this_ptr_conv.is_owned = false;
29314         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29315         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29316         memcpy(ret_arr->elems, AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
29317         return ret_arr;
29318 }
29319
29320 void  __attribute__((export_name("TS_AcceptChannel_set_payment_point"))) TS_AcceptChannel_set_payment_point(uint32_t this_ptr, int8_tArray val) {
29321         LDKAcceptChannel this_ptr_conv;
29322         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29323         this_ptr_conv.is_owned = false;
29324         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29325         LDKPublicKey val_ref;
29326         CHECK(val->arr_len == 33);
29327         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29328         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
29329 }
29330
29331 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_delayed_payment_basepoint"))) TS_AcceptChannel_get_delayed_payment_basepoint(uint32_t this_ptr) {
29332         LDKAcceptChannel this_ptr_conv;
29333         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29334         this_ptr_conv.is_owned = false;
29335         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29336         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29337         memcpy(ret_arr->elems, AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
29338         return ret_arr;
29339 }
29340
29341 void  __attribute__((export_name("TS_AcceptChannel_set_delayed_payment_basepoint"))) TS_AcceptChannel_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
29342         LDKAcceptChannel this_ptr_conv;
29343         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29344         this_ptr_conv.is_owned = false;
29345         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29346         LDKPublicKey val_ref;
29347         CHECK(val->arr_len == 33);
29348         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29349         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
29350 }
29351
29352 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_htlc_basepoint"))) TS_AcceptChannel_get_htlc_basepoint(uint32_t this_ptr) {
29353         LDKAcceptChannel this_ptr_conv;
29354         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29355         this_ptr_conv.is_owned = false;
29356         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29357         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29358         memcpy(ret_arr->elems, AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
29359         return ret_arr;
29360 }
29361
29362 void  __attribute__((export_name("TS_AcceptChannel_set_htlc_basepoint"))) TS_AcceptChannel_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
29363         LDKAcceptChannel this_ptr_conv;
29364         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29365         this_ptr_conv.is_owned = false;
29366         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29367         LDKPublicKey val_ref;
29368         CHECK(val->arr_len == 33);
29369         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29370         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
29371 }
29372
29373 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_first_per_commitment_point"))) TS_AcceptChannel_get_first_per_commitment_point(uint32_t this_ptr) {
29374         LDKAcceptChannel this_ptr_conv;
29375         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29376         this_ptr_conv.is_owned = false;
29377         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29378         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29379         memcpy(ret_arr->elems, AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
29380         return ret_arr;
29381 }
29382
29383 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) {
29384         LDKAcceptChannel this_ptr_conv;
29385         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29386         this_ptr_conv.is_owned = false;
29387         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29388         LDKPublicKey val_ref;
29389         CHECK(val->arr_len == 33);
29390         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29391         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
29392 }
29393
29394 uint32_t  __attribute__((export_name("TS_AcceptChannel_get_channel_type"))) TS_AcceptChannel_get_channel_type(uint32_t this_ptr) {
29395         LDKAcceptChannel this_ptr_conv;
29396         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29397         this_ptr_conv.is_owned = false;
29398         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29399         LDKChannelTypeFeatures ret_var = AcceptChannel_get_channel_type(&this_ptr_conv);
29400         uint32_t ret_ref = 0;
29401         if ((uintptr_t)ret_var.inner > 4096) {
29402                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29403                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29404         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29405                 ret_ref = (uintptr_t)ret_var.inner;
29406                 if (ret_var.is_owned) {
29407                         ret_ref |= 1;
29408                 }
29409         }
29410         return ret_ref;
29411 }
29412
29413 void  __attribute__((export_name("TS_AcceptChannel_set_channel_type"))) TS_AcceptChannel_set_channel_type(uint32_t this_ptr, uint32_t val) {
29414         LDKAcceptChannel this_ptr_conv;
29415         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29416         this_ptr_conv.is_owned = false;
29417         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29418         LDKChannelTypeFeatures val_conv;
29419         val_conv.inner = (void*)(val & (~1));
29420         val_conv.is_owned = (val & 1) || (val == 0);
29421         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29422         val_conv = ChannelTypeFeatures_clone(&val_conv);
29423         AcceptChannel_set_channel_type(&this_ptr_conv, val_conv);
29424 }
29425
29426 static inline uintptr_t AcceptChannel_clone_ptr(LDKAcceptChannel *NONNULL_PTR arg) {
29427         LDKAcceptChannel ret_var = AcceptChannel_clone(arg);
29428 uint32_t ret_ref = 0;
29429 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29430 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29431 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29432 ret_ref = (uintptr_t)ret_var.inner;
29433 if (ret_var.is_owned) {
29434         ret_ref |= 1;
29435 }
29436         return ret_ref;
29437 }
29438 uint32_t  __attribute__((export_name("TS_AcceptChannel_clone_ptr"))) TS_AcceptChannel_clone_ptr(uint32_t arg) {
29439         LDKAcceptChannel arg_conv;
29440         arg_conv.inner = (void*)(arg & (~1));
29441         arg_conv.is_owned = false;
29442         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29443         uint32_t ret_conv = AcceptChannel_clone_ptr(&arg_conv);
29444         return ret_conv;
29445 }
29446
29447 uint32_t  __attribute__((export_name("TS_AcceptChannel_clone"))) TS_AcceptChannel_clone(uint32_t orig) {
29448         LDKAcceptChannel orig_conv;
29449         orig_conv.inner = (void*)(orig & (~1));
29450         orig_conv.is_owned = false;
29451         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29452         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
29453         uint32_t ret_ref = 0;
29454         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29455         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29456         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29457         ret_ref = (uintptr_t)ret_var.inner;
29458         if (ret_var.is_owned) {
29459                 ret_ref |= 1;
29460         }
29461         return ret_ref;
29462 }
29463
29464 void  __attribute__((export_name("TS_FundingCreated_free"))) TS_FundingCreated_free(uint32_t this_obj) {
29465         LDKFundingCreated this_obj_conv;
29466         this_obj_conv.inner = (void*)(this_obj & (~1));
29467         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29468         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29469         FundingCreated_free(this_obj_conv);
29470 }
29471
29472 int8_tArray  __attribute__((export_name("TS_FundingCreated_get_temporary_channel_id"))) TS_FundingCreated_get_temporary_channel_id(uint32_t this_ptr) {
29473         LDKFundingCreated this_ptr_conv;
29474         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29475         this_ptr_conv.is_owned = false;
29476         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29477         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29478         memcpy(ret_arr->elems, *FundingCreated_get_temporary_channel_id(&this_ptr_conv), 32);
29479         return ret_arr;
29480 }
29481
29482 void  __attribute__((export_name("TS_FundingCreated_set_temporary_channel_id"))) TS_FundingCreated_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
29483         LDKFundingCreated this_ptr_conv;
29484         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29485         this_ptr_conv.is_owned = false;
29486         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29487         LDKThirtyTwoBytes val_ref;
29488         CHECK(val->arr_len == 32);
29489         memcpy(val_ref.data, val->elems, 32); FREE(val);
29490         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
29491 }
29492
29493 int8_tArray  __attribute__((export_name("TS_FundingCreated_get_funding_txid"))) TS_FundingCreated_get_funding_txid(uint32_t this_ptr) {
29494         LDKFundingCreated this_ptr_conv;
29495         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29496         this_ptr_conv.is_owned = false;
29497         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29498         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29499         memcpy(ret_arr->elems, *FundingCreated_get_funding_txid(&this_ptr_conv), 32);
29500         return ret_arr;
29501 }
29502
29503 void  __attribute__((export_name("TS_FundingCreated_set_funding_txid"))) TS_FundingCreated_set_funding_txid(uint32_t this_ptr, int8_tArray val) {
29504         LDKFundingCreated this_ptr_conv;
29505         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29506         this_ptr_conv.is_owned = false;
29507         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29508         LDKThirtyTwoBytes val_ref;
29509         CHECK(val->arr_len == 32);
29510         memcpy(val_ref.data, val->elems, 32); FREE(val);
29511         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
29512 }
29513
29514 int16_t  __attribute__((export_name("TS_FundingCreated_get_funding_output_index"))) TS_FundingCreated_get_funding_output_index(uint32_t this_ptr) {
29515         LDKFundingCreated this_ptr_conv;
29516         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29517         this_ptr_conv.is_owned = false;
29518         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29519         int16_t ret_conv = FundingCreated_get_funding_output_index(&this_ptr_conv);
29520         return ret_conv;
29521 }
29522
29523 void  __attribute__((export_name("TS_FundingCreated_set_funding_output_index"))) TS_FundingCreated_set_funding_output_index(uint32_t this_ptr, int16_t val) {
29524         LDKFundingCreated this_ptr_conv;
29525         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29526         this_ptr_conv.is_owned = false;
29527         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29528         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
29529 }
29530
29531 int8_tArray  __attribute__((export_name("TS_FundingCreated_get_signature"))) TS_FundingCreated_get_signature(uint32_t this_ptr) {
29532         LDKFundingCreated this_ptr_conv;
29533         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29534         this_ptr_conv.is_owned = false;
29535         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29536         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
29537         memcpy(ret_arr->elems, FundingCreated_get_signature(&this_ptr_conv).compact_form, 64);
29538         return ret_arr;
29539 }
29540
29541 void  __attribute__((export_name("TS_FundingCreated_set_signature"))) TS_FundingCreated_set_signature(uint32_t this_ptr, int8_tArray val) {
29542         LDKFundingCreated this_ptr_conv;
29543         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29544         this_ptr_conv.is_owned = false;
29545         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29546         LDKSignature val_ref;
29547         CHECK(val->arr_len == 64);
29548         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
29549         FundingCreated_set_signature(&this_ptr_conv, val_ref);
29550 }
29551
29552 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) {
29553         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
29554         CHECK(temporary_channel_id_arg->arr_len == 32);
29555         memcpy(temporary_channel_id_arg_ref.data, temporary_channel_id_arg->elems, 32); FREE(temporary_channel_id_arg);
29556         LDKThirtyTwoBytes funding_txid_arg_ref;
29557         CHECK(funding_txid_arg->arr_len == 32);
29558         memcpy(funding_txid_arg_ref.data, funding_txid_arg->elems, 32); FREE(funding_txid_arg);
29559         LDKSignature signature_arg_ref;
29560         CHECK(signature_arg->arr_len == 64);
29561         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
29562         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
29563         uint32_t ret_ref = 0;
29564         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29565         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29566         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29567         ret_ref = (uintptr_t)ret_var.inner;
29568         if (ret_var.is_owned) {
29569                 ret_ref |= 1;
29570         }
29571         return ret_ref;
29572 }
29573
29574 static inline uintptr_t FundingCreated_clone_ptr(LDKFundingCreated *NONNULL_PTR arg) {
29575         LDKFundingCreated ret_var = FundingCreated_clone(arg);
29576 uint32_t ret_ref = 0;
29577 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29578 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29579 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29580 ret_ref = (uintptr_t)ret_var.inner;
29581 if (ret_var.is_owned) {
29582         ret_ref |= 1;
29583 }
29584         return ret_ref;
29585 }
29586 uint32_t  __attribute__((export_name("TS_FundingCreated_clone_ptr"))) TS_FundingCreated_clone_ptr(uint32_t arg) {
29587         LDKFundingCreated arg_conv;
29588         arg_conv.inner = (void*)(arg & (~1));
29589         arg_conv.is_owned = false;
29590         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29591         uint32_t ret_conv = FundingCreated_clone_ptr(&arg_conv);
29592         return ret_conv;
29593 }
29594
29595 uint32_t  __attribute__((export_name("TS_FundingCreated_clone"))) TS_FundingCreated_clone(uint32_t orig) {
29596         LDKFundingCreated orig_conv;
29597         orig_conv.inner = (void*)(orig & (~1));
29598         orig_conv.is_owned = false;
29599         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29600         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
29601         uint32_t ret_ref = 0;
29602         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29603         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29604         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29605         ret_ref = (uintptr_t)ret_var.inner;
29606         if (ret_var.is_owned) {
29607                 ret_ref |= 1;
29608         }
29609         return ret_ref;
29610 }
29611
29612 void  __attribute__((export_name("TS_FundingSigned_free"))) TS_FundingSigned_free(uint32_t this_obj) {
29613         LDKFundingSigned this_obj_conv;
29614         this_obj_conv.inner = (void*)(this_obj & (~1));
29615         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29616         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29617         FundingSigned_free(this_obj_conv);
29618 }
29619
29620 int8_tArray  __attribute__((export_name("TS_FundingSigned_get_channel_id"))) TS_FundingSigned_get_channel_id(uint32_t this_ptr) {
29621         LDKFundingSigned this_ptr_conv;
29622         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29623         this_ptr_conv.is_owned = false;
29624         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29625         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29626         memcpy(ret_arr->elems, *FundingSigned_get_channel_id(&this_ptr_conv), 32);
29627         return ret_arr;
29628 }
29629
29630 void  __attribute__((export_name("TS_FundingSigned_set_channel_id"))) TS_FundingSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
29631         LDKFundingSigned this_ptr_conv;
29632         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29633         this_ptr_conv.is_owned = false;
29634         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29635         LDKThirtyTwoBytes val_ref;
29636         CHECK(val->arr_len == 32);
29637         memcpy(val_ref.data, val->elems, 32); FREE(val);
29638         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
29639 }
29640
29641 int8_tArray  __attribute__((export_name("TS_FundingSigned_get_signature"))) TS_FundingSigned_get_signature(uint32_t this_ptr) {
29642         LDKFundingSigned this_ptr_conv;
29643         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29644         this_ptr_conv.is_owned = false;
29645         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29646         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
29647         memcpy(ret_arr->elems, FundingSigned_get_signature(&this_ptr_conv).compact_form, 64);
29648         return ret_arr;
29649 }
29650
29651 void  __attribute__((export_name("TS_FundingSigned_set_signature"))) TS_FundingSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
29652         LDKFundingSigned this_ptr_conv;
29653         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29654         this_ptr_conv.is_owned = false;
29655         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29656         LDKSignature val_ref;
29657         CHECK(val->arr_len == 64);
29658         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
29659         FundingSigned_set_signature(&this_ptr_conv, val_ref);
29660 }
29661
29662 uint32_t  __attribute__((export_name("TS_FundingSigned_new"))) TS_FundingSigned_new(int8_tArray channel_id_arg, int8_tArray signature_arg) {
29663         LDKThirtyTwoBytes channel_id_arg_ref;
29664         CHECK(channel_id_arg->arr_len == 32);
29665         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
29666         LDKSignature signature_arg_ref;
29667         CHECK(signature_arg->arr_len == 64);
29668         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
29669         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
29670         uint32_t ret_ref = 0;
29671         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29672         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29673         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29674         ret_ref = (uintptr_t)ret_var.inner;
29675         if (ret_var.is_owned) {
29676                 ret_ref |= 1;
29677         }
29678         return ret_ref;
29679 }
29680
29681 static inline uintptr_t FundingSigned_clone_ptr(LDKFundingSigned *NONNULL_PTR arg) {
29682         LDKFundingSigned ret_var = FundingSigned_clone(arg);
29683 uint32_t ret_ref = 0;
29684 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29685 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29686 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29687 ret_ref = (uintptr_t)ret_var.inner;
29688 if (ret_var.is_owned) {
29689         ret_ref |= 1;
29690 }
29691         return ret_ref;
29692 }
29693 uint32_t  __attribute__((export_name("TS_FundingSigned_clone_ptr"))) TS_FundingSigned_clone_ptr(uint32_t arg) {
29694         LDKFundingSigned arg_conv;
29695         arg_conv.inner = (void*)(arg & (~1));
29696         arg_conv.is_owned = false;
29697         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29698         uint32_t ret_conv = FundingSigned_clone_ptr(&arg_conv);
29699         return ret_conv;
29700 }
29701
29702 uint32_t  __attribute__((export_name("TS_FundingSigned_clone"))) TS_FundingSigned_clone(uint32_t orig) {
29703         LDKFundingSigned orig_conv;
29704         orig_conv.inner = (void*)(orig & (~1));
29705         orig_conv.is_owned = false;
29706         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29707         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
29708         uint32_t ret_ref = 0;
29709         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29710         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29711         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29712         ret_ref = (uintptr_t)ret_var.inner;
29713         if (ret_var.is_owned) {
29714                 ret_ref |= 1;
29715         }
29716         return ret_ref;
29717 }
29718
29719 void  __attribute__((export_name("TS_ChannelReady_free"))) TS_ChannelReady_free(uint32_t this_obj) {
29720         LDKChannelReady this_obj_conv;
29721         this_obj_conv.inner = (void*)(this_obj & (~1));
29722         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29723         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29724         ChannelReady_free(this_obj_conv);
29725 }
29726
29727 int8_tArray  __attribute__((export_name("TS_ChannelReady_get_channel_id"))) TS_ChannelReady_get_channel_id(uint32_t this_ptr) {
29728         LDKChannelReady this_ptr_conv;
29729         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29730         this_ptr_conv.is_owned = false;
29731         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29732         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29733         memcpy(ret_arr->elems, *ChannelReady_get_channel_id(&this_ptr_conv), 32);
29734         return ret_arr;
29735 }
29736
29737 void  __attribute__((export_name("TS_ChannelReady_set_channel_id"))) TS_ChannelReady_set_channel_id(uint32_t this_ptr, int8_tArray val) {
29738         LDKChannelReady this_ptr_conv;
29739         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29740         this_ptr_conv.is_owned = false;
29741         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29742         LDKThirtyTwoBytes val_ref;
29743         CHECK(val->arr_len == 32);
29744         memcpy(val_ref.data, val->elems, 32); FREE(val);
29745         ChannelReady_set_channel_id(&this_ptr_conv, val_ref);
29746 }
29747
29748 int8_tArray  __attribute__((export_name("TS_ChannelReady_get_next_per_commitment_point"))) TS_ChannelReady_get_next_per_commitment_point(uint32_t this_ptr) {
29749         LDKChannelReady this_ptr_conv;
29750         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29751         this_ptr_conv.is_owned = false;
29752         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29753         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29754         memcpy(ret_arr->elems, ChannelReady_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
29755         return ret_arr;
29756 }
29757
29758 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) {
29759         LDKChannelReady this_ptr_conv;
29760         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29761         this_ptr_conv.is_owned = false;
29762         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29763         LDKPublicKey val_ref;
29764         CHECK(val->arr_len == 33);
29765         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29766         ChannelReady_set_next_per_commitment_point(&this_ptr_conv, val_ref);
29767 }
29768
29769 uint32_t  __attribute__((export_name("TS_ChannelReady_get_short_channel_id_alias"))) TS_ChannelReady_get_short_channel_id_alias(uint32_t this_ptr) {
29770         LDKChannelReady this_ptr_conv;
29771         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29772         this_ptr_conv.is_owned = false;
29773         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29774         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
29775         *ret_copy = ChannelReady_get_short_channel_id_alias(&this_ptr_conv);
29776         uint32_t ret_ref = (uintptr_t)ret_copy;
29777         return ret_ref;
29778 }
29779
29780 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) {
29781         LDKChannelReady this_ptr_conv;
29782         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29783         this_ptr_conv.is_owned = false;
29784         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29785         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29786         CHECK_ACCESS(val_ptr);
29787         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
29788         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
29789         ChannelReady_set_short_channel_id_alias(&this_ptr_conv, val_conv);
29790 }
29791
29792 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) {
29793         LDKThirtyTwoBytes channel_id_arg_ref;
29794         CHECK(channel_id_arg->arr_len == 32);
29795         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
29796         LDKPublicKey next_per_commitment_point_arg_ref;
29797         CHECK(next_per_commitment_point_arg->arr_len == 33);
29798         memcpy(next_per_commitment_point_arg_ref.compressed_form, next_per_commitment_point_arg->elems, 33); FREE(next_per_commitment_point_arg);
29799         void* short_channel_id_alias_arg_ptr = (void*)(((uintptr_t)short_channel_id_alias_arg) & ~1);
29800         CHECK_ACCESS(short_channel_id_alias_arg_ptr);
29801         LDKCOption_u64Z short_channel_id_alias_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_alias_arg_ptr);
29802         short_channel_id_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id_alias_arg) & ~1));
29803         LDKChannelReady ret_var = ChannelReady_new(channel_id_arg_ref, next_per_commitment_point_arg_ref, short_channel_id_alias_arg_conv);
29804         uint32_t ret_ref = 0;
29805         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29806         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29807         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29808         ret_ref = (uintptr_t)ret_var.inner;
29809         if (ret_var.is_owned) {
29810                 ret_ref |= 1;
29811         }
29812         return ret_ref;
29813 }
29814
29815 static inline uintptr_t ChannelReady_clone_ptr(LDKChannelReady *NONNULL_PTR arg) {
29816         LDKChannelReady ret_var = ChannelReady_clone(arg);
29817 uint32_t ret_ref = 0;
29818 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29819 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29820 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29821 ret_ref = (uintptr_t)ret_var.inner;
29822 if (ret_var.is_owned) {
29823         ret_ref |= 1;
29824 }
29825         return ret_ref;
29826 }
29827 uint32_t  __attribute__((export_name("TS_ChannelReady_clone_ptr"))) TS_ChannelReady_clone_ptr(uint32_t arg) {
29828         LDKChannelReady arg_conv;
29829         arg_conv.inner = (void*)(arg & (~1));
29830         arg_conv.is_owned = false;
29831         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29832         uint32_t ret_conv = ChannelReady_clone_ptr(&arg_conv);
29833         return ret_conv;
29834 }
29835
29836 uint32_t  __attribute__((export_name("TS_ChannelReady_clone"))) TS_ChannelReady_clone(uint32_t orig) {
29837         LDKChannelReady orig_conv;
29838         orig_conv.inner = (void*)(orig & (~1));
29839         orig_conv.is_owned = false;
29840         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29841         LDKChannelReady ret_var = ChannelReady_clone(&orig_conv);
29842         uint32_t ret_ref = 0;
29843         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29844         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29845         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29846         ret_ref = (uintptr_t)ret_var.inner;
29847         if (ret_var.is_owned) {
29848                 ret_ref |= 1;
29849         }
29850         return ret_ref;
29851 }
29852
29853 void  __attribute__((export_name("TS_Shutdown_free"))) TS_Shutdown_free(uint32_t this_obj) {
29854         LDKShutdown this_obj_conv;
29855         this_obj_conv.inner = (void*)(this_obj & (~1));
29856         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29857         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29858         Shutdown_free(this_obj_conv);
29859 }
29860
29861 int8_tArray  __attribute__((export_name("TS_Shutdown_get_channel_id"))) TS_Shutdown_get_channel_id(uint32_t this_ptr) {
29862         LDKShutdown this_ptr_conv;
29863         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29864         this_ptr_conv.is_owned = false;
29865         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29866         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29867         memcpy(ret_arr->elems, *Shutdown_get_channel_id(&this_ptr_conv), 32);
29868         return ret_arr;
29869 }
29870
29871 void  __attribute__((export_name("TS_Shutdown_set_channel_id"))) TS_Shutdown_set_channel_id(uint32_t this_ptr, int8_tArray val) {
29872         LDKShutdown this_ptr_conv;
29873         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29874         this_ptr_conv.is_owned = false;
29875         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29876         LDKThirtyTwoBytes val_ref;
29877         CHECK(val->arr_len == 32);
29878         memcpy(val_ref.data, val->elems, 32); FREE(val);
29879         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
29880 }
29881
29882 int8_tArray  __attribute__((export_name("TS_Shutdown_get_scriptpubkey"))) TS_Shutdown_get_scriptpubkey(uint32_t this_ptr) {
29883         LDKShutdown this_ptr_conv;
29884         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29885         this_ptr_conv.is_owned = false;
29886         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29887         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
29888         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
29889         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
29890         return ret_arr;
29891 }
29892
29893 void  __attribute__((export_name("TS_Shutdown_set_scriptpubkey"))) TS_Shutdown_set_scriptpubkey(uint32_t this_ptr, int8_tArray val) {
29894         LDKShutdown this_ptr_conv;
29895         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29896         this_ptr_conv.is_owned = false;
29897         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29898         LDKCVec_u8Z val_ref;
29899         val_ref.datalen = val->arr_len;
29900         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
29901         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
29902         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
29903 }
29904
29905 uint32_t  __attribute__((export_name("TS_Shutdown_new"))) TS_Shutdown_new(int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
29906         LDKThirtyTwoBytes channel_id_arg_ref;
29907         CHECK(channel_id_arg->arr_len == 32);
29908         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
29909         LDKCVec_u8Z scriptpubkey_arg_ref;
29910         scriptpubkey_arg_ref.datalen = scriptpubkey_arg->arr_len;
29911         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
29912         memcpy(scriptpubkey_arg_ref.data, scriptpubkey_arg->elems, scriptpubkey_arg_ref.datalen); FREE(scriptpubkey_arg);
29913         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
29914         uint32_t ret_ref = 0;
29915         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29916         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29917         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29918         ret_ref = (uintptr_t)ret_var.inner;
29919         if (ret_var.is_owned) {
29920                 ret_ref |= 1;
29921         }
29922         return ret_ref;
29923 }
29924
29925 static inline uintptr_t Shutdown_clone_ptr(LDKShutdown *NONNULL_PTR arg) {
29926         LDKShutdown ret_var = Shutdown_clone(arg);
29927 uint32_t ret_ref = 0;
29928 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29929 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29930 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29931 ret_ref = (uintptr_t)ret_var.inner;
29932 if (ret_var.is_owned) {
29933         ret_ref |= 1;
29934 }
29935         return ret_ref;
29936 }
29937 uint32_t  __attribute__((export_name("TS_Shutdown_clone_ptr"))) TS_Shutdown_clone_ptr(uint32_t arg) {
29938         LDKShutdown arg_conv;
29939         arg_conv.inner = (void*)(arg & (~1));
29940         arg_conv.is_owned = false;
29941         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29942         uint32_t ret_conv = Shutdown_clone_ptr(&arg_conv);
29943         return ret_conv;
29944 }
29945
29946 uint32_t  __attribute__((export_name("TS_Shutdown_clone"))) TS_Shutdown_clone(uint32_t orig) {
29947         LDKShutdown orig_conv;
29948         orig_conv.inner = (void*)(orig & (~1));
29949         orig_conv.is_owned = false;
29950         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29951         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
29952         uint32_t ret_ref = 0;
29953         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29954         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29955         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29956         ret_ref = (uintptr_t)ret_var.inner;
29957         if (ret_var.is_owned) {
29958                 ret_ref |= 1;
29959         }
29960         return ret_ref;
29961 }
29962
29963 void  __attribute__((export_name("TS_ClosingSignedFeeRange_free"))) TS_ClosingSignedFeeRange_free(uint32_t this_obj) {
29964         LDKClosingSignedFeeRange this_obj_conv;
29965         this_obj_conv.inner = (void*)(this_obj & (~1));
29966         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29967         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29968         ClosingSignedFeeRange_free(this_obj_conv);
29969 }
29970
29971 int64_t  __attribute__((export_name("TS_ClosingSignedFeeRange_get_min_fee_satoshis"))) TS_ClosingSignedFeeRange_get_min_fee_satoshis(uint32_t this_ptr) {
29972         LDKClosingSignedFeeRange this_ptr_conv;
29973         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29974         this_ptr_conv.is_owned = false;
29975         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29976         int64_t ret_conv = ClosingSignedFeeRange_get_min_fee_satoshis(&this_ptr_conv);
29977         return ret_conv;
29978 }
29979
29980 void  __attribute__((export_name("TS_ClosingSignedFeeRange_set_min_fee_satoshis"))) TS_ClosingSignedFeeRange_set_min_fee_satoshis(uint32_t this_ptr, int64_t val) {
29981         LDKClosingSignedFeeRange this_ptr_conv;
29982         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29983         this_ptr_conv.is_owned = false;
29984         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29985         ClosingSignedFeeRange_set_min_fee_satoshis(&this_ptr_conv, val);
29986 }
29987
29988 int64_t  __attribute__((export_name("TS_ClosingSignedFeeRange_get_max_fee_satoshis"))) TS_ClosingSignedFeeRange_get_max_fee_satoshis(uint32_t this_ptr) {
29989         LDKClosingSignedFeeRange this_ptr_conv;
29990         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29991         this_ptr_conv.is_owned = false;
29992         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29993         int64_t ret_conv = ClosingSignedFeeRange_get_max_fee_satoshis(&this_ptr_conv);
29994         return ret_conv;
29995 }
29996
29997 void  __attribute__((export_name("TS_ClosingSignedFeeRange_set_max_fee_satoshis"))) TS_ClosingSignedFeeRange_set_max_fee_satoshis(uint32_t this_ptr, int64_t val) {
29998         LDKClosingSignedFeeRange this_ptr_conv;
29999         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30000         this_ptr_conv.is_owned = false;
30001         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30002         ClosingSignedFeeRange_set_max_fee_satoshis(&this_ptr_conv, val);
30003 }
30004
30005 uint32_t  __attribute__((export_name("TS_ClosingSignedFeeRange_new"))) TS_ClosingSignedFeeRange_new(int64_t min_fee_satoshis_arg, int64_t max_fee_satoshis_arg) {
30006         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_new(min_fee_satoshis_arg, max_fee_satoshis_arg);
30007         uint32_t ret_ref = 0;
30008         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30009         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30010         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30011         ret_ref = (uintptr_t)ret_var.inner;
30012         if (ret_var.is_owned) {
30013                 ret_ref |= 1;
30014         }
30015         return ret_ref;
30016 }
30017
30018 static inline uintptr_t ClosingSignedFeeRange_clone_ptr(LDKClosingSignedFeeRange *NONNULL_PTR arg) {
30019         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(arg);
30020 uint32_t ret_ref = 0;
30021 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30022 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30023 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30024 ret_ref = (uintptr_t)ret_var.inner;
30025 if (ret_var.is_owned) {
30026         ret_ref |= 1;
30027 }
30028         return ret_ref;
30029 }
30030 uint32_t  __attribute__((export_name("TS_ClosingSignedFeeRange_clone_ptr"))) TS_ClosingSignedFeeRange_clone_ptr(uint32_t arg) {
30031         LDKClosingSignedFeeRange arg_conv;
30032         arg_conv.inner = (void*)(arg & (~1));
30033         arg_conv.is_owned = false;
30034         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30035         uint32_t ret_conv = ClosingSignedFeeRange_clone_ptr(&arg_conv);
30036         return ret_conv;
30037 }
30038
30039 uint32_t  __attribute__((export_name("TS_ClosingSignedFeeRange_clone"))) TS_ClosingSignedFeeRange_clone(uint32_t orig) {
30040         LDKClosingSignedFeeRange orig_conv;
30041         orig_conv.inner = (void*)(orig & (~1));
30042         orig_conv.is_owned = false;
30043         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30044         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(&orig_conv);
30045         uint32_t ret_ref = 0;
30046         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30047         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30048         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30049         ret_ref = (uintptr_t)ret_var.inner;
30050         if (ret_var.is_owned) {
30051                 ret_ref |= 1;
30052         }
30053         return ret_ref;
30054 }
30055
30056 void  __attribute__((export_name("TS_ClosingSigned_free"))) TS_ClosingSigned_free(uint32_t this_obj) {
30057         LDKClosingSigned this_obj_conv;
30058         this_obj_conv.inner = (void*)(this_obj & (~1));
30059         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30060         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30061         ClosingSigned_free(this_obj_conv);
30062 }
30063
30064 int8_tArray  __attribute__((export_name("TS_ClosingSigned_get_channel_id"))) TS_ClosingSigned_get_channel_id(uint32_t this_ptr) {
30065         LDKClosingSigned this_ptr_conv;
30066         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30067         this_ptr_conv.is_owned = false;
30068         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30069         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30070         memcpy(ret_arr->elems, *ClosingSigned_get_channel_id(&this_ptr_conv), 32);
30071         return ret_arr;
30072 }
30073
30074 void  __attribute__((export_name("TS_ClosingSigned_set_channel_id"))) TS_ClosingSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
30075         LDKClosingSigned this_ptr_conv;
30076         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30077         this_ptr_conv.is_owned = false;
30078         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30079         LDKThirtyTwoBytes val_ref;
30080         CHECK(val->arr_len == 32);
30081         memcpy(val_ref.data, val->elems, 32); FREE(val);
30082         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
30083 }
30084
30085 int64_t  __attribute__((export_name("TS_ClosingSigned_get_fee_satoshis"))) TS_ClosingSigned_get_fee_satoshis(uint32_t this_ptr) {
30086         LDKClosingSigned this_ptr_conv;
30087         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30088         this_ptr_conv.is_owned = false;
30089         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30090         int64_t ret_conv = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
30091         return ret_conv;
30092 }
30093
30094 void  __attribute__((export_name("TS_ClosingSigned_set_fee_satoshis"))) TS_ClosingSigned_set_fee_satoshis(uint32_t this_ptr, int64_t val) {
30095         LDKClosingSigned this_ptr_conv;
30096         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30097         this_ptr_conv.is_owned = false;
30098         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30099         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
30100 }
30101
30102 int8_tArray  __attribute__((export_name("TS_ClosingSigned_get_signature"))) TS_ClosingSigned_get_signature(uint32_t this_ptr) {
30103         LDKClosingSigned this_ptr_conv;
30104         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30105         this_ptr_conv.is_owned = false;
30106         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30107         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
30108         memcpy(ret_arr->elems, ClosingSigned_get_signature(&this_ptr_conv).compact_form, 64);
30109         return ret_arr;
30110 }
30111
30112 void  __attribute__((export_name("TS_ClosingSigned_set_signature"))) TS_ClosingSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
30113         LDKClosingSigned this_ptr_conv;
30114         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30115         this_ptr_conv.is_owned = false;
30116         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30117         LDKSignature val_ref;
30118         CHECK(val->arr_len == 64);
30119         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
30120         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
30121 }
30122
30123 uint32_t  __attribute__((export_name("TS_ClosingSigned_get_fee_range"))) TS_ClosingSigned_get_fee_range(uint32_t this_ptr) {
30124         LDKClosingSigned this_ptr_conv;
30125         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30126         this_ptr_conv.is_owned = false;
30127         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30128         LDKClosingSignedFeeRange ret_var = ClosingSigned_get_fee_range(&this_ptr_conv);
30129         uint32_t ret_ref = 0;
30130         if ((uintptr_t)ret_var.inner > 4096) {
30131                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30132                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30133         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30134                 ret_ref = (uintptr_t)ret_var.inner;
30135                 if (ret_var.is_owned) {
30136                         ret_ref |= 1;
30137                 }
30138         }
30139         return ret_ref;
30140 }
30141
30142 void  __attribute__((export_name("TS_ClosingSigned_set_fee_range"))) TS_ClosingSigned_set_fee_range(uint32_t this_ptr, uint32_t val) {
30143         LDKClosingSigned this_ptr_conv;
30144         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30145         this_ptr_conv.is_owned = false;
30146         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30147         LDKClosingSignedFeeRange val_conv;
30148         val_conv.inner = (void*)(val & (~1));
30149         val_conv.is_owned = (val & 1) || (val == 0);
30150         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30151         val_conv = ClosingSignedFeeRange_clone(&val_conv);
30152         ClosingSigned_set_fee_range(&this_ptr_conv, val_conv);
30153 }
30154
30155 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) {
30156         LDKThirtyTwoBytes channel_id_arg_ref;
30157         CHECK(channel_id_arg->arr_len == 32);
30158         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
30159         LDKSignature signature_arg_ref;
30160         CHECK(signature_arg->arr_len == 64);
30161         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
30162         LDKClosingSignedFeeRange fee_range_arg_conv;
30163         fee_range_arg_conv.inner = (void*)(fee_range_arg & (~1));
30164         fee_range_arg_conv.is_owned = (fee_range_arg & 1) || (fee_range_arg == 0);
30165         CHECK_INNER_FIELD_ACCESS_OR_NULL(fee_range_arg_conv);
30166         fee_range_arg_conv = ClosingSignedFeeRange_clone(&fee_range_arg_conv);
30167         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref, fee_range_arg_conv);
30168         uint32_t ret_ref = 0;
30169         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30170         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30171         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30172         ret_ref = (uintptr_t)ret_var.inner;
30173         if (ret_var.is_owned) {
30174                 ret_ref |= 1;
30175         }
30176         return ret_ref;
30177 }
30178
30179 static inline uintptr_t ClosingSigned_clone_ptr(LDKClosingSigned *NONNULL_PTR arg) {
30180         LDKClosingSigned ret_var = ClosingSigned_clone(arg);
30181 uint32_t ret_ref = 0;
30182 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30183 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30184 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30185 ret_ref = (uintptr_t)ret_var.inner;
30186 if (ret_var.is_owned) {
30187         ret_ref |= 1;
30188 }
30189         return ret_ref;
30190 }
30191 uint32_t  __attribute__((export_name("TS_ClosingSigned_clone_ptr"))) TS_ClosingSigned_clone_ptr(uint32_t arg) {
30192         LDKClosingSigned arg_conv;
30193         arg_conv.inner = (void*)(arg & (~1));
30194         arg_conv.is_owned = false;
30195         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30196         uint32_t ret_conv = ClosingSigned_clone_ptr(&arg_conv);
30197         return ret_conv;
30198 }
30199
30200 uint32_t  __attribute__((export_name("TS_ClosingSigned_clone"))) TS_ClosingSigned_clone(uint32_t orig) {
30201         LDKClosingSigned orig_conv;
30202         orig_conv.inner = (void*)(orig & (~1));
30203         orig_conv.is_owned = false;
30204         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30205         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
30206         uint32_t ret_ref = 0;
30207         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30208         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30209         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30210         ret_ref = (uintptr_t)ret_var.inner;
30211         if (ret_var.is_owned) {
30212                 ret_ref |= 1;
30213         }
30214         return ret_ref;
30215 }
30216
30217 void  __attribute__((export_name("TS_UpdateAddHTLC_free"))) TS_UpdateAddHTLC_free(uint32_t this_obj) {
30218         LDKUpdateAddHTLC this_obj_conv;
30219         this_obj_conv.inner = (void*)(this_obj & (~1));
30220         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30221         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30222         UpdateAddHTLC_free(this_obj_conv);
30223 }
30224
30225 int8_tArray  __attribute__((export_name("TS_UpdateAddHTLC_get_channel_id"))) TS_UpdateAddHTLC_get_channel_id(uint32_t this_ptr) {
30226         LDKUpdateAddHTLC this_ptr_conv;
30227         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30228         this_ptr_conv.is_owned = false;
30229         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30230         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30231         memcpy(ret_arr->elems, *UpdateAddHTLC_get_channel_id(&this_ptr_conv), 32);
30232         return ret_arr;
30233 }
30234
30235 void  __attribute__((export_name("TS_UpdateAddHTLC_set_channel_id"))) TS_UpdateAddHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
30236         LDKUpdateAddHTLC this_ptr_conv;
30237         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30238         this_ptr_conv.is_owned = false;
30239         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30240         LDKThirtyTwoBytes val_ref;
30241         CHECK(val->arr_len == 32);
30242         memcpy(val_ref.data, val->elems, 32); FREE(val);
30243         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
30244 }
30245
30246 int64_t  __attribute__((export_name("TS_UpdateAddHTLC_get_htlc_id"))) TS_UpdateAddHTLC_get_htlc_id(uint32_t this_ptr) {
30247         LDKUpdateAddHTLC this_ptr_conv;
30248         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30249         this_ptr_conv.is_owned = false;
30250         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30251         int64_t ret_conv = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
30252         return ret_conv;
30253 }
30254
30255 void  __attribute__((export_name("TS_UpdateAddHTLC_set_htlc_id"))) TS_UpdateAddHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
30256         LDKUpdateAddHTLC this_ptr_conv;
30257         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30258         this_ptr_conv.is_owned = false;
30259         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30260         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
30261 }
30262
30263 int64_t  __attribute__((export_name("TS_UpdateAddHTLC_get_amount_msat"))) TS_UpdateAddHTLC_get_amount_msat(uint32_t this_ptr) {
30264         LDKUpdateAddHTLC this_ptr_conv;
30265         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30266         this_ptr_conv.is_owned = false;
30267         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30268         int64_t ret_conv = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
30269         return ret_conv;
30270 }
30271
30272 void  __attribute__((export_name("TS_UpdateAddHTLC_set_amount_msat"))) TS_UpdateAddHTLC_set_amount_msat(uint32_t this_ptr, int64_t val) {
30273         LDKUpdateAddHTLC this_ptr_conv;
30274         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30275         this_ptr_conv.is_owned = false;
30276         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30277         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
30278 }
30279
30280 int8_tArray  __attribute__((export_name("TS_UpdateAddHTLC_get_payment_hash"))) TS_UpdateAddHTLC_get_payment_hash(uint32_t this_ptr) {
30281         LDKUpdateAddHTLC this_ptr_conv;
30282         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30283         this_ptr_conv.is_owned = false;
30284         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30285         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30286         memcpy(ret_arr->elems, *UpdateAddHTLC_get_payment_hash(&this_ptr_conv), 32);
30287         return ret_arr;
30288 }
30289
30290 void  __attribute__((export_name("TS_UpdateAddHTLC_set_payment_hash"))) TS_UpdateAddHTLC_set_payment_hash(uint32_t this_ptr, int8_tArray val) {
30291         LDKUpdateAddHTLC this_ptr_conv;
30292         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30293         this_ptr_conv.is_owned = false;
30294         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30295         LDKThirtyTwoBytes val_ref;
30296         CHECK(val->arr_len == 32);
30297         memcpy(val_ref.data, val->elems, 32); FREE(val);
30298         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
30299 }
30300
30301 int32_t  __attribute__((export_name("TS_UpdateAddHTLC_get_cltv_expiry"))) TS_UpdateAddHTLC_get_cltv_expiry(uint32_t this_ptr) {
30302         LDKUpdateAddHTLC this_ptr_conv;
30303         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30304         this_ptr_conv.is_owned = false;
30305         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30306         int32_t ret_conv = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
30307         return ret_conv;
30308 }
30309
30310 void  __attribute__((export_name("TS_UpdateAddHTLC_set_cltv_expiry"))) TS_UpdateAddHTLC_set_cltv_expiry(uint32_t this_ptr, int32_t val) {
30311         LDKUpdateAddHTLC this_ptr_conv;
30312         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30313         this_ptr_conv.is_owned = false;
30314         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30315         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
30316 }
30317
30318 static inline uintptr_t UpdateAddHTLC_clone_ptr(LDKUpdateAddHTLC *NONNULL_PTR arg) {
30319         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(arg);
30320 uint32_t ret_ref = 0;
30321 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30322 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30323 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30324 ret_ref = (uintptr_t)ret_var.inner;
30325 if (ret_var.is_owned) {
30326         ret_ref |= 1;
30327 }
30328         return ret_ref;
30329 }
30330 uint32_t  __attribute__((export_name("TS_UpdateAddHTLC_clone_ptr"))) TS_UpdateAddHTLC_clone_ptr(uint32_t arg) {
30331         LDKUpdateAddHTLC arg_conv;
30332         arg_conv.inner = (void*)(arg & (~1));
30333         arg_conv.is_owned = false;
30334         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30335         uint32_t ret_conv = UpdateAddHTLC_clone_ptr(&arg_conv);
30336         return ret_conv;
30337 }
30338
30339 uint32_t  __attribute__((export_name("TS_UpdateAddHTLC_clone"))) TS_UpdateAddHTLC_clone(uint32_t orig) {
30340         LDKUpdateAddHTLC orig_conv;
30341         orig_conv.inner = (void*)(orig & (~1));
30342         orig_conv.is_owned = false;
30343         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30344         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
30345         uint32_t ret_ref = 0;
30346         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30347         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30348         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30349         ret_ref = (uintptr_t)ret_var.inner;
30350         if (ret_var.is_owned) {
30351                 ret_ref |= 1;
30352         }
30353         return ret_ref;
30354 }
30355
30356 void  __attribute__((export_name("TS_UpdateFulfillHTLC_free"))) TS_UpdateFulfillHTLC_free(uint32_t this_obj) {
30357         LDKUpdateFulfillHTLC this_obj_conv;
30358         this_obj_conv.inner = (void*)(this_obj & (~1));
30359         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30360         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30361         UpdateFulfillHTLC_free(this_obj_conv);
30362 }
30363
30364 int8_tArray  __attribute__((export_name("TS_UpdateFulfillHTLC_get_channel_id"))) TS_UpdateFulfillHTLC_get_channel_id(uint32_t this_ptr) {
30365         LDKUpdateFulfillHTLC this_ptr_conv;
30366         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30367         this_ptr_conv.is_owned = false;
30368         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30369         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30370         memcpy(ret_arr->elems, *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv), 32);
30371         return ret_arr;
30372 }
30373
30374 void  __attribute__((export_name("TS_UpdateFulfillHTLC_set_channel_id"))) TS_UpdateFulfillHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
30375         LDKUpdateFulfillHTLC this_ptr_conv;
30376         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30377         this_ptr_conv.is_owned = false;
30378         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30379         LDKThirtyTwoBytes val_ref;
30380         CHECK(val->arr_len == 32);
30381         memcpy(val_ref.data, val->elems, 32); FREE(val);
30382         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
30383 }
30384
30385 int64_t  __attribute__((export_name("TS_UpdateFulfillHTLC_get_htlc_id"))) TS_UpdateFulfillHTLC_get_htlc_id(uint32_t this_ptr) {
30386         LDKUpdateFulfillHTLC this_ptr_conv;
30387         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30388         this_ptr_conv.is_owned = false;
30389         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30390         int64_t ret_conv = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
30391         return ret_conv;
30392 }
30393
30394 void  __attribute__((export_name("TS_UpdateFulfillHTLC_set_htlc_id"))) TS_UpdateFulfillHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
30395         LDKUpdateFulfillHTLC this_ptr_conv;
30396         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30397         this_ptr_conv.is_owned = false;
30398         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30399         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
30400 }
30401
30402 int8_tArray  __attribute__((export_name("TS_UpdateFulfillHTLC_get_payment_preimage"))) TS_UpdateFulfillHTLC_get_payment_preimage(uint32_t this_ptr) {
30403         LDKUpdateFulfillHTLC this_ptr_conv;
30404         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30405         this_ptr_conv.is_owned = false;
30406         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30407         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30408         memcpy(ret_arr->elems, *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv), 32);
30409         return ret_arr;
30410 }
30411
30412 void  __attribute__((export_name("TS_UpdateFulfillHTLC_set_payment_preimage"))) TS_UpdateFulfillHTLC_set_payment_preimage(uint32_t this_ptr, int8_tArray val) {
30413         LDKUpdateFulfillHTLC this_ptr_conv;
30414         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30415         this_ptr_conv.is_owned = false;
30416         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30417         LDKThirtyTwoBytes val_ref;
30418         CHECK(val->arr_len == 32);
30419         memcpy(val_ref.data, val->elems, 32); FREE(val);
30420         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
30421 }
30422
30423 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) {
30424         LDKThirtyTwoBytes channel_id_arg_ref;
30425         CHECK(channel_id_arg->arr_len == 32);
30426         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
30427         LDKThirtyTwoBytes payment_preimage_arg_ref;
30428         CHECK(payment_preimage_arg->arr_len == 32);
30429         memcpy(payment_preimage_arg_ref.data, payment_preimage_arg->elems, 32); FREE(payment_preimage_arg);
30430         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
30431         uint32_t ret_ref = 0;
30432         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30433         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30434         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30435         ret_ref = (uintptr_t)ret_var.inner;
30436         if (ret_var.is_owned) {
30437                 ret_ref |= 1;
30438         }
30439         return ret_ref;
30440 }
30441
30442 static inline uintptr_t UpdateFulfillHTLC_clone_ptr(LDKUpdateFulfillHTLC *NONNULL_PTR arg) {
30443         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(arg);
30444 uint32_t ret_ref = 0;
30445 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30446 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30447 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30448 ret_ref = (uintptr_t)ret_var.inner;
30449 if (ret_var.is_owned) {
30450         ret_ref |= 1;
30451 }
30452         return ret_ref;
30453 }
30454 uint32_t  __attribute__((export_name("TS_UpdateFulfillHTLC_clone_ptr"))) TS_UpdateFulfillHTLC_clone_ptr(uint32_t arg) {
30455         LDKUpdateFulfillHTLC arg_conv;
30456         arg_conv.inner = (void*)(arg & (~1));
30457         arg_conv.is_owned = false;
30458         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30459         uint32_t ret_conv = UpdateFulfillHTLC_clone_ptr(&arg_conv);
30460         return ret_conv;
30461 }
30462
30463 uint32_t  __attribute__((export_name("TS_UpdateFulfillHTLC_clone"))) TS_UpdateFulfillHTLC_clone(uint32_t orig) {
30464         LDKUpdateFulfillHTLC orig_conv;
30465         orig_conv.inner = (void*)(orig & (~1));
30466         orig_conv.is_owned = false;
30467         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30468         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
30469         uint32_t ret_ref = 0;
30470         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30471         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30472         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30473         ret_ref = (uintptr_t)ret_var.inner;
30474         if (ret_var.is_owned) {
30475                 ret_ref |= 1;
30476         }
30477         return ret_ref;
30478 }
30479
30480 void  __attribute__((export_name("TS_UpdateFailHTLC_free"))) TS_UpdateFailHTLC_free(uint32_t this_obj) {
30481         LDKUpdateFailHTLC this_obj_conv;
30482         this_obj_conv.inner = (void*)(this_obj & (~1));
30483         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30484         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30485         UpdateFailHTLC_free(this_obj_conv);
30486 }
30487
30488 int8_tArray  __attribute__((export_name("TS_UpdateFailHTLC_get_channel_id"))) TS_UpdateFailHTLC_get_channel_id(uint32_t this_ptr) {
30489         LDKUpdateFailHTLC this_ptr_conv;
30490         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30491         this_ptr_conv.is_owned = false;
30492         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30493         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30494         memcpy(ret_arr->elems, *UpdateFailHTLC_get_channel_id(&this_ptr_conv), 32);
30495         return ret_arr;
30496 }
30497
30498 void  __attribute__((export_name("TS_UpdateFailHTLC_set_channel_id"))) TS_UpdateFailHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
30499         LDKUpdateFailHTLC this_ptr_conv;
30500         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30501         this_ptr_conv.is_owned = false;
30502         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30503         LDKThirtyTwoBytes val_ref;
30504         CHECK(val->arr_len == 32);
30505         memcpy(val_ref.data, val->elems, 32); FREE(val);
30506         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
30507 }
30508
30509 int64_t  __attribute__((export_name("TS_UpdateFailHTLC_get_htlc_id"))) TS_UpdateFailHTLC_get_htlc_id(uint32_t this_ptr) {
30510         LDKUpdateFailHTLC this_ptr_conv;
30511         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30512         this_ptr_conv.is_owned = false;
30513         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30514         int64_t ret_conv = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
30515         return ret_conv;
30516 }
30517
30518 void  __attribute__((export_name("TS_UpdateFailHTLC_set_htlc_id"))) TS_UpdateFailHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
30519         LDKUpdateFailHTLC this_ptr_conv;
30520         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30521         this_ptr_conv.is_owned = false;
30522         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30523         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
30524 }
30525
30526 static inline uintptr_t UpdateFailHTLC_clone_ptr(LDKUpdateFailHTLC *NONNULL_PTR arg) {
30527         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(arg);
30528 uint32_t ret_ref = 0;
30529 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30530 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30531 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30532 ret_ref = (uintptr_t)ret_var.inner;
30533 if (ret_var.is_owned) {
30534         ret_ref |= 1;
30535 }
30536         return ret_ref;
30537 }
30538 uint32_t  __attribute__((export_name("TS_UpdateFailHTLC_clone_ptr"))) TS_UpdateFailHTLC_clone_ptr(uint32_t arg) {
30539         LDKUpdateFailHTLC arg_conv;
30540         arg_conv.inner = (void*)(arg & (~1));
30541         arg_conv.is_owned = false;
30542         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30543         uint32_t ret_conv = UpdateFailHTLC_clone_ptr(&arg_conv);
30544         return ret_conv;
30545 }
30546
30547 uint32_t  __attribute__((export_name("TS_UpdateFailHTLC_clone"))) TS_UpdateFailHTLC_clone(uint32_t orig) {
30548         LDKUpdateFailHTLC orig_conv;
30549         orig_conv.inner = (void*)(orig & (~1));
30550         orig_conv.is_owned = false;
30551         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30552         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
30553         uint32_t ret_ref = 0;
30554         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30555         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30556         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30557         ret_ref = (uintptr_t)ret_var.inner;
30558         if (ret_var.is_owned) {
30559                 ret_ref |= 1;
30560         }
30561         return ret_ref;
30562 }
30563
30564 void  __attribute__((export_name("TS_UpdateFailMalformedHTLC_free"))) TS_UpdateFailMalformedHTLC_free(uint32_t this_obj) {
30565         LDKUpdateFailMalformedHTLC this_obj_conv;
30566         this_obj_conv.inner = (void*)(this_obj & (~1));
30567         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30568         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30569         UpdateFailMalformedHTLC_free(this_obj_conv);
30570 }
30571
30572 int8_tArray  __attribute__((export_name("TS_UpdateFailMalformedHTLC_get_channel_id"))) TS_UpdateFailMalformedHTLC_get_channel_id(uint32_t this_ptr) {
30573         LDKUpdateFailMalformedHTLC this_ptr_conv;
30574         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30575         this_ptr_conv.is_owned = false;
30576         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30577         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30578         memcpy(ret_arr->elems, *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv), 32);
30579         return ret_arr;
30580 }
30581
30582 void  __attribute__((export_name("TS_UpdateFailMalformedHTLC_set_channel_id"))) TS_UpdateFailMalformedHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
30583         LDKUpdateFailMalformedHTLC this_ptr_conv;
30584         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30585         this_ptr_conv.is_owned = false;
30586         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30587         LDKThirtyTwoBytes val_ref;
30588         CHECK(val->arr_len == 32);
30589         memcpy(val_ref.data, val->elems, 32); FREE(val);
30590         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
30591 }
30592
30593 int64_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_get_htlc_id"))) TS_UpdateFailMalformedHTLC_get_htlc_id(uint32_t this_ptr) {
30594         LDKUpdateFailMalformedHTLC this_ptr_conv;
30595         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30596         this_ptr_conv.is_owned = false;
30597         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30598         int64_t ret_conv = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
30599         return ret_conv;
30600 }
30601
30602 void  __attribute__((export_name("TS_UpdateFailMalformedHTLC_set_htlc_id"))) TS_UpdateFailMalformedHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
30603         LDKUpdateFailMalformedHTLC this_ptr_conv;
30604         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30605         this_ptr_conv.is_owned = false;
30606         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30607         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
30608 }
30609
30610 int16_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_get_failure_code"))) TS_UpdateFailMalformedHTLC_get_failure_code(uint32_t this_ptr) {
30611         LDKUpdateFailMalformedHTLC this_ptr_conv;
30612         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30613         this_ptr_conv.is_owned = false;
30614         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30615         int16_t ret_conv = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
30616         return ret_conv;
30617 }
30618
30619 void  __attribute__((export_name("TS_UpdateFailMalformedHTLC_set_failure_code"))) TS_UpdateFailMalformedHTLC_set_failure_code(uint32_t this_ptr, int16_t val) {
30620         LDKUpdateFailMalformedHTLC this_ptr_conv;
30621         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30622         this_ptr_conv.is_owned = false;
30623         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30624         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
30625 }
30626
30627 static inline uintptr_t UpdateFailMalformedHTLC_clone_ptr(LDKUpdateFailMalformedHTLC *NONNULL_PTR arg) {
30628         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(arg);
30629 uint32_t ret_ref = 0;
30630 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30631 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30632 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30633 ret_ref = (uintptr_t)ret_var.inner;
30634 if (ret_var.is_owned) {
30635         ret_ref |= 1;
30636 }
30637         return ret_ref;
30638 }
30639 uint32_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_clone_ptr"))) TS_UpdateFailMalformedHTLC_clone_ptr(uint32_t arg) {
30640         LDKUpdateFailMalformedHTLC arg_conv;
30641         arg_conv.inner = (void*)(arg & (~1));
30642         arg_conv.is_owned = false;
30643         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30644         uint32_t ret_conv = UpdateFailMalformedHTLC_clone_ptr(&arg_conv);
30645         return ret_conv;
30646 }
30647
30648 uint32_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_clone"))) TS_UpdateFailMalformedHTLC_clone(uint32_t orig) {
30649         LDKUpdateFailMalformedHTLC orig_conv;
30650         orig_conv.inner = (void*)(orig & (~1));
30651         orig_conv.is_owned = false;
30652         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30653         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
30654         uint32_t ret_ref = 0;
30655         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30656         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30657         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30658         ret_ref = (uintptr_t)ret_var.inner;
30659         if (ret_var.is_owned) {
30660                 ret_ref |= 1;
30661         }
30662         return ret_ref;
30663 }
30664
30665 void  __attribute__((export_name("TS_CommitmentSigned_free"))) TS_CommitmentSigned_free(uint32_t this_obj) {
30666         LDKCommitmentSigned this_obj_conv;
30667         this_obj_conv.inner = (void*)(this_obj & (~1));
30668         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30669         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30670         CommitmentSigned_free(this_obj_conv);
30671 }
30672
30673 int8_tArray  __attribute__((export_name("TS_CommitmentSigned_get_channel_id"))) TS_CommitmentSigned_get_channel_id(uint32_t this_ptr) {
30674         LDKCommitmentSigned this_ptr_conv;
30675         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30676         this_ptr_conv.is_owned = false;
30677         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30678         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30679         memcpy(ret_arr->elems, *CommitmentSigned_get_channel_id(&this_ptr_conv), 32);
30680         return ret_arr;
30681 }
30682
30683 void  __attribute__((export_name("TS_CommitmentSigned_set_channel_id"))) TS_CommitmentSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
30684         LDKCommitmentSigned this_ptr_conv;
30685         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30686         this_ptr_conv.is_owned = false;
30687         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30688         LDKThirtyTwoBytes val_ref;
30689         CHECK(val->arr_len == 32);
30690         memcpy(val_ref.data, val->elems, 32); FREE(val);
30691         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
30692 }
30693
30694 int8_tArray  __attribute__((export_name("TS_CommitmentSigned_get_signature"))) TS_CommitmentSigned_get_signature(uint32_t this_ptr) {
30695         LDKCommitmentSigned this_ptr_conv;
30696         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30697         this_ptr_conv.is_owned = false;
30698         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30699         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
30700         memcpy(ret_arr->elems, CommitmentSigned_get_signature(&this_ptr_conv).compact_form, 64);
30701         return ret_arr;
30702 }
30703
30704 void  __attribute__((export_name("TS_CommitmentSigned_set_signature"))) TS_CommitmentSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
30705         LDKCommitmentSigned this_ptr_conv;
30706         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30707         this_ptr_conv.is_owned = false;
30708         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30709         LDKSignature val_ref;
30710         CHECK(val->arr_len == 64);
30711         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
30712         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
30713 }
30714
30715 ptrArray  __attribute__((export_name("TS_CommitmentSigned_get_htlc_signatures"))) TS_CommitmentSigned_get_htlc_signatures(uint32_t this_ptr) {
30716         LDKCommitmentSigned this_ptr_conv;
30717         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30718         this_ptr_conv.is_owned = false;
30719         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30720         LDKCVec_SignatureZ ret_var = CommitmentSigned_get_htlc_signatures(&this_ptr_conv);
30721         ptrArray ret_arr = NULL;
30722         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
30723         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 8);
30724         for (size_t m = 0; m < ret_var.datalen; m++) {
30725                 int8_tArray ret_conv_12_arr = init_int8_tArray(64, __LINE__);
30726                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].compact_form, 64);
30727                 ret_arr_ptr[m] = ret_conv_12_arr;
30728         }
30729         
30730         FREE(ret_var.data);
30731         return ret_arr;
30732 }
30733
30734 void  __attribute__((export_name("TS_CommitmentSigned_set_htlc_signatures"))) TS_CommitmentSigned_set_htlc_signatures(uint32_t this_ptr, ptrArray val) {
30735         LDKCommitmentSigned this_ptr_conv;
30736         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30737         this_ptr_conv.is_owned = false;
30738         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30739         LDKCVec_SignatureZ val_constr;
30740         val_constr.datalen = val->arr_len;
30741         if (val_constr.datalen > 0)
30742                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
30743         else
30744                 val_constr.data = NULL;
30745         int8_tArray* val_vals = (void*) val->elems;
30746         for (size_t m = 0; m < val_constr.datalen; m++) {
30747                 int8_tArray val_conv_12 = val_vals[m];
30748                 LDKSignature val_conv_12_ref;
30749                 CHECK(val_conv_12->arr_len == 64);
30750                 memcpy(val_conv_12_ref.compact_form, val_conv_12->elems, 64); FREE(val_conv_12);
30751                 val_constr.data[m] = val_conv_12_ref;
30752         }
30753         FREE(val);
30754         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
30755 }
30756
30757 uint32_t  __attribute__((export_name("TS_CommitmentSigned_new"))) TS_CommitmentSigned_new(int8_tArray channel_id_arg, int8_tArray signature_arg, ptrArray htlc_signatures_arg) {
30758         LDKThirtyTwoBytes channel_id_arg_ref;
30759         CHECK(channel_id_arg->arr_len == 32);
30760         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
30761         LDKSignature signature_arg_ref;
30762         CHECK(signature_arg->arr_len == 64);
30763         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
30764         LDKCVec_SignatureZ htlc_signatures_arg_constr;
30765         htlc_signatures_arg_constr.datalen = htlc_signatures_arg->arr_len;
30766         if (htlc_signatures_arg_constr.datalen > 0)
30767                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
30768         else
30769                 htlc_signatures_arg_constr.data = NULL;
30770         int8_tArray* htlc_signatures_arg_vals = (void*) htlc_signatures_arg->elems;
30771         for (size_t m = 0; m < htlc_signatures_arg_constr.datalen; m++) {
30772                 int8_tArray htlc_signatures_arg_conv_12 = htlc_signatures_arg_vals[m];
30773                 LDKSignature htlc_signatures_arg_conv_12_ref;
30774                 CHECK(htlc_signatures_arg_conv_12->arr_len == 64);
30775                 memcpy(htlc_signatures_arg_conv_12_ref.compact_form, htlc_signatures_arg_conv_12->elems, 64); FREE(htlc_signatures_arg_conv_12);
30776                 htlc_signatures_arg_constr.data[m] = htlc_signatures_arg_conv_12_ref;
30777         }
30778         FREE(htlc_signatures_arg);
30779         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
30780         uint32_t ret_ref = 0;
30781         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30782         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30783         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30784         ret_ref = (uintptr_t)ret_var.inner;
30785         if (ret_var.is_owned) {
30786                 ret_ref |= 1;
30787         }
30788         return ret_ref;
30789 }
30790
30791 static inline uintptr_t CommitmentSigned_clone_ptr(LDKCommitmentSigned *NONNULL_PTR arg) {
30792         LDKCommitmentSigned ret_var = CommitmentSigned_clone(arg);
30793 uint32_t ret_ref = 0;
30794 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30795 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30796 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30797 ret_ref = (uintptr_t)ret_var.inner;
30798 if (ret_var.is_owned) {
30799         ret_ref |= 1;
30800 }
30801         return ret_ref;
30802 }
30803 uint32_t  __attribute__((export_name("TS_CommitmentSigned_clone_ptr"))) TS_CommitmentSigned_clone_ptr(uint32_t arg) {
30804         LDKCommitmentSigned arg_conv;
30805         arg_conv.inner = (void*)(arg & (~1));
30806         arg_conv.is_owned = false;
30807         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30808         uint32_t ret_conv = CommitmentSigned_clone_ptr(&arg_conv);
30809         return ret_conv;
30810 }
30811
30812 uint32_t  __attribute__((export_name("TS_CommitmentSigned_clone"))) TS_CommitmentSigned_clone(uint32_t orig) {
30813         LDKCommitmentSigned orig_conv;
30814         orig_conv.inner = (void*)(orig & (~1));
30815         orig_conv.is_owned = false;
30816         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30817         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
30818         uint32_t ret_ref = 0;
30819         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30820         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30821         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30822         ret_ref = (uintptr_t)ret_var.inner;
30823         if (ret_var.is_owned) {
30824                 ret_ref |= 1;
30825         }
30826         return ret_ref;
30827 }
30828
30829 void  __attribute__((export_name("TS_RevokeAndACK_free"))) TS_RevokeAndACK_free(uint32_t this_obj) {
30830         LDKRevokeAndACK this_obj_conv;
30831         this_obj_conv.inner = (void*)(this_obj & (~1));
30832         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30833         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30834         RevokeAndACK_free(this_obj_conv);
30835 }
30836
30837 int8_tArray  __attribute__((export_name("TS_RevokeAndACK_get_channel_id"))) TS_RevokeAndACK_get_channel_id(uint32_t this_ptr) {
30838         LDKRevokeAndACK this_ptr_conv;
30839         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30840         this_ptr_conv.is_owned = false;
30841         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30842         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30843         memcpy(ret_arr->elems, *RevokeAndACK_get_channel_id(&this_ptr_conv), 32);
30844         return ret_arr;
30845 }
30846
30847 void  __attribute__((export_name("TS_RevokeAndACK_set_channel_id"))) TS_RevokeAndACK_set_channel_id(uint32_t this_ptr, int8_tArray val) {
30848         LDKRevokeAndACK this_ptr_conv;
30849         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30850         this_ptr_conv.is_owned = false;
30851         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30852         LDKThirtyTwoBytes val_ref;
30853         CHECK(val->arr_len == 32);
30854         memcpy(val_ref.data, val->elems, 32); FREE(val);
30855         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
30856 }
30857
30858 int8_tArray  __attribute__((export_name("TS_RevokeAndACK_get_per_commitment_secret"))) TS_RevokeAndACK_get_per_commitment_secret(uint32_t this_ptr) {
30859         LDKRevokeAndACK this_ptr_conv;
30860         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30861         this_ptr_conv.is_owned = false;
30862         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30863         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30864         memcpy(ret_arr->elems, *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv), 32);
30865         return ret_arr;
30866 }
30867
30868 void  __attribute__((export_name("TS_RevokeAndACK_set_per_commitment_secret"))) TS_RevokeAndACK_set_per_commitment_secret(uint32_t this_ptr, int8_tArray val) {
30869         LDKRevokeAndACK this_ptr_conv;
30870         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30871         this_ptr_conv.is_owned = false;
30872         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30873         LDKThirtyTwoBytes val_ref;
30874         CHECK(val->arr_len == 32);
30875         memcpy(val_ref.data, val->elems, 32); FREE(val);
30876         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
30877 }
30878
30879 int8_tArray  __attribute__((export_name("TS_RevokeAndACK_get_next_per_commitment_point"))) TS_RevokeAndACK_get_next_per_commitment_point(uint32_t this_ptr) {
30880         LDKRevokeAndACK this_ptr_conv;
30881         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30882         this_ptr_conv.is_owned = false;
30883         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30884         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
30885         memcpy(ret_arr->elems, RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
30886         return ret_arr;
30887 }
30888
30889 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) {
30890         LDKRevokeAndACK this_ptr_conv;
30891         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30892         this_ptr_conv.is_owned = false;
30893         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30894         LDKPublicKey val_ref;
30895         CHECK(val->arr_len == 33);
30896         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
30897         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
30898 }
30899
30900 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) {
30901         LDKThirtyTwoBytes channel_id_arg_ref;
30902         CHECK(channel_id_arg->arr_len == 32);
30903         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
30904         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
30905         CHECK(per_commitment_secret_arg->arr_len == 32);
30906         memcpy(per_commitment_secret_arg_ref.data, per_commitment_secret_arg->elems, 32); FREE(per_commitment_secret_arg);
30907         LDKPublicKey next_per_commitment_point_arg_ref;
30908         CHECK(next_per_commitment_point_arg->arr_len == 33);
30909         memcpy(next_per_commitment_point_arg_ref.compressed_form, next_per_commitment_point_arg->elems, 33); FREE(next_per_commitment_point_arg);
30910         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
30911         uint32_t ret_ref = 0;
30912         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30913         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30914         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30915         ret_ref = (uintptr_t)ret_var.inner;
30916         if (ret_var.is_owned) {
30917                 ret_ref |= 1;
30918         }
30919         return ret_ref;
30920 }
30921
30922 static inline uintptr_t RevokeAndACK_clone_ptr(LDKRevokeAndACK *NONNULL_PTR arg) {
30923         LDKRevokeAndACK ret_var = RevokeAndACK_clone(arg);
30924 uint32_t ret_ref = 0;
30925 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30926 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30927 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30928 ret_ref = (uintptr_t)ret_var.inner;
30929 if (ret_var.is_owned) {
30930         ret_ref |= 1;
30931 }
30932         return ret_ref;
30933 }
30934 uint32_t  __attribute__((export_name("TS_RevokeAndACK_clone_ptr"))) TS_RevokeAndACK_clone_ptr(uint32_t arg) {
30935         LDKRevokeAndACK arg_conv;
30936         arg_conv.inner = (void*)(arg & (~1));
30937         arg_conv.is_owned = false;
30938         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30939         uint32_t ret_conv = RevokeAndACK_clone_ptr(&arg_conv);
30940         return ret_conv;
30941 }
30942
30943 uint32_t  __attribute__((export_name("TS_RevokeAndACK_clone"))) TS_RevokeAndACK_clone(uint32_t orig) {
30944         LDKRevokeAndACK orig_conv;
30945         orig_conv.inner = (void*)(orig & (~1));
30946         orig_conv.is_owned = false;
30947         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30948         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
30949         uint32_t ret_ref = 0;
30950         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30951         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30952         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30953         ret_ref = (uintptr_t)ret_var.inner;
30954         if (ret_var.is_owned) {
30955                 ret_ref |= 1;
30956         }
30957         return ret_ref;
30958 }
30959
30960 void  __attribute__((export_name("TS_UpdateFee_free"))) TS_UpdateFee_free(uint32_t this_obj) {
30961         LDKUpdateFee this_obj_conv;
30962         this_obj_conv.inner = (void*)(this_obj & (~1));
30963         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30964         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30965         UpdateFee_free(this_obj_conv);
30966 }
30967
30968 int8_tArray  __attribute__((export_name("TS_UpdateFee_get_channel_id"))) TS_UpdateFee_get_channel_id(uint32_t this_ptr) {
30969         LDKUpdateFee this_ptr_conv;
30970         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30971         this_ptr_conv.is_owned = false;
30972         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30973         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30974         memcpy(ret_arr->elems, *UpdateFee_get_channel_id(&this_ptr_conv), 32);
30975         return ret_arr;
30976 }
30977
30978 void  __attribute__((export_name("TS_UpdateFee_set_channel_id"))) TS_UpdateFee_set_channel_id(uint32_t this_ptr, int8_tArray val) {
30979         LDKUpdateFee this_ptr_conv;
30980         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30981         this_ptr_conv.is_owned = false;
30982         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30983         LDKThirtyTwoBytes val_ref;
30984         CHECK(val->arr_len == 32);
30985         memcpy(val_ref.data, val->elems, 32); FREE(val);
30986         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
30987 }
30988
30989 int32_t  __attribute__((export_name("TS_UpdateFee_get_feerate_per_kw"))) TS_UpdateFee_get_feerate_per_kw(uint32_t this_ptr) {
30990         LDKUpdateFee this_ptr_conv;
30991         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30992         this_ptr_conv.is_owned = false;
30993         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30994         int32_t ret_conv = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
30995         return ret_conv;
30996 }
30997
30998 void  __attribute__((export_name("TS_UpdateFee_set_feerate_per_kw"))) TS_UpdateFee_set_feerate_per_kw(uint32_t this_ptr, int32_t val) {
30999         LDKUpdateFee this_ptr_conv;
31000         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31001         this_ptr_conv.is_owned = false;
31002         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31003         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
31004 }
31005
31006 uint32_t  __attribute__((export_name("TS_UpdateFee_new"))) TS_UpdateFee_new(int8_tArray channel_id_arg, int32_t feerate_per_kw_arg) {
31007         LDKThirtyTwoBytes channel_id_arg_ref;
31008         CHECK(channel_id_arg->arr_len == 32);
31009         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
31010         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
31011         uint32_t ret_ref = 0;
31012         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31013         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31014         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31015         ret_ref = (uintptr_t)ret_var.inner;
31016         if (ret_var.is_owned) {
31017                 ret_ref |= 1;
31018         }
31019         return ret_ref;
31020 }
31021
31022 static inline uintptr_t UpdateFee_clone_ptr(LDKUpdateFee *NONNULL_PTR arg) {
31023         LDKUpdateFee ret_var = UpdateFee_clone(arg);
31024 uint32_t ret_ref = 0;
31025 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31026 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31027 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31028 ret_ref = (uintptr_t)ret_var.inner;
31029 if (ret_var.is_owned) {
31030         ret_ref |= 1;
31031 }
31032         return ret_ref;
31033 }
31034 uint32_t  __attribute__((export_name("TS_UpdateFee_clone_ptr"))) TS_UpdateFee_clone_ptr(uint32_t arg) {
31035         LDKUpdateFee arg_conv;
31036         arg_conv.inner = (void*)(arg & (~1));
31037         arg_conv.is_owned = false;
31038         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31039         uint32_t ret_conv = UpdateFee_clone_ptr(&arg_conv);
31040         return ret_conv;
31041 }
31042
31043 uint32_t  __attribute__((export_name("TS_UpdateFee_clone"))) TS_UpdateFee_clone(uint32_t orig) {
31044         LDKUpdateFee orig_conv;
31045         orig_conv.inner = (void*)(orig & (~1));
31046         orig_conv.is_owned = false;
31047         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31048         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
31049         uint32_t ret_ref = 0;
31050         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31051         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31052         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31053         ret_ref = (uintptr_t)ret_var.inner;
31054         if (ret_var.is_owned) {
31055                 ret_ref |= 1;
31056         }
31057         return ret_ref;
31058 }
31059
31060 void  __attribute__((export_name("TS_DataLossProtect_free"))) TS_DataLossProtect_free(uint32_t this_obj) {
31061         LDKDataLossProtect this_obj_conv;
31062         this_obj_conv.inner = (void*)(this_obj & (~1));
31063         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31064         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31065         DataLossProtect_free(this_obj_conv);
31066 }
31067
31068 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) {
31069         LDKDataLossProtect this_ptr_conv;
31070         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31071         this_ptr_conv.is_owned = false;
31072         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31073         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
31074         memcpy(ret_arr->elems, *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv), 32);
31075         return ret_arr;
31076 }
31077
31078 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) {
31079         LDKDataLossProtect this_ptr_conv;
31080         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31081         this_ptr_conv.is_owned = false;
31082         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31083         LDKThirtyTwoBytes val_ref;
31084         CHECK(val->arr_len == 32);
31085         memcpy(val_ref.data, val->elems, 32); FREE(val);
31086         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
31087 }
31088
31089 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) {
31090         LDKDataLossProtect this_ptr_conv;
31091         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31092         this_ptr_conv.is_owned = false;
31093         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31094         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
31095         memcpy(ret_arr->elems, DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form, 33);
31096         return ret_arr;
31097 }
31098
31099 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) {
31100         LDKDataLossProtect this_ptr_conv;
31101         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31102         this_ptr_conv.is_owned = false;
31103         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31104         LDKPublicKey val_ref;
31105         CHECK(val->arr_len == 33);
31106         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
31107         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
31108 }
31109
31110 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) {
31111         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
31112         CHECK(your_last_per_commitment_secret_arg->arr_len == 32);
31113         memcpy(your_last_per_commitment_secret_arg_ref.data, your_last_per_commitment_secret_arg->elems, 32); FREE(your_last_per_commitment_secret_arg);
31114         LDKPublicKey my_current_per_commitment_point_arg_ref;
31115         CHECK(my_current_per_commitment_point_arg->arr_len == 33);
31116         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);
31117         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
31118         uint32_t ret_ref = 0;
31119         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31120         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31121         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31122         ret_ref = (uintptr_t)ret_var.inner;
31123         if (ret_var.is_owned) {
31124                 ret_ref |= 1;
31125         }
31126         return ret_ref;
31127 }
31128
31129 static inline uintptr_t DataLossProtect_clone_ptr(LDKDataLossProtect *NONNULL_PTR arg) {
31130         LDKDataLossProtect ret_var = DataLossProtect_clone(arg);
31131 uint32_t ret_ref = 0;
31132 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31133 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31134 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31135 ret_ref = (uintptr_t)ret_var.inner;
31136 if (ret_var.is_owned) {
31137         ret_ref |= 1;
31138 }
31139         return ret_ref;
31140 }
31141 uint32_t  __attribute__((export_name("TS_DataLossProtect_clone_ptr"))) TS_DataLossProtect_clone_ptr(uint32_t arg) {
31142         LDKDataLossProtect arg_conv;
31143         arg_conv.inner = (void*)(arg & (~1));
31144         arg_conv.is_owned = false;
31145         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31146         uint32_t ret_conv = DataLossProtect_clone_ptr(&arg_conv);
31147         return ret_conv;
31148 }
31149
31150 uint32_t  __attribute__((export_name("TS_DataLossProtect_clone"))) TS_DataLossProtect_clone(uint32_t orig) {
31151         LDKDataLossProtect orig_conv;
31152         orig_conv.inner = (void*)(orig & (~1));
31153         orig_conv.is_owned = false;
31154         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31155         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
31156         uint32_t ret_ref = 0;
31157         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31158         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31159         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31160         ret_ref = (uintptr_t)ret_var.inner;
31161         if (ret_var.is_owned) {
31162                 ret_ref |= 1;
31163         }
31164         return ret_ref;
31165 }
31166
31167 void  __attribute__((export_name("TS_ChannelReestablish_free"))) TS_ChannelReestablish_free(uint32_t this_obj) {
31168         LDKChannelReestablish this_obj_conv;
31169         this_obj_conv.inner = (void*)(this_obj & (~1));
31170         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31171         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31172         ChannelReestablish_free(this_obj_conv);
31173 }
31174
31175 int8_tArray  __attribute__((export_name("TS_ChannelReestablish_get_channel_id"))) TS_ChannelReestablish_get_channel_id(uint32_t this_ptr) {
31176         LDKChannelReestablish this_ptr_conv;
31177         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31178         this_ptr_conv.is_owned = false;
31179         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31180         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
31181         memcpy(ret_arr->elems, *ChannelReestablish_get_channel_id(&this_ptr_conv), 32);
31182         return ret_arr;
31183 }
31184
31185 void  __attribute__((export_name("TS_ChannelReestablish_set_channel_id"))) TS_ChannelReestablish_set_channel_id(uint32_t this_ptr, int8_tArray val) {
31186         LDKChannelReestablish this_ptr_conv;
31187         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31188         this_ptr_conv.is_owned = false;
31189         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31190         LDKThirtyTwoBytes val_ref;
31191         CHECK(val->arr_len == 32);
31192         memcpy(val_ref.data, val->elems, 32); FREE(val);
31193         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
31194 }
31195
31196 int64_t  __attribute__((export_name("TS_ChannelReestablish_get_next_local_commitment_number"))) TS_ChannelReestablish_get_next_local_commitment_number(uint32_t this_ptr) {
31197         LDKChannelReestablish this_ptr_conv;
31198         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31199         this_ptr_conv.is_owned = false;
31200         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31201         int64_t ret_conv = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
31202         return ret_conv;
31203 }
31204
31205 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) {
31206         LDKChannelReestablish this_ptr_conv;
31207         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31208         this_ptr_conv.is_owned = false;
31209         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31210         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
31211 }
31212
31213 int64_t  __attribute__((export_name("TS_ChannelReestablish_get_next_remote_commitment_number"))) TS_ChannelReestablish_get_next_remote_commitment_number(uint32_t this_ptr) {
31214         LDKChannelReestablish this_ptr_conv;
31215         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31216         this_ptr_conv.is_owned = false;
31217         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31218         int64_t ret_conv = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
31219         return ret_conv;
31220 }
31221
31222 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) {
31223         LDKChannelReestablish this_ptr_conv;
31224         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31225         this_ptr_conv.is_owned = false;
31226         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31227         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
31228 }
31229
31230 static inline uintptr_t ChannelReestablish_clone_ptr(LDKChannelReestablish *NONNULL_PTR arg) {
31231         LDKChannelReestablish ret_var = ChannelReestablish_clone(arg);
31232 uint32_t ret_ref = 0;
31233 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31234 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31235 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31236 ret_ref = (uintptr_t)ret_var.inner;
31237 if (ret_var.is_owned) {
31238         ret_ref |= 1;
31239 }
31240         return ret_ref;
31241 }
31242 uint32_t  __attribute__((export_name("TS_ChannelReestablish_clone_ptr"))) TS_ChannelReestablish_clone_ptr(uint32_t arg) {
31243         LDKChannelReestablish arg_conv;
31244         arg_conv.inner = (void*)(arg & (~1));
31245         arg_conv.is_owned = false;
31246         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31247         uint32_t ret_conv = ChannelReestablish_clone_ptr(&arg_conv);
31248         return ret_conv;
31249 }
31250
31251 uint32_t  __attribute__((export_name("TS_ChannelReestablish_clone"))) TS_ChannelReestablish_clone(uint32_t orig) {
31252         LDKChannelReestablish orig_conv;
31253         orig_conv.inner = (void*)(orig & (~1));
31254         orig_conv.is_owned = false;
31255         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31256         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
31257         uint32_t ret_ref = 0;
31258         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31259         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31260         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31261         ret_ref = (uintptr_t)ret_var.inner;
31262         if (ret_var.is_owned) {
31263                 ret_ref |= 1;
31264         }
31265         return ret_ref;
31266 }
31267
31268 void  __attribute__((export_name("TS_AnnouncementSignatures_free"))) TS_AnnouncementSignatures_free(uint32_t this_obj) {
31269         LDKAnnouncementSignatures this_obj_conv;
31270         this_obj_conv.inner = (void*)(this_obj & (~1));
31271         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31272         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31273         AnnouncementSignatures_free(this_obj_conv);
31274 }
31275
31276 int8_tArray  __attribute__((export_name("TS_AnnouncementSignatures_get_channel_id"))) TS_AnnouncementSignatures_get_channel_id(uint32_t this_ptr) {
31277         LDKAnnouncementSignatures this_ptr_conv;
31278         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31279         this_ptr_conv.is_owned = false;
31280         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31281         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
31282         memcpy(ret_arr->elems, *AnnouncementSignatures_get_channel_id(&this_ptr_conv), 32);
31283         return ret_arr;
31284 }
31285
31286 void  __attribute__((export_name("TS_AnnouncementSignatures_set_channel_id"))) TS_AnnouncementSignatures_set_channel_id(uint32_t this_ptr, int8_tArray val) {
31287         LDKAnnouncementSignatures this_ptr_conv;
31288         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31289         this_ptr_conv.is_owned = false;
31290         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31291         LDKThirtyTwoBytes val_ref;
31292         CHECK(val->arr_len == 32);
31293         memcpy(val_ref.data, val->elems, 32); FREE(val);
31294         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
31295 }
31296
31297 int64_t  __attribute__((export_name("TS_AnnouncementSignatures_get_short_channel_id"))) TS_AnnouncementSignatures_get_short_channel_id(uint32_t this_ptr) {
31298         LDKAnnouncementSignatures this_ptr_conv;
31299         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31300         this_ptr_conv.is_owned = false;
31301         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31302         int64_t ret_conv = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
31303         return ret_conv;
31304 }
31305
31306 void  __attribute__((export_name("TS_AnnouncementSignatures_set_short_channel_id"))) TS_AnnouncementSignatures_set_short_channel_id(uint32_t this_ptr, int64_t val) {
31307         LDKAnnouncementSignatures this_ptr_conv;
31308         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31309         this_ptr_conv.is_owned = false;
31310         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31311         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
31312 }
31313
31314 int8_tArray  __attribute__((export_name("TS_AnnouncementSignatures_get_node_signature"))) TS_AnnouncementSignatures_get_node_signature(uint32_t this_ptr) {
31315         LDKAnnouncementSignatures this_ptr_conv;
31316         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31317         this_ptr_conv.is_owned = false;
31318         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31319         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
31320         memcpy(ret_arr->elems, AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form, 64);
31321         return ret_arr;
31322 }
31323
31324 void  __attribute__((export_name("TS_AnnouncementSignatures_set_node_signature"))) TS_AnnouncementSignatures_set_node_signature(uint32_t this_ptr, int8_tArray val) {
31325         LDKAnnouncementSignatures this_ptr_conv;
31326         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31327         this_ptr_conv.is_owned = false;
31328         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31329         LDKSignature val_ref;
31330         CHECK(val->arr_len == 64);
31331         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
31332         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
31333 }
31334
31335 int8_tArray  __attribute__((export_name("TS_AnnouncementSignatures_get_bitcoin_signature"))) TS_AnnouncementSignatures_get_bitcoin_signature(uint32_t this_ptr) {
31336         LDKAnnouncementSignatures this_ptr_conv;
31337         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31338         this_ptr_conv.is_owned = false;
31339         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31340         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
31341         memcpy(ret_arr->elems, AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form, 64);
31342         return ret_arr;
31343 }
31344
31345 void  __attribute__((export_name("TS_AnnouncementSignatures_set_bitcoin_signature"))) TS_AnnouncementSignatures_set_bitcoin_signature(uint32_t this_ptr, int8_tArray val) {
31346         LDKAnnouncementSignatures this_ptr_conv;
31347         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31348         this_ptr_conv.is_owned = false;
31349         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31350         LDKSignature val_ref;
31351         CHECK(val->arr_len == 64);
31352         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
31353         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
31354 }
31355
31356 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) {
31357         LDKThirtyTwoBytes channel_id_arg_ref;
31358         CHECK(channel_id_arg->arr_len == 32);
31359         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
31360         LDKSignature node_signature_arg_ref;
31361         CHECK(node_signature_arg->arr_len == 64);
31362         memcpy(node_signature_arg_ref.compact_form, node_signature_arg->elems, 64); FREE(node_signature_arg);
31363         LDKSignature bitcoin_signature_arg_ref;
31364         CHECK(bitcoin_signature_arg->arr_len == 64);
31365         memcpy(bitcoin_signature_arg_ref.compact_form, bitcoin_signature_arg->elems, 64); FREE(bitcoin_signature_arg);
31366         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
31367         uint32_t ret_ref = 0;
31368         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31369         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31370         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31371         ret_ref = (uintptr_t)ret_var.inner;
31372         if (ret_var.is_owned) {
31373                 ret_ref |= 1;
31374         }
31375         return ret_ref;
31376 }
31377
31378 static inline uintptr_t AnnouncementSignatures_clone_ptr(LDKAnnouncementSignatures *NONNULL_PTR arg) {
31379         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(arg);
31380 uint32_t ret_ref = 0;
31381 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31382 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31383 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31384 ret_ref = (uintptr_t)ret_var.inner;
31385 if (ret_var.is_owned) {
31386         ret_ref |= 1;
31387 }
31388         return ret_ref;
31389 }
31390 uint32_t  __attribute__((export_name("TS_AnnouncementSignatures_clone_ptr"))) TS_AnnouncementSignatures_clone_ptr(uint32_t arg) {
31391         LDKAnnouncementSignatures arg_conv;
31392         arg_conv.inner = (void*)(arg & (~1));
31393         arg_conv.is_owned = false;
31394         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31395         uint32_t ret_conv = AnnouncementSignatures_clone_ptr(&arg_conv);
31396         return ret_conv;
31397 }
31398
31399 uint32_t  __attribute__((export_name("TS_AnnouncementSignatures_clone"))) TS_AnnouncementSignatures_clone(uint32_t orig) {
31400         LDKAnnouncementSignatures orig_conv;
31401         orig_conv.inner = (void*)(orig & (~1));
31402         orig_conv.is_owned = false;
31403         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31404         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
31405         uint32_t ret_ref = 0;
31406         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31407         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31408         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31409         ret_ref = (uintptr_t)ret_var.inner;
31410         if (ret_var.is_owned) {
31411                 ret_ref |= 1;
31412         }
31413         return ret_ref;
31414 }
31415
31416 void  __attribute__((export_name("TS_NetAddress_free"))) TS_NetAddress_free(uint32_t this_ptr) {
31417         if ((this_ptr & 1) != 0) return;
31418         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
31419         CHECK_ACCESS(this_ptr_ptr);
31420         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(this_ptr_ptr);
31421         FREE((void*)this_ptr);
31422         NetAddress_free(this_ptr_conv);
31423 }
31424
31425 static inline uintptr_t NetAddress_clone_ptr(LDKNetAddress *NONNULL_PTR arg) {
31426         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
31427         *ret_copy = NetAddress_clone(arg);
31428 uint32_t ret_ref = (uintptr_t)ret_copy;
31429         return ret_ref;
31430 }
31431 uint32_t  __attribute__((export_name("TS_NetAddress_clone_ptr"))) TS_NetAddress_clone_ptr(uint32_t arg) {
31432         LDKNetAddress* arg_conv = (LDKNetAddress*)arg;
31433         uint32_t ret_conv = NetAddress_clone_ptr(arg_conv);
31434         return ret_conv;
31435 }
31436
31437 uint32_t  __attribute__((export_name("TS_NetAddress_clone"))) TS_NetAddress_clone(uint32_t orig) {
31438         LDKNetAddress* orig_conv = (LDKNetAddress*)orig;
31439         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
31440         *ret_copy = NetAddress_clone(orig_conv);
31441         uint32_t ret_ref = (uintptr_t)ret_copy;
31442         return ret_ref;
31443 }
31444
31445 uint32_t  __attribute__((export_name("TS_NetAddress_ipv4"))) TS_NetAddress_ipv4(int8_tArray addr, int16_t port) {
31446         LDKFourBytes addr_ref;
31447         CHECK(addr->arr_len == 4);
31448         memcpy(addr_ref.data, addr->elems, 4); FREE(addr);
31449         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
31450         *ret_copy = NetAddress_ipv4(addr_ref, port);
31451         uint32_t ret_ref = (uintptr_t)ret_copy;
31452         return ret_ref;
31453 }
31454
31455 uint32_t  __attribute__((export_name("TS_NetAddress_ipv6"))) TS_NetAddress_ipv6(int8_tArray addr, int16_t port) {
31456         LDKSixteenBytes addr_ref;
31457         CHECK(addr->arr_len == 16);
31458         memcpy(addr_ref.data, addr->elems, 16); FREE(addr);
31459         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
31460         *ret_copy = NetAddress_ipv6(addr_ref, port);
31461         uint32_t ret_ref = (uintptr_t)ret_copy;
31462         return ret_ref;
31463 }
31464
31465 uint32_t  __attribute__((export_name("TS_NetAddress_onion_v2"))) TS_NetAddress_onion_v2(int8_tArray a) {
31466         LDKTwelveBytes a_ref;
31467         CHECK(a->arr_len == 12);
31468         memcpy(a_ref.data, a->elems, 12); FREE(a);
31469         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
31470         *ret_copy = NetAddress_onion_v2(a_ref);
31471         uint32_t ret_ref = (uintptr_t)ret_copy;
31472         return ret_ref;
31473 }
31474
31475 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) {
31476         LDKThirtyTwoBytes ed25519_pubkey_ref;
31477         CHECK(ed25519_pubkey->arr_len == 32);
31478         memcpy(ed25519_pubkey_ref.data, ed25519_pubkey->elems, 32); FREE(ed25519_pubkey);
31479         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
31480         *ret_copy = NetAddress_onion_v3(ed25519_pubkey_ref, checksum, version, port);
31481         uint32_t ret_ref = (uintptr_t)ret_copy;
31482         return ret_ref;
31483 }
31484
31485 uint32_t  __attribute__((export_name("TS_NetAddress_hostname"))) TS_NetAddress_hostname(uint32_t hostname, int16_t port) {
31486         LDKHostname hostname_conv;
31487         hostname_conv.inner = (void*)(hostname & (~1));
31488         hostname_conv.is_owned = (hostname & 1) || (hostname == 0);
31489         CHECK_INNER_FIELD_ACCESS_OR_NULL(hostname_conv);
31490         hostname_conv = Hostname_clone(&hostname_conv);
31491         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
31492         *ret_copy = NetAddress_hostname(hostname_conv, port);
31493         uint32_t ret_ref = (uintptr_t)ret_copy;
31494         return ret_ref;
31495 }
31496
31497 int8_tArray  __attribute__((export_name("TS_NetAddress_write"))) TS_NetAddress_write(uint32_t obj) {
31498         LDKNetAddress* obj_conv = (LDKNetAddress*)obj;
31499         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
31500         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31501         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31502         CVec_u8Z_free(ret_var);
31503         return ret_arr;
31504 }
31505
31506 uint32_t  __attribute__((export_name("TS_NetAddress_read"))) TS_NetAddress_read(int8_tArray ser) {
31507         LDKu8slice ser_ref;
31508         ser_ref.datalen = ser->arr_len;
31509         ser_ref.data = ser->elems;
31510         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
31511         *ret_conv = NetAddress_read(ser_ref);
31512         FREE(ser);
31513         return (uint32_t)ret_conv;
31514 }
31515
31516 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_free"))) TS_UnsignedNodeAnnouncement_free(uint32_t this_obj) {
31517         LDKUnsignedNodeAnnouncement this_obj_conv;
31518         this_obj_conv.inner = (void*)(this_obj & (~1));
31519         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31520         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31521         UnsignedNodeAnnouncement_free(this_obj_conv);
31522 }
31523
31524 uint32_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_features"))) TS_UnsignedNodeAnnouncement_get_features(uint32_t this_ptr) {
31525         LDKUnsignedNodeAnnouncement this_ptr_conv;
31526         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31527         this_ptr_conv.is_owned = false;
31528         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31529         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
31530         uint32_t ret_ref = 0;
31531         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31532         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31533         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31534         ret_ref = (uintptr_t)ret_var.inner;
31535         if (ret_var.is_owned) {
31536                 ret_ref |= 1;
31537         }
31538         return ret_ref;
31539 }
31540
31541 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_features"))) TS_UnsignedNodeAnnouncement_set_features(uint32_t this_ptr, uint32_t val) {
31542         LDKUnsignedNodeAnnouncement this_ptr_conv;
31543         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31544         this_ptr_conv.is_owned = false;
31545         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31546         LDKNodeFeatures val_conv;
31547         val_conv.inner = (void*)(val & (~1));
31548         val_conv.is_owned = (val & 1) || (val == 0);
31549         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31550         val_conv = NodeFeatures_clone(&val_conv);
31551         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
31552 }
31553
31554 int32_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_timestamp"))) TS_UnsignedNodeAnnouncement_get_timestamp(uint32_t this_ptr) {
31555         LDKUnsignedNodeAnnouncement this_ptr_conv;
31556         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31557         this_ptr_conv.is_owned = false;
31558         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31559         int32_t ret_conv = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
31560         return ret_conv;
31561 }
31562
31563 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_timestamp"))) TS_UnsignedNodeAnnouncement_set_timestamp(uint32_t this_ptr, int32_t val) {
31564         LDKUnsignedNodeAnnouncement this_ptr_conv;
31565         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31566         this_ptr_conv.is_owned = false;
31567         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31568         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
31569 }
31570
31571 int8_tArray  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_node_id"))) TS_UnsignedNodeAnnouncement_get_node_id(uint32_t this_ptr) {
31572         LDKUnsignedNodeAnnouncement this_ptr_conv;
31573         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31574         this_ptr_conv.is_owned = false;
31575         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31576         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
31577         memcpy(ret_arr->elems, UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form, 33);
31578         return ret_arr;
31579 }
31580
31581 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_node_id"))) TS_UnsignedNodeAnnouncement_set_node_id(uint32_t this_ptr, int8_tArray val) {
31582         LDKUnsignedNodeAnnouncement this_ptr_conv;
31583         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31584         this_ptr_conv.is_owned = false;
31585         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31586         LDKPublicKey val_ref;
31587         CHECK(val->arr_len == 33);
31588         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
31589         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
31590 }
31591
31592 int8_tArray  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_rgb"))) TS_UnsignedNodeAnnouncement_get_rgb(uint32_t this_ptr) {
31593         LDKUnsignedNodeAnnouncement this_ptr_conv;
31594         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31595         this_ptr_conv.is_owned = false;
31596         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31597         int8_tArray ret_arr = init_int8_tArray(3, __LINE__);
31598         memcpy(ret_arr->elems, *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv), 3);
31599         return ret_arr;
31600 }
31601
31602 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_rgb"))) TS_UnsignedNodeAnnouncement_set_rgb(uint32_t this_ptr, int8_tArray val) {
31603         LDKUnsignedNodeAnnouncement this_ptr_conv;
31604         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31605         this_ptr_conv.is_owned = false;
31606         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31607         LDKThreeBytes val_ref;
31608         CHECK(val->arr_len == 3);
31609         memcpy(val_ref.data, val->elems, 3); FREE(val);
31610         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
31611 }
31612
31613 int8_tArray  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_alias"))) TS_UnsignedNodeAnnouncement_get_alias(uint32_t this_ptr) {
31614         LDKUnsignedNodeAnnouncement this_ptr_conv;
31615         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31616         this_ptr_conv.is_owned = false;
31617         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31618         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
31619         memcpy(ret_arr->elems, *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv), 32);
31620         return ret_arr;
31621 }
31622
31623 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_alias"))) TS_UnsignedNodeAnnouncement_set_alias(uint32_t this_ptr, int8_tArray val) {
31624         LDKUnsignedNodeAnnouncement this_ptr_conv;
31625         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31626         this_ptr_conv.is_owned = false;
31627         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31628         LDKThirtyTwoBytes val_ref;
31629         CHECK(val->arr_len == 32);
31630         memcpy(val_ref.data, val->elems, 32); FREE(val);
31631         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
31632 }
31633
31634 uint32_tArray  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_addresses"))) TS_UnsignedNodeAnnouncement_get_addresses(uint32_t this_ptr) {
31635         LDKUnsignedNodeAnnouncement this_ptr_conv;
31636         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31637         this_ptr_conv.is_owned = false;
31638         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31639         LDKCVec_NetAddressZ ret_var = UnsignedNodeAnnouncement_get_addresses(&this_ptr_conv);
31640         uint32_tArray ret_arr = NULL;
31641         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
31642         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 8);
31643         for (size_t m = 0; m < ret_var.datalen; m++) {
31644                 LDKNetAddress *ret_conv_12_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
31645                 *ret_conv_12_copy = ret_var.data[m];
31646                 uint32_t ret_conv_12_ref = (uintptr_t)ret_conv_12_copy;
31647                 ret_arr_ptr[m] = ret_conv_12_ref;
31648         }
31649         
31650         FREE(ret_var.data);
31651         return ret_arr;
31652 }
31653
31654 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_addresses"))) TS_UnsignedNodeAnnouncement_set_addresses(uint32_t this_ptr, uint32_tArray val) {
31655         LDKUnsignedNodeAnnouncement this_ptr_conv;
31656         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31657         this_ptr_conv.is_owned = false;
31658         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31659         LDKCVec_NetAddressZ val_constr;
31660         val_constr.datalen = val->arr_len;
31661         if (val_constr.datalen > 0)
31662                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
31663         else
31664                 val_constr.data = NULL;
31665         uint32_t* val_vals = val->elems;
31666         for (size_t m = 0; m < val_constr.datalen; m++) {
31667                 uint32_t val_conv_12 = val_vals[m];
31668                 void* val_conv_12_ptr = (void*)(((uintptr_t)val_conv_12) & ~1);
31669                 CHECK_ACCESS(val_conv_12_ptr);
31670                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
31671                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)val_conv_12) & ~1));
31672                 val_constr.data[m] = val_conv_12_conv;
31673         }
31674         FREE(val);
31675         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
31676 }
31677
31678 static inline uintptr_t UnsignedNodeAnnouncement_clone_ptr(LDKUnsignedNodeAnnouncement *NONNULL_PTR arg) {
31679         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(arg);
31680 uint32_t ret_ref = 0;
31681 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31682 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31683 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31684 ret_ref = (uintptr_t)ret_var.inner;
31685 if (ret_var.is_owned) {
31686         ret_ref |= 1;
31687 }
31688         return ret_ref;
31689 }
31690 uint32_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_clone_ptr"))) TS_UnsignedNodeAnnouncement_clone_ptr(uint32_t arg) {
31691         LDKUnsignedNodeAnnouncement arg_conv;
31692         arg_conv.inner = (void*)(arg & (~1));
31693         arg_conv.is_owned = false;
31694         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31695         uint32_t ret_conv = UnsignedNodeAnnouncement_clone_ptr(&arg_conv);
31696         return ret_conv;
31697 }
31698
31699 uint32_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_clone"))) TS_UnsignedNodeAnnouncement_clone(uint32_t orig) {
31700         LDKUnsignedNodeAnnouncement orig_conv;
31701         orig_conv.inner = (void*)(orig & (~1));
31702         orig_conv.is_owned = false;
31703         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31704         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
31705         uint32_t ret_ref = 0;
31706         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31707         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31708         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31709         ret_ref = (uintptr_t)ret_var.inner;
31710         if (ret_var.is_owned) {
31711                 ret_ref |= 1;
31712         }
31713         return ret_ref;
31714 }
31715
31716 void  __attribute__((export_name("TS_NodeAnnouncement_free"))) TS_NodeAnnouncement_free(uint32_t this_obj) {
31717         LDKNodeAnnouncement this_obj_conv;
31718         this_obj_conv.inner = (void*)(this_obj & (~1));
31719         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31720         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31721         NodeAnnouncement_free(this_obj_conv);
31722 }
31723
31724 int8_tArray  __attribute__((export_name("TS_NodeAnnouncement_get_signature"))) TS_NodeAnnouncement_get_signature(uint32_t this_ptr) {
31725         LDKNodeAnnouncement this_ptr_conv;
31726         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31727         this_ptr_conv.is_owned = false;
31728         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31729         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
31730         memcpy(ret_arr->elems, NodeAnnouncement_get_signature(&this_ptr_conv).compact_form, 64);
31731         return ret_arr;
31732 }
31733
31734 void  __attribute__((export_name("TS_NodeAnnouncement_set_signature"))) TS_NodeAnnouncement_set_signature(uint32_t this_ptr, int8_tArray val) {
31735         LDKNodeAnnouncement this_ptr_conv;
31736         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31737         this_ptr_conv.is_owned = false;
31738         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31739         LDKSignature val_ref;
31740         CHECK(val->arr_len == 64);
31741         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
31742         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
31743 }
31744
31745 uint32_t  __attribute__((export_name("TS_NodeAnnouncement_get_contents"))) TS_NodeAnnouncement_get_contents(uint32_t this_ptr) {
31746         LDKNodeAnnouncement this_ptr_conv;
31747         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31748         this_ptr_conv.is_owned = false;
31749         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31750         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
31751         uint32_t ret_ref = 0;
31752         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31753         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31754         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31755         ret_ref = (uintptr_t)ret_var.inner;
31756         if (ret_var.is_owned) {
31757                 ret_ref |= 1;
31758         }
31759         return ret_ref;
31760 }
31761
31762 void  __attribute__((export_name("TS_NodeAnnouncement_set_contents"))) TS_NodeAnnouncement_set_contents(uint32_t this_ptr, uint32_t val) {
31763         LDKNodeAnnouncement this_ptr_conv;
31764         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31765         this_ptr_conv.is_owned = false;
31766         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31767         LDKUnsignedNodeAnnouncement val_conv;
31768         val_conv.inner = (void*)(val & (~1));
31769         val_conv.is_owned = (val & 1) || (val == 0);
31770         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31771         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
31772         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
31773 }
31774
31775 uint32_t  __attribute__((export_name("TS_NodeAnnouncement_new"))) TS_NodeAnnouncement_new(int8_tArray signature_arg, uint32_t contents_arg) {
31776         LDKSignature signature_arg_ref;
31777         CHECK(signature_arg->arr_len == 64);
31778         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
31779         LDKUnsignedNodeAnnouncement contents_arg_conv;
31780         contents_arg_conv.inner = (void*)(contents_arg & (~1));
31781         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
31782         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
31783         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
31784         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
31785         uint32_t ret_ref = 0;
31786         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31787         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31788         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31789         ret_ref = (uintptr_t)ret_var.inner;
31790         if (ret_var.is_owned) {
31791                 ret_ref |= 1;
31792         }
31793         return ret_ref;
31794 }
31795
31796 static inline uintptr_t NodeAnnouncement_clone_ptr(LDKNodeAnnouncement *NONNULL_PTR arg) {
31797         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(arg);
31798 uint32_t ret_ref = 0;
31799 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31800 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31801 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31802 ret_ref = (uintptr_t)ret_var.inner;
31803 if (ret_var.is_owned) {
31804         ret_ref |= 1;
31805 }
31806         return ret_ref;
31807 }
31808 uint32_t  __attribute__((export_name("TS_NodeAnnouncement_clone_ptr"))) TS_NodeAnnouncement_clone_ptr(uint32_t arg) {
31809         LDKNodeAnnouncement arg_conv;
31810         arg_conv.inner = (void*)(arg & (~1));
31811         arg_conv.is_owned = false;
31812         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31813         uint32_t ret_conv = NodeAnnouncement_clone_ptr(&arg_conv);
31814         return ret_conv;
31815 }
31816
31817 uint32_t  __attribute__((export_name("TS_NodeAnnouncement_clone"))) TS_NodeAnnouncement_clone(uint32_t orig) {
31818         LDKNodeAnnouncement orig_conv;
31819         orig_conv.inner = (void*)(orig & (~1));
31820         orig_conv.is_owned = false;
31821         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31822         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
31823         uint32_t ret_ref = 0;
31824         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31825         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31826         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31827         ret_ref = (uintptr_t)ret_var.inner;
31828         if (ret_var.is_owned) {
31829                 ret_ref |= 1;
31830         }
31831         return ret_ref;
31832 }
31833
31834 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_free"))) TS_UnsignedChannelAnnouncement_free(uint32_t this_obj) {
31835         LDKUnsignedChannelAnnouncement this_obj_conv;
31836         this_obj_conv.inner = (void*)(this_obj & (~1));
31837         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31838         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31839         UnsignedChannelAnnouncement_free(this_obj_conv);
31840 }
31841
31842 uint32_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_features"))) TS_UnsignedChannelAnnouncement_get_features(uint32_t this_ptr) {
31843         LDKUnsignedChannelAnnouncement this_ptr_conv;
31844         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31845         this_ptr_conv.is_owned = false;
31846         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31847         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
31848         uint32_t ret_ref = 0;
31849         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31850         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31851         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31852         ret_ref = (uintptr_t)ret_var.inner;
31853         if (ret_var.is_owned) {
31854                 ret_ref |= 1;
31855         }
31856         return ret_ref;
31857 }
31858
31859 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_features"))) TS_UnsignedChannelAnnouncement_set_features(uint32_t this_ptr, uint32_t val) {
31860         LDKUnsignedChannelAnnouncement this_ptr_conv;
31861         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31862         this_ptr_conv.is_owned = false;
31863         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31864         LDKChannelFeatures val_conv;
31865         val_conv.inner = (void*)(val & (~1));
31866         val_conv.is_owned = (val & 1) || (val == 0);
31867         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31868         val_conv = ChannelFeatures_clone(&val_conv);
31869         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
31870 }
31871
31872 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_chain_hash"))) TS_UnsignedChannelAnnouncement_get_chain_hash(uint32_t this_ptr) {
31873         LDKUnsignedChannelAnnouncement this_ptr_conv;
31874         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31875         this_ptr_conv.is_owned = false;
31876         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31877         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
31878         memcpy(ret_arr->elems, *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv), 32);
31879         return ret_arr;
31880 }
31881
31882 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_chain_hash"))) TS_UnsignedChannelAnnouncement_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
31883         LDKUnsignedChannelAnnouncement this_ptr_conv;
31884         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31885         this_ptr_conv.is_owned = false;
31886         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31887         LDKThirtyTwoBytes val_ref;
31888         CHECK(val->arr_len == 32);
31889         memcpy(val_ref.data, val->elems, 32); FREE(val);
31890         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
31891 }
31892
31893 int64_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_short_channel_id"))) TS_UnsignedChannelAnnouncement_get_short_channel_id(uint32_t this_ptr) {
31894         LDKUnsignedChannelAnnouncement this_ptr_conv;
31895         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31896         this_ptr_conv.is_owned = false;
31897         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31898         int64_t ret_conv = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
31899         return ret_conv;
31900 }
31901
31902 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_short_channel_id"))) TS_UnsignedChannelAnnouncement_set_short_channel_id(uint32_t this_ptr, int64_t val) {
31903         LDKUnsignedChannelAnnouncement this_ptr_conv;
31904         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31905         this_ptr_conv.is_owned = false;
31906         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31907         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
31908 }
31909
31910 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_node_id_1"))) TS_UnsignedChannelAnnouncement_get_node_id_1(uint32_t this_ptr) {
31911         LDKUnsignedChannelAnnouncement this_ptr_conv;
31912         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31913         this_ptr_conv.is_owned = false;
31914         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31915         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
31916         memcpy(ret_arr->elems, UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form, 33);
31917         return ret_arr;
31918 }
31919
31920 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_node_id_1"))) TS_UnsignedChannelAnnouncement_set_node_id_1(uint32_t this_ptr, int8_tArray val) {
31921         LDKUnsignedChannelAnnouncement this_ptr_conv;
31922         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31923         this_ptr_conv.is_owned = false;
31924         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31925         LDKPublicKey val_ref;
31926         CHECK(val->arr_len == 33);
31927         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
31928         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
31929 }
31930
31931 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_node_id_2"))) TS_UnsignedChannelAnnouncement_get_node_id_2(uint32_t this_ptr) {
31932         LDKUnsignedChannelAnnouncement this_ptr_conv;
31933         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31934         this_ptr_conv.is_owned = false;
31935         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31936         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
31937         memcpy(ret_arr->elems, UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form, 33);
31938         return ret_arr;
31939 }
31940
31941 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_node_id_2"))) TS_UnsignedChannelAnnouncement_set_node_id_2(uint32_t this_ptr, int8_tArray val) {
31942         LDKUnsignedChannelAnnouncement this_ptr_conv;
31943         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31944         this_ptr_conv.is_owned = false;
31945         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31946         LDKPublicKey val_ref;
31947         CHECK(val->arr_len == 33);
31948         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
31949         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
31950 }
31951
31952 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_bitcoin_key_1"))) TS_UnsignedChannelAnnouncement_get_bitcoin_key_1(uint32_t this_ptr) {
31953         LDKUnsignedChannelAnnouncement this_ptr_conv;
31954         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31955         this_ptr_conv.is_owned = false;
31956         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31957         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
31958         memcpy(ret_arr->elems, UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form, 33);
31959         return ret_arr;
31960 }
31961
31962 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_bitcoin_key_1"))) TS_UnsignedChannelAnnouncement_set_bitcoin_key_1(uint32_t this_ptr, int8_tArray val) {
31963         LDKUnsignedChannelAnnouncement this_ptr_conv;
31964         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31965         this_ptr_conv.is_owned = false;
31966         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31967         LDKPublicKey val_ref;
31968         CHECK(val->arr_len == 33);
31969         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
31970         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
31971 }
31972
31973 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_bitcoin_key_2"))) TS_UnsignedChannelAnnouncement_get_bitcoin_key_2(uint32_t this_ptr) {
31974         LDKUnsignedChannelAnnouncement this_ptr_conv;
31975         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31976         this_ptr_conv.is_owned = false;
31977         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31978         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
31979         memcpy(ret_arr->elems, UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form, 33);
31980         return ret_arr;
31981 }
31982
31983 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_bitcoin_key_2"))) TS_UnsignedChannelAnnouncement_set_bitcoin_key_2(uint32_t this_ptr, int8_tArray val) {
31984         LDKUnsignedChannelAnnouncement this_ptr_conv;
31985         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31986         this_ptr_conv.is_owned = false;
31987         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31988         LDKPublicKey val_ref;
31989         CHECK(val->arr_len == 33);
31990         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
31991         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
31992 }
31993
31994 static inline uintptr_t UnsignedChannelAnnouncement_clone_ptr(LDKUnsignedChannelAnnouncement *NONNULL_PTR arg) {
31995         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(arg);
31996 uint32_t ret_ref = 0;
31997 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31998 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31999 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32000 ret_ref = (uintptr_t)ret_var.inner;
32001 if (ret_var.is_owned) {
32002         ret_ref |= 1;
32003 }
32004         return ret_ref;
32005 }
32006 uint32_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_clone_ptr"))) TS_UnsignedChannelAnnouncement_clone_ptr(uint32_t arg) {
32007         LDKUnsignedChannelAnnouncement arg_conv;
32008         arg_conv.inner = (void*)(arg & (~1));
32009         arg_conv.is_owned = false;
32010         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32011         uint32_t ret_conv = UnsignedChannelAnnouncement_clone_ptr(&arg_conv);
32012         return ret_conv;
32013 }
32014
32015 uint32_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_clone"))) TS_UnsignedChannelAnnouncement_clone(uint32_t orig) {
32016         LDKUnsignedChannelAnnouncement orig_conv;
32017         orig_conv.inner = (void*)(orig & (~1));
32018         orig_conv.is_owned = false;
32019         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32020         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
32021         uint32_t ret_ref = 0;
32022         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32023         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32024         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32025         ret_ref = (uintptr_t)ret_var.inner;
32026         if (ret_var.is_owned) {
32027                 ret_ref |= 1;
32028         }
32029         return ret_ref;
32030 }
32031
32032 void  __attribute__((export_name("TS_ChannelAnnouncement_free"))) TS_ChannelAnnouncement_free(uint32_t this_obj) {
32033         LDKChannelAnnouncement this_obj_conv;
32034         this_obj_conv.inner = (void*)(this_obj & (~1));
32035         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32036         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32037         ChannelAnnouncement_free(this_obj_conv);
32038 }
32039
32040 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_get_node_signature_1"))) TS_ChannelAnnouncement_get_node_signature_1(uint32_t this_ptr) {
32041         LDKChannelAnnouncement this_ptr_conv;
32042         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32043         this_ptr_conv.is_owned = false;
32044         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32045         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
32046         memcpy(ret_arr->elems, ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form, 64);
32047         return ret_arr;
32048 }
32049
32050 void  __attribute__((export_name("TS_ChannelAnnouncement_set_node_signature_1"))) TS_ChannelAnnouncement_set_node_signature_1(uint32_t this_ptr, int8_tArray val) {
32051         LDKChannelAnnouncement this_ptr_conv;
32052         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32053         this_ptr_conv.is_owned = false;
32054         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32055         LDKSignature val_ref;
32056         CHECK(val->arr_len == 64);
32057         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
32058         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
32059 }
32060
32061 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_get_node_signature_2"))) TS_ChannelAnnouncement_get_node_signature_2(uint32_t this_ptr) {
32062         LDKChannelAnnouncement this_ptr_conv;
32063         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32064         this_ptr_conv.is_owned = false;
32065         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32066         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
32067         memcpy(ret_arr->elems, ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form, 64);
32068         return ret_arr;
32069 }
32070
32071 void  __attribute__((export_name("TS_ChannelAnnouncement_set_node_signature_2"))) TS_ChannelAnnouncement_set_node_signature_2(uint32_t this_ptr, int8_tArray val) {
32072         LDKChannelAnnouncement this_ptr_conv;
32073         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32074         this_ptr_conv.is_owned = false;
32075         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32076         LDKSignature val_ref;
32077         CHECK(val->arr_len == 64);
32078         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
32079         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
32080 }
32081
32082 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_get_bitcoin_signature_1"))) TS_ChannelAnnouncement_get_bitcoin_signature_1(uint32_t this_ptr) {
32083         LDKChannelAnnouncement this_ptr_conv;
32084         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32085         this_ptr_conv.is_owned = false;
32086         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32087         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
32088         memcpy(ret_arr->elems, ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form, 64);
32089         return ret_arr;
32090 }
32091
32092 void  __attribute__((export_name("TS_ChannelAnnouncement_set_bitcoin_signature_1"))) TS_ChannelAnnouncement_set_bitcoin_signature_1(uint32_t this_ptr, int8_tArray val) {
32093         LDKChannelAnnouncement this_ptr_conv;
32094         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32095         this_ptr_conv.is_owned = false;
32096         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32097         LDKSignature val_ref;
32098         CHECK(val->arr_len == 64);
32099         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
32100         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
32101 }
32102
32103 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_get_bitcoin_signature_2"))) TS_ChannelAnnouncement_get_bitcoin_signature_2(uint32_t this_ptr) {
32104         LDKChannelAnnouncement this_ptr_conv;
32105         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32106         this_ptr_conv.is_owned = false;
32107         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32108         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
32109         memcpy(ret_arr->elems, ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form, 64);
32110         return ret_arr;
32111 }
32112
32113 void  __attribute__((export_name("TS_ChannelAnnouncement_set_bitcoin_signature_2"))) TS_ChannelAnnouncement_set_bitcoin_signature_2(uint32_t this_ptr, int8_tArray val) {
32114         LDKChannelAnnouncement this_ptr_conv;
32115         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32116         this_ptr_conv.is_owned = false;
32117         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32118         LDKSignature val_ref;
32119         CHECK(val->arr_len == 64);
32120         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
32121         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
32122 }
32123
32124 uint32_t  __attribute__((export_name("TS_ChannelAnnouncement_get_contents"))) TS_ChannelAnnouncement_get_contents(uint32_t this_ptr) {
32125         LDKChannelAnnouncement this_ptr_conv;
32126         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32127         this_ptr_conv.is_owned = false;
32128         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32129         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
32130         uint32_t ret_ref = 0;
32131         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32132         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32133         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32134         ret_ref = (uintptr_t)ret_var.inner;
32135         if (ret_var.is_owned) {
32136                 ret_ref |= 1;
32137         }
32138         return ret_ref;
32139 }
32140
32141 void  __attribute__((export_name("TS_ChannelAnnouncement_set_contents"))) TS_ChannelAnnouncement_set_contents(uint32_t this_ptr, uint32_t val) {
32142         LDKChannelAnnouncement this_ptr_conv;
32143         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32144         this_ptr_conv.is_owned = false;
32145         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32146         LDKUnsignedChannelAnnouncement val_conv;
32147         val_conv.inner = (void*)(val & (~1));
32148         val_conv.is_owned = (val & 1) || (val == 0);
32149         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32150         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
32151         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
32152 }
32153
32154 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) {
32155         LDKSignature node_signature_1_arg_ref;
32156         CHECK(node_signature_1_arg->arr_len == 64);
32157         memcpy(node_signature_1_arg_ref.compact_form, node_signature_1_arg->elems, 64); FREE(node_signature_1_arg);
32158         LDKSignature node_signature_2_arg_ref;
32159         CHECK(node_signature_2_arg->arr_len == 64);
32160         memcpy(node_signature_2_arg_ref.compact_form, node_signature_2_arg->elems, 64); FREE(node_signature_2_arg);
32161         LDKSignature bitcoin_signature_1_arg_ref;
32162         CHECK(bitcoin_signature_1_arg->arr_len == 64);
32163         memcpy(bitcoin_signature_1_arg_ref.compact_form, bitcoin_signature_1_arg->elems, 64); FREE(bitcoin_signature_1_arg);
32164         LDKSignature bitcoin_signature_2_arg_ref;
32165         CHECK(bitcoin_signature_2_arg->arr_len == 64);
32166         memcpy(bitcoin_signature_2_arg_ref.compact_form, bitcoin_signature_2_arg->elems, 64); FREE(bitcoin_signature_2_arg);
32167         LDKUnsignedChannelAnnouncement contents_arg_conv;
32168         contents_arg_conv.inner = (void*)(contents_arg & (~1));
32169         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
32170         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
32171         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
32172         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);
32173         uint32_t ret_ref = 0;
32174         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32175         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32176         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32177         ret_ref = (uintptr_t)ret_var.inner;
32178         if (ret_var.is_owned) {
32179                 ret_ref |= 1;
32180         }
32181         return ret_ref;
32182 }
32183
32184 static inline uintptr_t ChannelAnnouncement_clone_ptr(LDKChannelAnnouncement *NONNULL_PTR arg) {
32185         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(arg);
32186 uint32_t ret_ref = 0;
32187 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32188 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32189 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32190 ret_ref = (uintptr_t)ret_var.inner;
32191 if (ret_var.is_owned) {
32192         ret_ref |= 1;
32193 }
32194         return ret_ref;
32195 }
32196 uint32_t  __attribute__((export_name("TS_ChannelAnnouncement_clone_ptr"))) TS_ChannelAnnouncement_clone_ptr(uint32_t arg) {
32197         LDKChannelAnnouncement arg_conv;
32198         arg_conv.inner = (void*)(arg & (~1));
32199         arg_conv.is_owned = false;
32200         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32201         uint32_t ret_conv = ChannelAnnouncement_clone_ptr(&arg_conv);
32202         return ret_conv;
32203 }
32204
32205 uint32_t  __attribute__((export_name("TS_ChannelAnnouncement_clone"))) TS_ChannelAnnouncement_clone(uint32_t orig) {
32206         LDKChannelAnnouncement orig_conv;
32207         orig_conv.inner = (void*)(orig & (~1));
32208         orig_conv.is_owned = false;
32209         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32210         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
32211         uint32_t ret_ref = 0;
32212         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32213         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32214         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32215         ret_ref = (uintptr_t)ret_var.inner;
32216         if (ret_var.is_owned) {
32217                 ret_ref |= 1;
32218         }
32219         return ret_ref;
32220 }
32221
32222 void  __attribute__((export_name("TS_UnsignedChannelUpdate_free"))) TS_UnsignedChannelUpdate_free(uint32_t this_obj) {
32223         LDKUnsignedChannelUpdate this_obj_conv;
32224         this_obj_conv.inner = (void*)(this_obj & (~1));
32225         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32226         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32227         UnsignedChannelUpdate_free(this_obj_conv);
32228 }
32229
32230 int8_tArray  __attribute__((export_name("TS_UnsignedChannelUpdate_get_chain_hash"))) TS_UnsignedChannelUpdate_get_chain_hash(uint32_t this_ptr) {
32231         LDKUnsignedChannelUpdate this_ptr_conv;
32232         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32233         this_ptr_conv.is_owned = false;
32234         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32235         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
32236         memcpy(ret_arr->elems, *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv), 32);
32237         return ret_arr;
32238 }
32239
32240 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_chain_hash"))) TS_UnsignedChannelUpdate_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
32241         LDKUnsignedChannelUpdate this_ptr_conv;
32242         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32243         this_ptr_conv.is_owned = false;
32244         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32245         LDKThirtyTwoBytes val_ref;
32246         CHECK(val->arr_len == 32);
32247         memcpy(val_ref.data, val->elems, 32); FREE(val);
32248         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
32249 }
32250
32251 int64_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_short_channel_id"))) TS_UnsignedChannelUpdate_get_short_channel_id(uint32_t this_ptr) {
32252         LDKUnsignedChannelUpdate this_ptr_conv;
32253         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32254         this_ptr_conv.is_owned = false;
32255         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32256         int64_t ret_conv = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
32257         return ret_conv;
32258 }
32259
32260 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_short_channel_id"))) TS_UnsignedChannelUpdate_set_short_channel_id(uint32_t this_ptr, int64_t val) {
32261         LDKUnsignedChannelUpdate this_ptr_conv;
32262         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32263         this_ptr_conv.is_owned = false;
32264         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32265         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
32266 }
32267
32268 int32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_timestamp"))) TS_UnsignedChannelUpdate_get_timestamp(uint32_t this_ptr) {
32269         LDKUnsignedChannelUpdate this_ptr_conv;
32270         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32271         this_ptr_conv.is_owned = false;
32272         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32273         int32_t ret_conv = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
32274         return ret_conv;
32275 }
32276
32277 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_timestamp"))) TS_UnsignedChannelUpdate_set_timestamp(uint32_t this_ptr, int32_t val) {
32278         LDKUnsignedChannelUpdate this_ptr_conv;
32279         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32280         this_ptr_conv.is_owned = false;
32281         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32282         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
32283 }
32284
32285 int8_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_flags"))) TS_UnsignedChannelUpdate_get_flags(uint32_t this_ptr) {
32286         LDKUnsignedChannelUpdate this_ptr_conv;
32287         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32288         this_ptr_conv.is_owned = false;
32289         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32290         int8_t ret_conv = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
32291         return ret_conv;
32292 }
32293
32294 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_flags"))) TS_UnsignedChannelUpdate_set_flags(uint32_t this_ptr, int8_t val) {
32295         LDKUnsignedChannelUpdate this_ptr_conv;
32296         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32297         this_ptr_conv.is_owned = false;
32298         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32299         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
32300 }
32301
32302 int16_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_cltv_expiry_delta"))) TS_UnsignedChannelUpdate_get_cltv_expiry_delta(uint32_t this_ptr) {
32303         LDKUnsignedChannelUpdate this_ptr_conv;
32304         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32305         this_ptr_conv.is_owned = false;
32306         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32307         int16_t ret_conv = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
32308         return ret_conv;
32309 }
32310
32311 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_cltv_expiry_delta"))) TS_UnsignedChannelUpdate_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
32312         LDKUnsignedChannelUpdate this_ptr_conv;
32313         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32314         this_ptr_conv.is_owned = false;
32315         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32316         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
32317 }
32318
32319 int64_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_htlc_minimum_msat"))) TS_UnsignedChannelUpdate_get_htlc_minimum_msat(uint32_t this_ptr) {
32320         LDKUnsignedChannelUpdate this_ptr_conv;
32321         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32322         this_ptr_conv.is_owned = false;
32323         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32324         int64_t ret_conv = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
32325         return ret_conv;
32326 }
32327
32328 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_htlc_minimum_msat"))) TS_UnsignedChannelUpdate_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
32329         LDKUnsignedChannelUpdate this_ptr_conv;
32330         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32331         this_ptr_conv.is_owned = false;
32332         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32333         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
32334 }
32335
32336 int64_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_htlc_maximum_msat"))) TS_UnsignedChannelUpdate_get_htlc_maximum_msat(uint32_t this_ptr) {
32337         LDKUnsignedChannelUpdate this_ptr_conv;
32338         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32339         this_ptr_conv.is_owned = false;
32340         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32341         int64_t ret_conv = UnsignedChannelUpdate_get_htlc_maximum_msat(&this_ptr_conv);
32342         return ret_conv;
32343 }
32344
32345 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_htlc_maximum_msat"))) TS_UnsignedChannelUpdate_set_htlc_maximum_msat(uint32_t this_ptr, int64_t val) {
32346         LDKUnsignedChannelUpdate this_ptr_conv;
32347         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32348         this_ptr_conv.is_owned = false;
32349         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32350         UnsignedChannelUpdate_set_htlc_maximum_msat(&this_ptr_conv, val);
32351 }
32352
32353 int32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_fee_base_msat"))) TS_UnsignedChannelUpdate_get_fee_base_msat(uint32_t this_ptr) {
32354         LDKUnsignedChannelUpdate this_ptr_conv;
32355         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32356         this_ptr_conv.is_owned = false;
32357         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32358         int32_t ret_conv = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
32359         return ret_conv;
32360 }
32361
32362 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_fee_base_msat"))) TS_UnsignedChannelUpdate_set_fee_base_msat(uint32_t this_ptr, int32_t val) {
32363         LDKUnsignedChannelUpdate this_ptr_conv;
32364         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32365         this_ptr_conv.is_owned = false;
32366         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32367         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
32368 }
32369
32370 int32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_fee_proportional_millionths"))) TS_UnsignedChannelUpdate_get_fee_proportional_millionths(uint32_t this_ptr) {
32371         LDKUnsignedChannelUpdate this_ptr_conv;
32372         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32373         this_ptr_conv.is_owned = false;
32374         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32375         int32_t ret_conv = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
32376         return ret_conv;
32377 }
32378
32379 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_fee_proportional_millionths"))) TS_UnsignedChannelUpdate_set_fee_proportional_millionths(uint32_t this_ptr, int32_t val) {
32380         LDKUnsignedChannelUpdate this_ptr_conv;
32381         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32382         this_ptr_conv.is_owned = false;
32383         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32384         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
32385 }
32386
32387 int8_tArray  __attribute__((export_name("TS_UnsignedChannelUpdate_get_excess_data"))) TS_UnsignedChannelUpdate_get_excess_data(uint32_t this_ptr) {
32388         LDKUnsignedChannelUpdate this_ptr_conv;
32389         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32390         this_ptr_conv.is_owned = false;
32391         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32392         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_get_excess_data(&this_ptr_conv);
32393         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32394         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32395         CVec_u8Z_free(ret_var);
32396         return ret_arr;
32397 }
32398
32399 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_excess_data"))) TS_UnsignedChannelUpdate_set_excess_data(uint32_t this_ptr, int8_tArray val) {
32400         LDKUnsignedChannelUpdate this_ptr_conv;
32401         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32402         this_ptr_conv.is_owned = false;
32403         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32404         LDKCVec_u8Z val_ref;
32405         val_ref.datalen = val->arr_len;
32406         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
32407         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
32408         UnsignedChannelUpdate_set_excess_data(&this_ptr_conv, val_ref);
32409 }
32410
32411 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) {
32412         LDKThirtyTwoBytes chain_hash_arg_ref;
32413         CHECK(chain_hash_arg->arr_len == 32);
32414         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
32415         LDKCVec_u8Z excess_data_arg_ref;
32416         excess_data_arg_ref.datalen = excess_data_arg->arr_len;
32417         excess_data_arg_ref.data = MALLOC(excess_data_arg_ref.datalen, "LDKCVec_u8Z Bytes");
32418         memcpy(excess_data_arg_ref.data, excess_data_arg->elems, excess_data_arg_ref.datalen); FREE(excess_data_arg);
32419         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);
32420         uint32_t ret_ref = 0;
32421         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32422         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32423         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32424         ret_ref = (uintptr_t)ret_var.inner;
32425         if (ret_var.is_owned) {
32426                 ret_ref |= 1;
32427         }
32428         return ret_ref;
32429 }
32430
32431 static inline uintptr_t UnsignedChannelUpdate_clone_ptr(LDKUnsignedChannelUpdate *NONNULL_PTR arg) {
32432         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(arg);
32433 uint32_t ret_ref = 0;
32434 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32435 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32436 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32437 ret_ref = (uintptr_t)ret_var.inner;
32438 if (ret_var.is_owned) {
32439         ret_ref |= 1;
32440 }
32441         return ret_ref;
32442 }
32443 uint32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_clone_ptr"))) TS_UnsignedChannelUpdate_clone_ptr(uint32_t arg) {
32444         LDKUnsignedChannelUpdate arg_conv;
32445         arg_conv.inner = (void*)(arg & (~1));
32446         arg_conv.is_owned = false;
32447         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32448         uint32_t ret_conv = UnsignedChannelUpdate_clone_ptr(&arg_conv);
32449         return ret_conv;
32450 }
32451
32452 uint32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_clone"))) TS_UnsignedChannelUpdate_clone(uint32_t orig) {
32453         LDKUnsignedChannelUpdate orig_conv;
32454         orig_conv.inner = (void*)(orig & (~1));
32455         orig_conv.is_owned = false;
32456         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32457         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
32458         uint32_t ret_ref = 0;
32459         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32460         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32461         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32462         ret_ref = (uintptr_t)ret_var.inner;
32463         if (ret_var.is_owned) {
32464                 ret_ref |= 1;
32465         }
32466         return ret_ref;
32467 }
32468
32469 void  __attribute__((export_name("TS_ChannelUpdate_free"))) TS_ChannelUpdate_free(uint32_t this_obj) {
32470         LDKChannelUpdate this_obj_conv;
32471         this_obj_conv.inner = (void*)(this_obj & (~1));
32472         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32473         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32474         ChannelUpdate_free(this_obj_conv);
32475 }
32476
32477 int8_tArray  __attribute__((export_name("TS_ChannelUpdate_get_signature"))) TS_ChannelUpdate_get_signature(uint32_t this_ptr) {
32478         LDKChannelUpdate this_ptr_conv;
32479         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32480         this_ptr_conv.is_owned = false;
32481         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32482         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
32483         memcpy(ret_arr->elems, ChannelUpdate_get_signature(&this_ptr_conv).compact_form, 64);
32484         return ret_arr;
32485 }
32486
32487 void  __attribute__((export_name("TS_ChannelUpdate_set_signature"))) TS_ChannelUpdate_set_signature(uint32_t this_ptr, int8_tArray val) {
32488         LDKChannelUpdate this_ptr_conv;
32489         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32490         this_ptr_conv.is_owned = false;
32491         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32492         LDKSignature val_ref;
32493         CHECK(val->arr_len == 64);
32494         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
32495         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
32496 }
32497
32498 uint32_t  __attribute__((export_name("TS_ChannelUpdate_get_contents"))) TS_ChannelUpdate_get_contents(uint32_t this_ptr) {
32499         LDKChannelUpdate this_ptr_conv;
32500         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32501         this_ptr_conv.is_owned = false;
32502         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32503         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
32504         uint32_t ret_ref = 0;
32505         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32506         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32507         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32508         ret_ref = (uintptr_t)ret_var.inner;
32509         if (ret_var.is_owned) {
32510                 ret_ref |= 1;
32511         }
32512         return ret_ref;
32513 }
32514
32515 void  __attribute__((export_name("TS_ChannelUpdate_set_contents"))) TS_ChannelUpdate_set_contents(uint32_t this_ptr, uint32_t val) {
32516         LDKChannelUpdate this_ptr_conv;
32517         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32518         this_ptr_conv.is_owned = false;
32519         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32520         LDKUnsignedChannelUpdate val_conv;
32521         val_conv.inner = (void*)(val & (~1));
32522         val_conv.is_owned = (val & 1) || (val == 0);
32523         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32524         val_conv = UnsignedChannelUpdate_clone(&val_conv);
32525         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
32526 }
32527
32528 uint32_t  __attribute__((export_name("TS_ChannelUpdate_new"))) TS_ChannelUpdate_new(int8_tArray signature_arg, uint32_t contents_arg) {
32529         LDKSignature signature_arg_ref;
32530         CHECK(signature_arg->arr_len == 64);
32531         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
32532         LDKUnsignedChannelUpdate contents_arg_conv;
32533         contents_arg_conv.inner = (void*)(contents_arg & (~1));
32534         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
32535         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
32536         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
32537         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
32538         uint32_t ret_ref = 0;
32539         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32540         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32541         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32542         ret_ref = (uintptr_t)ret_var.inner;
32543         if (ret_var.is_owned) {
32544                 ret_ref |= 1;
32545         }
32546         return ret_ref;
32547 }
32548
32549 static inline uintptr_t ChannelUpdate_clone_ptr(LDKChannelUpdate *NONNULL_PTR arg) {
32550         LDKChannelUpdate ret_var = ChannelUpdate_clone(arg);
32551 uint32_t ret_ref = 0;
32552 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32553 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32554 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32555 ret_ref = (uintptr_t)ret_var.inner;
32556 if (ret_var.is_owned) {
32557         ret_ref |= 1;
32558 }
32559         return ret_ref;
32560 }
32561 uint32_t  __attribute__((export_name("TS_ChannelUpdate_clone_ptr"))) TS_ChannelUpdate_clone_ptr(uint32_t arg) {
32562         LDKChannelUpdate arg_conv;
32563         arg_conv.inner = (void*)(arg & (~1));
32564         arg_conv.is_owned = false;
32565         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32566         uint32_t ret_conv = ChannelUpdate_clone_ptr(&arg_conv);
32567         return ret_conv;
32568 }
32569
32570 uint32_t  __attribute__((export_name("TS_ChannelUpdate_clone"))) TS_ChannelUpdate_clone(uint32_t orig) {
32571         LDKChannelUpdate orig_conv;
32572         orig_conv.inner = (void*)(orig & (~1));
32573         orig_conv.is_owned = false;
32574         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32575         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
32576         uint32_t ret_ref = 0;
32577         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32578         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32579         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32580         ret_ref = (uintptr_t)ret_var.inner;
32581         if (ret_var.is_owned) {
32582                 ret_ref |= 1;
32583         }
32584         return ret_ref;
32585 }
32586
32587 void  __attribute__((export_name("TS_QueryChannelRange_free"))) TS_QueryChannelRange_free(uint32_t this_obj) {
32588         LDKQueryChannelRange this_obj_conv;
32589         this_obj_conv.inner = (void*)(this_obj & (~1));
32590         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32591         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32592         QueryChannelRange_free(this_obj_conv);
32593 }
32594
32595 int8_tArray  __attribute__((export_name("TS_QueryChannelRange_get_chain_hash"))) TS_QueryChannelRange_get_chain_hash(uint32_t this_ptr) {
32596         LDKQueryChannelRange this_ptr_conv;
32597         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32598         this_ptr_conv.is_owned = false;
32599         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32600         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
32601         memcpy(ret_arr->elems, *QueryChannelRange_get_chain_hash(&this_ptr_conv), 32);
32602         return ret_arr;
32603 }
32604
32605 void  __attribute__((export_name("TS_QueryChannelRange_set_chain_hash"))) TS_QueryChannelRange_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
32606         LDKQueryChannelRange this_ptr_conv;
32607         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32608         this_ptr_conv.is_owned = false;
32609         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32610         LDKThirtyTwoBytes val_ref;
32611         CHECK(val->arr_len == 32);
32612         memcpy(val_ref.data, val->elems, 32); FREE(val);
32613         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
32614 }
32615
32616 int32_t  __attribute__((export_name("TS_QueryChannelRange_get_first_blocknum"))) TS_QueryChannelRange_get_first_blocknum(uint32_t this_ptr) {
32617         LDKQueryChannelRange this_ptr_conv;
32618         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32619         this_ptr_conv.is_owned = false;
32620         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32621         int32_t ret_conv = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
32622         return ret_conv;
32623 }
32624
32625 void  __attribute__((export_name("TS_QueryChannelRange_set_first_blocknum"))) TS_QueryChannelRange_set_first_blocknum(uint32_t this_ptr, int32_t val) {
32626         LDKQueryChannelRange this_ptr_conv;
32627         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32628         this_ptr_conv.is_owned = false;
32629         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32630         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
32631 }
32632
32633 int32_t  __attribute__((export_name("TS_QueryChannelRange_get_number_of_blocks"))) TS_QueryChannelRange_get_number_of_blocks(uint32_t this_ptr) {
32634         LDKQueryChannelRange this_ptr_conv;
32635         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32636         this_ptr_conv.is_owned = false;
32637         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32638         int32_t ret_conv = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
32639         return ret_conv;
32640 }
32641
32642 void  __attribute__((export_name("TS_QueryChannelRange_set_number_of_blocks"))) TS_QueryChannelRange_set_number_of_blocks(uint32_t this_ptr, int32_t val) {
32643         LDKQueryChannelRange this_ptr_conv;
32644         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32645         this_ptr_conv.is_owned = false;
32646         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32647         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
32648 }
32649
32650 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) {
32651         LDKThirtyTwoBytes chain_hash_arg_ref;
32652         CHECK(chain_hash_arg->arr_len == 32);
32653         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
32654         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
32655         uint32_t ret_ref = 0;
32656         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32657         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32658         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32659         ret_ref = (uintptr_t)ret_var.inner;
32660         if (ret_var.is_owned) {
32661                 ret_ref |= 1;
32662         }
32663         return ret_ref;
32664 }
32665
32666 static inline uintptr_t QueryChannelRange_clone_ptr(LDKQueryChannelRange *NONNULL_PTR arg) {
32667         LDKQueryChannelRange ret_var = QueryChannelRange_clone(arg);
32668 uint32_t ret_ref = 0;
32669 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32670 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32671 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32672 ret_ref = (uintptr_t)ret_var.inner;
32673 if (ret_var.is_owned) {
32674         ret_ref |= 1;
32675 }
32676         return ret_ref;
32677 }
32678 uint32_t  __attribute__((export_name("TS_QueryChannelRange_clone_ptr"))) TS_QueryChannelRange_clone_ptr(uint32_t arg) {
32679         LDKQueryChannelRange arg_conv;
32680         arg_conv.inner = (void*)(arg & (~1));
32681         arg_conv.is_owned = false;
32682         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32683         uint32_t ret_conv = QueryChannelRange_clone_ptr(&arg_conv);
32684         return ret_conv;
32685 }
32686
32687 uint32_t  __attribute__((export_name("TS_QueryChannelRange_clone"))) TS_QueryChannelRange_clone(uint32_t orig) {
32688         LDKQueryChannelRange orig_conv;
32689         orig_conv.inner = (void*)(orig & (~1));
32690         orig_conv.is_owned = false;
32691         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32692         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
32693         uint32_t ret_ref = 0;
32694         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32695         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32696         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32697         ret_ref = (uintptr_t)ret_var.inner;
32698         if (ret_var.is_owned) {
32699                 ret_ref |= 1;
32700         }
32701         return ret_ref;
32702 }
32703
32704 void  __attribute__((export_name("TS_ReplyChannelRange_free"))) TS_ReplyChannelRange_free(uint32_t this_obj) {
32705         LDKReplyChannelRange this_obj_conv;
32706         this_obj_conv.inner = (void*)(this_obj & (~1));
32707         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32708         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32709         ReplyChannelRange_free(this_obj_conv);
32710 }
32711
32712 int8_tArray  __attribute__((export_name("TS_ReplyChannelRange_get_chain_hash"))) TS_ReplyChannelRange_get_chain_hash(uint32_t this_ptr) {
32713         LDKReplyChannelRange this_ptr_conv;
32714         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32715         this_ptr_conv.is_owned = false;
32716         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32717         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
32718         memcpy(ret_arr->elems, *ReplyChannelRange_get_chain_hash(&this_ptr_conv), 32);
32719         return ret_arr;
32720 }
32721
32722 void  __attribute__((export_name("TS_ReplyChannelRange_set_chain_hash"))) TS_ReplyChannelRange_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
32723         LDKReplyChannelRange this_ptr_conv;
32724         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32725         this_ptr_conv.is_owned = false;
32726         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32727         LDKThirtyTwoBytes val_ref;
32728         CHECK(val->arr_len == 32);
32729         memcpy(val_ref.data, val->elems, 32); FREE(val);
32730         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
32731 }
32732
32733 int32_t  __attribute__((export_name("TS_ReplyChannelRange_get_first_blocknum"))) TS_ReplyChannelRange_get_first_blocknum(uint32_t this_ptr) {
32734         LDKReplyChannelRange this_ptr_conv;
32735         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32736         this_ptr_conv.is_owned = false;
32737         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32738         int32_t ret_conv = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
32739         return ret_conv;
32740 }
32741
32742 void  __attribute__((export_name("TS_ReplyChannelRange_set_first_blocknum"))) TS_ReplyChannelRange_set_first_blocknum(uint32_t this_ptr, int32_t val) {
32743         LDKReplyChannelRange this_ptr_conv;
32744         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32745         this_ptr_conv.is_owned = false;
32746         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32747         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
32748 }
32749
32750 int32_t  __attribute__((export_name("TS_ReplyChannelRange_get_number_of_blocks"))) TS_ReplyChannelRange_get_number_of_blocks(uint32_t this_ptr) {
32751         LDKReplyChannelRange this_ptr_conv;
32752         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32753         this_ptr_conv.is_owned = false;
32754         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32755         int32_t ret_conv = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
32756         return ret_conv;
32757 }
32758
32759 void  __attribute__((export_name("TS_ReplyChannelRange_set_number_of_blocks"))) TS_ReplyChannelRange_set_number_of_blocks(uint32_t this_ptr, int32_t val) {
32760         LDKReplyChannelRange this_ptr_conv;
32761         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32762         this_ptr_conv.is_owned = false;
32763         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32764         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
32765 }
32766
32767 jboolean  __attribute__((export_name("TS_ReplyChannelRange_get_sync_complete"))) TS_ReplyChannelRange_get_sync_complete(uint32_t this_ptr) {
32768         LDKReplyChannelRange this_ptr_conv;
32769         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32770         this_ptr_conv.is_owned = false;
32771         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32772         jboolean ret_conv = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
32773         return ret_conv;
32774 }
32775
32776 void  __attribute__((export_name("TS_ReplyChannelRange_set_sync_complete"))) TS_ReplyChannelRange_set_sync_complete(uint32_t this_ptr, jboolean val) {
32777         LDKReplyChannelRange this_ptr_conv;
32778         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32779         this_ptr_conv.is_owned = false;
32780         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32781         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
32782 }
32783
32784 int64_tArray  __attribute__((export_name("TS_ReplyChannelRange_get_short_channel_ids"))) TS_ReplyChannelRange_get_short_channel_ids(uint32_t this_ptr) {
32785         LDKReplyChannelRange this_ptr_conv;
32786         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32787         this_ptr_conv.is_owned = false;
32788         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32789         LDKCVec_u64Z ret_var = ReplyChannelRange_get_short_channel_ids(&this_ptr_conv);
32790         int64_tArray ret_arr = NULL;
32791         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
32792         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
32793         for (size_t i = 0; i < ret_var.datalen; i++) {
32794                 int64_t ret_conv_8_conv = ret_var.data[i];
32795                 ret_arr_ptr[i] = ret_conv_8_conv;
32796         }
32797         
32798         FREE(ret_var.data);
32799         return ret_arr;
32800 }
32801
32802 void  __attribute__((export_name("TS_ReplyChannelRange_set_short_channel_ids"))) TS_ReplyChannelRange_set_short_channel_ids(uint32_t this_ptr, int64_tArray val) {
32803         LDKReplyChannelRange this_ptr_conv;
32804         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32805         this_ptr_conv.is_owned = false;
32806         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32807         LDKCVec_u64Z val_constr;
32808         val_constr.datalen = val->arr_len;
32809         if (val_constr.datalen > 0)
32810                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
32811         else
32812                 val_constr.data = NULL;
32813         int64_t* val_vals = val->elems;
32814         for (size_t i = 0; i < val_constr.datalen; i++) {
32815                 int64_t val_conv_8 = val_vals[i];
32816                 val_constr.data[i] = val_conv_8;
32817         }
32818         FREE(val);
32819         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
32820 }
32821
32822 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) {
32823         LDKThirtyTwoBytes chain_hash_arg_ref;
32824         CHECK(chain_hash_arg->arr_len == 32);
32825         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
32826         LDKCVec_u64Z short_channel_ids_arg_constr;
32827         short_channel_ids_arg_constr.datalen = short_channel_ids_arg->arr_len;
32828         if (short_channel_ids_arg_constr.datalen > 0)
32829                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
32830         else
32831                 short_channel_ids_arg_constr.data = NULL;
32832         int64_t* short_channel_ids_arg_vals = short_channel_ids_arg->elems;
32833         for (size_t i = 0; i < short_channel_ids_arg_constr.datalen; i++) {
32834                 int64_t short_channel_ids_arg_conv_8 = short_channel_ids_arg_vals[i];
32835                 short_channel_ids_arg_constr.data[i] = short_channel_ids_arg_conv_8;
32836         }
32837         FREE(short_channel_ids_arg);
32838         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
32839         uint32_t ret_ref = 0;
32840         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32841         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32842         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32843         ret_ref = (uintptr_t)ret_var.inner;
32844         if (ret_var.is_owned) {
32845                 ret_ref |= 1;
32846         }
32847         return ret_ref;
32848 }
32849
32850 static inline uintptr_t ReplyChannelRange_clone_ptr(LDKReplyChannelRange *NONNULL_PTR arg) {
32851         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(arg);
32852 uint32_t ret_ref = 0;
32853 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32854 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32855 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32856 ret_ref = (uintptr_t)ret_var.inner;
32857 if (ret_var.is_owned) {
32858         ret_ref |= 1;
32859 }
32860         return ret_ref;
32861 }
32862 uint32_t  __attribute__((export_name("TS_ReplyChannelRange_clone_ptr"))) TS_ReplyChannelRange_clone_ptr(uint32_t arg) {
32863         LDKReplyChannelRange arg_conv;
32864         arg_conv.inner = (void*)(arg & (~1));
32865         arg_conv.is_owned = false;
32866         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32867         uint32_t ret_conv = ReplyChannelRange_clone_ptr(&arg_conv);
32868         return ret_conv;
32869 }
32870
32871 uint32_t  __attribute__((export_name("TS_ReplyChannelRange_clone"))) TS_ReplyChannelRange_clone(uint32_t orig) {
32872         LDKReplyChannelRange orig_conv;
32873         orig_conv.inner = (void*)(orig & (~1));
32874         orig_conv.is_owned = false;
32875         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32876         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
32877         uint32_t ret_ref = 0;
32878         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32879         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32880         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32881         ret_ref = (uintptr_t)ret_var.inner;
32882         if (ret_var.is_owned) {
32883                 ret_ref |= 1;
32884         }
32885         return ret_ref;
32886 }
32887
32888 void  __attribute__((export_name("TS_QueryShortChannelIds_free"))) TS_QueryShortChannelIds_free(uint32_t this_obj) {
32889         LDKQueryShortChannelIds this_obj_conv;
32890         this_obj_conv.inner = (void*)(this_obj & (~1));
32891         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32892         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32893         QueryShortChannelIds_free(this_obj_conv);
32894 }
32895
32896 int8_tArray  __attribute__((export_name("TS_QueryShortChannelIds_get_chain_hash"))) TS_QueryShortChannelIds_get_chain_hash(uint32_t this_ptr) {
32897         LDKQueryShortChannelIds this_ptr_conv;
32898         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32899         this_ptr_conv.is_owned = false;
32900         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32901         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
32902         memcpy(ret_arr->elems, *QueryShortChannelIds_get_chain_hash(&this_ptr_conv), 32);
32903         return ret_arr;
32904 }
32905
32906 void  __attribute__((export_name("TS_QueryShortChannelIds_set_chain_hash"))) TS_QueryShortChannelIds_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
32907         LDKQueryShortChannelIds this_ptr_conv;
32908         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32909         this_ptr_conv.is_owned = false;
32910         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32911         LDKThirtyTwoBytes val_ref;
32912         CHECK(val->arr_len == 32);
32913         memcpy(val_ref.data, val->elems, 32); FREE(val);
32914         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
32915 }
32916
32917 int64_tArray  __attribute__((export_name("TS_QueryShortChannelIds_get_short_channel_ids"))) TS_QueryShortChannelIds_get_short_channel_ids(uint32_t this_ptr) {
32918         LDKQueryShortChannelIds this_ptr_conv;
32919         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32920         this_ptr_conv.is_owned = false;
32921         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32922         LDKCVec_u64Z ret_var = QueryShortChannelIds_get_short_channel_ids(&this_ptr_conv);
32923         int64_tArray ret_arr = NULL;
32924         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
32925         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
32926         for (size_t i = 0; i < ret_var.datalen; i++) {
32927                 int64_t ret_conv_8_conv = ret_var.data[i];
32928                 ret_arr_ptr[i] = ret_conv_8_conv;
32929         }
32930         
32931         FREE(ret_var.data);
32932         return ret_arr;
32933 }
32934
32935 void  __attribute__((export_name("TS_QueryShortChannelIds_set_short_channel_ids"))) TS_QueryShortChannelIds_set_short_channel_ids(uint32_t this_ptr, int64_tArray val) {
32936         LDKQueryShortChannelIds this_ptr_conv;
32937         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32938         this_ptr_conv.is_owned = false;
32939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32940         LDKCVec_u64Z val_constr;
32941         val_constr.datalen = val->arr_len;
32942         if (val_constr.datalen > 0)
32943                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
32944         else
32945                 val_constr.data = NULL;
32946         int64_t* val_vals = val->elems;
32947         for (size_t i = 0; i < val_constr.datalen; i++) {
32948                 int64_t val_conv_8 = val_vals[i];
32949                 val_constr.data[i] = val_conv_8;
32950         }
32951         FREE(val);
32952         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
32953 }
32954
32955 uint32_t  __attribute__((export_name("TS_QueryShortChannelIds_new"))) TS_QueryShortChannelIds_new(int8_tArray chain_hash_arg, int64_tArray short_channel_ids_arg) {
32956         LDKThirtyTwoBytes chain_hash_arg_ref;
32957         CHECK(chain_hash_arg->arr_len == 32);
32958         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
32959         LDKCVec_u64Z short_channel_ids_arg_constr;
32960         short_channel_ids_arg_constr.datalen = short_channel_ids_arg->arr_len;
32961         if (short_channel_ids_arg_constr.datalen > 0)
32962                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
32963         else
32964                 short_channel_ids_arg_constr.data = NULL;
32965         int64_t* short_channel_ids_arg_vals = short_channel_ids_arg->elems;
32966         for (size_t i = 0; i < short_channel_ids_arg_constr.datalen; i++) {
32967                 int64_t short_channel_ids_arg_conv_8 = short_channel_ids_arg_vals[i];
32968                 short_channel_ids_arg_constr.data[i] = short_channel_ids_arg_conv_8;
32969         }
32970         FREE(short_channel_ids_arg);
32971         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
32972         uint32_t ret_ref = 0;
32973         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32974         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32975         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32976         ret_ref = (uintptr_t)ret_var.inner;
32977         if (ret_var.is_owned) {
32978                 ret_ref |= 1;
32979         }
32980         return ret_ref;
32981 }
32982
32983 static inline uintptr_t QueryShortChannelIds_clone_ptr(LDKQueryShortChannelIds *NONNULL_PTR arg) {
32984         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(arg);
32985 uint32_t ret_ref = 0;
32986 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32987 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32988 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32989 ret_ref = (uintptr_t)ret_var.inner;
32990 if (ret_var.is_owned) {
32991         ret_ref |= 1;
32992 }
32993         return ret_ref;
32994 }
32995 uint32_t  __attribute__((export_name("TS_QueryShortChannelIds_clone_ptr"))) TS_QueryShortChannelIds_clone_ptr(uint32_t arg) {
32996         LDKQueryShortChannelIds arg_conv;
32997         arg_conv.inner = (void*)(arg & (~1));
32998         arg_conv.is_owned = false;
32999         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33000         uint32_t ret_conv = QueryShortChannelIds_clone_ptr(&arg_conv);
33001         return ret_conv;
33002 }
33003
33004 uint32_t  __attribute__((export_name("TS_QueryShortChannelIds_clone"))) TS_QueryShortChannelIds_clone(uint32_t orig) {
33005         LDKQueryShortChannelIds orig_conv;
33006         orig_conv.inner = (void*)(orig & (~1));
33007         orig_conv.is_owned = false;
33008         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33009         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
33010         uint32_t ret_ref = 0;
33011         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33012         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33013         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33014         ret_ref = (uintptr_t)ret_var.inner;
33015         if (ret_var.is_owned) {
33016                 ret_ref |= 1;
33017         }
33018         return ret_ref;
33019 }
33020
33021 void  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_free"))) TS_ReplyShortChannelIdsEnd_free(uint32_t this_obj) {
33022         LDKReplyShortChannelIdsEnd this_obj_conv;
33023         this_obj_conv.inner = (void*)(this_obj & (~1));
33024         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33025         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33026         ReplyShortChannelIdsEnd_free(this_obj_conv);
33027 }
33028
33029 int8_tArray  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_get_chain_hash"))) TS_ReplyShortChannelIdsEnd_get_chain_hash(uint32_t this_ptr) {
33030         LDKReplyShortChannelIdsEnd this_ptr_conv;
33031         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33032         this_ptr_conv.is_owned = false;
33033         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33034         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
33035         memcpy(ret_arr->elems, *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv), 32);
33036         return ret_arr;
33037 }
33038
33039 void  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_set_chain_hash"))) TS_ReplyShortChannelIdsEnd_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
33040         LDKReplyShortChannelIdsEnd this_ptr_conv;
33041         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33042         this_ptr_conv.is_owned = false;
33043         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33044         LDKThirtyTwoBytes val_ref;
33045         CHECK(val->arr_len == 32);
33046         memcpy(val_ref.data, val->elems, 32); FREE(val);
33047         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
33048 }
33049
33050 jboolean  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_get_full_information"))) TS_ReplyShortChannelIdsEnd_get_full_information(uint32_t this_ptr) {
33051         LDKReplyShortChannelIdsEnd this_ptr_conv;
33052         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33053         this_ptr_conv.is_owned = false;
33054         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33055         jboolean ret_conv = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
33056         return ret_conv;
33057 }
33058
33059 void  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_set_full_information"))) TS_ReplyShortChannelIdsEnd_set_full_information(uint32_t this_ptr, jboolean val) {
33060         LDKReplyShortChannelIdsEnd this_ptr_conv;
33061         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33062         this_ptr_conv.is_owned = false;
33063         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33064         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
33065 }
33066
33067 uint32_t  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_new"))) TS_ReplyShortChannelIdsEnd_new(int8_tArray chain_hash_arg, jboolean full_information_arg) {
33068         LDKThirtyTwoBytes chain_hash_arg_ref;
33069         CHECK(chain_hash_arg->arr_len == 32);
33070         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
33071         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
33072         uint32_t ret_ref = 0;
33073         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33074         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33075         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33076         ret_ref = (uintptr_t)ret_var.inner;
33077         if (ret_var.is_owned) {
33078                 ret_ref |= 1;
33079         }
33080         return ret_ref;
33081 }
33082
33083 static inline uintptr_t ReplyShortChannelIdsEnd_clone_ptr(LDKReplyShortChannelIdsEnd *NONNULL_PTR arg) {
33084         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(arg);
33085 uint32_t ret_ref = 0;
33086 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33087 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33088 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33089 ret_ref = (uintptr_t)ret_var.inner;
33090 if (ret_var.is_owned) {
33091         ret_ref |= 1;
33092 }
33093         return ret_ref;
33094 }
33095 uint32_t  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_clone_ptr"))) TS_ReplyShortChannelIdsEnd_clone_ptr(uint32_t arg) {
33096         LDKReplyShortChannelIdsEnd arg_conv;
33097         arg_conv.inner = (void*)(arg & (~1));
33098         arg_conv.is_owned = false;
33099         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33100         uint32_t ret_conv = ReplyShortChannelIdsEnd_clone_ptr(&arg_conv);
33101         return ret_conv;
33102 }
33103
33104 uint32_t  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_clone"))) TS_ReplyShortChannelIdsEnd_clone(uint32_t orig) {
33105         LDKReplyShortChannelIdsEnd orig_conv;
33106         orig_conv.inner = (void*)(orig & (~1));
33107         orig_conv.is_owned = false;
33108         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33109         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
33110         uint32_t ret_ref = 0;
33111         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33112         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33113         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33114         ret_ref = (uintptr_t)ret_var.inner;
33115         if (ret_var.is_owned) {
33116                 ret_ref |= 1;
33117         }
33118         return ret_ref;
33119 }
33120
33121 void  __attribute__((export_name("TS_GossipTimestampFilter_free"))) TS_GossipTimestampFilter_free(uint32_t this_obj) {
33122         LDKGossipTimestampFilter this_obj_conv;
33123         this_obj_conv.inner = (void*)(this_obj & (~1));
33124         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33125         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33126         GossipTimestampFilter_free(this_obj_conv);
33127 }
33128
33129 int8_tArray  __attribute__((export_name("TS_GossipTimestampFilter_get_chain_hash"))) TS_GossipTimestampFilter_get_chain_hash(uint32_t this_ptr) {
33130         LDKGossipTimestampFilter this_ptr_conv;
33131         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33132         this_ptr_conv.is_owned = false;
33133         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33134         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
33135         memcpy(ret_arr->elems, *GossipTimestampFilter_get_chain_hash(&this_ptr_conv), 32);
33136         return ret_arr;
33137 }
33138
33139 void  __attribute__((export_name("TS_GossipTimestampFilter_set_chain_hash"))) TS_GossipTimestampFilter_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
33140         LDKGossipTimestampFilter this_ptr_conv;
33141         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33142         this_ptr_conv.is_owned = false;
33143         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33144         LDKThirtyTwoBytes val_ref;
33145         CHECK(val->arr_len == 32);
33146         memcpy(val_ref.data, val->elems, 32); FREE(val);
33147         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
33148 }
33149
33150 int32_t  __attribute__((export_name("TS_GossipTimestampFilter_get_first_timestamp"))) TS_GossipTimestampFilter_get_first_timestamp(uint32_t this_ptr) {
33151         LDKGossipTimestampFilter this_ptr_conv;
33152         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33153         this_ptr_conv.is_owned = false;
33154         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33155         int32_t ret_conv = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
33156         return ret_conv;
33157 }
33158
33159 void  __attribute__((export_name("TS_GossipTimestampFilter_set_first_timestamp"))) TS_GossipTimestampFilter_set_first_timestamp(uint32_t this_ptr, int32_t val) {
33160         LDKGossipTimestampFilter this_ptr_conv;
33161         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33162         this_ptr_conv.is_owned = false;
33163         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33164         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
33165 }
33166
33167 int32_t  __attribute__((export_name("TS_GossipTimestampFilter_get_timestamp_range"))) TS_GossipTimestampFilter_get_timestamp_range(uint32_t this_ptr) {
33168         LDKGossipTimestampFilter this_ptr_conv;
33169         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33170         this_ptr_conv.is_owned = false;
33171         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33172         int32_t ret_conv = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
33173         return ret_conv;
33174 }
33175
33176 void  __attribute__((export_name("TS_GossipTimestampFilter_set_timestamp_range"))) TS_GossipTimestampFilter_set_timestamp_range(uint32_t this_ptr, int32_t val) {
33177         LDKGossipTimestampFilter this_ptr_conv;
33178         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33179         this_ptr_conv.is_owned = false;
33180         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33181         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
33182 }
33183
33184 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) {
33185         LDKThirtyTwoBytes chain_hash_arg_ref;
33186         CHECK(chain_hash_arg->arr_len == 32);
33187         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
33188         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
33189         uint32_t ret_ref = 0;
33190         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33191         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33192         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33193         ret_ref = (uintptr_t)ret_var.inner;
33194         if (ret_var.is_owned) {
33195                 ret_ref |= 1;
33196         }
33197         return ret_ref;
33198 }
33199
33200 static inline uintptr_t GossipTimestampFilter_clone_ptr(LDKGossipTimestampFilter *NONNULL_PTR arg) {
33201         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(arg);
33202 uint32_t ret_ref = 0;
33203 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33204 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33205 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33206 ret_ref = (uintptr_t)ret_var.inner;
33207 if (ret_var.is_owned) {
33208         ret_ref |= 1;
33209 }
33210         return ret_ref;
33211 }
33212 uint32_t  __attribute__((export_name("TS_GossipTimestampFilter_clone_ptr"))) TS_GossipTimestampFilter_clone_ptr(uint32_t arg) {
33213         LDKGossipTimestampFilter arg_conv;
33214         arg_conv.inner = (void*)(arg & (~1));
33215         arg_conv.is_owned = false;
33216         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33217         uint32_t ret_conv = GossipTimestampFilter_clone_ptr(&arg_conv);
33218         return ret_conv;
33219 }
33220
33221 uint32_t  __attribute__((export_name("TS_GossipTimestampFilter_clone"))) TS_GossipTimestampFilter_clone(uint32_t orig) {
33222         LDKGossipTimestampFilter orig_conv;
33223         orig_conv.inner = (void*)(orig & (~1));
33224         orig_conv.is_owned = false;
33225         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33226         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
33227         uint32_t ret_ref = 0;
33228         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33229         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33230         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33231         ret_ref = (uintptr_t)ret_var.inner;
33232         if (ret_var.is_owned) {
33233                 ret_ref |= 1;
33234         }
33235         return ret_ref;
33236 }
33237
33238 void  __attribute__((export_name("TS_ErrorAction_free"))) TS_ErrorAction_free(uint32_t this_ptr) {
33239         if ((this_ptr & 1) != 0) return;
33240         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
33241         CHECK_ACCESS(this_ptr_ptr);
33242         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(this_ptr_ptr);
33243         FREE((void*)this_ptr);
33244         ErrorAction_free(this_ptr_conv);
33245 }
33246
33247 static inline uintptr_t ErrorAction_clone_ptr(LDKErrorAction *NONNULL_PTR arg) {
33248         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
33249         *ret_copy = ErrorAction_clone(arg);
33250 uint32_t ret_ref = (uintptr_t)ret_copy;
33251         return ret_ref;
33252 }
33253 uint32_t  __attribute__((export_name("TS_ErrorAction_clone_ptr"))) TS_ErrorAction_clone_ptr(uint32_t arg) {
33254         LDKErrorAction* arg_conv = (LDKErrorAction*)arg;
33255         uint32_t ret_conv = ErrorAction_clone_ptr(arg_conv);
33256         return ret_conv;
33257 }
33258
33259 uint32_t  __attribute__((export_name("TS_ErrorAction_clone"))) TS_ErrorAction_clone(uint32_t orig) {
33260         LDKErrorAction* orig_conv = (LDKErrorAction*)orig;
33261         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
33262         *ret_copy = ErrorAction_clone(orig_conv);
33263         uint32_t ret_ref = (uintptr_t)ret_copy;
33264         return ret_ref;
33265 }
33266
33267 uint32_t  __attribute__((export_name("TS_ErrorAction_disconnect_peer"))) TS_ErrorAction_disconnect_peer(uint32_t msg) {
33268         LDKErrorMessage msg_conv;
33269         msg_conv.inner = (void*)(msg & (~1));
33270         msg_conv.is_owned = (msg & 1) || (msg == 0);
33271         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
33272         msg_conv = ErrorMessage_clone(&msg_conv);
33273         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
33274         *ret_copy = ErrorAction_disconnect_peer(msg_conv);
33275         uint32_t ret_ref = (uintptr_t)ret_copy;
33276         return ret_ref;
33277 }
33278
33279 uint32_t  __attribute__((export_name("TS_ErrorAction_ignore_error"))) TS_ErrorAction_ignore_error() {
33280         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
33281         *ret_copy = ErrorAction_ignore_error();
33282         uint32_t ret_ref = (uintptr_t)ret_copy;
33283         return ret_ref;
33284 }
33285
33286 uint32_t  __attribute__((export_name("TS_ErrorAction_ignore_and_log"))) TS_ErrorAction_ignore_and_log(uint32_t a) {
33287         LDKLevel a_conv = LDKLevel_from_js(a);
33288         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
33289         *ret_copy = ErrorAction_ignore_and_log(a_conv);
33290         uint32_t ret_ref = (uintptr_t)ret_copy;
33291         return ret_ref;
33292 }
33293
33294 uint32_t  __attribute__((export_name("TS_ErrorAction_ignore_duplicate_gossip"))) TS_ErrorAction_ignore_duplicate_gossip() {
33295         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
33296         *ret_copy = ErrorAction_ignore_duplicate_gossip();
33297         uint32_t ret_ref = (uintptr_t)ret_copy;
33298         return ret_ref;
33299 }
33300
33301 uint32_t  __attribute__((export_name("TS_ErrorAction_send_error_message"))) TS_ErrorAction_send_error_message(uint32_t msg) {
33302         LDKErrorMessage msg_conv;
33303         msg_conv.inner = (void*)(msg & (~1));
33304         msg_conv.is_owned = (msg & 1) || (msg == 0);
33305         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
33306         msg_conv = ErrorMessage_clone(&msg_conv);
33307         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
33308         *ret_copy = ErrorAction_send_error_message(msg_conv);
33309         uint32_t ret_ref = (uintptr_t)ret_copy;
33310         return ret_ref;
33311 }
33312
33313 uint32_t  __attribute__((export_name("TS_ErrorAction_send_warning_message"))) TS_ErrorAction_send_warning_message(uint32_t msg, uint32_t log_level) {
33314         LDKWarningMessage msg_conv;
33315         msg_conv.inner = (void*)(msg & (~1));
33316         msg_conv.is_owned = (msg & 1) || (msg == 0);
33317         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
33318         msg_conv = WarningMessage_clone(&msg_conv);
33319         LDKLevel log_level_conv = LDKLevel_from_js(log_level);
33320         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
33321         *ret_copy = ErrorAction_send_warning_message(msg_conv, log_level_conv);
33322         uint32_t ret_ref = (uintptr_t)ret_copy;
33323         return ret_ref;
33324 }
33325
33326 void  __attribute__((export_name("TS_LightningError_free"))) TS_LightningError_free(uint32_t this_obj) {
33327         LDKLightningError this_obj_conv;
33328         this_obj_conv.inner = (void*)(this_obj & (~1));
33329         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33330         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33331         LightningError_free(this_obj_conv);
33332 }
33333
33334 jstring  __attribute__((export_name("TS_LightningError_get_err"))) TS_LightningError_get_err(uint32_t this_ptr) {
33335         LDKLightningError this_ptr_conv;
33336         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33337         this_ptr_conv.is_owned = false;
33338         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33339         LDKStr ret_str = LightningError_get_err(&this_ptr_conv);
33340         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
33341         Str_free(ret_str);
33342         return ret_conv;
33343 }
33344
33345 void  __attribute__((export_name("TS_LightningError_set_err"))) TS_LightningError_set_err(uint32_t this_ptr, jstring val) {
33346         LDKLightningError this_ptr_conv;
33347         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33348         this_ptr_conv.is_owned = false;
33349         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33350         LDKStr val_conv = str_ref_to_owned_c(val);
33351         LightningError_set_err(&this_ptr_conv, val_conv);
33352 }
33353
33354 uint32_t  __attribute__((export_name("TS_LightningError_get_action"))) TS_LightningError_get_action(uint32_t this_ptr) {
33355         LDKLightningError this_ptr_conv;
33356         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33357         this_ptr_conv.is_owned = false;
33358         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33359         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
33360         *ret_copy = LightningError_get_action(&this_ptr_conv);
33361         uint32_t ret_ref = (uintptr_t)ret_copy;
33362         return ret_ref;
33363 }
33364
33365 void  __attribute__((export_name("TS_LightningError_set_action"))) TS_LightningError_set_action(uint32_t this_ptr, uint32_t val) {
33366         LDKLightningError this_ptr_conv;
33367         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33368         this_ptr_conv.is_owned = false;
33369         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33370         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
33371         CHECK_ACCESS(val_ptr);
33372         LDKErrorAction val_conv = *(LDKErrorAction*)(val_ptr);
33373         val_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)val) & ~1));
33374         LightningError_set_action(&this_ptr_conv, val_conv);
33375 }
33376
33377 uint32_t  __attribute__((export_name("TS_LightningError_new"))) TS_LightningError_new(jstring err_arg, uint32_t action_arg) {
33378         LDKStr err_arg_conv = str_ref_to_owned_c(err_arg);
33379         void* action_arg_ptr = (void*)(((uintptr_t)action_arg) & ~1);
33380         CHECK_ACCESS(action_arg_ptr);
33381         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(action_arg_ptr);
33382         action_arg_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)action_arg) & ~1));
33383         LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv);
33384         uint32_t ret_ref = 0;
33385         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33386         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33387         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33388         ret_ref = (uintptr_t)ret_var.inner;
33389         if (ret_var.is_owned) {
33390                 ret_ref |= 1;
33391         }
33392         return ret_ref;
33393 }
33394
33395 static inline uintptr_t LightningError_clone_ptr(LDKLightningError *NONNULL_PTR arg) {
33396         LDKLightningError ret_var = LightningError_clone(arg);
33397 uint32_t ret_ref = 0;
33398 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33399 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33400 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33401 ret_ref = (uintptr_t)ret_var.inner;
33402 if (ret_var.is_owned) {
33403         ret_ref |= 1;
33404 }
33405         return ret_ref;
33406 }
33407 uint32_t  __attribute__((export_name("TS_LightningError_clone_ptr"))) TS_LightningError_clone_ptr(uint32_t arg) {
33408         LDKLightningError arg_conv;
33409         arg_conv.inner = (void*)(arg & (~1));
33410         arg_conv.is_owned = false;
33411         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33412         uint32_t ret_conv = LightningError_clone_ptr(&arg_conv);
33413         return ret_conv;
33414 }
33415
33416 uint32_t  __attribute__((export_name("TS_LightningError_clone"))) TS_LightningError_clone(uint32_t orig) {
33417         LDKLightningError orig_conv;
33418         orig_conv.inner = (void*)(orig & (~1));
33419         orig_conv.is_owned = false;
33420         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33421         LDKLightningError ret_var = LightningError_clone(&orig_conv);
33422         uint32_t ret_ref = 0;
33423         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33424         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33425         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33426         ret_ref = (uintptr_t)ret_var.inner;
33427         if (ret_var.is_owned) {
33428                 ret_ref |= 1;
33429         }
33430         return ret_ref;
33431 }
33432
33433 void  __attribute__((export_name("TS_CommitmentUpdate_free"))) TS_CommitmentUpdate_free(uint32_t this_obj) {
33434         LDKCommitmentUpdate this_obj_conv;
33435         this_obj_conv.inner = (void*)(this_obj & (~1));
33436         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33437         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33438         CommitmentUpdate_free(this_obj_conv);
33439 }
33440
33441 uint32_tArray  __attribute__((export_name("TS_CommitmentUpdate_get_update_add_htlcs"))) TS_CommitmentUpdate_get_update_add_htlcs(uint32_t this_ptr) {
33442         LDKCommitmentUpdate this_ptr_conv;
33443         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33444         this_ptr_conv.is_owned = false;
33445         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33446         LDKCVec_UpdateAddHTLCZ ret_var = CommitmentUpdate_get_update_add_htlcs(&this_ptr_conv);
33447         uint32_tArray ret_arr = NULL;
33448         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
33449         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 8);
33450         for (size_t p = 0; p < ret_var.datalen; p++) {
33451                 LDKUpdateAddHTLC ret_conv_15_var = ret_var.data[p];
33452                 uint32_t ret_conv_15_ref = 0;
33453                 CHECK((((uintptr_t)ret_conv_15_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33454                 CHECK((((uintptr_t)&ret_conv_15_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33455                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_15_var);
33456                 ret_conv_15_ref = (uintptr_t)ret_conv_15_var.inner;
33457                 if (ret_conv_15_var.is_owned) {
33458                         ret_conv_15_ref |= 1;
33459                 }
33460                 ret_arr_ptr[p] = ret_conv_15_ref;
33461         }
33462         
33463         FREE(ret_var.data);
33464         return ret_arr;
33465 }
33466
33467 void  __attribute__((export_name("TS_CommitmentUpdate_set_update_add_htlcs"))) TS_CommitmentUpdate_set_update_add_htlcs(uint32_t this_ptr, uint32_tArray val) {
33468         LDKCommitmentUpdate this_ptr_conv;
33469         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33470         this_ptr_conv.is_owned = false;
33471         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33472         LDKCVec_UpdateAddHTLCZ val_constr;
33473         val_constr.datalen = val->arr_len;
33474         if (val_constr.datalen > 0)
33475                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
33476         else
33477                 val_constr.data = NULL;
33478         uint32_t* val_vals = val->elems;
33479         for (size_t p = 0; p < val_constr.datalen; p++) {
33480                 uint32_t val_conv_15 = val_vals[p];
33481                 LDKUpdateAddHTLC val_conv_15_conv;
33482                 val_conv_15_conv.inner = (void*)(val_conv_15 & (~1));
33483                 val_conv_15_conv.is_owned = (val_conv_15 & 1) || (val_conv_15 == 0);
33484                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_15_conv);
33485                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
33486                 val_constr.data[p] = val_conv_15_conv;
33487         }
33488         FREE(val);
33489         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
33490 }
33491
33492 uint32_tArray  __attribute__((export_name("TS_CommitmentUpdate_get_update_fulfill_htlcs"))) TS_CommitmentUpdate_get_update_fulfill_htlcs(uint32_t this_ptr) {
33493         LDKCommitmentUpdate this_ptr_conv;
33494         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33495         this_ptr_conv.is_owned = false;
33496         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33497         LDKCVec_UpdateFulfillHTLCZ ret_var = CommitmentUpdate_get_update_fulfill_htlcs(&this_ptr_conv);
33498         uint32_tArray ret_arr = NULL;
33499         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
33500         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 8);
33501         for (size_t t = 0; t < ret_var.datalen; t++) {
33502                 LDKUpdateFulfillHTLC ret_conv_19_var = ret_var.data[t];
33503                 uint32_t ret_conv_19_ref = 0;
33504                 CHECK((((uintptr_t)ret_conv_19_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33505                 CHECK((((uintptr_t)&ret_conv_19_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33506                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_19_var);
33507                 ret_conv_19_ref = (uintptr_t)ret_conv_19_var.inner;
33508                 if (ret_conv_19_var.is_owned) {
33509                         ret_conv_19_ref |= 1;
33510                 }
33511                 ret_arr_ptr[t] = ret_conv_19_ref;
33512         }
33513         
33514         FREE(ret_var.data);
33515         return ret_arr;
33516 }
33517
33518 void  __attribute__((export_name("TS_CommitmentUpdate_set_update_fulfill_htlcs"))) TS_CommitmentUpdate_set_update_fulfill_htlcs(uint32_t this_ptr, uint32_tArray val) {
33519         LDKCommitmentUpdate this_ptr_conv;
33520         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33521         this_ptr_conv.is_owned = false;
33522         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33523         LDKCVec_UpdateFulfillHTLCZ val_constr;
33524         val_constr.datalen = val->arr_len;
33525         if (val_constr.datalen > 0)
33526                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
33527         else
33528                 val_constr.data = NULL;
33529         uint32_t* val_vals = val->elems;
33530         for (size_t t = 0; t < val_constr.datalen; t++) {
33531                 uint32_t val_conv_19 = val_vals[t];
33532                 LDKUpdateFulfillHTLC val_conv_19_conv;
33533                 val_conv_19_conv.inner = (void*)(val_conv_19 & (~1));
33534                 val_conv_19_conv.is_owned = (val_conv_19 & 1) || (val_conv_19 == 0);
33535                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_19_conv);
33536                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
33537                 val_constr.data[t] = val_conv_19_conv;
33538         }
33539         FREE(val);
33540         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
33541 }
33542
33543 uint32_tArray  __attribute__((export_name("TS_CommitmentUpdate_get_update_fail_htlcs"))) TS_CommitmentUpdate_get_update_fail_htlcs(uint32_t this_ptr) {
33544         LDKCommitmentUpdate this_ptr_conv;
33545         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33546         this_ptr_conv.is_owned = false;
33547         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33548         LDKCVec_UpdateFailHTLCZ ret_var = CommitmentUpdate_get_update_fail_htlcs(&this_ptr_conv);
33549         uint32_tArray ret_arr = NULL;
33550         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
33551         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 8);
33552         for (size_t q = 0; q < ret_var.datalen; q++) {
33553                 LDKUpdateFailHTLC ret_conv_16_var = ret_var.data[q];
33554                 uint32_t ret_conv_16_ref = 0;
33555                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33556                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33557                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
33558                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
33559                 if (ret_conv_16_var.is_owned) {
33560                         ret_conv_16_ref |= 1;
33561                 }
33562                 ret_arr_ptr[q] = ret_conv_16_ref;
33563         }
33564         
33565         FREE(ret_var.data);
33566         return ret_arr;
33567 }
33568
33569 void  __attribute__((export_name("TS_CommitmentUpdate_set_update_fail_htlcs"))) TS_CommitmentUpdate_set_update_fail_htlcs(uint32_t this_ptr, uint32_tArray val) {
33570         LDKCommitmentUpdate this_ptr_conv;
33571         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33572         this_ptr_conv.is_owned = false;
33573         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33574         LDKCVec_UpdateFailHTLCZ val_constr;
33575         val_constr.datalen = val->arr_len;
33576         if (val_constr.datalen > 0)
33577                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
33578         else
33579                 val_constr.data = NULL;
33580         uint32_t* val_vals = val->elems;
33581         for (size_t q = 0; q < val_constr.datalen; q++) {
33582                 uint32_t val_conv_16 = val_vals[q];
33583                 LDKUpdateFailHTLC val_conv_16_conv;
33584                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
33585                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
33586                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
33587                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
33588                 val_constr.data[q] = val_conv_16_conv;
33589         }
33590         FREE(val);
33591         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
33592 }
33593
33594 uint32_tArray  __attribute__((export_name("TS_CommitmentUpdate_get_update_fail_malformed_htlcs"))) TS_CommitmentUpdate_get_update_fail_malformed_htlcs(uint32_t this_ptr) {
33595         LDKCommitmentUpdate this_ptr_conv;
33596         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33597         this_ptr_conv.is_owned = false;
33598         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33599         LDKCVec_UpdateFailMalformedHTLCZ ret_var = CommitmentUpdate_get_update_fail_malformed_htlcs(&this_ptr_conv);
33600         uint32_tArray ret_arr = NULL;
33601         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
33602         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 8);
33603         for (size_t z = 0; z < ret_var.datalen; z++) {
33604                 LDKUpdateFailMalformedHTLC ret_conv_25_var = ret_var.data[z];
33605                 uint32_t ret_conv_25_ref = 0;
33606                 CHECK((((uintptr_t)ret_conv_25_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33607                 CHECK((((uintptr_t)&ret_conv_25_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33608                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_25_var);
33609                 ret_conv_25_ref = (uintptr_t)ret_conv_25_var.inner;
33610                 if (ret_conv_25_var.is_owned) {
33611                         ret_conv_25_ref |= 1;
33612                 }
33613                 ret_arr_ptr[z] = ret_conv_25_ref;
33614         }
33615         
33616         FREE(ret_var.data);
33617         return ret_arr;
33618 }
33619
33620 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) {
33621         LDKCommitmentUpdate this_ptr_conv;
33622         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33623         this_ptr_conv.is_owned = false;
33624         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33625         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
33626         val_constr.datalen = val->arr_len;
33627         if (val_constr.datalen > 0)
33628                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
33629         else
33630                 val_constr.data = NULL;
33631         uint32_t* val_vals = val->elems;
33632         for (size_t z = 0; z < val_constr.datalen; z++) {
33633                 uint32_t val_conv_25 = val_vals[z];
33634                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
33635                 val_conv_25_conv.inner = (void*)(val_conv_25 & (~1));
33636                 val_conv_25_conv.is_owned = (val_conv_25 & 1) || (val_conv_25 == 0);
33637                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_25_conv);
33638                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
33639                 val_constr.data[z] = val_conv_25_conv;
33640         }
33641         FREE(val);
33642         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
33643 }
33644
33645 uint32_t  __attribute__((export_name("TS_CommitmentUpdate_get_update_fee"))) TS_CommitmentUpdate_get_update_fee(uint32_t this_ptr) {
33646         LDKCommitmentUpdate this_ptr_conv;
33647         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33648         this_ptr_conv.is_owned = false;
33649         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33650         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
33651         uint32_t ret_ref = 0;
33652         if ((uintptr_t)ret_var.inner > 4096) {
33653                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33654                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33655         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33656                 ret_ref = (uintptr_t)ret_var.inner;
33657                 if (ret_var.is_owned) {
33658                         ret_ref |= 1;
33659                 }
33660         }
33661         return ret_ref;
33662 }
33663
33664 void  __attribute__((export_name("TS_CommitmentUpdate_set_update_fee"))) TS_CommitmentUpdate_set_update_fee(uint32_t this_ptr, uint32_t val) {
33665         LDKCommitmentUpdate this_ptr_conv;
33666         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33667         this_ptr_conv.is_owned = false;
33668         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33669         LDKUpdateFee val_conv;
33670         val_conv.inner = (void*)(val & (~1));
33671         val_conv.is_owned = (val & 1) || (val == 0);
33672         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33673         val_conv = UpdateFee_clone(&val_conv);
33674         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
33675 }
33676
33677 uint32_t  __attribute__((export_name("TS_CommitmentUpdate_get_commitment_signed"))) TS_CommitmentUpdate_get_commitment_signed(uint32_t this_ptr) {
33678         LDKCommitmentUpdate this_ptr_conv;
33679         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33680         this_ptr_conv.is_owned = false;
33681         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33682         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
33683         uint32_t ret_ref = 0;
33684         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33685         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33686         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33687         ret_ref = (uintptr_t)ret_var.inner;
33688         if (ret_var.is_owned) {
33689                 ret_ref |= 1;
33690         }
33691         return ret_ref;
33692 }
33693
33694 void  __attribute__((export_name("TS_CommitmentUpdate_set_commitment_signed"))) TS_CommitmentUpdate_set_commitment_signed(uint32_t this_ptr, uint32_t val) {
33695         LDKCommitmentUpdate this_ptr_conv;
33696         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33697         this_ptr_conv.is_owned = false;
33698         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33699         LDKCommitmentSigned val_conv;
33700         val_conv.inner = (void*)(val & (~1));
33701         val_conv.is_owned = (val & 1) || (val == 0);
33702         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33703         val_conv = CommitmentSigned_clone(&val_conv);
33704         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
33705 }
33706
33707 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) {
33708         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
33709         update_add_htlcs_arg_constr.datalen = update_add_htlcs_arg->arr_len;
33710         if (update_add_htlcs_arg_constr.datalen > 0)
33711                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
33712         else
33713                 update_add_htlcs_arg_constr.data = NULL;
33714         uint32_t* update_add_htlcs_arg_vals = update_add_htlcs_arg->elems;
33715         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
33716                 uint32_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
33717                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
33718                 update_add_htlcs_arg_conv_15_conv.inner = (void*)(update_add_htlcs_arg_conv_15 & (~1));
33719                 update_add_htlcs_arg_conv_15_conv.is_owned = (update_add_htlcs_arg_conv_15 & 1) || (update_add_htlcs_arg_conv_15 == 0);
33720                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_add_htlcs_arg_conv_15_conv);
33721                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
33722                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
33723         }
33724         FREE(update_add_htlcs_arg);
33725         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
33726         update_fulfill_htlcs_arg_constr.datalen = update_fulfill_htlcs_arg->arr_len;
33727         if (update_fulfill_htlcs_arg_constr.datalen > 0)
33728                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
33729         else
33730                 update_fulfill_htlcs_arg_constr.data = NULL;
33731         uint32_t* update_fulfill_htlcs_arg_vals = update_fulfill_htlcs_arg->elems;
33732         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
33733                 uint32_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
33734                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
33735                 update_fulfill_htlcs_arg_conv_19_conv.inner = (void*)(update_fulfill_htlcs_arg_conv_19 & (~1));
33736                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = (update_fulfill_htlcs_arg_conv_19 & 1) || (update_fulfill_htlcs_arg_conv_19 == 0);
33737                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fulfill_htlcs_arg_conv_19_conv);
33738                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
33739                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
33740         }
33741         FREE(update_fulfill_htlcs_arg);
33742         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
33743         update_fail_htlcs_arg_constr.datalen = update_fail_htlcs_arg->arr_len;
33744         if (update_fail_htlcs_arg_constr.datalen > 0)
33745                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
33746         else
33747                 update_fail_htlcs_arg_constr.data = NULL;
33748         uint32_t* update_fail_htlcs_arg_vals = update_fail_htlcs_arg->elems;
33749         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
33750                 uint32_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
33751                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
33752                 update_fail_htlcs_arg_conv_16_conv.inner = (void*)(update_fail_htlcs_arg_conv_16 & (~1));
33753                 update_fail_htlcs_arg_conv_16_conv.is_owned = (update_fail_htlcs_arg_conv_16 & 1) || (update_fail_htlcs_arg_conv_16 == 0);
33754                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_htlcs_arg_conv_16_conv);
33755                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
33756                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
33757         }
33758         FREE(update_fail_htlcs_arg);
33759         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
33760         update_fail_malformed_htlcs_arg_constr.datalen = update_fail_malformed_htlcs_arg->arr_len;
33761         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
33762                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
33763         else
33764                 update_fail_malformed_htlcs_arg_constr.data = NULL;
33765         uint32_t* update_fail_malformed_htlcs_arg_vals = update_fail_malformed_htlcs_arg->elems;
33766         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
33767                 uint32_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
33768                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
33769                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = (void*)(update_fail_malformed_htlcs_arg_conv_25 & (~1));
33770                 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);
33771                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_malformed_htlcs_arg_conv_25_conv);
33772                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
33773                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
33774         }
33775         FREE(update_fail_malformed_htlcs_arg);
33776         LDKUpdateFee update_fee_arg_conv;
33777         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
33778         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
33779         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fee_arg_conv);
33780         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
33781         LDKCommitmentSigned commitment_signed_arg_conv;
33782         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
33783         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
33784         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_signed_arg_conv);
33785         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
33786         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);
33787         uint32_t ret_ref = 0;
33788         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33789         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33790         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33791         ret_ref = (uintptr_t)ret_var.inner;
33792         if (ret_var.is_owned) {
33793                 ret_ref |= 1;
33794         }
33795         return ret_ref;
33796 }
33797
33798 static inline uintptr_t CommitmentUpdate_clone_ptr(LDKCommitmentUpdate *NONNULL_PTR arg) {
33799         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(arg);
33800 uint32_t ret_ref = 0;
33801 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33802 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33803 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33804 ret_ref = (uintptr_t)ret_var.inner;
33805 if (ret_var.is_owned) {
33806         ret_ref |= 1;
33807 }
33808         return ret_ref;
33809 }
33810 uint32_t  __attribute__((export_name("TS_CommitmentUpdate_clone_ptr"))) TS_CommitmentUpdate_clone_ptr(uint32_t arg) {
33811         LDKCommitmentUpdate arg_conv;
33812         arg_conv.inner = (void*)(arg & (~1));
33813         arg_conv.is_owned = false;
33814         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33815         uint32_t ret_conv = CommitmentUpdate_clone_ptr(&arg_conv);
33816         return ret_conv;
33817 }
33818
33819 uint32_t  __attribute__((export_name("TS_CommitmentUpdate_clone"))) TS_CommitmentUpdate_clone(uint32_t orig) {
33820         LDKCommitmentUpdate orig_conv;
33821         orig_conv.inner = (void*)(orig & (~1));
33822         orig_conv.is_owned = false;
33823         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33824         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
33825         uint32_t ret_ref = 0;
33826         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33827         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33828         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33829         ret_ref = (uintptr_t)ret_var.inner;
33830         if (ret_var.is_owned) {
33831                 ret_ref |= 1;
33832         }
33833         return ret_ref;
33834 }
33835
33836 void  __attribute__((export_name("TS_ChannelMessageHandler_free"))) TS_ChannelMessageHandler_free(uint32_t this_ptr) {
33837         if ((this_ptr & 1) != 0) return;
33838         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
33839         CHECK_ACCESS(this_ptr_ptr);
33840         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(this_ptr_ptr);
33841         FREE((void*)this_ptr);
33842         ChannelMessageHandler_free(this_ptr_conv);
33843 }
33844
33845 void  __attribute__((export_name("TS_RoutingMessageHandler_free"))) TS_RoutingMessageHandler_free(uint32_t this_ptr) {
33846         if ((this_ptr & 1) != 0) return;
33847         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
33848         CHECK_ACCESS(this_ptr_ptr);
33849         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(this_ptr_ptr);
33850         FREE((void*)this_ptr);
33851         RoutingMessageHandler_free(this_ptr_conv);
33852 }
33853
33854 int8_tArray  __attribute__((export_name("TS_AcceptChannel_write"))) TS_AcceptChannel_write(uint32_t obj) {
33855         LDKAcceptChannel obj_conv;
33856         obj_conv.inner = (void*)(obj & (~1));
33857         obj_conv.is_owned = false;
33858         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33859         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
33860         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33861         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33862         CVec_u8Z_free(ret_var);
33863         return ret_arr;
33864 }
33865
33866 uint32_t  __attribute__((export_name("TS_AcceptChannel_read"))) TS_AcceptChannel_read(int8_tArray ser) {
33867         LDKu8slice ser_ref;
33868         ser_ref.datalen = ser->arr_len;
33869         ser_ref.data = ser->elems;
33870         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
33871         *ret_conv = AcceptChannel_read(ser_ref);
33872         FREE(ser);
33873         return (uint32_t)ret_conv;
33874 }
33875
33876 int8_tArray  __attribute__((export_name("TS_AnnouncementSignatures_write"))) TS_AnnouncementSignatures_write(uint32_t obj) {
33877         LDKAnnouncementSignatures obj_conv;
33878         obj_conv.inner = (void*)(obj & (~1));
33879         obj_conv.is_owned = false;
33880         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33881         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
33882         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33883         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33884         CVec_u8Z_free(ret_var);
33885         return ret_arr;
33886 }
33887
33888 uint32_t  __attribute__((export_name("TS_AnnouncementSignatures_read"))) TS_AnnouncementSignatures_read(int8_tArray ser) {
33889         LDKu8slice ser_ref;
33890         ser_ref.datalen = ser->arr_len;
33891         ser_ref.data = ser->elems;
33892         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
33893         *ret_conv = AnnouncementSignatures_read(ser_ref);
33894         FREE(ser);
33895         return (uint32_t)ret_conv;
33896 }
33897
33898 int8_tArray  __attribute__((export_name("TS_ChannelReestablish_write"))) TS_ChannelReestablish_write(uint32_t obj) {
33899         LDKChannelReestablish obj_conv;
33900         obj_conv.inner = (void*)(obj & (~1));
33901         obj_conv.is_owned = false;
33902         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33903         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
33904         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33905         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33906         CVec_u8Z_free(ret_var);
33907         return ret_arr;
33908 }
33909
33910 uint32_t  __attribute__((export_name("TS_ChannelReestablish_read"))) TS_ChannelReestablish_read(int8_tArray ser) {
33911         LDKu8slice ser_ref;
33912         ser_ref.datalen = ser->arr_len;
33913         ser_ref.data = ser->elems;
33914         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
33915         *ret_conv = ChannelReestablish_read(ser_ref);
33916         FREE(ser);
33917         return (uint32_t)ret_conv;
33918 }
33919
33920 int8_tArray  __attribute__((export_name("TS_ClosingSigned_write"))) TS_ClosingSigned_write(uint32_t obj) {
33921         LDKClosingSigned obj_conv;
33922         obj_conv.inner = (void*)(obj & (~1));
33923         obj_conv.is_owned = false;
33924         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33925         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
33926         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33927         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33928         CVec_u8Z_free(ret_var);
33929         return ret_arr;
33930 }
33931
33932 uint32_t  __attribute__((export_name("TS_ClosingSigned_read"))) TS_ClosingSigned_read(int8_tArray ser) {
33933         LDKu8slice ser_ref;
33934         ser_ref.datalen = ser->arr_len;
33935         ser_ref.data = ser->elems;
33936         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
33937         *ret_conv = ClosingSigned_read(ser_ref);
33938         FREE(ser);
33939         return (uint32_t)ret_conv;
33940 }
33941
33942 int8_tArray  __attribute__((export_name("TS_ClosingSignedFeeRange_write"))) TS_ClosingSignedFeeRange_write(uint32_t obj) {
33943         LDKClosingSignedFeeRange obj_conv;
33944         obj_conv.inner = (void*)(obj & (~1));
33945         obj_conv.is_owned = false;
33946         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33947         LDKCVec_u8Z ret_var = ClosingSignedFeeRange_write(&obj_conv);
33948         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33949         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33950         CVec_u8Z_free(ret_var);
33951         return ret_arr;
33952 }
33953
33954 uint32_t  __attribute__((export_name("TS_ClosingSignedFeeRange_read"))) TS_ClosingSignedFeeRange_read(int8_tArray ser) {
33955         LDKu8slice ser_ref;
33956         ser_ref.datalen = ser->arr_len;
33957         ser_ref.data = ser->elems;
33958         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
33959         *ret_conv = ClosingSignedFeeRange_read(ser_ref);
33960         FREE(ser);
33961         return (uint32_t)ret_conv;
33962 }
33963
33964 int8_tArray  __attribute__((export_name("TS_CommitmentSigned_write"))) TS_CommitmentSigned_write(uint32_t obj) {
33965         LDKCommitmentSigned obj_conv;
33966         obj_conv.inner = (void*)(obj & (~1));
33967         obj_conv.is_owned = false;
33968         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33969         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
33970         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33971         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33972         CVec_u8Z_free(ret_var);
33973         return ret_arr;
33974 }
33975
33976 uint32_t  __attribute__((export_name("TS_CommitmentSigned_read"))) TS_CommitmentSigned_read(int8_tArray ser) {
33977         LDKu8slice ser_ref;
33978         ser_ref.datalen = ser->arr_len;
33979         ser_ref.data = ser->elems;
33980         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
33981         *ret_conv = CommitmentSigned_read(ser_ref);
33982         FREE(ser);
33983         return (uint32_t)ret_conv;
33984 }
33985
33986 int8_tArray  __attribute__((export_name("TS_FundingCreated_write"))) TS_FundingCreated_write(uint32_t obj) {
33987         LDKFundingCreated obj_conv;
33988         obj_conv.inner = (void*)(obj & (~1));
33989         obj_conv.is_owned = false;
33990         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33991         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
33992         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33993         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33994         CVec_u8Z_free(ret_var);
33995         return ret_arr;
33996 }
33997
33998 uint32_t  __attribute__((export_name("TS_FundingCreated_read"))) TS_FundingCreated_read(int8_tArray ser) {
33999         LDKu8slice ser_ref;
34000         ser_ref.datalen = ser->arr_len;
34001         ser_ref.data = ser->elems;
34002         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
34003         *ret_conv = FundingCreated_read(ser_ref);
34004         FREE(ser);
34005         return (uint32_t)ret_conv;
34006 }
34007
34008 int8_tArray  __attribute__((export_name("TS_FundingSigned_write"))) TS_FundingSigned_write(uint32_t obj) {
34009         LDKFundingSigned obj_conv;
34010         obj_conv.inner = (void*)(obj & (~1));
34011         obj_conv.is_owned = false;
34012         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34013         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
34014         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34015         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34016         CVec_u8Z_free(ret_var);
34017         return ret_arr;
34018 }
34019
34020 uint32_t  __attribute__((export_name("TS_FundingSigned_read"))) TS_FundingSigned_read(int8_tArray ser) {
34021         LDKu8slice ser_ref;
34022         ser_ref.datalen = ser->arr_len;
34023         ser_ref.data = ser->elems;
34024         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
34025         *ret_conv = FundingSigned_read(ser_ref);
34026         FREE(ser);
34027         return (uint32_t)ret_conv;
34028 }
34029
34030 int8_tArray  __attribute__((export_name("TS_ChannelReady_write"))) TS_ChannelReady_write(uint32_t obj) {
34031         LDKChannelReady obj_conv;
34032         obj_conv.inner = (void*)(obj & (~1));
34033         obj_conv.is_owned = false;
34034         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34035         LDKCVec_u8Z ret_var = ChannelReady_write(&obj_conv);
34036         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34037         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34038         CVec_u8Z_free(ret_var);
34039         return ret_arr;
34040 }
34041
34042 uint32_t  __attribute__((export_name("TS_ChannelReady_read"))) TS_ChannelReady_read(int8_tArray ser) {
34043         LDKu8slice ser_ref;
34044         ser_ref.datalen = ser->arr_len;
34045         ser_ref.data = ser->elems;
34046         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
34047         *ret_conv = ChannelReady_read(ser_ref);
34048         FREE(ser);
34049         return (uint32_t)ret_conv;
34050 }
34051
34052 int8_tArray  __attribute__((export_name("TS_Init_write"))) TS_Init_write(uint32_t obj) {
34053         LDKInit obj_conv;
34054         obj_conv.inner = (void*)(obj & (~1));
34055         obj_conv.is_owned = false;
34056         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34057         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
34058         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34059         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34060         CVec_u8Z_free(ret_var);
34061         return ret_arr;
34062 }
34063
34064 uint32_t  __attribute__((export_name("TS_Init_read"))) TS_Init_read(int8_tArray ser) {
34065         LDKu8slice ser_ref;
34066         ser_ref.datalen = ser->arr_len;
34067         ser_ref.data = ser->elems;
34068         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
34069         *ret_conv = Init_read(ser_ref);
34070         FREE(ser);
34071         return (uint32_t)ret_conv;
34072 }
34073
34074 int8_tArray  __attribute__((export_name("TS_OpenChannel_write"))) TS_OpenChannel_write(uint32_t obj) {
34075         LDKOpenChannel obj_conv;
34076         obj_conv.inner = (void*)(obj & (~1));
34077         obj_conv.is_owned = false;
34078         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34079         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
34080         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34081         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34082         CVec_u8Z_free(ret_var);
34083         return ret_arr;
34084 }
34085
34086 uint32_t  __attribute__((export_name("TS_OpenChannel_read"))) TS_OpenChannel_read(int8_tArray ser) {
34087         LDKu8slice ser_ref;
34088         ser_ref.datalen = ser->arr_len;
34089         ser_ref.data = ser->elems;
34090         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
34091         *ret_conv = OpenChannel_read(ser_ref);
34092         FREE(ser);
34093         return (uint32_t)ret_conv;
34094 }
34095
34096 int8_tArray  __attribute__((export_name("TS_RevokeAndACK_write"))) TS_RevokeAndACK_write(uint32_t obj) {
34097         LDKRevokeAndACK obj_conv;
34098         obj_conv.inner = (void*)(obj & (~1));
34099         obj_conv.is_owned = false;
34100         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34101         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
34102         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34103         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34104         CVec_u8Z_free(ret_var);
34105         return ret_arr;
34106 }
34107
34108 uint32_t  __attribute__((export_name("TS_RevokeAndACK_read"))) TS_RevokeAndACK_read(int8_tArray ser) {
34109         LDKu8slice ser_ref;
34110         ser_ref.datalen = ser->arr_len;
34111         ser_ref.data = ser->elems;
34112         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
34113         *ret_conv = RevokeAndACK_read(ser_ref);
34114         FREE(ser);
34115         return (uint32_t)ret_conv;
34116 }
34117
34118 int8_tArray  __attribute__((export_name("TS_Shutdown_write"))) TS_Shutdown_write(uint32_t obj) {
34119         LDKShutdown obj_conv;
34120         obj_conv.inner = (void*)(obj & (~1));
34121         obj_conv.is_owned = false;
34122         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34123         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
34124         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34125         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34126         CVec_u8Z_free(ret_var);
34127         return ret_arr;
34128 }
34129
34130 uint32_t  __attribute__((export_name("TS_Shutdown_read"))) TS_Shutdown_read(int8_tArray ser) {
34131         LDKu8slice ser_ref;
34132         ser_ref.datalen = ser->arr_len;
34133         ser_ref.data = ser->elems;
34134         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
34135         *ret_conv = Shutdown_read(ser_ref);
34136         FREE(ser);
34137         return (uint32_t)ret_conv;
34138 }
34139
34140 int8_tArray  __attribute__((export_name("TS_UpdateFailHTLC_write"))) TS_UpdateFailHTLC_write(uint32_t obj) {
34141         LDKUpdateFailHTLC obj_conv;
34142         obj_conv.inner = (void*)(obj & (~1));
34143         obj_conv.is_owned = false;
34144         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34145         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
34146         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34147         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34148         CVec_u8Z_free(ret_var);
34149         return ret_arr;
34150 }
34151
34152 uint32_t  __attribute__((export_name("TS_UpdateFailHTLC_read"))) TS_UpdateFailHTLC_read(int8_tArray ser) {
34153         LDKu8slice ser_ref;
34154         ser_ref.datalen = ser->arr_len;
34155         ser_ref.data = ser->elems;
34156         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
34157         *ret_conv = UpdateFailHTLC_read(ser_ref);
34158         FREE(ser);
34159         return (uint32_t)ret_conv;
34160 }
34161
34162 int8_tArray  __attribute__((export_name("TS_UpdateFailMalformedHTLC_write"))) TS_UpdateFailMalformedHTLC_write(uint32_t obj) {
34163         LDKUpdateFailMalformedHTLC obj_conv;
34164         obj_conv.inner = (void*)(obj & (~1));
34165         obj_conv.is_owned = false;
34166         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34167         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
34168         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34169         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34170         CVec_u8Z_free(ret_var);
34171         return ret_arr;
34172 }
34173
34174 uint32_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_read"))) TS_UpdateFailMalformedHTLC_read(int8_tArray ser) {
34175         LDKu8slice ser_ref;
34176         ser_ref.datalen = ser->arr_len;
34177         ser_ref.data = ser->elems;
34178         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
34179         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
34180         FREE(ser);
34181         return (uint32_t)ret_conv;
34182 }
34183
34184 int8_tArray  __attribute__((export_name("TS_UpdateFee_write"))) TS_UpdateFee_write(uint32_t obj) {
34185         LDKUpdateFee obj_conv;
34186         obj_conv.inner = (void*)(obj & (~1));
34187         obj_conv.is_owned = false;
34188         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34189         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
34190         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34191         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34192         CVec_u8Z_free(ret_var);
34193         return ret_arr;
34194 }
34195
34196 uint32_t  __attribute__((export_name("TS_UpdateFee_read"))) TS_UpdateFee_read(int8_tArray ser) {
34197         LDKu8slice ser_ref;
34198         ser_ref.datalen = ser->arr_len;
34199         ser_ref.data = ser->elems;
34200         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
34201         *ret_conv = UpdateFee_read(ser_ref);
34202         FREE(ser);
34203         return (uint32_t)ret_conv;
34204 }
34205
34206 int8_tArray  __attribute__((export_name("TS_UpdateFulfillHTLC_write"))) TS_UpdateFulfillHTLC_write(uint32_t obj) {
34207         LDKUpdateFulfillHTLC obj_conv;
34208         obj_conv.inner = (void*)(obj & (~1));
34209         obj_conv.is_owned = false;
34210         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34211         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
34212         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34213         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34214         CVec_u8Z_free(ret_var);
34215         return ret_arr;
34216 }
34217
34218 uint32_t  __attribute__((export_name("TS_UpdateFulfillHTLC_read"))) TS_UpdateFulfillHTLC_read(int8_tArray ser) {
34219         LDKu8slice ser_ref;
34220         ser_ref.datalen = ser->arr_len;
34221         ser_ref.data = ser->elems;
34222         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
34223         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
34224         FREE(ser);
34225         return (uint32_t)ret_conv;
34226 }
34227
34228 int8_tArray  __attribute__((export_name("TS_UpdateAddHTLC_write"))) TS_UpdateAddHTLC_write(uint32_t obj) {
34229         LDKUpdateAddHTLC obj_conv;
34230         obj_conv.inner = (void*)(obj & (~1));
34231         obj_conv.is_owned = false;
34232         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34233         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
34234         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34235         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34236         CVec_u8Z_free(ret_var);
34237         return ret_arr;
34238 }
34239
34240 uint32_t  __attribute__((export_name("TS_UpdateAddHTLC_read"))) TS_UpdateAddHTLC_read(int8_tArray ser) {
34241         LDKu8slice ser_ref;
34242         ser_ref.datalen = ser->arr_len;
34243         ser_ref.data = ser->elems;
34244         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
34245         *ret_conv = UpdateAddHTLC_read(ser_ref);
34246         FREE(ser);
34247         return (uint32_t)ret_conv;
34248 }
34249
34250 int8_tArray  __attribute__((export_name("TS_Ping_write"))) TS_Ping_write(uint32_t obj) {
34251         LDKPing obj_conv;
34252         obj_conv.inner = (void*)(obj & (~1));
34253         obj_conv.is_owned = false;
34254         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34255         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
34256         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34257         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34258         CVec_u8Z_free(ret_var);
34259         return ret_arr;
34260 }
34261
34262 uint32_t  __attribute__((export_name("TS_Ping_read"))) TS_Ping_read(int8_tArray ser) {
34263         LDKu8slice ser_ref;
34264         ser_ref.datalen = ser->arr_len;
34265         ser_ref.data = ser->elems;
34266         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
34267         *ret_conv = Ping_read(ser_ref);
34268         FREE(ser);
34269         return (uint32_t)ret_conv;
34270 }
34271
34272 int8_tArray  __attribute__((export_name("TS_Pong_write"))) TS_Pong_write(uint32_t obj) {
34273         LDKPong obj_conv;
34274         obj_conv.inner = (void*)(obj & (~1));
34275         obj_conv.is_owned = false;
34276         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34277         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
34278         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34279         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34280         CVec_u8Z_free(ret_var);
34281         return ret_arr;
34282 }
34283
34284 uint32_t  __attribute__((export_name("TS_Pong_read"))) TS_Pong_read(int8_tArray ser) {
34285         LDKu8slice ser_ref;
34286         ser_ref.datalen = ser->arr_len;
34287         ser_ref.data = ser->elems;
34288         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
34289         *ret_conv = Pong_read(ser_ref);
34290         FREE(ser);
34291         return (uint32_t)ret_conv;
34292 }
34293
34294 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_write"))) TS_UnsignedChannelAnnouncement_write(uint32_t obj) {
34295         LDKUnsignedChannelAnnouncement obj_conv;
34296         obj_conv.inner = (void*)(obj & (~1));
34297         obj_conv.is_owned = false;
34298         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34299         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
34300         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34301         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34302         CVec_u8Z_free(ret_var);
34303         return ret_arr;
34304 }
34305
34306 uint32_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_read"))) TS_UnsignedChannelAnnouncement_read(int8_tArray ser) {
34307         LDKu8slice ser_ref;
34308         ser_ref.datalen = ser->arr_len;
34309         ser_ref.data = ser->elems;
34310         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
34311         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
34312         FREE(ser);
34313         return (uint32_t)ret_conv;
34314 }
34315
34316 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_write"))) TS_ChannelAnnouncement_write(uint32_t obj) {
34317         LDKChannelAnnouncement obj_conv;
34318         obj_conv.inner = (void*)(obj & (~1));
34319         obj_conv.is_owned = false;
34320         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34321         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
34322         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34323         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34324         CVec_u8Z_free(ret_var);
34325         return ret_arr;
34326 }
34327
34328 uint32_t  __attribute__((export_name("TS_ChannelAnnouncement_read"))) TS_ChannelAnnouncement_read(int8_tArray ser) {
34329         LDKu8slice ser_ref;
34330         ser_ref.datalen = ser->arr_len;
34331         ser_ref.data = ser->elems;
34332         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
34333         *ret_conv = ChannelAnnouncement_read(ser_ref);
34334         FREE(ser);
34335         return (uint32_t)ret_conv;
34336 }
34337
34338 int8_tArray  __attribute__((export_name("TS_UnsignedChannelUpdate_write"))) TS_UnsignedChannelUpdate_write(uint32_t obj) {
34339         LDKUnsignedChannelUpdate obj_conv;
34340         obj_conv.inner = (void*)(obj & (~1));
34341         obj_conv.is_owned = false;
34342         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34343         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
34344         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34345         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34346         CVec_u8Z_free(ret_var);
34347         return ret_arr;
34348 }
34349
34350 uint32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_read"))) TS_UnsignedChannelUpdate_read(int8_tArray ser) {
34351         LDKu8slice ser_ref;
34352         ser_ref.datalen = ser->arr_len;
34353         ser_ref.data = ser->elems;
34354         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
34355         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
34356         FREE(ser);
34357         return (uint32_t)ret_conv;
34358 }
34359
34360 int8_tArray  __attribute__((export_name("TS_ChannelUpdate_write"))) TS_ChannelUpdate_write(uint32_t obj) {
34361         LDKChannelUpdate obj_conv;
34362         obj_conv.inner = (void*)(obj & (~1));
34363         obj_conv.is_owned = false;
34364         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34365         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
34366         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34367         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34368         CVec_u8Z_free(ret_var);
34369         return ret_arr;
34370 }
34371
34372 uint32_t  __attribute__((export_name("TS_ChannelUpdate_read"))) TS_ChannelUpdate_read(int8_tArray ser) {
34373         LDKu8slice ser_ref;
34374         ser_ref.datalen = ser->arr_len;
34375         ser_ref.data = ser->elems;
34376         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
34377         *ret_conv = ChannelUpdate_read(ser_ref);
34378         FREE(ser);
34379         return (uint32_t)ret_conv;
34380 }
34381
34382 int8_tArray  __attribute__((export_name("TS_ErrorMessage_write"))) TS_ErrorMessage_write(uint32_t obj) {
34383         LDKErrorMessage obj_conv;
34384         obj_conv.inner = (void*)(obj & (~1));
34385         obj_conv.is_owned = false;
34386         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34387         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
34388         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34389         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34390         CVec_u8Z_free(ret_var);
34391         return ret_arr;
34392 }
34393
34394 uint32_t  __attribute__((export_name("TS_ErrorMessage_read"))) TS_ErrorMessage_read(int8_tArray ser) {
34395         LDKu8slice ser_ref;
34396         ser_ref.datalen = ser->arr_len;
34397         ser_ref.data = ser->elems;
34398         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
34399         *ret_conv = ErrorMessage_read(ser_ref);
34400         FREE(ser);
34401         return (uint32_t)ret_conv;
34402 }
34403
34404 int8_tArray  __attribute__((export_name("TS_WarningMessage_write"))) TS_WarningMessage_write(uint32_t obj) {
34405         LDKWarningMessage obj_conv;
34406         obj_conv.inner = (void*)(obj & (~1));
34407         obj_conv.is_owned = false;
34408         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34409         LDKCVec_u8Z ret_var = WarningMessage_write(&obj_conv);
34410         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34411         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34412         CVec_u8Z_free(ret_var);
34413         return ret_arr;
34414 }
34415
34416 uint32_t  __attribute__((export_name("TS_WarningMessage_read"))) TS_WarningMessage_read(int8_tArray ser) {
34417         LDKu8slice ser_ref;
34418         ser_ref.datalen = ser->arr_len;
34419         ser_ref.data = ser->elems;
34420         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
34421         *ret_conv = WarningMessage_read(ser_ref);
34422         FREE(ser);
34423         return (uint32_t)ret_conv;
34424 }
34425
34426 int8_tArray  __attribute__((export_name("TS_UnsignedNodeAnnouncement_write"))) TS_UnsignedNodeAnnouncement_write(uint32_t obj) {
34427         LDKUnsignedNodeAnnouncement obj_conv;
34428         obj_conv.inner = (void*)(obj & (~1));
34429         obj_conv.is_owned = false;
34430         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34431         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
34432         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34433         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34434         CVec_u8Z_free(ret_var);
34435         return ret_arr;
34436 }
34437
34438 uint32_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_read"))) TS_UnsignedNodeAnnouncement_read(int8_tArray ser) {
34439         LDKu8slice ser_ref;
34440         ser_ref.datalen = ser->arr_len;
34441         ser_ref.data = ser->elems;
34442         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
34443         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
34444         FREE(ser);
34445         return (uint32_t)ret_conv;
34446 }
34447
34448 int8_tArray  __attribute__((export_name("TS_NodeAnnouncement_write"))) TS_NodeAnnouncement_write(uint32_t obj) {
34449         LDKNodeAnnouncement obj_conv;
34450         obj_conv.inner = (void*)(obj & (~1));
34451         obj_conv.is_owned = false;
34452         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34453         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
34454         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34455         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34456         CVec_u8Z_free(ret_var);
34457         return ret_arr;
34458 }
34459
34460 uint32_t  __attribute__((export_name("TS_NodeAnnouncement_read"))) TS_NodeAnnouncement_read(int8_tArray ser) {
34461         LDKu8slice ser_ref;
34462         ser_ref.datalen = ser->arr_len;
34463         ser_ref.data = ser->elems;
34464         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
34465         *ret_conv = NodeAnnouncement_read(ser_ref);
34466         FREE(ser);
34467         return (uint32_t)ret_conv;
34468 }
34469
34470 uint32_t  __attribute__((export_name("TS_QueryShortChannelIds_read"))) TS_QueryShortChannelIds_read(int8_tArray ser) {
34471         LDKu8slice ser_ref;
34472         ser_ref.datalen = ser->arr_len;
34473         ser_ref.data = ser->elems;
34474         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
34475         *ret_conv = QueryShortChannelIds_read(ser_ref);
34476         FREE(ser);
34477         return (uint32_t)ret_conv;
34478 }
34479
34480 int8_tArray  __attribute__((export_name("TS_QueryShortChannelIds_write"))) TS_QueryShortChannelIds_write(uint32_t obj) {
34481         LDKQueryShortChannelIds obj_conv;
34482         obj_conv.inner = (void*)(obj & (~1));
34483         obj_conv.is_owned = false;
34484         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34485         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
34486         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34487         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34488         CVec_u8Z_free(ret_var);
34489         return ret_arr;
34490 }
34491
34492 int8_tArray  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_write"))) TS_ReplyShortChannelIdsEnd_write(uint32_t obj) {
34493         LDKReplyShortChannelIdsEnd obj_conv;
34494         obj_conv.inner = (void*)(obj & (~1));
34495         obj_conv.is_owned = false;
34496         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34497         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
34498         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34499         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34500         CVec_u8Z_free(ret_var);
34501         return ret_arr;
34502 }
34503
34504 uint32_t  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_read"))) TS_ReplyShortChannelIdsEnd_read(int8_tArray ser) {
34505         LDKu8slice ser_ref;
34506         ser_ref.datalen = ser->arr_len;
34507         ser_ref.data = ser->elems;
34508         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
34509         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
34510         FREE(ser);
34511         return (uint32_t)ret_conv;
34512 }
34513
34514 int32_t  __attribute__((export_name("TS_QueryChannelRange_end_blocknum"))) TS_QueryChannelRange_end_blocknum(uint32_t this_arg) {
34515         LDKQueryChannelRange this_arg_conv;
34516         this_arg_conv.inner = (void*)(this_arg & (~1));
34517         this_arg_conv.is_owned = false;
34518         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34519         int32_t ret_conv = QueryChannelRange_end_blocknum(&this_arg_conv);
34520         return ret_conv;
34521 }
34522
34523 int8_tArray  __attribute__((export_name("TS_QueryChannelRange_write"))) TS_QueryChannelRange_write(uint32_t obj) {
34524         LDKQueryChannelRange obj_conv;
34525         obj_conv.inner = (void*)(obj & (~1));
34526         obj_conv.is_owned = false;
34527         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34528         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
34529         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34530         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34531         CVec_u8Z_free(ret_var);
34532         return ret_arr;
34533 }
34534
34535 uint32_t  __attribute__((export_name("TS_QueryChannelRange_read"))) TS_QueryChannelRange_read(int8_tArray ser) {
34536         LDKu8slice ser_ref;
34537         ser_ref.datalen = ser->arr_len;
34538         ser_ref.data = ser->elems;
34539         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
34540         *ret_conv = QueryChannelRange_read(ser_ref);
34541         FREE(ser);
34542         return (uint32_t)ret_conv;
34543 }
34544
34545 uint32_t  __attribute__((export_name("TS_ReplyChannelRange_read"))) TS_ReplyChannelRange_read(int8_tArray ser) {
34546         LDKu8slice ser_ref;
34547         ser_ref.datalen = ser->arr_len;
34548         ser_ref.data = ser->elems;
34549         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
34550         *ret_conv = ReplyChannelRange_read(ser_ref);
34551         FREE(ser);
34552         return (uint32_t)ret_conv;
34553 }
34554
34555 int8_tArray  __attribute__((export_name("TS_ReplyChannelRange_write"))) TS_ReplyChannelRange_write(uint32_t obj) {
34556         LDKReplyChannelRange obj_conv;
34557         obj_conv.inner = (void*)(obj & (~1));
34558         obj_conv.is_owned = false;
34559         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34560         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
34561         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34562         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34563         CVec_u8Z_free(ret_var);
34564         return ret_arr;
34565 }
34566
34567 int8_tArray  __attribute__((export_name("TS_GossipTimestampFilter_write"))) TS_GossipTimestampFilter_write(uint32_t obj) {
34568         LDKGossipTimestampFilter obj_conv;
34569         obj_conv.inner = (void*)(obj & (~1));
34570         obj_conv.is_owned = false;
34571         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34572         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
34573         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34574         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34575         CVec_u8Z_free(ret_var);
34576         return ret_arr;
34577 }
34578
34579 uint32_t  __attribute__((export_name("TS_GossipTimestampFilter_read"))) TS_GossipTimestampFilter_read(int8_tArray ser) {
34580         LDKu8slice ser_ref;
34581         ser_ref.datalen = ser->arr_len;
34582         ser_ref.data = ser->elems;
34583         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
34584         *ret_conv = GossipTimestampFilter_read(ser_ref);
34585         FREE(ser);
34586         return (uint32_t)ret_conv;
34587 }
34588
34589 void  __attribute__((export_name("TS_CustomMessageHandler_free"))) TS_CustomMessageHandler_free(uint32_t this_ptr) {
34590         if ((this_ptr & 1) != 0) return;
34591         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
34592         CHECK_ACCESS(this_ptr_ptr);
34593         LDKCustomMessageHandler this_ptr_conv = *(LDKCustomMessageHandler*)(this_ptr_ptr);
34594         FREE((void*)this_ptr);
34595         CustomMessageHandler_free(this_ptr_conv);
34596 }
34597
34598 void  __attribute__((export_name("TS_IgnoringMessageHandler_free"))) TS_IgnoringMessageHandler_free(uint32_t this_obj) {
34599         LDKIgnoringMessageHandler this_obj_conv;
34600         this_obj_conv.inner = (void*)(this_obj & (~1));
34601         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34602         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34603         IgnoringMessageHandler_free(this_obj_conv);
34604 }
34605
34606 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_new"))) TS_IgnoringMessageHandler_new() {
34607         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
34608         uint32_t ret_ref = 0;
34609         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34610         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34611         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34612         ret_ref = (uintptr_t)ret_var.inner;
34613         if (ret_var.is_owned) {
34614                 ret_ref |= 1;
34615         }
34616         return ret_ref;
34617 }
34618
34619 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_as_MessageSendEventsProvider"))) TS_IgnoringMessageHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
34620         LDKIgnoringMessageHandler this_arg_conv;
34621         this_arg_conv.inner = (void*)(this_arg & (~1));
34622         this_arg_conv.is_owned = false;
34623         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34624         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
34625         *ret_ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
34626         return (uint32_t)ret_ret;
34627 }
34628
34629 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_as_RoutingMessageHandler"))) TS_IgnoringMessageHandler_as_RoutingMessageHandler(uint32_t this_arg) {
34630         LDKIgnoringMessageHandler this_arg_conv;
34631         this_arg_conv.inner = (void*)(this_arg & (~1));
34632         this_arg_conv.is_owned = false;
34633         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34634         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
34635         *ret_ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
34636         return (uint32_t)ret_ret;
34637 }
34638
34639 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_as_CustomMessageReader"))) TS_IgnoringMessageHandler_as_CustomMessageReader(uint32_t this_arg) {
34640         LDKIgnoringMessageHandler this_arg_conv;
34641         this_arg_conv.inner = (void*)(this_arg & (~1));
34642         this_arg_conv.is_owned = false;
34643         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34644         LDKCustomMessageReader* ret_ret = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
34645         *ret_ret = IgnoringMessageHandler_as_CustomMessageReader(&this_arg_conv);
34646         return (uint32_t)ret_ret;
34647 }
34648
34649 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_as_CustomMessageHandler"))) TS_IgnoringMessageHandler_as_CustomMessageHandler(uint32_t this_arg) {
34650         LDKIgnoringMessageHandler this_arg_conv;
34651         this_arg_conv.inner = (void*)(this_arg & (~1));
34652         this_arg_conv.is_owned = false;
34653         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34654         LDKCustomMessageHandler* ret_ret = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
34655         *ret_ret = IgnoringMessageHandler_as_CustomMessageHandler(&this_arg_conv);
34656         return (uint32_t)ret_ret;
34657 }
34658
34659 void  __attribute__((export_name("TS_ErroringMessageHandler_free"))) TS_ErroringMessageHandler_free(uint32_t this_obj) {
34660         LDKErroringMessageHandler this_obj_conv;
34661         this_obj_conv.inner = (void*)(this_obj & (~1));
34662         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34663         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34664         ErroringMessageHandler_free(this_obj_conv);
34665 }
34666
34667 uint32_t  __attribute__((export_name("TS_ErroringMessageHandler_new"))) TS_ErroringMessageHandler_new() {
34668         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
34669         uint32_t ret_ref = 0;
34670         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34671         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34672         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34673         ret_ref = (uintptr_t)ret_var.inner;
34674         if (ret_var.is_owned) {
34675                 ret_ref |= 1;
34676         }
34677         return ret_ref;
34678 }
34679
34680 uint32_t  __attribute__((export_name("TS_ErroringMessageHandler_as_MessageSendEventsProvider"))) TS_ErroringMessageHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
34681         LDKErroringMessageHandler this_arg_conv;
34682         this_arg_conv.inner = (void*)(this_arg & (~1));
34683         this_arg_conv.is_owned = false;
34684         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34685         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
34686         *ret_ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
34687         return (uint32_t)ret_ret;
34688 }
34689
34690 uint32_t  __attribute__((export_name("TS_ErroringMessageHandler_as_ChannelMessageHandler"))) TS_ErroringMessageHandler_as_ChannelMessageHandler(uint32_t this_arg) {
34691         LDKErroringMessageHandler this_arg_conv;
34692         this_arg_conv.inner = (void*)(this_arg & (~1));
34693         this_arg_conv.is_owned = false;
34694         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34695         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
34696         *ret_ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
34697         return (uint32_t)ret_ret;
34698 }
34699
34700 void  __attribute__((export_name("TS_MessageHandler_free"))) TS_MessageHandler_free(uint32_t this_obj) {
34701         LDKMessageHandler this_obj_conv;
34702         this_obj_conv.inner = (void*)(this_obj & (~1));
34703         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34704         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34705         MessageHandler_free(this_obj_conv);
34706 }
34707
34708 uint32_t  __attribute__((export_name("TS_MessageHandler_get_chan_handler"))) TS_MessageHandler_get_chan_handler(uint32_t this_ptr) {
34709         LDKMessageHandler this_ptr_conv;
34710         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34711         this_ptr_conv.is_owned = false;
34712         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34713         // WARNING: This object doesn't live past this scope, needs clone!
34714         uint32_t ret_ret = ((uintptr_t)MessageHandler_get_chan_handler(&this_ptr_conv)) | 1;
34715         return ret_ret;
34716 }
34717
34718 void  __attribute__((export_name("TS_MessageHandler_set_chan_handler"))) TS_MessageHandler_set_chan_handler(uint32_t this_ptr, uint32_t val) {
34719         LDKMessageHandler this_ptr_conv;
34720         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34721         this_ptr_conv.is_owned = false;
34722         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34723         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
34724         CHECK_ACCESS(val_ptr);
34725         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(val_ptr);
34726         if (val_conv.free == LDKChannelMessageHandler_JCalls_free) {
34727                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34728                 LDKChannelMessageHandler_JCalls_cloned(&val_conv);
34729         }
34730         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
34731 }
34732
34733 uint32_t  __attribute__((export_name("TS_MessageHandler_get_route_handler"))) TS_MessageHandler_get_route_handler(uint32_t this_ptr) {
34734         LDKMessageHandler this_ptr_conv;
34735         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34736         this_ptr_conv.is_owned = false;
34737         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34738         // WARNING: This object doesn't live past this scope, needs clone!
34739         uint32_t ret_ret = ((uintptr_t)MessageHandler_get_route_handler(&this_ptr_conv)) | 1;
34740         return ret_ret;
34741 }
34742
34743 void  __attribute__((export_name("TS_MessageHandler_set_route_handler"))) TS_MessageHandler_set_route_handler(uint32_t this_ptr, uint32_t val) {
34744         LDKMessageHandler this_ptr_conv;
34745         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34746         this_ptr_conv.is_owned = false;
34747         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34748         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
34749         CHECK_ACCESS(val_ptr);
34750         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(val_ptr);
34751         if (val_conv.free == LDKRoutingMessageHandler_JCalls_free) {
34752                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34753                 LDKRoutingMessageHandler_JCalls_cloned(&val_conv);
34754         }
34755         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
34756 }
34757
34758 uint32_t  __attribute__((export_name("TS_MessageHandler_new"))) TS_MessageHandler_new(uint32_t chan_handler_arg, uint32_t route_handler_arg) {
34759         void* chan_handler_arg_ptr = (void*)(((uintptr_t)chan_handler_arg) & ~1);
34760         CHECK_ACCESS(chan_handler_arg_ptr);
34761         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(chan_handler_arg_ptr);
34762         if (chan_handler_arg_conv.free == LDKChannelMessageHandler_JCalls_free) {
34763                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34764                 LDKChannelMessageHandler_JCalls_cloned(&chan_handler_arg_conv);
34765         }
34766         void* route_handler_arg_ptr = (void*)(((uintptr_t)route_handler_arg) & ~1);
34767         CHECK_ACCESS(route_handler_arg_ptr);
34768         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(route_handler_arg_ptr);
34769         if (route_handler_arg_conv.free == LDKRoutingMessageHandler_JCalls_free) {
34770                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34771                 LDKRoutingMessageHandler_JCalls_cloned(&route_handler_arg_conv);
34772         }
34773         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
34774         uint32_t ret_ref = 0;
34775         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34776         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34777         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34778         ret_ref = (uintptr_t)ret_var.inner;
34779         if (ret_var.is_owned) {
34780                 ret_ref |= 1;
34781         }
34782         return ret_ref;
34783 }
34784
34785 static inline uintptr_t SocketDescriptor_clone_ptr(LDKSocketDescriptor *NONNULL_PTR arg) {
34786         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
34787         *ret_ret = SocketDescriptor_clone(arg);
34788         return (uint32_t)ret_ret;
34789 }
34790 uint32_t  __attribute__((export_name("TS_SocketDescriptor_clone_ptr"))) TS_SocketDescriptor_clone_ptr(uint32_t arg) {
34791         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
34792         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
34793         LDKSocketDescriptor* arg_conv = (LDKSocketDescriptor*)arg_ptr;
34794         uint32_t ret_conv = SocketDescriptor_clone_ptr(arg_conv);
34795         return ret_conv;
34796 }
34797
34798 uint32_t  __attribute__((export_name("TS_SocketDescriptor_clone"))) TS_SocketDescriptor_clone(uint32_t orig) {
34799         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
34800         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
34801         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)orig_ptr;
34802         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
34803         *ret_ret = SocketDescriptor_clone(orig_conv);
34804         return (uint32_t)ret_ret;
34805 }
34806
34807 void  __attribute__((export_name("TS_SocketDescriptor_free"))) TS_SocketDescriptor_free(uint32_t this_ptr) {
34808         if ((this_ptr & 1) != 0) return;
34809         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
34810         CHECK_ACCESS(this_ptr_ptr);
34811         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(this_ptr_ptr);
34812         FREE((void*)this_ptr);
34813         SocketDescriptor_free(this_ptr_conv);
34814 }
34815
34816 void  __attribute__((export_name("TS_PeerHandleError_free"))) TS_PeerHandleError_free(uint32_t this_obj) {
34817         LDKPeerHandleError this_obj_conv;
34818         this_obj_conv.inner = (void*)(this_obj & (~1));
34819         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34820         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34821         PeerHandleError_free(this_obj_conv);
34822 }
34823
34824 jboolean  __attribute__((export_name("TS_PeerHandleError_get_no_connection_possible"))) TS_PeerHandleError_get_no_connection_possible(uint32_t this_ptr) {
34825         LDKPeerHandleError this_ptr_conv;
34826         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34827         this_ptr_conv.is_owned = false;
34828         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34829         jboolean ret_conv = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
34830         return ret_conv;
34831 }
34832
34833 void  __attribute__((export_name("TS_PeerHandleError_set_no_connection_possible"))) TS_PeerHandleError_set_no_connection_possible(uint32_t this_ptr, jboolean val) {
34834         LDKPeerHandleError this_ptr_conv;
34835         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34836         this_ptr_conv.is_owned = false;
34837         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34838         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
34839 }
34840
34841 uint32_t  __attribute__((export_name("TS_PeerHandleError_new"))) TS_PeerHandleError_new(jboolean no_connection_possible_arg) {
34842         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
34843         uint32_t ret_ref = 0;
34844         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34845         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34846         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34847         ret_ref = (uintptr_t)ret_var.inner;
34848         if (ret_var.is_owned) {
34849                 ret_ref |= 1;
34850         }
34851         return ret_ref;
34852 }
34853
34854 static inline uintptr_t PeerHandleError_clone_ptr(LDKPeerHandleError *NONNULL_PTR arg) {
34855         LDKPeerHandleError ret_var = PeerHandleError_clone(arg);
34856 uint32_t ret_ref = 0;
34857 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34858 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34859 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34860 ret_ref = (uintptr_t)ret_var.inner;
34861 if (ret_var.is_owned) {
34862         ret_ref |= 1;
34863 }
34864         return ret_ref;
34865 }
34866 uint32_t  __attribute__((export_name("TS_PeerHandleError_clone_ptr"))) TS_PeerHandleError_clone_ptr(uint32_t arg) {
34867         LDKPeerHandleError arg_conv;
34868         arg_conv.inner = (void*)(arg & (~1));
34869         arg_conv.is_owned = false;
34870         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34871         uint32_t ret_conv = PeerHandleError_clone_ptr(&arg_conv);
34872         return ret_conv;
34873 }
34874
34875 uint32_t  __attribute__((export_name("TS_PeerHandleError_clone"))) TS_PeerHandleError_clone(uint32_t orig) {
34876         LDKPeerHandleError orig_conv;
34877         orig_conv.inner = (void*)(orig & (~1));
34878         orig_conv.is_owned = false;
34879         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34880         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
34881         uint32_t ret_ref = 0;
34882         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34883         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34884         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34885         ret_ref = (uintptr_t)ret_var.inner;
34886         if (ret_var.is_owned) {
34887                 ret_ref |= 1;
34888         }
34889         return ret_ref;
34890 }
34891
34892 void  __attribute__((export_name("TS_PeerManager_free"))) TS_PeerManager_free(uint32_t this_obj) {
34893         LDKPeerManager this_obj_conv;
34894         this_obj_conv.inner = (void*)(this_obj & (~1));
34895         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34896         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34897         PeerManager_free(this_obj_conv);
34898 }
34899
34900 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) {
34901         LDKMessageHandler message_handler_conv;
34902         message_handler_conv.inner = (void*)(message_handler & (~1));
34903         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
34904         CHECK_INNER_FIELD_ACCESS_OR_NULL(message_handler_conv);
34905         // WARNING: we need a move here but no clone is available for LDKMessageHandler
34906         LDKSecretKey our_node_secret_ref;
34907         CHECK(our_node_secret->arr_len == 32);
34908         memcpy(our_node_secret_ref.bytes, our_node_secret->elems, 32); FREE(our_node_secret);
34909         unsigned char ephemeral_random_data_arr[32];
34910         CHECK(ephemeral_random_data->arr_len == 32);
34911         memcpy(ephemeral_random_data_arr, ephemeral_random_data->elems, 32); FREE(ephemeral_random_data);
34912         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
34913         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
34914         CHECK_ACCESS(logger_ptr);
34915         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
34916         if (logger_conv.free == LDKLogger_JCalls_free) {
34917                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34918                 LDKLogger_JCalls_cloned(&logger_conv);
34919         }
34920         void* custom_message_handler_ptr = (void*)(((uintptr_t)custom_message_handler) & ~1);
34921         CHECK_ACCESS(custom_message_handler_ptr);
34922         LDKCustomMessageHandler custom_message_handler_conv = *(LDKCustomMessageHandler*)(custom_message_handler_ptr);
34923         if (custom_message_handler_conv.free == LDKCustomMessageHandler_JCalls_free) {
34924                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34925                 LDKCustomMessageHandler_JCalls_cloned(&custom_message_handler_conv);
34926         }
34927         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv, custom_message_handler_conv);
34928         uint32_t ret_ref = 0;
34929         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34930         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34931         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34932         ret_ref = (uintptr_t)ret_var.inner;
34933         if (ret_var.is_owned) {
34934                 ret_ref |= 1;
34935         }
34936         return ret_ref;
34937 }
34938
34939 ptrArray  __attribute__((export_name("TS_PeerManager_get_peer_node_ids"))) TS_PeerManager_get_peer_node_ids(uint32_t this_arg) {
34940         LDKPeerManager this_arg_conv;
34941         this_arg_conv.inner = (void*)(this_arg & (~1));
34942         this_arg_conv.is_owned = false;
34943         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34944         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
34945         ptrArray ret_arr = NULL;
34946         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
34947         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 8);
34948         for (size_t m = 0; m < ret_var.datalen; m++) {
34949                 int8_tArray ret_conv_12_arr = init_int8_tArray(33, __LINE__);
34950                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].compressed_form, 33);
34951                 ret_arr_ptr[m] = ret_conv_12_arr;
34952         }
34953         
34954         FREE(ret_var.data);
34955         return ret_arr;
34956 }
34957
34958 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) {
34959         LDKPeerManager this_arg_conv;
34960         this_arg_conv.inner = (void*)(this_arg & (~1));
34961         this_arg_conv.is_owned = false;
34962         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34963         LDKPublicKey their_node_id_ref;
34964         CHECK(their_node_id->arr_len == 33);
34965         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
34966         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
34967         CHECK_ACCESS(descriptor_ptr);
34968         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
34969         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
34970                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34971                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
34972         }
34973         void* remote_network_address_ptr = (void*)(((uintptr_t)remote_network_address) & ~1);
34974         CHECK_ACCESS(remote_network_address_ptr);
34975         LDKCOption_NetAddressZ remote_network_address_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_ptr);
34976         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
34977         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv, remote_network_address_conv);
34978         return (uint32_t)ret_conv;
34979 }
34980
34981 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) {
34982         LDKPeerManager this_arg_conv;
34983         this_arg_conv.inner = (void*)(this_arg & (~1));
34984         this_arg_conv.is_owned = false;
34985         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34986         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
34987         CHECK_ACCESS(descriptor_ptr);
34988         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
34989         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
34990                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34991                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
34992         }
34993         void* remote_network_address_ptr = (void*)(((uintptr_t)remote_network_address) & ~1);
34994         CHECK_ACCESS(remote_network_address_ptr);
34995         LDKCOption_NetAddressZ remote_network_address_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_ptr);
34996         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
34997         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv, remote_network_address_conv);
34998         return (uint32_t)ret_conv;
34999 }
35000
35001 uint32_t  __attribute__((export_name("TS_PeerManager_write_buffer_space_avail"))) TS_PeerManager_write_buffer_space_avail(uint32_t this_arg, uint32_t descriptor) {
35002         LDKPeerManager this_arg_conv;
35003         this_arg_conv.inner = (void*)(this_arg & (~1));
35004         this_arg_conv.is_owned = false;
35005         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35006         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
35007         if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
35008         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
35009         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
35010         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
35011         return (uint32_t)ret_conv;
35012 }
35013
35014 uint32_t  __attribute__((export_name("TS_PeerManager_read_event"))) TS_PeerManager_read_event(uint32_t this_arg, uint32_t peer_descriptor, int8_tArray data) {
35015         LDKPeerManager this_arg_conv;
35016         this_arg_conv.inner = (void*)(this_arg & (~1));
35017         this_arg_conv.is_owned = false;
35018         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35019         void* peer_descriptor_ptr = (void*)(((uintptr_t)peer_descriptor) & ~1);
35020         if (!(peer_descriptor & 1)) { CHECK_ACCESS(peer_descriptor_ptr); }
35021         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)peer_descriptor_ptr;
35022         LDKu8slice data_ref;
35023         data_ref.datalen = data->arr_len;
35024         data_ref.data = data->elems;
35025         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
35026         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
35027         FREE(data);
35028         return (uint32_t)ret_conv;
35029 }
35030
35031 void  __attribute__((export_name("TS_PeerManager_process_events"))) TS_PeerManager_process_events(uint32_t this_arg) {
35032         LDKPeerManager this_arg_conv;
35033         this_arg_conv.inner = (void*)(this_arg & (~1));
35034         this_arg_conv.is_owned = false;
35035         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35036         PeerManager_process_events(&this_arg_conv);
35037 }
35038
35039 void  __attribute__((export_name("TS_PeerManager_socket_disconnected"))) TS_PeerManager_socket_disconnected(uint32_t this_arg, uint32_t descriptor) {
35040         LDKPeerManager this_arg_conv;
35041         this_arg_conv.inner = (void*)(this_arg & (~1));
35042         this_arg_conv.is_owned = false;
35043         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35044         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
35045         if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
35046         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
35047         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
35048 }
35049
35050 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) {
35051         LDKPeerManager this_arg_conv;
35052         this_arg_conv.inner = (void*)(this_arg & (~1));
35053         this_arg_conv.is_owned = false;
35054         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35055         LDKPublicKey node_id_ref;
35056         CHECK(node_id->arr_len == 33);
35057         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
35058         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
35059 }
35060
35061 void  __attribute__((export_name("TS_PeerManager_disconnect_all_peers"))) TS_PeerManager_disconnect_all_peers(uint32_t this_arg) {
35062         LDKPeerManager this_arg_conv;
35063         this_arg_conv.inner = (void*)(this_arg & (~1));
35064         this_arg_conv.is_owned = false;
35065         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35066         PeerManager_disconnect_all_peers(&this_arg_conv);
35067 }
35068
35069 void  __attribute__((export_name("TS_PeerManager_timer_tick_occurred"))) TS_PeerManager_timer_tick_occurred(uint32_t this_arg) {
35070         LDKPeerManager this_arg_conv;
35071         this_arg_conv.inner = (void*)(this_arg & (~1));
35072         this_arg_conv.is_owned = false;
35073         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35074         PeerManager_timer_tick_occurred(&this_arg_conv);
35075 }
35076
35077 int64_t  __attribute__((export_name("TS_htlc_success_tx_weight"))) TS_htlc_success_tx_weight(jboolean opt_anchors) {
35078         int64_t ret_conv = htlc_success_tx_weight(opt_anchors);
35079         return ret_conv;
35080 }
35081
35082 int64_t  __attribute__((export_name("TS_htlc_timeout_tx_weight"))) TS_htlc_timeout_tx_weight(jboolean opt_anchors) {
35083         int64_t ret_conv = htlc_timeout_tx_weight(opt_anchors);
35084         return ret_conv;
35085 }
35086
35087 int8_tArray  __attribute__((export_name("TS_build_commitment_secret"))) TS_build_commitment_secret(int8_tArray commitment_seed, int64_t idx) {
35088         unsigned char commitment_seed_arr[32];
35089         CHECK(commitment_seed->arr_len == 32);
35090         memcpy(commitment_seed_arr, commitment_seed->elems, 32); FREE(commitment_seed);
35091         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
35092         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
35093         memcpy(ret_arr->elems, build_commitment_secret(commitment_seed_ref, idx).data, 32);
35094         return ret_arr;
35095 }
35096
35097 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) {
35098         LDKCVec_u8Z to_holder_script_ref;
35099         to_holder_script_ref.datalen = to_holder_script->arr_len;
35100         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
35101         memcpy(to_holder_script_ref.data, to_holder_script->elems, to_holder_script_ref.datalen); FREE(to_holder_script);
35102         LDKCVec_u8Z to_counterparty_script_ref;
35103         to_counterparty_script_ref.datalen = to_counterparty_script->arr_len;
35104         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
35105         memcpy(to_counterparty_script_ref.data, to_counterparty_script->elems, to_counterparty_script_ref.datalen); FREE(to_counterparty_script);
35106         LDKOutPoint funding_outpoint_conv;
35107         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
35108         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
35109         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
35110         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
35111         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);
35112         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35113         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35114         Transaction_free(ret_var);
35115         return ret_arr;
35116 }
35117
35118 void  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_free"))) TS_CounterpartyCommitmentSecrets_free(uint32_t this_obj) {
35119         LDKCounterpartyCommitmentSecrets this_obj_conv;
35120         this_obj_conv.inner = (void*)(this_obj & (~1));
35121         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35122         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35123         CounterpartyCommitmentSecrets_free(this_obj_conv);
35124 }
35125
35126 static inline uintptr_t CounterpartyCommitmentSecrets_clone_ptr(LDKCounterpartyCommitmentSecrets *NONNULL_PTR arg) {
35127         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(arg);
35128 uint32_t ret_ref = 0;
35129 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35130 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35131 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35132 ret_ref = (uintptr_t)ret_var.inner;
35133 if (ret_var.is_owned) {
35134         ret_ref |= 1;
35135 }
35136         return ret_ref;
35137 }
35138 uint32_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_clone_ptr"))) TS_CounterpartyCommitmentSecrets_clone_ptr(uint32_t arg) {
35139         LDKCounterpartyCommitmentSecrets arg_conv;
35140         arg_conv.inner = (void*)(arg & (~1));
35141         arg_conv.is_owned = false;
35142         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35143         uint32_t ret_conv = CounterpartyCommitmentSecrets_clone_ptr(&arg_conv);
35144         return ret_conv;
35145 }
35146
35147 uint32_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_clone"))) TS_CounterpartyCommitmentSecrets_clone(uint32_t orig) {
35148         LDKCounterpartyCommitmentSecrets orig_conv;
35149         orig_conv.inner = (void*)(orig & (~1));
35150         orig_conv.is_owned = false;
35151         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35152         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(&orig_conv);
35153         uint32_t ret_ref = 0;
35154         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35155         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35156         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35157         ret_ref = (uintptr_t)ret_var.inner;
35158         if (ret_var.is_owned) {
35159                 ret_ref |= 1;
35160         }
35161         return ret_ref;
35162 }
35163
35164 uint32_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_new"))) TS_CounterpartyCommitmentSecrets_new() {
35165         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_new();
35166         uint32_t ret_ref = 0;
35167         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35168         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35169         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35170         ret_ref = (uintptr_t)ret_var.inner;
35171         if (ret_var.is_owned) {
35172                 ret_ref |= 1;
35173         }
35174         return ret_ref;
35175 }
35176
35177 int64_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_get_min_seen_secret"))) TS_CounterpartyCommitmentSecrets_get_min_seen_secret(uint32_t this_arg) {
35178         LDKCounterpartyCommitmentSecrets this_arg_conv;
35179         this_arg_conv.inner = (void*)(this_arg & (~1));
35180         this_arg_conv.is_owned = false;
35181         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35182         int64_t ret_conv = CounterpartyCommitmentSecrets_get_min_seen_secret(&this_arg_conv);
35183         return ret_conv;
35184 }
35185
35186 uint32_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_provide_secret"))) TS_CounterpartyCommitmentSecrets_provide_secret(uint32_t this_arg, int64_t idx, int8_tArray secret) {
35187         LDKCounterpartyCommitmentSecrets this_arg_conv;
35188         this_arg_conv.inner = (void*)(this_arg & (~1));
35189         this_arg_conv.is_owned = false;
35190         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35191         LDKThirtyTwoBytes secret_ref;
35192         CHECK(secret->arr_len == 32);
35193         memcpy(secret_ref.data, secret->elems, 32); FREE(secret);
35194         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
35195         *ret_conv = CounterpartyCommitmentSecrets_provide_secret(&this_arg_conv, idx, secret_ref);
35196         return (uint32_t)ret_conv;
35197 }
35198
35199 int8_tArray  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_get_secret"))) TS_CounterpartyCommitmentSecrets_get_secret(uint32_t this_arg, int64_t idx) {
35200         LDKCounterpartyCommitmentSecrets this_arg_conv;
35201         this_arg_conv.inner = (void*)(this_arg & (~1));
35202         this_arg_conv.is_owned = false;
35203         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35204         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
35205         memcpy(ret_arr->elems, CounterpartyCommitmentSecrets_get_secret(&this_arg_conv, idx).data, 32);
35206         return ret_arr;
35207 }
35208
35209 int8_tArray  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_write"))) TS_CounterpartyCommitmentSecrets_write(uint32_t obj) {
35210         LDKCounterpartyCommitmentSecrets obj_conv;
35211         obj_conv.inner = (void*)(obj & (~1));
35212         obj_conv.is_owned = false;
35213         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35214         LDKCVec_u8Z ret_var = CounterpartyCommitmentSecrets_write(&obj_conv);
35215         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35216         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35217         CVec_u8Z_free(ret_var);
35218         return ret_arr;
35219 }
35220
35221 uint32_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_read"))) TS_CounterpartyCommitmentSecrets_read(int8_tArray ser) {
35222         LDKu8slice ser_ref;
35223         ser_ref.datalen = ser->arr_len;
35224         ser_ref.data = ser->elems;
35225         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
35226         *ret_conv = CounterpartyCommitmentSecrets_read(ser_ref);
35227         FREE(ser);
35228         return (uint32_t)ret_conv;
35229 }
35230
35231 uint32_t  __attribute__((export_name("TS_derive_private_key"))) TS_derive_private_key(int8_tArray per_commitment_point, int8_tArray base_secret) {
35232         LDKPublicKey per_commitment_point_ref;
35233         CHECK(per_commitment_point->arr_len == 33);
35234         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
35235         unsigned char base_secret_arr[32];
35236         CHECK(base_secret->arr_len == 32);
35237         memcpy(base_secret_arr, base_secret->elems, 32); FREE(base_secret);
35238         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
35239         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
35240         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
35241         return (uint32_t)ret_conv;
35242 }
35243
35244 uint32_t  __attribute__((export_name("TS_derive_public_key"))) TS_derive_public_key(int8_tArray per_commitment_point, int8_tArray base_point) {
35245         LDKPublicKey per_commitment_point_ref;
35246         CHECK(per_commitment_point->arr_len == 33);
35247         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
35248         LDKPublicKey base_point_ref;
35249         CHECK(base_point->arr_len == 33);
35250         memcpy(base_point_ref.compressed_form, base_point->elems, 33); FREE(base_point);
35251         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
35252         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
35253         return (uint32_t)ret_conv;
35254 }
35255
35256 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) {
35257         unsigned char per_commitment_secret_arr[32];
35258         CHECK(per_commitment_secret->arr_len == 32);
35259         memcpy(per_commitment_secret_arr, per_commitment_secret->elems, 32); FREE(per_commitment_secret);
35260         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
35261         unsigned char countersignatory_revocation_base_secret_arr[32];
35262         CHECK(countersignatory_revocation_base_secret->arr_len == 32);
35263         memcpy(countersignatory_revocation_base_secret_arr, countersignatory_revocation_base_secret->elems, 32); FREE(countersignatory_revocation_base_secret);
35264         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
35265         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
35266         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
35267         return (uint32_t)ret_conv;
35268 }
35269
35270 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) {
35271         LDKPublicKey per_commitment_point_ref;
35272         CHECK(per_commitment_point->arr_len == 33);
35273         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
35274         LDKPublicKey countersignatory_revocation_base_point_ref;
35275         CHECK(countersignatory_revocation_base_point->arr_len == 33);
35276         memcpy(countersignatory_revocation_base_point_ref.compressed_form, countersignatory_revocation_base_point->elems, 33); FREE(countersignatory_revocation_base_point);
35277         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
35278         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
35279         return (uint32_t)ret_conv;
35280 }
35281
35282 void  __attribute__((export_name("TS_TxCreationKeys_free"))) TS_TxCreationKeys_free(uint32_t this_obj) {
35283         LDKTxCreationKeys this_obj_conv;
35284         this_obj_conv.inner = (void*)(this_obj & (~1));
35285         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35286         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35287         TxCreationKeys_free(this_obj_conv);
35288 }
35289
35290 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_per_commitment_point"))) TS_TxCreationKeys_get_per_commitment_point(uint32_t this_ptr) {
35291         LDKTxCreationKeys this_ptr_conv;
35292         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35293         this_ptr_conv.is_owned = false;
35294         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35295         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
35296         memcpy(ret_arr->elems, TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form, 33);
35297         return ret_arr;
35298 }
35299
35300 void  __attribute__((export_name("TS_TxCreationKeys_set_per_commitment_point"))) TS_TxCreationKeys_set_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
35301         LDKTxCreationKeys this_ptr_conv;
35302         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35303         this_ptr_conv.is_owned = false;
35304         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35305         LDKPublicKey val_ref;
35306         CHECK(val->arr_len == 33);
35307         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
35308         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
35309 }
35310
35311 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_revocation_key"))) TS_TxCreationKeys_get_revocation_key(uint32_t this_ptr) {
35312         LDKTxCreationKeys this_ptr_conv;
35313         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35314         this_ptr_conv.is_owned = false;
35315         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35316         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
35317         memcpy(ret_arr->elems, TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form, 33);
35318         return ret_arr;
35319 }
35320
35321 void  __attribute__((export_name("TS_TxCreationKeys_set_revocation_key"))) TS_TxCreationKeys_set_revocation_key(uint32_t this_ptr, int8_tArray val) {
35322         LDKTxCreationKeys this_ptr_conv;
35323         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35324         this_ptr_conv.is_owned = false;
35325         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35326         LDKPublicKey val_ref;
35327         CHECK(val->arr_len == 33);
35328         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
35329         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
35330 }
35331
35332 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_broadcaster_htlc_key"))) TS_TxCreationKeys_get_broadcaster_htlc_key(uint32_t this_ptr) {
35333         LDKTxCreationKeys this_ptr_conv;
35334         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35335         this_ptr_conv.is_owned = false;
35336         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35337         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
35338         memcpy(ret_arr->elems, TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form, 33);
35339         return ret_arr;
35340 }
35341
35342 void  __attribute__((export_name("TS_TxCreationKeys_set_broadcaster_htlc_key"))) TS_TxCreationKeys_set_broadcaster_htlc_key(uint32_t this_ptr, int8_tArray val) {
35343         LDKTxCreationKeys this_ptr_conv;
35344         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35345         this_ptr_conv.is_owned = false;
35346         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35347         LDKPublicKey val_ref;
35348         CHECK(val->arr_len == 33);
35349         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
35350         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
35351 }
35352
35353 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_countersignatory_htlc_key"))) TS_TxCreationKeys_get_countersignatory_htlc_key(uint32_t this_ptr) {
35354         LDKTxCreationKeys this_ptr_conv;
35355         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35356         this_ptr_conv.is_owned = false;
35357         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35358         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
35359         memcpy(ret_arr->elems, TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form, 33);
35360         return ret_arr;
35361 }
35362
35363 void  __attribute__((export_name("TS_TxCreationKeys_set_countersignatory_htlc_key"))) TS_TxCreationKeys_set_countersignatory_htlc_key(uint32_t this_ptr, int8_tArray val) {
35364         LDKTxCreationKeys this_ptr_conv;
35365         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35366         this_ptr_conv.is_owned = false;
35367         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35368         LDKPublicKey val_ref;
35369         CHECK(val->arr_len == 33);
35370         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
35371         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
35372 }
35373
35374 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_broadcaster_delayed_payment_key"))) TS_TxCreationKeys_get_broadcaster_delayed_payment_key(uint32_t this_ptr) {
35375         LDKTxCreationKeys this_ptr_conv;
35376         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35377         this_ptr_conv.is_owned = false;
35378         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35379         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
35380         memcpy(ret_arr->elems, TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form, 33);
35381         return ret_arr;
35382 }
35383
35384 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) {
35385         LDKTxCreationKeys this_ptr_conv;
35386         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35387         this_ptr_conv.is_owned = false;
35388         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35389         LDKPublicKey val_ref;
35390         CHECK(val->arr_len == 33);
35391         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
35392         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
35393 }
35394
35395 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) {
35396         LDKPublicKey per_commitment_point_arg_ref;
35397         CHECK(per_commitment_point_arg->arr_len == 33);
35398         memcpy(per_commitment_point_arg_ref.compressed_form, per_commitment_point_arg->elems, 33); FREE(per_commitment_point_arg);
35399         LDKPublicKey revocation_key_arg_ref;
35400         CHECK(revocation_key_arg->arr_len == 33);
35401         memcpy(revocation_key_arg_ref.compressed_form, revocation_key_arg->elems, 33); FREE(revocation_key_arg);
35402         LDKPublicKey broadcaster_htlc_key_arg_ref;
35403         CHECK(broadcaster_htlc_key_arg->arr_len == 33);
35404         memcpy(broadcaster_htlc_key_arg_ref.compressed_form, broadcaster_htlc_key_arg->elems, 33); FREE(broadcaster_htlc_key_arg);
35405         LDKPublicKey countersignatory_htlc_key_arg_ref;
35406         CHECK(countersignatory_htlc_key_arg->arr_len == 33);
35407         memcpy(countersignatory_htlc_key_arg_ref.compressed_form, countersignatory_htlc_key_arg->elems, 33); FREE(countersignatory_htlc_key_arg);
35408         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
35409         CHECK(broadcaster_delayed_payment_key_arg->arr_len == 33);
35410         memcpy(broadcaster_delayed_payment_key_arg_ref.compressed_form, broadcaster_delayed_payment_key_arg->elems, 33); FREE(broadcaster_delayed_payment_key_arg);
35411         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);
35412         uint32_t ret_ref = 0;
35413         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35414         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35415         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35416         ret_ref = (uintptr_t)ret_var.inner;
35417         if (ret_var.is_owned) {
35418                 ret_ref |= 1;
35419         }
35420         return ret_ref;
35421 }
35422
35423 static inline uintptr_t TxCreationKeys_clone_ptr(LDKTxCreationKeys *NONNULL_PTR arg) {
35424         LDKTxCreationKeys ret_var = TxCreationKeys_clone(arg);
35425 uint32_t ret_ref = 0;
35426 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35427 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35428 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35429 ret_ref = (uintptr_t)ret_var.inner;
35430 if (ret_var.is_owned) {
35431         ret_ref |= 1;
35432 }
35433         return ret_ref;
35434 }
35435 uint32_t  __attribute__((export_name("TS_TxCreationKeys_clone_ptr"))) TS_TxCreationKeys_clone_ptr(uint32_t arg) {
35436         LDKTxCreationKeys arg_conv;
35437         arg_conv.inner = (void*)(arg & (~1));
35438         arg_conv.is_owned = false;
35439         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35440         uint32_t ret_conv = TxCreationKeys_clone_ptr(&arg_conv);
35441         return ret_conv;
35442 }
35443
35444 uint32_t  __attribute__((export_name("TS_TxCreationKeys_clone"))) TS_TxCreationKeys_clone(uint32_t orig) {
35445         LDKTxCreationKeys orig_conv;
35446         orig_conv.inner = (void*)(orig & (~1));
35447         orig_conv.is_owned = false;
35448         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35449         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
35450         uint32_t ret_ref = 0;
35451         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35452         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35453         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35454         ret_ref = (uintptr_t)ret_var.inner;
35455         if (ret_var.is_owned) {
35456                 ret_ref |= 1;
35457         }
35458         return ret_ref;
35459 }
35460
35461 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_write"))) TS_TxCreationKeys_write(uint32_t obj) {
35462         LDKTxCreationKeys obj_conv;
35463         obj_conv.inner = (void*)(obj & (~1));
35464         obj_conv.is_owned = false;
35465         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35466         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
35467         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35468         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35469         CVec_u8Z_free(ret_var);
35470         return ret_arr;
35471 }
35472
35473 uint32_t  __attribute__((export_name("TS_TxCreationKeys_read"))) TS_TxCreationKeys_read(int8_tArray ser) {
35474         LDKu8slice ser_ref;
35475         ser_ref.datalen = ser->arr_len;
35476         ser_ref.data = ser->elems;
35477         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
35478         *ret_conv = TxCreationKeys_read(ser_ref);
35479         FREE(ser);
35480         return (uint32_t)ret_conv;
35481 }
35482
35483 void  __attribute__((export_name("TS_ChannelPublicKeys_free"))) TS_ChannelPublicKeys_free(uint32_t this_obj) {
35484         LDKChannelPublicKeys this_obj_conv;
35485         this_obj_conv.inner = (void*)(this_obj & (~1));
35486         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35487         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35488         ChannelPublicKeys_free(this_obj_conv);
35489 }
35490
35491 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_funding_pubkey"))) TS_ChannelPublicKeys_get_funding_pubkey(uint32_t this_ptr) {
35492         LDKChannelPublicKeys this_ptr_conv;
35493         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35494         this_ptr_conv.is_owned = false;
35495         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35496         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
35497         memcpy(ret_arr->elems, ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
35498         return ret_arr;
35499 }
35500
35501 void  __attribute__((export_name("TS_ChannelPublicKeys_set_funding_pubkey"))) TS_ChannelPublicKeys_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
35502         LDKChannelPublicKeys this_ptr_conv;
35503         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35504         this_ptr_conv.is_owned = false;
35505         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35506         LDKPublicKey val_ref;
35507         CHECK(val->arr_len == 33);
35508         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
35509         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
35510 }
35511
35512 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_revocation_basepoint"))) TS_ChannelPublicKeys_get_revocation_basepoint(uint32_t this_ptr) {
35513         LDKChannelPublicKeys this_ptr_conv;
35514         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35515         this_ptr_conv.is_owned = false;
35516         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35517         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
35518         memcpy(ret_arr->elems, ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
35519         return ret_arr;
35520 }
35521
35522 void  __attribute__((export_name("TS_ChannelPublicKeys_set_revocation_basepoint"))) TS_ChannelPublicKeys_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
35523         LDKChannelPublicKeys this_ptr_conv;
35524         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35525         this_ptr_conv.is_owned = false;
35526         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35527         LDKPublicKey val_ref;
35528         CHECK(val->arr_len == 33);
35529         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
35530         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
35531 }
35532
35533 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_payment_point"))) TS_ChannelPublicKeys_get_payment_point(uint32_t this_ptr) {
35534         LDKChannelPublicKeys this_ptr_conv;
35535         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35536         this_ptr_conv.is_owned = false;
35537         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35538         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
35539         memcpy(ret_arr->elems, ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form, 33);
35540         return ret_arr;
35541 }
35542
35543 void  __attribute__((export_name("TS_ChannelPublicKeys_set_payment_point"))) TS_ChannelPublicKeys_set_payment_point(uint32_t this_ptr, int8_tArray val) {
35544         LDKChannelPublicKeys this_ptr_conv;
35545         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35546         this_ptr_conv.is_owned = false;
35547         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35548         LDKPublicKey val_ref;
35549         CHECK(val->arr_len == 33);
35550         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
35551         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
35552 }
35553
35554 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_delayed_payment_basepoint"))) TS_ChannelPublicKeys_get_delayed_payment_basepoint(uint32_t this_ptr) {
35555         LDKChannelPublicKeys this_ptr_conv;
35556         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35557         this_ptr_conv.is_owned = false;
35558         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35559         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
35560         memcpy(ret_arr->elems, ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
35561         return ret_arr;
35562 }
35563
35564 void  __attribute__((export_name("TS_ChannelPublicKeys_set_delayed_payment_basepoint"))) TS_ChannelPublicKeys_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
35565         LDKChannelPublicKeys this_ptr_conv;
35566         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35567         this_ptr_conv.is_owned = false;
35568         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35569         LDKPublicKey val_ref;
35570         CHECK(val->arr_len == 33);
35571         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
35572         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
35573 }
35574
35575 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_htlc_basepoint"))) TS_ChannelPublicKeys_get_htlc_basepoint(uint32_t this_ptr) {
35576         LDKChannelPublicKeys this_ptr_conv;
35577         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35578         this_ptr_conv.is_owned = false;
35579         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35580         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
35581         memcpy(ret_arr->elems, ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
35582         return ret_arr;
35583 }
35584
35585 void  __attribute__((export_name("TS_ChannelPublicKeys_set_htlc_basepoint"))) TS_ChannelPublicKeys_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
35586         LDKChannelPublicKeys this_ptr_conv;
35587         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35588         this_ptr_conv.is_owned = false;
35589         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35590         LDKPublicKey val_ref;
35591         CHECK(val->arr_len == 33);
35592         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
35593         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
35594 }
35595
35596 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) {
35597         LDKPublicKey funding_pubkey_arg_ref;
35598         CHECK(funding_pubkey_arg->arr_len == 33);
35599         memcpy(funding_pubkey_arg_ref.compressed_form, funding_pubkey_arg->elems, 33); FREE(funding_pubkey_arg);
35600         LDKPublicKey revocation_basepoint_arg_ref;
35601         CHECK(revocation_basepoint_arg->arr_len == 33);
35602         memcpy(revocation_basepoint_arg_ref.compressed_form, revocation_basepoint_arg->elems, 33); FREE(revocation_basepoint_arg);
35603         LDKPublicKey payment_point_arg_ref;
35604         CHECK(payment_point_arg->arr_len == 33);
35605         memcpy(payment_point_arg_ref.compressed_form, payment_point_arg->elems, 33); FREE(payment_point_arg);
35606         LDKPublicKey delayed_payment_basepoint_arg_ref;
35607         CHECK(delayed_payment_basepoint_arg->arr_len == 33);
35608         memcpy(delayed_payment_basepoint_arg_ref.compressed_form, delayed_payment_basepoint_arg->elems, 33); FREE(delayed_payment_basepoint_arg);
35609         LDKPublicKey htlc_basepoint_arg_ref;
35610         CHECK(htlc_basepoint_arg->arr_len == 33);
35611         memcpy(htlc_basepoint_arg_ref.compressed_form, htlc_basepoint_arg->elems, 33); FREE(htlc_basepoint_arg);
35612         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);
35613         uint32_t ret_ref = 0;
35614         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35615         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35616         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35617         ret_ref = (uintptr_t)ret_var.inner;
35618         if (ret_var.is_owned) {
35619                 ret_ref |= 1;
35620         }
35621         return ret_ref;
35622 }
35623
35624 static inline uintptr_t ChannelPublicKeys_clone_ptr(LDKChannelPublicKeys *NONNULL_PTR arg) {
35625         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(arg);
35626 uint32_t ret_ref = 0;
35627 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35628 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35629 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35630 ret_ref = (uintptr_t)ret_var.inner;
35631 if (ret_var.is_owned) {
35632         ret_ref |= 1;
35633 }
35634         return ret_ref;
35635 }
35636 uint32_t  __attribute__((export_name("TS_ChannelPublicKeys_clone_ptr"))) TS_ChannelPublicKeys_clone_ptr(uint32_t arg) {
35637         LDKChannelPublicKeys arg_conv;
35638         arg_conv.inner = (void*)(arg & (~1));
35639         arg_conv.is_owned = false;
35640         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35641         uint32_t ret_conv = ChannelPublicKeys_clone_ptr(&arg_conv);
35642         return ret_conv;
35643 }
35644
35645 uint32_t  __attribute__((export_name("TS_ChannelPublicKeys_clone"))) TS_ChannelPublicKeys_clone(uint32_t orig) {
35646         LDKChannelPublicKeys orig_conv;
35647         orig_conv.inner = (void*)(orig & (~1));
35648         orig_conv.is_owned = false;
35649         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35650         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
35651         uint32_t ret_ref = 0;
35652         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35653         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35654         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35655         ret_ref = (uintptr_t)ret_var.inner;
35656         if (ret_var.is_owned) {
35657                 ret_ref |= 1;
35658         }
35659         return ret_ref;
35660 }
35661
35662 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_write"))) TS_ChannelPublicKeys_write(uint32_t obj) {
35663         LDKChannelPublicKeys obj_conv;
35664         obj_conv.inner = (void*)(obj & (~1));
35665         obj_conv.is_owned = false;
35666         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35667         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
35668         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35669         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35670         CVec_u8Z_free(ret_var);
35671         return ret_arr;
35672 }
35673
35674 uint32_t  __attribute__((export_name("TS_ChannelPublicKeys_read"))) TS_ChannelPublicKeys_read(int8_tArray ser) {
35675         LDKu8slice ser_ref;
35676         ser_ref.datalen = ser->arr_len;
35677         ser_ref.data = ser->elems;
35678         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
35679         *ret_conv = ChannelPublicKeys_read(ser_ref);
35680         FREE(ser);
35681         return (uint32_t)ret_conv;
35682 }
35683
35684 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) {
35685         LDKPublicKey per_commitment_point_ref;
35686         CHECK(per_commitment_point->arr_len == 33);
35687         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
35688         LDKPublicKey broadcaster_delayed_payment_base_ref;
35689         CHECK(broadcaster_delayed_payment_base->arr_len == 33);
35690         memcpy(broadcaster_delayed_payment_base_ref.compressed_form, broadcaster_delayed_payment_base->elems, 33); FREE(broadcaster_delayed_payment_base);
35691         LDKPublicKey broadcaster_htlc_base_ref;
35692         CHECK(broadcaster_htlc_base->arr_len == 33);
35693         memcpy(broadcaster_htlc_base_ref.compressed_form, broadcaster_htlc_base->elems, 33); FREE(broadcaster_htlc_base);
35694         LDKPublicKey countersignatory_revocation_base_ref;
35695         CHECK(countersignatory_revocation_base->arr_len == 33);
35696         memcpy(countersignatory_revocation_base_ref.compressed_form, countersignatory_revocation_base->elems, 33); FREE(countersignatory_revocation_base);
35697         LDKPublicKey countersignatory_htlc_base_ref;
35698         CHECK(countersignatory_htlc_base->arr_len == 33);
35699         memcpy(countersignatory_htlc_base_ref.compressed_form, countersignatory_htlc_base->elems, 33); FREE(countersignatory_htlc_base);
35700         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
35701         *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);
35702         return (uint32_t)ret_conv;
35703 }
35704
35705 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) {
35706         LDKPublicKey per_commitment_point_ref;
35707         CHECK(per_commitment_point->arr_len == 33);
35708         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
35709         LDKChannelPublicKeys broadcaster_keys_conv;
35710         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
35711         broadcaster_keys_conv.is_owned = false;
35712         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
35713         LDKChannelPublicKeys countersignatory_keys_conv;
35714         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
35715         countersignatory_keys_conv.is_owned = false;
35716         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
35717         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
35718         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
35719         return (uint32_t)ret_conv;
35720 }
35721
35722 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) {
35723         LDKPublicKey revocation_key_ref;
35724         CHECK(revocation_key->arr_len == 33);
35725         memcpy(revocation_key_ref.compressed_form, revocation_key->elems, 33); FREE(revocation_key);
35726         LDKPublicKey broadcaster_delayed_payment_key_ref;
35727         CHECK(broadcaster_delayed_payment_key->arr_len == 33);
35728         memcpy(broadcaster_delayed_payment_key_ref.compressed_form, broadcaster_delayed_payment_key->elems, 33); FREE(broadcaster_delayed_payment_key);
35729         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
35730         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35731         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35732         CVec_u8Z_free(ret_var);
35733         return ret_arr;
35734 }
35735
35736 void  __attribute__((export_name("TS_HTLCOutputInCommitment_free"))) TS_HTLCOutputInCommitment_free(uint32_t this_obj) {
35737         LDKHTLCOutputInCommitment this_obj_conv;
35738         this_obj_conv.inner = (void*)(this_obj & (~1));
35739         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35740         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35741         HTLCOutputInCommitment_free(this_obj_conv);
35742 }
35743
35744 jboolean  __attribute__((export_name("TS_HTLCOutputInCommitment_get_offered"))) TS_HTLCOutputInCommitment_get_offered(uint32_t this_ptr) {
35745         LDKHTLCOutputInCommitment this_ptr_conv;
35746         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35747         this_ptr_conv.is_owned = false;
35748         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35749         jboolean ret_conv = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
35750         return ret_conv;
35751 }
35752
35753 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_offered"))) TS_HTLCOutputInCommitment_set_offered(uint32_t this_ptr, jboolean val) {
35754         LDKHTLCOutputInCommitment this_ptr_conv;
35755         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35756         this_ptr_conv.is_owned = false;
35757         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35758         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
35759 }
35760
35761 int64_t  __attribute__((export_name("TS_HTLCOutputInCommitment_get_amount_msat"))) TS_HTLCOutputInCommitment_get_amount_msat(uint32_t this_ptr) {
35762         LDKHTLCOutputInCommitment this_ptr_conv;
35763         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35764         this_ptr_conv.is_owned = false;
35765         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35766         int64_t ret_conv = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
35767         return ret_conv;
35768 }
35769
35770 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_amount_msat"))) TS_HTLCOutputInCommitment_set_amount_msat(uint32_t this_ptr, int64_t val) {
35771         LDKHTLCOutputInCommitment this_ptr_conv;
35772         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35773         this_ptr_conv.is_owned = false;
35774         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35775         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
35776 }
35777
35778 int32_t  __attribute__((export_name("TS_HTLCOutputInCommitment_get_cltv_expiry"))) TS_HTLCOutputInCommitment_get_cltv_expiry(uint32_t this_ptr) {
35779         LDKHTLCOutputInCommitment this_ptr_conv;
35780         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35781         this_ptr_conv.is_owned = false;
35782         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35783         int32_t ret_conv = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
35784         return ret_conv;
35785 }
35786
35787 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_cltv_expiry"))) TS_HTLCOutputInCommitment_set_cltv_expiry(uint32_t this_ptr, int32_t val) {
35788         LDKHTLCOutputInCommitment this_ptr_conv;
35789         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35790         this_ptr_conv.is_owned = false;
35791         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35792         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
35793 }
35794
35795 int8_tArray  __attribute__((export_name("TS_HTLCOutputInCommitment_get_payment_hash"))) TS_HTLCOutputInCommitment_get_payment_hash(uint32_t this_ptr) {
35796         LDKHTLCOutputInCommitment this_ptr_conv;
35797         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35798         this_ptr_conv.is_owned = false;
35799         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35800         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
35801         memcpy(ret_arr->elems, *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv), 32);
35802         return ret_arr;
35803 }
35804
35805 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_payment_hash"))) TS_HTLCOutputInCommitment_set_payment_hash(uint32_t this_ptr, int8_tArray val) {
35806         LDKHTLCOutputInCommitment this_ptr_conv;
35807         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35808         this_ptr_conv.is_owned = false;
35809         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35810         LDKThirtyTwoBytes val_ref;
35811         CHECK(val->arr_len == 32);
35812         memcpy(val_ref.data, val->elems, 32); FREE(val);
35813         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
35814 }
35815
35816 uint32_t  __attribute__((export_name("TS_HTLCOutputInCommitment_get_transaction_output_index"))) TS_HTLCOutputInCommitment_get_transaction_output_index(uint32_t this_ptr) {
35817         LDKHTLCOutputInCommitment this_ptr_conv;
35818         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35819         this_ptr_conv.is_owned = false;
35820         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35821         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
35822         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
35823         uint32_t ret_ref = (uintptr_t)ret_copy;
35824         return ret_ref;
35825 }
35826
35827 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_transaction_output_index"))) TS_HTLCOutputInCommitment_set_transaction_output_index(uint32_t this_ptr, uint32_t val) {
35828         LDKHTLCOutputInCommitment this_ptr_conv;
35829         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35830         this_ptr_conv.is_owned = false;
35831         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35832         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
35833         CHECK_ACCESS(val_ptr);
35834         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
35835         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)val) & ~1));
35836         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
35837 }
35838
35839 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) {
35840         LDKThirtyTwoBytes payment_hash_arg_ref;
35841         CHECK(payment_hash_arg->arr_len == 32);
35842         memcpy(payment_hash_arg_ref.data, payment_hash_arg->elems, 32); FREE(payment_hash_arg);
35843         void* transaction_output_index_arg_ptr = (void*)(((uintptr_t)transaction_output_index_arg) & ~1);
35844         CHECK_ACCESS(transaction_output_index_arg_ptr);
35845         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(transaction_output_index_arg_ptr);
35846         transaction_output_index_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)transaction_output_index_arg) & ~1));
35847         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
35848         uint32_t ret_ref = 0;
35849         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35850         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35851         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35852         ret_ref = (uintptr_t)ret_var.inner;
35853         if (ret_var.is_owned) {
35854                 ret_ref |= 1;
35855         }
35856         return ret_ref;
35857 }
35858
35859 static inline uintptr_t HTLCOutputInCommitment_clone_ptr(LDKHTLCOutputInCommitment *NONNULL_PTR arg) {
35860         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(arg);
35861 uint32_t ret_ref = 0;
35862 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35863 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35864 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35865 ret_ref = (uintptr_t)ret_var.inner;
35866 if (ret_var.is_owned) {
35867         ret_ref |= 1;
35868 }
35869         return ret_ref;
35870 }
35871 uint32_t  __attribute__((export_name("TS_HTLCOutputInCommitment_clone_ptr"))) TS_HTLCOutputInCommitment_clone_ptr(uint32_t arg) {
35872         LDKHTLCOutputInCommitment arg_conv;
35873         arg_conv.inner = (void*)(arg & (~1));
35874         arg_conv.is_owned = false;
35875         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35876         uint32_t ret_conv = HTLCOutputInCommitment_clone_ptr(&arg_conv);
35877         return ret_conv;
35878 }
35879
35880 uint32_t  __attribute__((export_name("TS_HTLCOutputInCommitment_clone"))) TS_HTLCOutputInCommitment_clone(uint32_t orig) {
35881         LDKHTLCOutputInCommitment orig_conv;
35882         orig_conv.inner = (void*)(orig & (~1));
35883         orig_conv.is_owned = false;
35884         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35885         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
35886         uint32_t ret_ref = 0;
35887         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35888         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35889         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35890         ret_ref = (uintptr_t)ret_var.inner;
35891         if (ret_var.is_owned) {
35892                 ret_ref |= 1;
35893         }
35894         return ret_ref;
35895 }
35896
35897 int8_tArray  __attribute__((export_name("TS_HTLCOutputInCommitment_write"))) TS_HTLCOutputInCommitment_write(uint32_t obj) {
35898         LDKHTLCOutputInCommitment obj_conv;
35899         obj_conv.inner = (void*)(obj & (~1));
35900         obj_conv.is_owned = false;
35901         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35902         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
35903         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35904         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35905         CVec_u8Z_free(ret_var);
35906         return ret_arr;
35907 }
35908
35909 uint32_t  __attribute__((export_name("TS_HTLCOutputInCommitment_read"))) TS_HTLCOutputInCommitment_read(int8_tArray ser) {
35910         LDKu8slice ser_ref;
35911         ser_ref.datalen = ser->arr_len;
35912         ser_ref.data = ser->elems;
35913         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
35914         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
35915         FREE(ser);
35916         return (uint32_t)ret_conv;
35917 }
35918
35919 int8_tArray  __attribute__((export_name("TS_get_htlc_redeemscript"))) TS_get_htlc_redeemscript(uint32_t htlc, jboolean opt_anchors, uint32_t keys) {
35920         LDKHTLCOutputInCommitment htlc_conv;
35921         htlc_conv.inner = (void*)(htlc & (~1));
35922         htlc_conv.is_owned = false;
35923         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
35924         LDKTxCreationKeys keys_conv;
35925         keys_conv.inner = (void*)(keys & (~1));
35926         keys_conv.is_owned = false;
35927         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
35928         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, opt_anchors, &keys_conv);
35929         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35930         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35931         CVec_u8Z_free(ret_var);
35932         return ret_arr;
35933 }
35934
35935 int8_tArray  __attribute__((export_name("TS_make_funding_redeemscript"))) TS_make_funding_redeemscript(int8_tArray broadcaster, int8_tArray countersignatory) {
35936         LDKPublicKey broadcaster_ref;
35937         CHECK(broadcaster->arr_len == 33);
35938         memcpy(broadcaster_ref.compressed_form, broadcaster->elems, 33); FREE(broadcaster);
35939         LDKPublicKey countersignatory_ref;
35940         CHECK(countersignatory->arr_len == 33);
35941         memcpy(countersignatory_ref.compressed_form, countersignatory->elems, 33); FREE(countersignatory);
35942         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
35943         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35944         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35945         CVec_u8Z_free(ret_var);
35946         return ret_arr;
35947 }
35948
35949 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) {
35950         unsigned char commitment_txid_arr[32];
35951         CHECK(commitment_txid->arr_len == 32);
35952         memcpy(commitment_txid_arr, commitment_txid->elems, 32); FREE(commitment_txid);
35953         unsigned char (*commitment_txid_ref)[32] = &commitment_txid_arr;
35954         LDKHTLCOutputInCommitment htlc_conv;
35955         htlc_conv.inner = (void*)(htlc & (~1));
35956         htlc_conv.is_owned = false;
35957         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
35958         LDKPublicKey broadcaster_delayed_payment_key_ref;
35959         CHECK(broadcaster_delayed_payment_key->arr_len == 33);
35960         memcpy(broadcaster_delayed_payment_key_ref.compressed_form, broadcaster_delayed_payment_key->elems, 33); FREE(broadcaster_delayed_payment_key);
35961         LDKPublicKey revocation_key_ref;
35962         CHECK(revocation_key->arr_len == 33);
35963         memcpy(revocation_key_ref.compressed_form, revocation_key->elems, 33); FREE(revocation_key);
35964         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);
35965         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35966         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35967         Transaction_free(ret_var);
35968         return ret_arr;
35969 }
35970
35971 int8_tArray  __attribute__((export_name("TS_get_anchor_redeemscript"))) TS_get_anchor_redeemscript(int8_tArray funding_pubkey) {
35972         LDKPublicKey funding_pubkey_ref;
35973         CHECK(funding_pubkey->arr_len == 33);
35974         memcpy(funding_pubkey_ref.compressed_form, funding_pubkey->elems, 33); FREE(funding_pubkey);
35975         LDKCVec_u8Z ret_var = get_anchor_redeemscript(funding_pubkey_ref);
35976         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35977         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35978         CVec_u8Z_free(ret_var);
35979         return ret_arr;
35980 }
35981
35982 void  __attribute__((export_name("TS_ChannelTransactionParameters_free"))) TS_ChannelTransactionParameters_free(uint32_t this_obj) {
35983         LDKChannelTransactionParameters this_obj_conv;
35984         this_obj_conv.inner = (void*)(this_obj & (~1));
35985         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35986         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35987         ChannelTransactionParameters_free(this_obj_conv);
35988 }
35989
35990 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_holder_pubkeys"))) TS_ChannelTransactionParameters_get_holder_pubkeys(uint32_t this_ptr) {
35991         LDKChannelTransactionParameters this_ptr_conv;
35992         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35993         this_ptr_conv.is_owned = false;
35994         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35995         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
35996         uint32_t ret_ref = 0;
35997         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35998         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35999         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36000         ret_ref = (uintptr_t)ret_var.inner;
36001         if (ret_var.is_owned) {
36002                 ret_ref |= 1;
36003         }
36004         return ret_ref;
36005 }
36006
36007 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_holder_pubkeys"))) TS_ChannelTransactionParameters_set_holder_pubkeys(uint32_t this_ptr, uint32_t val) {
36008         LDKChannelTransactionParameters this_ptr_conv;
36009         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36010         this_ptr_conv.is_owned = false;
36011         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36012         LDKChannelPublicKeys val_conv;
36013         val_conv.inner = (void*)(val & (~1));
36014         val_conv.is_owned = (val & 1) || (val == 0);
36015         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36016         val_conv = ChannelPublicKeys_clone(&val_conv);
36017         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
36018 }
36019
36020 int16_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_holder_selected_contest_delay"))) TS_ChannelTransactionParameters_get_holder_selected_contest_delay(uint32_t this_ptr) {
36021         LDKChannelTransactionParameters this_ptr_conv;
36022         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36023         this_ptr_conv.is_owned = false;
36024         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36025         int16_t ret_conv = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
36026         return ret_conv;
36027 }
36028
36029 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) {
36030         LDKChannelTransactionParameters this_ptr_conv;
36031         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36032         this_ptr_conv.is_owned = false;
36033         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36034         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
36035 }
36036
36037 jboolean  __attribute__((export_name("TS_ChannelTransactionParameters_get_is_outbound_from_holder"))) TS_ChannelTransactionParameters_get_is_outbound_from_holder(uint32_t this_ptr) {
36038         LDKChannelTransactionParameters this_ptr_conv;
36039         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36040         this_ptr_conv.is_owned = false;
36041         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36042         jboolean ret_conv = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
36043         return ret_conv;
36044 }
36045
36046 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_is_outbound_from_holder"))) TS_ChannelTransactionParameters_set_is_outbound_from_holder(uint32_t this_ptr, jboolean val) {
36047         LDKChannelTransactionParameters this_ptr_conv;
36048         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36049         this_ptr_conv.is_owned = false;
36050         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36051         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
36052 }
36053
36054 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_counterparty_parameters"))) TS_ChannelTransactionParameters_get_counterparty_parameters(uint32_t this_ptr) {
36055         LDKChannelTransactionParameters this_ptr_conv;
36056         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36057         this_ptr_conv.is_owned = false;
36058         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36059         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
36060         uint32_t ret_ref = 0;
36061         if ((uintptr_t)ret_var.inner > 4096) {
36062                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36063                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36064         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36065                 ret_ref = (uintptr_t)ret_var.inner;
36066                 if (ret_var.is_owned) {
36067                         ret_ref |= 1;
36068                 }
36069         }
36070         return ret_ref;
36071 }
36072
36073 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_counterparty_parameters"))) TS_ChannelTransactionParameters_set_counterparty_parameters(uint32_t this_ptr, uint32_t val) {
36074         LDKChannelTransactionParameters this_ptr_conv;
36075         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36076         this_ptr_conv.is_owned = false;
36077         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36078         LDKCounterpartyChannelTransactionParameters val_conv;
36079         val_conv.inner = (void*)(val & (~1));
36080         val_conv.is_owned = (val & 1) || (val == 0);
36081         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36082         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
36083         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
36084 }
36085
36086 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_funding_outpoint"))) TS_ChannelTransactionParameters_get_funding_outpoint(uint32_t this_ptr) {
36087         LDKChannelTransactionParameters this_ptr_conv;
36088         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36089         this_ptr_conv.is_owned = false;
36090         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36091         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
36092         uint32_t ret_ref = 0;
36093         if ((uintptr_t)ret_var.inner > 4096) {
36094                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36095                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36096         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36097                 ret_ref = (uintptr_t)ret_var.inner;
36098                 if (ret_var.is_owned) {
36099                         ret_ref |= 1;
36100                 }
36101         }
36102         return ret_ref;
36103 }
36104
36105 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_funding_outpoint"))) TS_ChannelTransactionParameters_set_funding_outpoint(uint32_t this_ptr, uint32_t val) {
36106         LDKChannelTransactionParameters this_ptr_conv;
36107         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36108         this_ptr_conv.is_owned = false;
36109         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36110         LDKOutPoint val_conv;
36111         val_conv.inner = (void*)(val & (~1));
36112         val_conv.is_owned = (val & 1) || (val == 0);
36113         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36114         val_conv = OutPoint_clone(&val_conv);
36115         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
36116 }
36117
36118 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_opt_anchors"))) TS_ChannelTransactionParameters_get_opt_anchors(uint32_t this_ptr) {
36119         LDKChannelTransactionParameters this_ptr_conv;
36120         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36121         this_ptr_conv.is_owned = false;
36122         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36123         uint32_t ret_conv = LDKCOption_NoneZ_to_js(ChannelTransactionParameters_get_opt_anchors(&this_ptr_conv));
36124         return ret_conv;
36125 }
36126
36127 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_opt_anchors"))) TS_ChannelTransactionParameters_set_opt_anchors(uint32_t this_ptr, uint32_t val) {
36128         LDKChannelTransactionParameters this_ptr_conv;
36129         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36130         this_ptr_conv.is_owned = false;
36131         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36132         LDKCOption_NoneZ val_conv = LDKCOption_NoneZ_from_js(val);
36133         ChannelTransactionParameters_set_opt_anchors(&this_ptr_conv, val_conv);
36134 }
36135
36136 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) {
36137         LDKChannelPublicKeys holder_pubkeys_arg_conv;
36138         holder_pubkeys_arg_conv.inner = (void*)(holder_pubkeys_arg & (~1));
36139         holder_pubkeys_arg_conv.is_owned = (holder_pubkeys_arg & 1) || (holder_pubkeys_arg == 0);
36140         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_pubkeys_arg_conv);
36141         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
36142         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
36143         counterparty_parameters_arg_conv.inner = (void*)(counterparty_parameters_arg & (~1));
36144         counterparty_parameters_arg_conv.is_owned = (counterparty_parameters_arg & 1) || (counterparty_parameters_arg == 0);
36145         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_parameters_arg_conv);
36146         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
36147         LDKOutPoint funding_outpoint_arg_conv;
36148         funding_outpoint_arg_conv.inner = (void*)(funding_outpoint_arg & (~1));
36149         funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
36150         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_arg_conv);
36151         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
36152         LDKCOption_NoneZ opt_anchors_arg_conv = LDKCOption_NoneZ_from_js(opt_anchors_arg);
36153         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);
36154         uint32_t ret_ref = 0;
36155         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36156         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36157         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36158         ret_ref = (uintptr_t)ret_var.inner;
36159         if (ret_var.is_owned) {
36160                 ret_ref |= 1;
36161         }
36162         return ret_ref;
36163 }
36164
36165 static inline uintptr_t ChannelTransactionParameters_clone_ptr(LDKChannelTransactionParameters *NONNULL_PTR arg) {
36166         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(arg);
36167 uint32_t ret_ref = 0;
36168 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36169 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36170 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36171 ret_ref = (uintptr_t)ret_var.inner;
36172 if (ret_var.is_owned) {
36173         ret_ref |= 1;
36174 }
36175         return ret_ref;
36176 }
36177 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_clone_ptr"))) TS_ChannelTransactionParameters_clone_ptr(uint32_t arg) {
36178         LDKChannelTransactionParameters arg_conv;
36179         arg_conv.inner = (void*)(arg & (~1));
36180         arg_conv.is_owned = false;
36181         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36182         uint32_t ret_conv = ChannelTransactionParameters_clone_ptr(&arg_conv);
36183         return ret_conv;
36184 }
36185
36186 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_clone"))) TS_ChannelTransactionParameters_clone(uint32_t orig) {
36187         LDKChannelTransactionParameters orig_conv;
36188         orig_conv.inner = (void*)(orig & (~1));
36189         orig_conv.is_owned = false;
36190         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36191         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
36192         uint32_t ret_ref = 0;
36193         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36194         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36195         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36196         ret_ref = (uintptr_t)ret_var.inner;
36197         if (ret_var.is_owned) {
36198                 ret_ref |= 1;
36199         }
36200         return ret_ref;
36201 }
36202
36203 void  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_free"))) TS_CounterpartyChannelTransactionParameters_free(uint32_t this_obj) {
36204         LDKCounterpartyChannelTransactionParameters this_obj_conv;
36205         this_obj_conv.inner = (void*)(this_obj & (~1));
36206         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36207         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36208         CounterpartyChannelTransactionParameters_free(this_obj_conv);
36209 }
36210
36211 uint32_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_get_pubkeys"))) TS_CounterpartyChannelTransactionParameters_get_pubkeys(uint32_t this_ptr) {
36212         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
36213         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36214         this_ptr_conv.is_owned = false;
36215         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36216         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
36217         uint32_t ret_ref = 0;
36218         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36219         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36220         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36221         ret_ref = (uintptr_t)ret_var.inner;
36222         if (ret_var.is_owned) {
36223                 ret_ref |= 1;
36224         }
36225         return ret_ref;
36226 }
36227
36228 void  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_set_pubkeys"))) TS_CounterpartyChannelTransactionParameters_set_pubkeys(uint32_t this_ptr, uint32_t val) {
36229         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
36230         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36231         this_ptr_conv.is_owned = false;
36232         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36233         LDKChannelPublicKeys val_conv;
36234         val_conv.inner = (void*)(val & (~1));
36235         val_conv.is_owned = (val & 1) || (val == 0);
36236         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36237         val_conv = ChannelPublicKeys_clone(&val_conv);
36238         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
36239 }
36240
36241 int16_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_get_selected_contest_delay"))) TS_CounterpartyChannelTransactionParameters_get_selected_contest_delay(uint32_t this_ptr) {
36242         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
36243         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36244         this_ptr_conv.is_owned = false;
36245         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36246         int16_t ret_conv = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
36247         return ret_conv;
36248 }
36249
36250 void  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_set_selected_contest_delay"))) TS_CounterpartyChannelTransactionParameters_set_selected_contest_delay(uint32_t this_ptr, int16_t val) {
36251         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
36252         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36253         this_ptr_conv.is_owned = false;
36254         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36255         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
36256 }
36257
36258 uint32_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_new"))) TS_CounterpartyChannelTransactionParameters_new(uint32_t pubkeys_arg, int16_t selected_contest_delay_arg) {
36259         LDKChannelPublicKeys pubkeys_arg_conv;
36260         pubkeys_arg_conv.inner = (void*)(pubkeys_arg & (~1));
36261         pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
36262         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_arg_conv);
36263         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
36264         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
36265         uint32_t ret_ref = 0;
36266         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36267         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36268         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36269         ret_ref = (uintptr_t)ret_var.inner;
36270         if (ret_var.is_owned) {
36271                 ret_ref |= 1;
36272         }
36273         return ret_ref;
36274 }
36275
36276 static inline uintptr_t CounterpartyChannelTransactionParameters_clone_ptr(LDKCounterpartyChannelTransactionParameters *NONNULL_PTR arg) {
36277         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(arg);
36278 uint32_t ret_ref = 0;
36279 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36280 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36281 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36282 ret_ref = (uintptr_t)ret_var.inner;
36283 if (ret_var.is_owned) {
36284         ret_ref |= 1;
36285 }
36286         return ret_ref;
36287 }
36288 uint32_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_clone_ptr"))) TS_CounterpartyChannelTransactionParameters_clone_ptr(uint32_t arg) {
36289         LDKCounterpartyChannelTransactionParameters arg_conv;
36290         arg_conv.inner = (void*)(arg & (~1));
36291         arg_conv.is_owned = false;
36292         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36293         uint32_t ret_conv = CounterpartyChannelTransactionParameters_clone_ptr(&arg_conv);
36294         return ret_conv;
36295 }
36296
36297 uint32_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_clone"))) TS_CounterpartyChannelTransactionParameters_clone(uint32_t orig) {
36298         LDKCounterpartyChannelTransactionParameters orig_conv;
36299         orig_conv.inner = (void*)(orig & (~1));
36300         orig_conv.is_owned = false;
36301         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36302         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
36303         uint32_t ret_ref = 0;
36304         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36305         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36306         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36307         ret_ref = (uintptr_t)ret_var.inner;
36308         if (ret_var.is_owned) {
36309                 ret_ref |= 1;
36310         }
36311         return ret_ref;
36312 }
36313
36314 jboolean  __attribute__((export_name("TS_ChannelTransactionParameters_is_populated"))) TS_ChannelTransactionParameters_is_populated(uint32_t this_arg) {
36315         LDKChannelTransactionParameters this_arg_conv;
36316         this_arg_conv.inner = (void*)(this_arg & (~1));
36317         this_arg_conv.is_owned = false;
36318         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36319         jboolean ret_conv = ChannelTransactionParameters_is_populated(&this_arg_conv);
36320         return ret_conv;
36321 }
36322
36323 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_as_holder_broadcastable"))) TS_ChannelTransactionParameters_as_holder_broadcastable(uint32_t this_arg) {
36324         LDKChannelTransactionParameters this_arg_conv;
36325         this_arg_conv.inner = (void*)(this_arg & (~1));
36326         this_arg_conv.is_owned = false;
36327         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36328         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
36329         uint32_t ret_ref = 0;
36330         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36331         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36332         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36333         ret_ref = (uintptr_t)ret_var.inner;
36334         if (ret_var.is_owned) {
36335                 ret_ref |= 1;
36336         }
36337         return ret_ref;
36338 }
36339
36340 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_as_counterparty_broadcastable"))) TS_ChannelTransactionParameters_as_counterparty_broadcastable(uint32_t this_arg) {
36341         LDKChannelTransactionParameters this_arg_conv;
36342         this_arg_conv.inner = (void*)(this_arg & (~1));
36343         this_arg_conv.is_owned = false;
36344         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36345         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
36346         uint32_t ret_ref = 0;
36347         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36348         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36349         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36350         ret_ref = (uintptr_t)ret_var.inner;
36351         if (ret_var.is_owned) {
36352                 ret_ref |= 1;
36353         }
36354         return ret_ref;
36355 }
36356
36357 int8_tArray  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_write"))) TS_CounterpartyChannelTransactionParameters_write(uint32_t obj) {
36358         LDKCounterpartyChannelTransactionParameters obj_conv;
36359         obj_conv.inner = (void*)(obj & (~1));
36360         obj_conv.is_owned = false;
36361         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36362         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
36363         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36364         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36365         CVec_u8Z_free(ret_var);
36366         return ret_arr;
36367 }
36368
36369 uint32_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_read"))) TS_CounterpartyChannelTransactionParameters_read(int8_tArray ser) {
36370         LDKu8slice ser_ref;
36371         ser_ref.datalen = ser->arr_len;
36372         ser_ref.data = ser->elems;
36373         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
36374         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
36375         FREE(ser);
36376         return (uint32_t)ret_conv;
36377 }
36378
36379 int8_tArray  __attribute__((export_name("TS_ChannelTransactionParameters_write"))) TS_ChannelTransactionParameters_write(uint32_t obj) {
36380         LDKChannelTransactionParameters obj_conv;
36381         obj_conv.inner = (void*)(obj & (~1));
36382         obj_conv.is_owned = false;
36383         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36384         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
36385         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36386         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36387         CVec_u8Z_free(ret_var);
36388         return ret_arr;
36389 }
36390
36391 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_read"))) TS_ChannelTransactionParameters_read(int8_tArray ser) {
36392         LDKu8slice ser_ref;
36393         ser_ref.datalen = ser->arr_len;
36394         ser_ref.data = ser->elems;
36395         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
36396         *ret_conv = ChannelTransactionParameters_read(ser_ref);
36397         FREE(ser);
36398         return (uint32_t)ret_conv;
36399 }
36400
36401 void  __attribute__((export_name("TS_DirectedChannelTransactionParameters_free"))) TS_DirectedChannelTransactionParameters_free(uint32_t this_obj) {
36402         LDKDirectedChannelTransactionParameters this_obj_conv;
36403         this_obj_conv.inner = (void*)(this_obj & (~1));
36404         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36405         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36406         DirectedChannelTransactionParameters_free(this_obj_conv);
36407 }
36408
36409 uint32_t  __attribute__((export_name("TS_DirectedChannelTransactionParameters_broadcaster_pubkeys"))) TS_DirectedChannelTransactionParameters_broadcaster_pubkeys(uint32_t this_arg) {
36410         LDKDirectedChannelTransactionParameters this_arg_conv;
36411         this_arg_conv.inner = (void*)(this_arg & (~1));
36412         this_arg_conv.is_owned = false;
36413         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36414         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
36415         uint32_t ret_ref = 0;
36416         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36417         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36418         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36419         ret_ref = (uintptr_t)ret_var.inner;
36420         if (ret_var.is_owned) {
36421                 ret_ref |= 1;
36422         }
36423         return ret_ref;
36424 }
36425
36426 uint32_t  __attribute__((export_name("TS_DirectedChannelTransactionParameters_countersignatory_pubkeys"))) TS_DirectedChannelTransactionParameters_countersignatory_pubkeys(uint32_t this_arg) {
36427         LDKDirectedChannelTransactionParameters this_arg_conv;
36428         this_arg_conv.inner = (void*)(this_arg & (~1));
36429         this_arg_conv.is_owned = false;
36430         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36431         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
36432         uint32_t ret_ref = 0;
36433         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36434         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36435         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36436         ret_ref = (uintptr_t)ret_var.inner;
36437         if (ret_var.is_owned) {
36438                 ret_ref |= 1;
36439         }
36440         return ret_ref;
36441 }
36442
36443 int16_t  __attribute__((export_name("TS_DirectedChannelTransactionParameters_contest_delay"))) TS_DirectedChannelTransactionParameters_contest_delay(uint32_t this_arg) {
36444         LDKDirectedChannelTransactionParameters this_arg_conv;
36445         this_arg_conv.inner = (void*)(this_arg & (~1));
36446         this_arg_conv.is_owned = false;
36447         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36448         int16_t ret_conv = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
36449         return ret_conv;
36450 }
36451
36452 jboolean  __attribute__((export_name("TS_DirectedChannelTransactionParameters_is_outbound"))) TS_DirectedChannelTransactionParameters_is_outbound(uint32_t this_arg) {
36453         LDKDirectedChannelTransactionParameters this_arg_conv;
36454         this_arg_conv.inner = (void*)(this_arg & (~1));
36455         this_arg_conv.is_owned = false;
36456         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36457         jboolean ret_conv = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
36458         return ret_conv;
36459 }
36460
36461 uint32_t  __attribute__((export_name("TS_DirectedChannelTransactionParameters_funding_outpoint"))) TS_DirectedChannelTransactionParameters_funding_outpoint(uint32_t this_arg) {
36462         LDKDirectedChannelTransactionParameters this_arg_conv;
36463         this_arg_conv.inner = (void*)(this_arg & (~1));
36464         this_arg_conv.is_owned = false;
36465         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36466         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
36467         uint32_t ret_ref = 0;
36468         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36469         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36470         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36471         ret_ref = (uintptr_t)ret_var.inner;
36472         if (ret_var.is_owned) {
36473                 ret_ref |= 1;
36474         }
36475         return ret_ref;
36476 }
36477
36478 jboolean  __attribute__((export_name("TS_DirectedChannelTransactionParameters_opt_anchors"))) TS_DirectedChannelTransactionParameters_opt_anchors(uint32_t this_arg) {
36479         LDKDirectedChannelTransactionParameters this_arg_conv;
36480         this_arg_conv.inner = (void*)(this_arg & (~1));
36481         this_arg_conv.is_owned = false;
36482         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36483         jboolean ret_conv = DirectedChannelTransactionParameters_opt_anchors(&this_arg_conv);
36484         return ret_conv;
36485 }
36486
36487 void  __attribute__((export_name("TS_HolderCommitmentTransaction_free"))) TS_HolderCommitmentTransaction_free(uint32_t this_obj) {
36488         LDKHolderCommitmentTransaction this_obj_conv;
36489         this_obj_conv.inner = (void*)(this_obj & (~1));
36490         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36491         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36492         HolderCommitmentTransaction_free(this_obj_conv);
36493 }
36494
36495 int8_tArray  __attribute__((export_name("TS_HolderCommitmentTransaction_get_counterparty_sig"))) TS_HolderCommitmentTransaction_get_counterparty_sig(uint32_t this_ptr) {
36496         LDKHolderCommitmentTransaction this_ptr_conv;
36497         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36498         this_ptr_conv.is_owned = false;
36499         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36500         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
36501         memcpy(ret_arr->elems, HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form, 64);
36502         return ret_arr;
36503 }
36504
36505 void  __attribute__((export_name("TS_HolderCommitmentTransaction_set_counterparty_sig"))) TS_HolderCommitmentTransaction_set_counterparty_sig(uint32_t this_ptr, int8_tArray val) {
36506         LDKHolderCommitmentTransaction this_ptr_conv;
36507         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36508         this_ptr_conv.is_owned = false;
36509         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36510         LDKSignature val_ref;
36511         CHECK(val->arr_len == 64);
36512         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
36513         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
36514 }
36515
36516 ptrArray  __attribute__((export_name("TS_HolderCommitmentTransaction_get_counterparty_htlc_sigs"))) TS_HolderCommitmentTransaction_get_counterparty_htlc_sigs(uint32_t this_ptr) {
36517         LDKHolderCommitmentTransaction this_ptr_conv;
36518         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36519         this_ptr_conv.is_owned = false;
36520         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36521         LDKCVec_SignatureZ ret_var = HolderCommitmentTransaction_get_counterparty_htlc_sigs(&this_ptr_conv);
36522         ptrArray ret_arr = NULL;
36523         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
36524         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 8);
36525         for (size_t m = 0; m < ret_var.datalen; m++) {
36526                 int8_tArray ret_conv_12_arr = init_int8_tArray(64, __LINE__);
36527                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].compact_form, 64);
36528                 ret_arr_ptr[m] = ret_conv_12_arr;
36529         }
36530         
36531         FREE(ret_var.data);
36532         return ret_arr;
36533 }
36534
36535 void  __attribute__((export_name("TS_HolderCommitmentTransaction_set_counterparty_htlc_sigs"))) TS_HolderCommitmentTransaction_set_counterparty_htlc_sigs(uint32_t this_ptr, ptrArray val) {
36536         LDKHolderCommitmentTransaction this_ptr_conv;
36537         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36538         this_ptr_conv.is_owned = false;
36539         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36540         LDKCVec_SignatureZ val_constr;
36541         val_constr.datalen = val->arr_len;
36542         if (val_constr.datalen > 0)
36543                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
36544         else
36545                 val_constr.data = NULL;
36546         int8_tArray* val_vals = (void*) val->elems;
36547         for (size_t m = 0; m < val_constr.datalen; m++) {
36548                 int8_tArray val_conv_12 = val_vals[m];
36549                 LDKSignature val_conv_12_ref;
36550                 CHECK(val_conv_12->arr_len == 64);
36551                 memcpy(val_conv_12_ref.compact_form, val_conv_12->elems, 64); FREE(val_conv_12);
36552                 val_constr.data[m] = val_conv_12_ref;
36553         }
36554         FREE(val);
36555         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
36556 }
36557
36558 static inline uintptr_t HolderCommitmentTransaction_clone_ptr(LDKHolderCommitmentTransaction *NONNULL_PTR arg) {
36559         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(arg);
36560 uint32_t ret_ref = 0;
36561 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36562 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36563 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36564 ret_ref = (uintptr_t)ret_var.inner;
36565 if (ret_var.is_owned) {
36566         ret_ref |= 1;
36567 }
36568         return ret_ref;
36569 }
36570 uint32_t  __attribute__((export_name("TS_HolderCommitmentTransaction_clone_ptr"))) TS_HolderCommitmentTransaction_clone_ptr(uint32_t arg) {
36571         LDKHolderCommitmentTransaction arg_conv;
36572         arg_conv.inner = (void*)(arg & (~1));
36573         arg_conv.is_owned = false;
36574         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36575         uint32_t ret_conv = HolderCommitmentTransaction_clone_ptr(&arg_conv);
36576         return ret_conv;
36577 }
36578
36579 uint32_t  __attribute__((export_name("TS_HolderCommitmentTransaction_clone"))) TS_HolderCommitmentTransaction_clone(uint32_t orig) {
36580         LDKHolderCommitmentTransaction orig_conv;
36581         orig_conv.inner = (void*)(orig & (~1));
36582         orig_conv.is_owned = false;
36583         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36584         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
36585         uint32_t ret_ref = 0;
36586         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36587         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36588         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36589         ret_ref = (uintptr_t)ret_var.inner;
36590         if (ret_var.is_owned) {
36591                 ret_ref |= 1;
36592         }
36593         return ret_ref;
36594 }
36595
36596 int8_tArray  __attribute__((export_name("TS_HolderCommitmentTransaction_write"))) TS_HolderCommitmentTransaction_write(uint32_t obj) {
36597         LDKHolderCommitmentTransaction obj_conv;
36598         obj_conv.inner = (void*)(obj & (~1));
36599         obj_conv.is_owned = false;
36600         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36601         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
36602         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36603         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36604         CVec_u8Z_free(ret_var);
36605         return ret_arr;
36606 }
36607
36608 uint32_t  __attribute__((export_name("TS_HolderCommitmentTransaction_read"))) TS_HolderCommitmentTransaction_read(int8_tArray ser) {
36609         LDKu8slice ser_ref;
36610         ser_ref.datalen = ser->arr_len;
36611         ser_ref.data = ser->elems;
36612         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
36613         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
36614         FREE(ser);
36615         return (uint32_t)ret_conv;
36616 }
36617
36618 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) {
36619         LDKCommitmentTransaction commitment_tx_conv;
36620         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
36621         commitment_tx_conv.is_owned = (commitment_tx & 1) || (commitment_tx == 0);
36622         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
36623         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
36624         LDKSignature counterparty_sig_ref;
36625         CHECK(counterparty_sig->arr_len == 64);
36626         memcpy(counterparty_sig_ref.compact_form, counterparty_sig->elems, 64); FREE(counterparty_sig);
36627         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
36628         counterparty_htlc_sigs_constr.datalen = counterparty_htlc_sigs->arr_len;
36629         if (counterparty_htlc_sigs_constr.datalen > 0)
36630                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
36631         else
36632                 counterparty_htlc_sigs_constr.data = NULL;
36633         int8_tArray* counterparty_htlc_sigs_vals = (void*) counterparty_htlc_sigs->elems;
36634         for (size_t m = 0; m < counterparty_htlc_sigs_constr.datalen; m++) {
36635                 int8_tArray counterparty_htlc_sigs_conv_12 = counterparty_htlc_sigs_vals[m];
36636                 LDKSignature counterparty_htlc_sigs_conv_12_ref;
36637                 CHECK(counterparty_htlc_sigs_conv_12->arr_len == 64);
36638                 memcpy(counterparty_htlc_sigs_conv_12_ref.compact_form, counterparty_htlc_sigs_conv_12->elems, 64); FREE(counterparty_htlc_sigs_conv_12);
36639                 counterparty_htlc_sigs_constr.data[m] = counterparty_htlc_sigs_conv_12_ref;
36640         }
36641         FREE(counterparty_htlc_sigs);
36642         LDKPublicKey holder_funding_key_ref;
36643         CHECK(holder_funding_key->arr_len == 33);
36644         memcpy(holder_funding_key_ref.compressed_form, holder_funding_key->elems, 33); FREE(holder_funding_key);
36645         LDKPublicKey counterparty_funding_key_ref;
36646         CHECK(counterparty_funding_key->arr_len == 33);
36647         memcpy(counterparty_funding_key_ref.compressed_form, counterparty_funding_key->elems, 33); FREE(counterparty_funding_key);
36648         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
36649         uint32_t ret_ref = 0;
36650         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36651         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36652         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36653         ret_ref = (uintptr_t)ret_var.inner;
36654         if (ret_var.is_owned) {
36655                 ret_ref |= 1;
36656         }
36657         return ret_ref;
36658 }
36659
36660 void  __attribute__((export_name("TS_BuiltCommitmentTransaction_free"))) TS_BuiltCommitmentTransaction_free(uint32_t this_obj) {
36661         LDKBuiltCommitmentTransaction this_obj_conv;
36662         this_obj_conv.inner = (void*)(this_obj & (~1));
36663         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36664         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36665         BuiltCommitmentTransaction_free(this_obj_conv);
36666 }
36667
36668 int8_tArray  __attribute__((export_name("TS_BuiltCommitmentTransaction_get_transaction"))) TS_BuiltCommitmentTransaction_get_transaction(uint32_t this_ptr) {
36669         LDKBuiltCommitmentTransaction this_ptr_conv;
36670         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36671         this_ptr_conv.is_owned = false;
36672         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36673         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
36674         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36675         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36676         Transaction_free(ret_var);
36677         return ret_arr;
36678 }
36679
36680 void  __attribute__((export_name("TS_BuiltCommitmentTransaction_set_transaction"))) TS_BuiltCommitmentTransaction_set_transaction(uint32_t this_ptr, int8_tArray val) {
36681         LDKBuiltCommitmentTransaction this_ptr_conv;
36682         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36683         this_ptr_conv.is_owned = false;
36684         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36685         LDKTransaction val_ref;
36686         val_ref.datalen = val->arr_len;
36687         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
36688         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
36689         val_ref.data_is_owned = true;
36690         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
36691 }
36692
36693 int8_tArray  __attribute__((export_name("TS_BuiltCommitmentTransaction_get_txid"))) TS_BuiltCommitmentTransaction_get_txid(uint32_t this_ptr) {
36694         LDKBuiltCommitmentTransaction this_ptr_conv;
36695         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36696         this_ptr_conv.is_owned = false;
36697         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36698         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
36699         memcpy(ret_arr->elems, *BuiltCommitmentTransaction_get_txid(&this_ptr_conv), 32);
36700         return ret_arr;
36701 }
36702
36703 void  __attribute__((export_name("TS_BuiltCommitmentTransaction_set_txid"))) TS_BuiltCommitmentTransaction_set_txid(uint32_t this_ptr, int8_tArray val) {
36704         LDKBuiltCommitmentTransaction this_ptr_conv;
36705         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36706         this_ptr_conv.is_owned = false;
36707         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36708         LDKThirtyTwoBytes val_ref;
36709         CHECK(val->arr_len == 32);
36710         memcpy(val_ref.data, val->elems, 32); FREE(val);
36711         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
36712 }
36713
36714 uint32_t  __attribute__((export_name("TS_BuiltCommitmentTransaction_new"))) TS_BuiltCommitmentTransaction_new(int8_tArray transaction_arg, int8_tArray txid_arg) {
36715         LDKTransaction transaction_arg_ref;
36716         transaction_arg_ref.datalen = transaction_arg->arr_len;
36717         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
36718         memcpy(transaction_arg_ref.data, transaction_arg->elems, transaction_arg_ref.datalen); FREE(transaction_arg);
36719         transaction_arg_ref.data_is_owned = true;
36720         LDKThirtyTwoBytes txid_arg_ref;
36721         CHECK(txid_arg->arr_len == 32);
36722         memcpy(txid_arg_ref.data, txid_arg->elems, 32); FREE(txid_arg);
36723         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
36724         uint32_t ret_ref = 0;
36725         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36726         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36727         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36728         ret_ref = (uintptr_t)ret_var.inner;
36729         if (ret_var.is_owned) {
36730                 ret_ref |= 1;
36731         }
36732         return ret_ref;
36733 }
36734
36735 static inline uintptr_t BuiltCommitmentTransaction_clone_ptr(LDKBuiltCommitmentTransaction *NONNULL_PTR arg) {
36736         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(arg);
36737 uint32_t ret_ref = 0;
36738 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36739 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36740 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36741 ret_ref = (uintptr_t)ret_var.inner;
36742 if (ret_var.is_owned) {
36743         ret_ref |= 1;
36744 }
36745         return ret_ref;
36746 }
36747 uint32_t  __attribute__((export_name("TS_BuiltCommitmentTransaction_clone_ptr"))) TS_BuiltCommitmentTransaction_clone_ptr(uint32_t arg) {
36748         LDKBuiltCommitmentTransaction arg_conv;
36749         arg_conv.inner = (void*)(arg & (~1));
36750         arg_conv.is_owned = false;
36751         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36752         uint32_t ret_conv = BuiltCommitmentTransaction_clone_ptr(&arg_conv);
36753         return ret_conv;
36754 }
36755
36756 uint32_t  __attribute__((export_name("TS_BuiltCommitmentTransaction_clone"))) TS_BuiltCommitmentTransaction_clone(uint32_t orig) {
36757         LDKBuiltCommitmentTransaction orig_conv;
36758         orig_conv.inner = (void*)(orig & (~1));
36759         orig_conv.is_owned = false;
36760         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36761         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
36762         uint32_t ret_ref = 0;
36763         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36764         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36765         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36766         ret_ref = (uintptr_t)ret_var.inner;
36767         if (ret_var.is_owned) {
36768                 ret_ref |= 1;
36769         }
36770         return ret_ref;
36771 }
36772
36773 int8_tArray  __attribute__((export_name("TS_BuiltCommitmentTransaction_write"))) TS_BuiltCommitmentTransaction_write(uint32_t obj) {
36774         LDKBuiltCommitmentTransaction obj_conv;
36775         obj_conv.inner = (void*)(obj & (~1));
36776         obj_conv.is_owned = false;
36777         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36778         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
36779         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36780         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36781         CVec_u8Z_free(ret_var);
36782         return ret_arr;
36783 }
36784
36785 uint32_t  __attribute__((export_name("TS_BuiltCommitmentTransaction_read"))) TS_BuiltCommitmentTransaction_read(int8_tArray ser) {
36786         LDKu8slice ser_ref;
36787         ser_ref.datalen = ser->arr_len;
36788         ser_ref.data = ser->elems;
36789         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
36790         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
36791         FREE(ser);
36792         return (uint32_t)ret_conv;
36793 }
36794
36795 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) {
36796         LDKBuiltCommitmentTransaction this_arg_conv;
36797         this_arg_conv.inner = (void*)(this_arg & (~1));
36798         this_arg_conv.is_owned = false;
36799         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36800         LDKu8slice funding_redeemscript_ref;
36801         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
36802         funding_redeemscript_ref.data = funding_redeemscript->elems;
36803         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
36804         memcpy(ret_arr->elems, BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data, 32);
36805         FREE(funding_redeemscript);
36806         return ret_arr;
36807 }
36808
36809 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) {
36810         LDKBuiltCommitmentTransaction this_arg_conv;
36811         this_arg_conv.inner = (void*)(this_arg & (~1));
36812         this_arg_conv.is_owned = false;
36813         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36814         unsigned char funding_key_arr[32];
36815         CHECK(funding_key->arr_len == 32);
36816         memcpy(funding_key_arr, funding_key->elems, 32); FREE(funding_key);
36817         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
36818         LDKu8slice funding_redeemscript_ref;
36819         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
36820         funding_redeemscript_ref.data = funding_redeemscript->elems;
36821         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
36822         memcpy(ret_arr->elems, BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form, 64);
36823         FREE(funding_redeemscript);
36824         return ret_arr;
36825 }
36826
36827 void  __attribute__((export_name("TS_ClosingTransaction_free"))) TS_ClosingTransaction_free(uint32_t this_obj) {
36828         LDKClosingTransaction this_obj_conv;
36829         this_obj_conv.inner = (void*)(this_obj & (~1));
36830         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36831         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36832         ClosingTransaction_free(this_obj_conv);
36833 }
36834
36835 static inline uintptr_t ClosingTransaction_clone_ptr(LDKClosingTransaction *NONNULL_PTR arg) {
36836         LDKClosingTransaction ret_var = ClosingTransaction_clone(arg);
36837 uint32_t ret_ref = 0;
36838 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36839 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36840 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36841 ret_ref = (uintptr_t)ret_var.inner;
36842 if (ret_var.is_owned) {
36843         ret_ref |= 1;
36844 }
36845         return ret_ref;
36846 }
36847 uint32_t  __attribute__((export_name("TS_ClosingTransaction_clone_ptr"))) TS_ClosingTransaction_clone_ptr(uint32_t arg) {
36848         LDKClosingTransaction arg_conv;
36849         arg_conv.inner = (void*)(arg & (~1));
36850         arg_conv.is_owned = false;
36851         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36852         uint32_t ret_conv = ClosingTransaction_clone_ptr(&arg_conv);
36853         return ret_conv;
36854 }
36855
36856 uint32_t  __attribute__((export_name("TS_ClosingTransaction_clone"))) TS_ClosingTransaction_clone(uint32_t orig) {
36857         LDKClosingTransaction orig_conv;
36858         orig_conv.inner = (void*)(orig & (~1));
36859         orig_conv.is_owned = false;
36860         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36861         LDKClosingTransaction ret_var = ClosingTransaction_clone(&orig_conv);
36862         uint32_t ret_ref = 0;
36863         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36864         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36865         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36866         ret_ref = (uintptr_t)ret_var.inner;
36867         if (ret_var.is_owned) {
36868                 ret_ref |= 1;
36869         }
36870         return ret_ref;
36871 }
36872
36873 int64_t  __attribute__((export_name("TS_ClosingTransaction_hash"))) TS_ClosingTransaction_hash(uint32_t o) {
36874         LDKClosingTransaction o_conv;
36875         o_conv.inner = (void*)(o & (~1));
36876         o_conv.is_owned = false;
36877         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
36878         int64_t ret_conv = ClosingTransaction_hash(&o_conv);
36879         return ret_conv;
36880 }
36881
36882 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) {
36883         LDKCVec_u8Z to_holder_script_ref;
36884         to_holder_script_ref.datalen = to_holder_script->arr_len;
36885         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
36886         memcpy(to_holder_script_ref.data, to_holder_script->elems, to_holder_script_ref.datalen); FREE(to_holder_script);
36887         LDKCVec_u8Z to_counterparty_script_ref;
36888         to_counterparty_script_ref.datalen = to_counterparty_script->arr_len;
36889         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
36890         memcpy(to_counterparty_script_ref.data, to_counterparty_script->elems, to_counterparty_script_ref.datalen); FREE(to_counterparty_script);
36891         LDKOutPoint funding_outpoint_conv;
36892         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
36893         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
36894         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
36895         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
36896         LDKClosingTransaction ret_var = ClosingTransaction_new(to_holder_value_sat, to_counterparty_value_sat, to_holder_script_ref, to_counterparty_script_ref, funding_outpoint_conv);
36897         uint32_t ret_ref = 0;
36898         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36899         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36900         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36901         ret_ref = (uintptr_t)ret_var.inner;
36902         if (ret_var.is_owned) {
36903                 ret_ref |= 1;
36904         }
36905         return ret_ref;
36906 }
36907
36908 uint32_t  __attribute__((export_name("TS_ClosingTransaction_trust"))) TS_ClosingTransaction_trust(uint32_t this_arg) {
36909         LDKClosingTransaction this_arg_conv;
36910         this_arg_conv.inner = (void*)(this_arg & (~1));
36911         this_arg_conv.is_owned = false;
36912         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36913         LDKTrustedClosingTransaction ret_var = ClosingTransaction_trust(&this_arg_conv);
36914         uint32_t ret_ref = 0;
36915         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36916         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36917         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36918         ret_ref = (uintptr_t)ret_var.inner;
36919         if (ret_var.is_owned) {
36920                 ret_ref |= 1;
36921         }
36922         return ret_ref;
36923 }
36924
36925 uint32_t  __attribute__((export_name("TS_ClosingTransaction_verify"))) TS_ClosingTransaction_verify(uint32_t this_arg, uint32_t funding_outpoint) {
36926         LDKClosingTransaction this_arg_conv;
36927         this_arg_conv.inner = (void*)(this_arg & (~1));
36928         this_arg_conv.is_owned = false;
36929         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36930         LDKOutPoint funding_outpoint_conv;
36931         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
36932         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
36933         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
36934         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
36935         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
36936         *ret_conv = ClosingTransaction_verify(&this_arg_conv, funding_outpoint_conv);
36937         return (uint32_t)ret_conv;
36938 }
36939
36940 int64_t  __attribute__((export_name("TS_ClosingTransaction_to_holder_value_sat"))) TS_ClosingTransaction_to_holder_value_sat(uint32_t this_arg) {
36941         LDKClosingTransaction this_arg_conv;
36942         this_arg_conv.inner = (void*)(this_arg & (~1));
36943         this_arg_conv.is_owned = false;
36944         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36945         int64_t ret_conv = ClosingTransaction_to_holder_value_sat(&this_arg_conv);
36946         return ret_conv;
36947 }
36948
36949 int64_t  __attribute__((export_name("TS_ClosingTransaction_to_counterparty_value_sat"))) TS_ClosingTransaction_to_counterparty_value_sat(uint32_t this_arg) {
36950         LDKClosingTransaction this_arg_conv;
36951         this_arg_conv.inner = (void*)(this_arg & (~1));
36952         this_arg_conv.is_owned = false;
36953         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36954         int64_t ret_conv = ClosingTransaction_to_counterparty_value_sat(&this_arg_conv);
36955         return ret_conv;
36956 }
36957
36958 int8_tArray  __attribute__((export_name("TS_ClosingTransaction_to_holder_script"))) TS_ClosingTransaction_to_holder_script(uint32_t this_arg) {
36959         LDKClosingTransaction this_arg_conv;
36960         this_arg_conv.inner = (void*)(this_arg & (~1));
36961         this_arg_conv.is_owned = false;
36962         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36963         LDKu8slice ret_var = ClosingTransaction_to_holder_script(&this_arg_conv);
36964         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36965         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36966         return ret_arr;
36967 }
36968
36969 int8_tArray  __attribute__((export_name("TS_ClosingTransaction_to_counterparty_script"))) TS_ClosingTransaction_to_counterparty_script(uint32_t this_arg) {
36970         LDKClosingTransaction this_arg_conv;
36971         this_arg_conv.inner = (void*)(this_arg & (~1));
36972         this_arg_conv.is_owned = false;
36973         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36974         LDKu8slice ret_var = ClosingTransaction_to_counterparty_script(&this_arg_conv);
36975         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36976         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36977         return ret_arr;
36978 }
36979
36980 void  __attribute__((export_name("TS_TrustedClosingTransaction_free"))) TS_TrustedClosingTransaction_free(uint32_t this_obj) {
36981         LDKTrustedClosingTransaction this_obj_conv;
36982         this_obj_conv.inner = (void*)(this_obj & (~1));
36983         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36984         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36985         TrustedClosingTransaction_free(this_obj_conv);
36986 }
36987
36988 int8_tArray  __attribute__((export_name("TS_TrustedClosingTransaction_built_transaction"))) TS_TrustedClosingTransaction_built_transaction(uint32_t this_arg) {
36989         LDKTrustedClosingTransaction this_arg_conv;
36990         this_arg_conv.inner = (void*)(this_arg & (~1));
36991         this_arg_conv.is_owned = false;
36992         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36993         LDKTransaction ret_var = TrustedClosingTransaction_built_transaction(&this_arg_conv);
36994         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36995         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36996         Transaction_free(ret_var);
36997         return ret_arr;
36998 }
36999
37000 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) {
37001         LDKTrustedClosingTransaction this_arg_conv;
37002         this_arg_conv.inner = (void*)(this_arg & (~1));
37003         this_arg_conv.is_owned = false;
37004         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37005         LDKu8slice funding_redeemscript_ref;
37006         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
37007         funding_redeemscript_ref.data = funding_redeemscript->elems;
37008         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
37009         memcpy(ret_arr->elems, TrustedClosingTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data, 32);
37010         FREE(funding_redeemscript);
37011         return ret_arr;
37012 }
37013
37014 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) {
37015         LDKTrustedClosingTransaction this_arg_conv;
37016         this_arg_conv.inner = (void*)(this_arg & (~1));
37017         this_arg_conv.is_owned = false;
37018         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37019         unsigned char funding_key_arr[32];
37020         CHECK(funding_key->arr_len == 32);
37021         memcpy(funding_key_arr, funding_key->elems, 32); FREE(funding_key);
37022         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
37023         LDKu8slice funding_redeemscript_ref;
37024         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
37025         funding_redeemscript_ref.data = funding_redeemscript->elems;
37026         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
37027         memcpy(ret_arr->elems, TrustedClosingTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form, 64);
37028         FREE(funding_redeemscript);
37029         return ret_arr;
37030 }
37031
37032 void  __attribute__((export_name("TS_CommitmentTransaction_free"))) TS_CommitmentTransaction_free(uint32_t this_obj) {
37033         LDKCommitmentTransaction this_obj_conv;
37034         this_obj_conv.inner = (void*)(this_obj & (~1));
37035         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37036         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37037         CommitmentTransaction_free(this_obj_conv);
37038 }
37039
37040 static inline uintptr_t CommitmentTransaction_clone_ptr(LDKCommitmentTransaction *NONNULL_PTR arg) {
37041         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(arg);
37042 uint32_t ret_ref = 0;
37043 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37044 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37045 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37046 ret_ref = (uintptr_t)ret_var.inner;
37047 if (ret_var.is_owned) {
37048         ret_ref |= 1;
37049 }
37050         return ret_ref;
37051 }
37052 uint32_t  __attribute__((export_name("TS_CommitmentTransaction_clone_ptr"))) TS_CommitmentTransaction_clone_ptr(uint32_t arg) {
37053         LDKCommitmentTransaction arg_conv;
37054         arg_conv.inner = (void*)(arg & (~1));
37055         arg_conv.is_owned = false;
37056         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37057         uint32_t ret_conv = CommitmentTransaction_clone_ptr(&arg_conv);
37058         return ret_conv;
37059 }
37060
37061 uint32_t  __attribute__((export_name("TS_CommitmentTransaction_clone"))) TS_CommitmentTransaction_clone(uint32_t orig) {
37062         LDKCommitmentTransaction orig_conv;
37063         orig_conv.inner = (void*)(orig & (~1));
37064         orig_conv.is_owned = false;
37065         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37066         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
37067         uint32_t ret_ref = 0;
37068         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37069         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37070         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37071         ret_ref = (uintptr_t)ret_var.inner;
37072         if (ret_var.is_owned) {
37073                 ret_ref |= 1;
37074         }
37075         return ret_ref;
37076 }
37077
37078 int8_tArray  __attribute__((export_name("TS_CommitmentTransaction_write"))) TS_CommitmentTransaction_write(uint32_t obj) {
37079         LDKCommitmentTransaction obj_conv;
37080         obj_conv.inner = (void*)(obj & (~1));
37081         obj_conv.is_owned = false;
37082         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37083         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
37084         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
37085         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
37086         CVec_u8Z_free(ret_var);
37087         return ret_arr;
37088 }
37089
37090 uint32_t  __attribute__((export_name("TS_CommitmentTransaction_read"))) TS_CommitmentTransaction_read(int8_tArray ser) {
37091         LDKu8slice ser_ref;
37092         ser_ref.datalen = ser->arr_len;
37093         ser_ref.data = ser->elems;
37094         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
37095         *ret_conv = CommitmentTransaction_read(ser_ref);
37096         FREE(ser);
37097         return (uint32_t)ret_conv;
37098 }
37099
37100 int64_t  __attribute__((export_name("TS_CommitmentTransaction_commitment_number"))) TS_CommitmentTransaction_commitment_number(uint32_t this_arg) {
37101         LDKCommitmentTransaction this_arg_conv;
37102         this_arg_conv.inner = (void*)(this_arg & (~1));
37103         this_arg_conv.is_owned = false;
37104         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37105         int64_t ret_conv = CommitmentTransaction_commitment_number(&this_arg_conv);
37106         return ret_conv;
37107 }
37108
37109 int64_t  __attribute__((export_name("TS_CommitmentTransaction_to_broadcaster_value_sat"))) TS_CommitmentTransaction_to_broadcaster_value_sat(uint32_t this_arg) {
37110         LDKCommitmentTransaction this_arg_conv;
37111         this_arg_conv.inner = (void*)(this_arg & (~1));
37112         this_arg_conv.is_owned = false;
37113         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37114         int64_t ret_conv = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
37115         return ret_conv;
37116 }
37117
37118 int64_t  __attribute__((export_name("TS_CommitmentTransaction_to_countersignatory_value_sat"))) TS_CommitmentTransaction_to_countersignatory_value_sat(uint32_t this_arg) {
37119         LDKCommitmentTransaction this_arg_conv;
37120         this_arg_conv.inner = (void*)(this_arg & (~1));
37121         this_arg_conv.is_owned = false;
37122         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37123         int64_t ret_conv = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
37124         return ret_conv;
37125 }
37126
37127 int32_t  __attribute__((export_name("TS_CommitmentTransaction_feerate_per_kw"))) TS_CommitmentTransaction_feerate_per_kw(uint32_t this_arg) {
37128         LDKCommitmentTransaction this_arg_conv;
37129         this_arg_conv.inner = (void*)(this_arg & (~1));
37130         this_arg_conv.is_owned = false;
37131         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37132         int32_t ret_conv = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
37133         return ret_conv;
37134 }
37135
37136 uint32_t  __attribute__((export_name("TS_CommitmentTransaction_trust"))) TS_CommitmentTransaction_trust(uint32_t this_arg) {
37137         LDKCommitmentTransaction this_arg_conv;
37138         this_arg_conv.inner = (void*)(this_arg & (~1));
37139         this_arg_conv.is_owned = false;
37140         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37141         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
37142         uint32_t ret_ref = 0;
37143         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37144         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37145         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37146         ret_ref = (uintptr_t)ret_var.inner;
37147         if (ret_var.is_owned) {
37148                 ret_ref |= 1;
37149         }
37150         return ret_ref;
37151 }
37152
37153 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) {
37154         LDKCommitmentTransaction this_arg_conv;
37155         this_arg_conv.inner = (void*)(this_arg & (~1));
37156         this_arg_conv.is_owned = false;
37157         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37158         LDKDirectedChannelTransactionParameters channel_parameters_conv;
37159         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
37160         channel_parameters_conv.is_owned = false;
37161         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
37162         LDKChannelPublicKeys broadcaster_keys_conv;
37163         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
37164         broadcaster_keys_conv.is_owned = false;
37165         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
37166         LDKChannelPublicKeys countersignatory_keys_conv;
37167         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
37168         countersignatory_keys_conv.is_owned = false;
37169         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
37170         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
37171         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
37172         return (uint32_t)ret_conv;
37173 }
37174
37175 void  __attribute__((export_name("TS_TrustedCommitmentTransaction_free"))) TS_TrustedCommitmentTransaction_free(uint32_t this_obj) {
37176         LDKTrustedCommitmentTransaction this_obj_conv;
37177         this_obj_conv.inner = (void*)(this_obj & (~1));
37178         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37179         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37180         TrustedCommitmentTransaction_free(this_obj_conv);
37181 }
37182
37183 int8_tArray  __attribute__((export_name("TS_TrustedCommitmentTransaction_txid"))) TS_TrustedCommitmentTransaction_txid(uint32_t this_arg) {
37184         LDKTrustedCommitmentTransaction this_arg_conv;
37185         this_arg_conv.inner = (void*)(this_arg & (~1));
37186         this_arg_conv.is_owned = false;
37187         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37188         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
37189         memcpy(ret_arr->elems, TrustedCommitmentTransaction_txid(&this_arg_conv).data, 32);
37190         return ret_arr;
37191 }
37192
37193 uint32_t  __attribute__((export_name("TS_TrustedCommitmentTransaction_built_transaction"))) TS_TrustedCommitmentTransaction_built_transaction(uint32_t this_arg) {
37194         LDKTrustedCommitmentTransaction this_arg_conv;
37195         this_arg_conv.inner = (void*)(this_arg & (~1));
37196         this_arg_conv.is_owned = false;
37197         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37198         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
37199         uint32_t ret_ref = 0;
37200         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37201         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37202         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37203         ret_ref = (uintptr_t)ret_var.inner;
37204         if (ret_var.is_owned) {
37205                 ret_ref |= 1;
37206         }
37207         return ret_ref;
37208 }
37209
37210 uint32_t  __attribute__((export_name("TS_TrustedCommitmentTransaction_keys"))) TS_TrustedCommitmentTransaction_keys(uint32_t this_arg) {
37211         LDKTrustedCommitmentTransaction this_arg_conv;
37212         this_arg_conv.inner = (void*)(this_arg & (~1));
37213         this_arg_conv.is_owned = false;
37214         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37215         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
37216         uint32_t ret_ref = 0;
37217         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37218         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37219         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37220         ret_ref = (uintptr_t)ret_var.inner;
37221         if (ret_var.is_owned) {
37222                 ret_ref |= 1;
37223         }
37224         return ret_ref;
37225 }
37226
37227 jboolean  __attribute__((export_name("TS_TrustedCommitmentTransaction_opt_anchors"))) TS_TrustedCommitmentTransaction_opt_anchors(uint32_t this_arg) {
37228         LDKTrustedCommitmentTransaction this_arg_conv;
37229         this_arg_conv.inner = (void*)(this_arg & (~1));
37230         this_arg_conv.is_owned = false;
37231         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37232         jboolean ret_conv = TrustedCommitmentTransaction_opt_anchors(&this_arg_conv);
37233         return ret_conv;
37234 }
37235
37236 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) {
37237         LDKTrustedCommitmentTransaction this_arg_conv;
37238         this_arg_conv.inner = (void*)(this_arg & (~1));
37239         this_arg_conv.is_owned = false;
37240         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37241         unsigned char htlc_base_key_arr[32];
37242         CHECK(htlc_base_key->arr_len == 32);
37243         memcpy(htlc_base_key_arr, htlc_base_key->elems, 32); FREE(htlc_base_key);
37244         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
37245         LDKDirectedChannelTransactionParameters channel_parameters_conv;
37246         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
37247         channel_parameters_conv.is_owned = false;
37248         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
37249         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
37250         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
37251         return (uint32_t)ret_conv;
37252 }
37253
37254 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) {
37255         LDKPublicKey broadcaster_payment_basepoint_ref;
37256         CHECK(broadcaster_payment_basepoint->arr_len == 33);
37257         memcpy(broadcaster_payment_basepoint_ref.compressed_form, broadcaster_payment_basepoint->elems, 33); FREE(broadcaster_payment_basepoint);
37258         LDKPublicKey countersignatory_payment_basepoint_ref;
37259         CHECK(countersignatory_payment_basepoint->arr_len == 33);
37260         memcpy(countersignatory_payment_basepoint_ref.compressed_form, countersignatory_payment_basepoint->elems, 33); FREE(countersignatory_payment_basepoint);
37261         int64_t ret_conv = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
37262         return ret_conv;
37263 }
37264
37265 jboolean  __attribute__((export_name("TS_InitFeatures_eq"))) TS_InitFeatures_eq(uint32_t a, uint32_t b) {
37266         LDKInitFeatures a_conv;
37267         a_conv.inner = (void*)(a & (~1));
37268         a_conv.is_owned = false;
37269         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37270         LDKInitFeatures b_conv;
37271         b_conv.inner = (void*)(b & (~1));
37272         b_conv.is_owned = false;
37273         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37274         jboolean ret_conv = InitFeatures_eq(&a_conv, &b_conv);
37275         return ret_conv;
37276 }
37277
37278 jboolean  __attribute__((export_name("TS_NodeFeatures_eq"))) TS_NodeFeatures_eq(uint32_t a, uint32_t b) {
37279         LDKNodeFeatures a_conv;
37280         a_conv.inner = (void*)(a & (~1));
37281         a_conv.is_owned = false;
37282         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37283         LDKNodeFeatures b_conv;
37284         b_conv.inner = (void*)(b & (~1));
37285         b_conv.is_owned = false;
37286         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37287         jboolean ret_conv = NodeFeatures_eq(&a_conv, &b_conv);
37288         return ret_conv;
37289 }
37290
37291 jboolean  __attribute__((export_name("TS_ChannelFeatures_eq"))) TS_ChannelFeatures_eq(uint32_t a, uint32_t b) {
37292         LDKChannelFeatures a_conv;
37293         a_conv.inner = (void*)(a & (~1));
37294         a_conv.is_owned = false;
37295         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37296         LDKChannelFeatures b_conv;
37297         b_conv.inner = (void*)(b & (~1));
37298         b_conv.is_owned = false;
37299         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37300         jboolean ret_conv = ChannelFeatures_eq(&a_conv, &b_conv);
37301         return ret_conv;
37302 }
37303
37304 jboolean  __attribute__((export_name("TS_InvoiceFeatures_eq"))) TS_InvoiceFeatures_eq(uint32_t a, uint32_t b) {
37305         LDKInvoiceFeatures a_conv;
37306         a_conv.inner = (void*)(a & (~1));
37307         a_conv.is_owned = false;
37308         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37309         LDKInvoiceFeatures b_conv;
37310         b_conv.inner = (void*)(b & (~1));
37311         b_conv.is_owned = false;
37312         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37313         jboolean ret_conv = InvoiceFeatures_eq(&a_conv, &b_conv);
37314         return ret_conv;
37315 }
37316
37317 jboolean  __attribute__((export_name("TS_ChannelTypeFeatures_eq"))) TS_ChannelTypeFeatures_eq(uint32_t a, uint32_t b) {
37318         LDKChannelTypeFeatures a_conv;
37319         a_conv.inner = (void*)(a & (~1));
37320         a_conv.is_owned = false;
37321         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37322         LDKChannelTypeFeatures b_conv;
37323         b_conv.inner = (void*)(b & (~1));
37324         b_conv.is_owned = false;
37325         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37326         jboolean ret_conv = ChannelTypeFeatures_eq(&a_conv, &b_conv);
37327         return ret_conv;
37328 }
37329
37330 static inline uintptr_t InitFeatures_clone_ptr(LDKInitFeatures *NONNULL_PTR arg) {
37331         LDKInitFeatures ret_var = InitFeatures_clone(arg);
37332 uint32_t ret_ref = 0;
37333 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37334 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37335 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37336 ret_ref = (uintptr_t)ret_var.inner;
37337 if (ret_var.is_owned) {
37338         ret_ref |= 1;
37339 }
37340         return ret_ref;
37341 }
37342 uint32_t  __attribute__((export_name("TS_InitFeatures_clone_ptr"))) TS_InitFeatures_clone_ptr(uint32_t arg) {
37343         LDKInitFeatures arg_conv;
37344         arg_conv.inner = (void*)(arg & (~1));
37345         arg_conv.is_owned = false;
37346         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37347         uint32_t ret_conv = InitFeatures_clone_ptr(&arg_conv);
37348         return ret_conv;
37349 }
37350
37351 uint32_t  __attribute__((export_name("TS_InitFeatures_clone"))) TS_InitFeatures_clone(uint32_t orig) {
37352         LDKInitFeatures orig_conv;
37353         orig_conv.inner = (void*)(orig & (~1));
37354         orig_conv.is_owned = false;
37355         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37356         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
37357         uint32_t ret_ref = 0;
37358         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37359         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37360         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37361         ret_ref = (uintptr_t)ret_var.inner;
37362         if (ret_var.is_owned) {
37363                 ret_ref |= 1;
37364         }
37365         return ret_ref;
37366 }
37367
37368 static inline uintptr_t NodeFeatures_clone_ptr(LDKNodeFeatures *NONNULL_PTR arg) {
37369         LDKNodeFeatures ret_var = NodeFeatures_clone(arg);
37370 uint32_t ret_ref = 0;
37371 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37372 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37373 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37374 ret_ref = (uintptr_t)ret_var.inner;
37375 if (ret_var.is_owned) {
37376         ret_ref |= 1;
37377 }
37378         return ret_ref;
37379 }
37380 uint32_t  __attribute__((export_name("TS_NodeFeatures_clone_ptr"))) TS_NodeFeatures_clone_ptr(uint32_t arg) {
37381         LDKNodeFeatures arg_conv;
37382         arg_conv.inner = (void*)(arg & (~1));
37383         arg_conv.is_owned = false;
37384         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37385         uint32_t ret_conv = NodeFeatures_clone_ptr(&arg_conv);
37386         return ret_conv;
37387 }
37388
37389 uint32_t  __attribute__((export_name("TS_NodeFeatures_clone"))) TS_NodeFeatures_clone(uint32_t orig) {
37390         LDKNodeFeatures orig_conv;
37391         orig_conv.inner = (void*)(orig & (~1));
37392         orig_conv.is_owned = false;
37393         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37394         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
37395         uint32_t ret_ref = 0;
37396         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37397         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37398         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37399         ret_ref = (uintptr_t)ret_var.inner;
37400         if (ret_var.is_owned) {
37401                 ret_ref |= 1;
37402         }
37403         return ret_ref;
37404 }
37405
37406 static inline uintptr_t ChannelFeatures_clone_ptr(LDKChannelFeatures *NONNULL_PTR arg) {
37407         LDKChannelFeatures ret_var = ChannelFeatures_clone(arg);
37408 uint32_t ret_ref = 0;
37409 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37410 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37411 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37412 ret_ref = (uintptr_t)ret_var.inner;
37413 if (ret_var.is_owned) {
37414         ret_ref |= 1;
37415 }
37416         return ret_ref;
37417 }
37418 uint32_t  __attribute__((export_name("TS_ChannelFeatures_clone_ptr"))) TS_ChannelFeatures_clone_ptr(uint32_t arg) {
37419         LDKChannelFeatures arg_conv;
37420         arg_conv.inner = (void*)(arg & (~1));
37421         arg_conv.is_owned = false;
37422         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37423         uint32_t ret_conv = ChannelFeatures_clone_ptr(&arg_conv);
37424         return ret_conv;
37425 }
37426
37427 uint32_t  __attribute__((export_name("TS_ChannelFeatures_clone"))) TS_ChannelFeatures_clone(uint32_t orig) {
37428         LDKChannelFeatures orig_conv;
37429         orig_conv.inner = (void*)(orig & (~1));
37430         orig_conv.is_owned = false;
37431         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37432         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
37433         uint32_t ret_ref = 0;
37434         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37435         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37436         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37437         ret_ref = (uintptr_t)ret_var.inner;
37438         if (ret_var.is_owned) {
37439                 ret_ref |= 1;
37440         }
37441         return ret_ref;
37442 }
37443
37444 static inline uintptr_t InvoiceFeatures_clone_ptr(LDKInvoiceFeatures *NONNULL_PTR arg) {
37445         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(arg);
37446 uint32_t ret_ref = 0;
37447 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37448 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37449 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37450 ret_ref = (uintptr_t)ret_var.inner;
37451 if (ret_var.is_owned) {
37452         ret_ref |= 1;
37453 }
37454         return ret_ref;
37455 }
37456 uint32_t  __attribute__((export_name("TS_InvoiceFeatures_clone_ptr"))) TS_InvoiceFeatures_clone_ptr(uint32_t arg) {
37457         LDKInvoiceFeatures arg_conv;
37458         arg_conv.inner = (void*)(arg & (~1));
37459         arg_conv.is_owned = false;
37460         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37461         uint32_t ret_conv = InvoiceFeatures_clone_ptr(&arg_conv);
37462         return ret_conv;
37463 }
37464
37465 uint32_t  __attribute__((export_name("TS_InvoiceFeatures_clone"))) TS_InvoiceFeatures_clone(uint32_t orig) {
37466         LDKInvoiceFeatures orig_conv;
37467         orig_conv.inner = (void*)(orig & (~1));
37468         orig_conv.is_owned = false;
37469         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37470         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
37471         uint32_t ret_ref = 0;
37472         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37473         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37474         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37475         ret_ref = (uintptr_t)ret_var.inner;
37476         if (ret_var.is_owned) {
37477                 ret_ref |= 1;
37478         }
37479         return ret_ref;
37480 }
37481
37482 static inline uintptr_t ChannelTypeFeatures_clone_ptr(LDKChannelTypeFeatures *NONNULL_PTR arg) {
37483         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(arg);
37484 uint32_t ret_ref = 0;
37485 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37486 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37487 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37488 ret_ref = (uintptr_t)ret_var.inner;
37489 if (ret_var.is_owned) {
37490         ret_ref |= 1;
37491 }
37492         return ret_ref;
37493 }
37494 uint32_t  __attribute__((export_name("TS_ChannelTypeFeatures_clone_ptr"))) TS_ChannelTypeFeatures_clone_ptr(uint32_t arg) {
37495         LDKChannelTypeFeatures arg_conv;
37496         arg_conv.inner = (void*)(arg & (~1));
37497         arg_conv.is_owned = false;
37498         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37499         uint32_t ret_conv = ChannelTypeFeatures_clone_ptr(&arg_conv);
37500         return ret_conv;
37501 }
37502
37503 uint32_t  __attribute__((export_name("TS_ChannelTypeFeatures_clone"))) TS_ChannelTypeFeatures_clone(uint32_t orig) {
37504         LDKChannelTypeFeatures orig_conv;
37505         orig_conv.inner = (void*)(orig & (~1));
37506         orig_conv.is_owned = false;
37507         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37508         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(&orig_conv);
37509         uint32_t ret_ref = 0;
37510         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37511         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37512         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37513         ret_ref = (uintptr_t)ret_var.inner;
37514         if (ret_var.is_owned) {
37515                 ret_ref |= 1;
37516         }
37517         return ret_ref;
37518 }
37519
37520 void  __attribute__((export_name("TS_InitFeatures_free"))) TS_InitFeatures_free(uint32_t this_obj) {
37521         LDKInitFeatures this_obj_conv;
37522         this_obj_conv.inner = (void*)(this_obj & (~1));
37523         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37524         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37525         InitFeatures_free(this_obj_conv);
37526 }
37527
37528 void  __attribute__((export_name("TS_NodeFeatures_free"))) TS_NodeFeatures_free(uint32_t this_obj) {
37529         LDKNodeFeatures this_obj_conv;
37530         this_obj_conv.inner = (void*)(this_obj & (~1));
37531         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37532         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37533         NodeFeatures_free(this_obj_conv);
37534 }
37535
37536 void  __attribute__((export_name("TS_ChannelFeatures_free"))) TS_ChannelFeatures_free(uint32_t this_obj) {
37537         LDKChannelFeatures this_obj_conv;
37538         this_obj_conv.inner = (void*)(this_obj & (~1));
37539         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37540         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37541         ChannelFeatures_free(this_obj_conv);
37542 }
37543
37544 void  __attribute__((export_name("TS_InvoiceFeatures_free"))) TS_InvoiceFeatures_free(uint32_t this_obj) {
37545         LDKInvoiceFeatures this_obj_conv;
37546         this_obj_conv.inner = (void*)(this_obj & (~1));
37547         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37548         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37549         InvoiceFeatures_free(this_obj_conv);
37550 }
37551
37552 void  __attribute__((export_name("TS_ChannelTypeFeatures_free"))) TS_ChannelTypeFeatures_free(uint32_t this_obj) {
37553         LDKChannelTypeFeatures this_obj_conv;
37554         this_obj_conv.inner = (void*)(this_obj & (~1));
37555         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37556         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37557         ChannelTypeFeatures_free(this_obj_conv);
37558 }
37559
37560 uint32_t  __attribute__((export_name("TS_InitFeatures_empty"))) TS_InitFeatures_empty() {
37561         LDKInitFeatures ret_var = InitFeatures_empty();
37562         uint32_t ret_ref = 0;
37563         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37564         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37565         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37566         ret_ref = (uintptr_t)ret_var.inner;
37567         if (ret_var.is_owned) {
37568                 ret_ref |= 1;
37569         }
37570         return ret_ref;
37571 }
37572
37573 uint32_t  __attribute__((export_name("TS_InitFeatures_known"))) TS_InitFeatures_known() {
37574         LDKInitFeatures ret_var = InitFeatures_known();
37575         uint32_t ret_ref = 0;
37576         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37577         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37578         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37579         ret_ref = (uintptr_t)ret_var.inner;
37580         if (ret_var.is_owned) {
37581                 ret_ref |= 1;
37582         }
37583         return ret_ref;
37584 }
37585
37586 jboolean  __attribute__((export_name("TS_InitFeatures_requires_unknown_bits"))) TS_InitFeatures_requires_unknown_bits(uint32_t this_arg) {
37587         LDKInitFeatures this_arg_conv;
37588         this_arg_conv.inner = (void*)(this_arg & (~1));
37589         this_arg_conv.is_owned = false;
37590         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37591         jboolean ret_conv = InitFeatures_requires_unknown_bits(&this_arg_conv);
37592         return ret_conv;
37593 }
37594
37595 uint32_t  __attribute__((export_name("TS_NodeFeatures_empty"))) TS_NodeFeatures_empty() {
37596         LDKNodeFeatures ret_var = NodeFeatures_empty();
37597         uint32_t ret_ref = 0;
37598         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37599         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37600         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37601         ret_ref = (uintptr_t)ret_var.inner;
37602         if (ret_var.is_owned) {
37603                 ret_ref |= 1;
37604         }
37605         return ret_ref;
37606 }
37607
37608 uint32_t  __attribute__((export_name("TS_NodeFeatures_known"))) TS_NodeFeatures_known() {
37609         LDKNodeFeatures ret_var = NodeFeatures_known();
37610         uint32_t ret_ref = 0;
37611         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37612         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37613         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37614         ret_ref = (uintptr_t)ret_var.inner;
37615         if (ret_var.is_owned) {
37616                 ret_ref |= 1;
37617         }
37618         return ret_ref;
37619 }
37620
37621 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_unknown_bits"))) TS_NodeFeatures_requires_unknown_bits(uint32_t this_arg) {
37622         LDKNodeFeatures this_arg_conv;
37623         this_arg_conv.inner = (void*)(this_arg & (~1));
37624         this_arg_conv.is_owned = false;
37625         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37626         jboolean ret_conv = NodeFeatures_requires_unknown_bits(&this_arg_conv);
37627         return ret_conv;
37628 }
37629
37630 uint32_t  __attribute__((export_name("TS_ChannelFeatures_empty"))) TS_ChannelFeatures_empty() {
37631         LDKChannelFeatures ret_var = ChannelFeatures_empty();
37632         uint32_t ret_ref = 0;
37633         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37634         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37635         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37636         ret_ref = (uintptr_t)ret_var.inner;
37637         if (ret_var.is_owned) {
37638                 ret_ref |= 1;
37639         }
37640         return ret_ref;
37641 }
37642
37643 uint32_t  __attribute__((export_name("TS_ChannelFeatures_known"))) TS_ChannelFeatures_known() {
37644         LDKChannelFeatures ret_var = ChannelFeatures_known();
37645         uint32_t ret_ref = 0;
37646         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37647         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37648         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37649         ret_ref = (uintptr_t)ret_var.inner;
37650         if (ret_var.is_owned) {
37651                 ret_ref |= 1;
37652         }
37653         return ret_ref;
37654 }
37655
37656 jboolean  __attribute__((export_name("TS_ChannelFeatures_requires_unknown_bits"))) TS_ChannelFeatures_requires_unknown_bits(uint32_t this_arg) {
37657         LDKChannelFeatures this_arg_conv;
37658         this_arg_conv.inner = (void*)(this_arg & (~1));
37659         this_arg_conv.is_owned = false;
37660         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37661         jboolean ret_conv = ChannelFeatures_requires_unknown_bits(&this_arg_conv);
37662         return ret_conv;
37663 }
37664
37665 uint32_t  __attribute__((export_name("TS_InvoiceFeatures_empty"))) TS_InvoiceFeatures_empty() {
37666         LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
37667         uint32_t ret_ref = 0;
37668         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37669         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37670         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37671         ret_ref = (uintptr_t)ret_var.inner;
37672         if (ret_var.is_owned) {
37673                 ret_ref |= 1;
37674         }
37675         return ret_ref;
37676 }
37677
37678 uint32_t  __attribute__((export_name("TS_InvoiceFeatures_known"))) TS_InvoiceFeatures_known() {
37679         LDKInvoiceFeatures ret_var = InvoiceFeatures_known();
37680         uint32_t ret_ref = 0;
37681         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37682         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37683         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37684         ret_ref = (uintptr_t)ret_var.inner;
37685         if (ret_var.is_owned) {
37686                 ret_ref |= 1;
37687         }
37688         return ret_ref;
37689 }
37690
37691 jboolean  __attribute__((export_name("TS_InvoiceFeatures_requires_unknown_bits"))) TS_InvoiceFeatures_requires_unknown_bits(uint32_t this_arg) {
37692         LDKInvoiceFeatures this_arg_conv;
37693         this_arg_conv.inner = (void*)(this_arg & (~1));
37694         this_arg_conv.is_owned = false;
37695         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37696         jboolean ret_conv = InvoiceFeatures_requires_unknown_bits(&this_arg_conv);
37697         return ret_conv;
37698 }
37699
37700 uint32_t  __attribute__((export_name("TS_ChannelTypeFeatures_empty"))) TS_ChannelTypeFeatures_empty() {
37701         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_empty();
37702         uint32_t ret_ref = 0;
37703         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37704         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37705         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37706         ret_ref = (uintptr_t)ret_var.inner;
37707         if (ret_var.is_owned) {
37708                 ret_ref |= 1;
37709         }
37710         return ret_ref;
37711 }
37712
37713 uint32_t  __attribute__((export_name("TS_ChannelTypeFeatures_known"))) TS_ChannelTypeFeatures_known() {
37714         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_known();
37715         uint32_t ret_ref = 0;
37716         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37717         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37718         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37719         ret_ref = (uintptr_t)ret_var.inner;
37720         if (ret_var.is_owned) {
37721                 ret_ref |= 1;
37722         }
37723         return ret_ref;
37724 }
37725
37726 jboolean  __attribute__((export_name("TS_ChannelTypeFeatures_requires_unknown_bits"))) TS_ChannelTypeFeatures_requires_unknown_bits(uint32_t this_arg) {
37727         LDKChannelTypeFeatures this_arg_conv;
37728         this_arg_conv.inner = (void*)(this_arg & (~1));
37729         this_arg_conv.is_owned = false;
37730         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37731         jboolean ret_conv = ChannelTypeFeatures_requires_unknown_bits(&this_arg_conv);
37732         return ret_conv;
37733 }
37734
37735 int8_tArray  __attribute__((export_name("TS_InitFeatures_write"))) TS_InitFeatures_write(uint32_t obj) {
37736         LDKInitFeatures obj_conv;
37737         obj_conv.inner = (void*)(obj & (~1));
37738         obj_conv.is_owned = false;
37739         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37740         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
37741         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
37742         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
37743         CVec_u8Z_free(ret_var);
37744         return ret_arr;
37745 }
37746
37747 uint32_t  __attribute__((export_name("TS_InitFeatures_read"))) TS_InitFeatures_read(int8_tArray ser) {
37748         LDKu8slice ser_ref;
37749         ser_ref.datalen = ser->arr_len;
37750         ser_ref.data = ser->elems;
37751         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
37752         *ret_conv = InitFeatures_read(ser_ref);
37753         FREE(ser);
37754         return (uint32_t)ret_conv;
37755 }
37756
37757 int8_tArray  __attribute__((export_name("TS_ChannelFeatures_write"))) TS_ChannelFeatures_write(uint32_t obj) {
37758         LDKChannelFeatures obj_conv;
37759         obj_conv.inner = (void*)(obj & (~1));
37760         obj_conv.is_owned = false;
37761         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37762         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
37763         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
37764         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
37765         CVec_u8Z_free(ret_var);
37766         return ret_arr;
37767 }
37768
37769 uint32_t  __attribute__((export_name("TS_ChannelFeatures_read"))) TS_ChannelFeatures_read(int8_tArray ser) {
37770         LDKu8slice ser_ref;
37771         ser_ref.datalen = ser->arr_len;
37772         ser_ref.data = ser->elems;
37773         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
37774         *ret_conv = ChannelFeatures_read(ser_ref);
37775         FREE(ser);
37776         return (uint32_t)ret_conv;
37777 }
37778
37779 int8_tArray  __attribute__((export_name("TS_NodeFeatures_write"))) TS_NodeFeatures_write(uint32_t obj) {
37780         LDKNodeFeatures obj_conv;
37781         obj_conv.inner = (void*)(obj & (~1));
37782         obj_conv.is_owned = false;
37783         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37784         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
37785         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
37786         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
37787         CVec_u8Z_free(ret_var);
37788         return ret_arr;
37789 }
37790
37791 uint32_t  __attribute__((export_name("TS_NodeFeatures_read"))) TS_NodeFeatures_read(int8_tArray ser) {
37792         LDKu8slice ser_ref;
37793         ser_ref.datalen = ser->arr_len;
37794         ser_ref.data = ser->elems;
37795         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
37796         *ret_conv = NodeFeatures_read(ser_ref);
37797         FREE(ser);
37798         return (uint32_t)ret_conv;
37799 }
37800
37801 int8_tArray  __attribute__((export_name("TS_InvoiceFeatures_write"))) TS_InvoiceFeatures_write(uint32_t obj) {
37802         LDKInvoiceFeatures obj_conv;
37803         obj_conv.inner = (void*)(obj & (~1));
37804         obj_conv.is_owned = false;
37805         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37806         LDKCVec_u8Z ret_var = InvoiceFeatures_write(&obj_conv);
37807         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
37808         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
37809         CVec_u8Z_free(ret_var);
37810         return ret_arr;
37811 }
37812
37813 uint32_t  __attribute__((export_name("TS_InvoiceFeatures_read"))) TS_InvoiceFeatures_read(int8_tArray ser) {
37814         LDKu8slice ser_ref;
37815         ser_ref.datalen = ser->arr_len;
37816         ser_ref.data = ser->elems;
37817         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
37818         *ret_conv = InvoiceFeatures_read(ser_ref);
37819         FREE(ser);
37820         return (uint32_t)ret_conv;
37821 }
37822
37823 int8_tArray  __attribute__((export_name("TS_ChannelTypeFeatures_write"))) TS_ChannelTypeFeatures_write(uint32_t obj) {
37824         LDKChannelTypeFeatures obj_conv;
37825         obj_conv.inner = (void*)(obj & (~1));
37826         obj_conv.is_owned = false;
37827         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37828         LDKCVec_u8Z ret_var = ChannelTypeFeatures_write(&obj_conv);
37829         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
37830         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
37831         CVec_u8Z_free(ret_var);
37832         return ret_arr;
37833 }
37834
37835 uint32_t  __attribute__((export_name("TS_ChannelTypeFeatures_read"))) TS_ChannelTypeFeatures_read(int8_tArray ser) {
37836         LDKu8slice ser_ref;
37837         ser_ref.datalen = ser->arr_len;
37838         ser_ref.data = ser->elems;
37839         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
37840         *ret_conv = ChannelTypeFeatures_read(ser_ref);
37841         FREE(ser);
37842         return (uint32_t)ret_conv;
37843 }
37844
37845 void  __attribute__((export_name("TS_InitFeatures_set_data_loss_protect_optional"))) TS_InitFeatures_set_data_loss_protect_optional(uint32_t this_arg) {
37846         LDKInitFeatures this_arg_conv;
37847         this_arg_conv.inner = (void*)(this_arg & (~1));
37848         this_arg_conv.is_owned = false;
37849         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37850         InitFeatures_set_data_loss_protect_optional(&this_arg_conv);
37851 }
37852
37853 void  __attribute__((export_name("TS_InitFeatures_set_data_loss_protect_required"))) TS_InitFeatures_set_data_loss_protect_required(uint32_t this_arg) {
37854         LDKInitFeatures this_arg_conv;
37855         this_arg_conv.inner = (void*)(this_arg & (~1));
37856         this_arg_conv.is_owned = false;
37857         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37858         InitFeatures_set_data_loss_protect_required(&this_arg_conv);
37859 }
37860
37861 jboolean  __attribute__((export_name("TS_InitFeatures_supports_data_loss_protect"))) TS_InitFeatures_supports_data_loss_protect(uint32_t this_arg) {
37862         LDKInitFeatures this_arg_conv;
37863         this_arg_conv.inner = (void*)(this_arg & (~1));
37864         this_arg_conv.is_owned = false;
37865         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37866         jboolean ret_conv = InitFeatures_supports_data_loss_protect(&this_arg_conv);
37867         return ret_conv;
37868 }
37869
37870 void  __attribute__((export_name("TS_NodeFeatures_set_data_loss_protect_optional"))) TS_NodeFeatures_set_data_loss_protect_optional(uint32_t this_arg) {
37871         LDKNodeFeatures this_arg_conv;
37872         this_arg_conv.inner = (void*)(this_arg & (~1));
37873         this_arg_conv.is_owned = false;
37874         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37875         NodeFeatures_set_data_loss_protect_optional(&this_arg_conv);
37876 }
37877
37878 void  __attribute__((export_name("TS_NodeFeatures_set_data_loss_protect_required"))) TS_NodeFeatures_set_data_loss_protect_required(uint32_t this_arg) {
37879         LDKNodeFeatures this_arg_conv;
37880         this_arg_conv.inner = (void*)(this_arg & (~1));
37881         this_arg_conv.is_owned = false;
37882         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37883         NodeFeatures_set_data_loss_protect_required(&this_arg_conv);
37884 }
37885
37886 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_data_loss_protect"))) TS_NodeFeatures_supports_data_loss_protect(uint32_t this_arg) {
37887         LDKNodeFeatures this_arg_conv;
37888         this_arg_conv.inner = (void*)(this_arg & (~1));
37889         this_arg_conv.is_owned = false;
37890         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37891         jboolean ret_conv = NodeFeatures_supports_data_loss_protect(&this_arg_conv);
37892         return ret_conv;
37893 }
37894
37895 jboolean  __attribute__((export_name("TS_InitFeatures_requires_data_loss_protect"))) TS_InitFeatures_requires_data_loss_protect(uint32_t this_arg) {
37896         LDKInitFeatures this_arg_conv;
37897         this_arg_conv.inner = (void*)(this_arg & (~1));
37898         this_arg_conv.is_owned = false;
37899         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37900         jboolean ret_conv = InitFeatures_requires_data_loss_protect(&this_arg_conv);
37901         return ret_conv;
37902 }
37903
37904 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_data_loss_protect"))) TS_NodeFeatures_requires_data_loss_protect(uint32_t this_arg) {
37905         LDKNodeFeatures this_arg_conv;
37906         this_arg_conv.inner = (void*)(this_arg & (~1));
37907         this_arg_conv.is_owned = false;
37908         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37909         jboolean ret_conv = NodeFeatures_requires_data_loss_protect(&this_arg_conv);
37910         return ret_conv;
37911 }
37912
37913 void  __attribute__((export_name("TS_InitFeatures_set_initial_routing_sync_optional"))) TS_InitFeatures_set_initial_routing_sync_optional(uint32_t this_arg) {
37914         LDKInitFeatures this_arg_conv;
37915         this_arg_conv.inner = (void*)(this_arg & (~1));
37916         this_arg_conv.is_owned = false;
37917         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37918         InitFeatures_set_initial_routing_sync_optional(&this_arg_conv);
37919 }
37920
37921 void  __attribute__((export_name("TS_InitFeatures_set_initial_routing_sync_required"))) TS_InitFeatures_set_initial_routing_sync_required(uint32_t this_arg) {
37922         LDKInitFeatures this_arg_conv;
37923         this_arg_conv.inner = (void*)(this_arg & (~1));
37924         this_arg_conv.is_owned = false;
37925         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37926         InitFeatures_set_initial_routing_sync_required(&this_arg_conv);
37927 }
37928
37929 jboolean  __attribute__((export_name("TS_InitFeatures_initial_routing_sync"))) TS_InitFeatures_initial_routing_sync(uint32_t this_arg) {
37930         LDKInitFeatures this_arg_conv;
37931         this_arg_conv.inner = (void*)(this_arg & (~1));
37932         this_arg_conv.is_owned = false;
37933         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37934         jboolean ret_conv = InitFeatures_initial_routing_sync(&this_arg_conv);
37935         return ret_conv;
37936 }
37937
37938 void  __attribute__((export_name("TS_InitFeatures_set_upfront_shutdown_script_optional"))) TS_InitFeatures_set_upfront_shutdown_script_optional(uint32_t this_arg) {
37939         LDKInitFeatures this_arg_conv;
37940         this_arg_conv.inner = (void*)(this_arg & (~1));
37941         this_arg_conv.is_owned = false;
37942         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37943         InitFeatures_set_upfront_shutdown_script_optional(&this_arg_conv);
37944 }
37945
37946 void  __attribute__((export_name("TS_InitFeatures_set_upfront_shutdown_script_required"))) TS_InitFeatures_set_upfront_shutdown_script_required(uint32_t this_arg) {
37947         LDKInitFeatures this_arg_conv;
37948         this_arg_conv.inner = (void*)(this_arg & (~1));
37949         this_arg_conv.is_owned = false;
37950         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37951         InitFeatures_set_upfront_shutdown_script_required(&this_arg_conv);
37952 }
37953
37954 jboolean  __attribute__((export_name("TS_InitFeatures_supports_upfront_shutdown_script"))) TS_InitFeatures_supports_upfront_shutdown_script(uint32_t this_arg) {
37955         LDKInitFeatures this_arg_conv;
37956         this_arg_conv.inner = (void*)(this_arg & (~1));
37957         this_arg_conv.is_owned = false;
37958         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37959         jboolean ret_conv = InitFeatures_supports_upfront_shutdown_script(&this_arg_conv);
37960         return ret_conv;
37961 }
37962
37963 void  __attribute__((export_name("TS_NodeFeatures_set_upfront_shutdown_script_optional"))) TS_NodeFeatures_set_upfront_shutdown_script_optional(uint32_t this_arg) {
37964         LDKNodeFeatures this_arg_conv;
37965         this_arg_conv.inner = (void*)(this_arg & (~1));
37966         this_arg_conv.is_owned = false;
37967         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37968         NodeFeatures_set_upfront_shutdown_script_optional(&this_arg_conv);
37969 }
37970
37971 void  __attribute__((export_name("TS_NodeFeatures_set_upfront_shutdown_script_required"))) TS_NodeFeatures_set_upfront_shutdown_script_required(uint32_t this_arg) {
37972         LDKNodeFeatures this_arg_conv;
37973         this_arg_conv.inner = (void*)(this_arg & (~1));
37974         this_arg_conv.is_owned = false;
37975         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37976         NodeFeatures_set_upfront_shutdown_script_required(&this_arg_conv);
37977 }
37978
37979 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_upfront_shutdown_script"))) TS_NodeFeatures_supports_upfront_shutdown_script(uint32_t this_arg) {
37980         LDKNodeFeatures this_arg_conv;
37981         this_arg_conv.inner = (void*)(this_arg & (~1));
37982         this_arg_conv.is_owned = false;
37983         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37984         jboolean ret_conv = NodeFeatures_supports_upfront_shutdown_script(&this_arg_conv);
37985         return ret_conv;
37986 }
37987
37988 jboolean  __attribute__((export_name("TS_InitFeatures_requires_upfront_shutdown_script"))) TS_InitFeatures_requires_upfront_shutdown_script(uint32_t this_arg) {
37989         LDKInitFeatures this_arg_conv;
37990         this_arg_conv.inner = (void*)(this_arg & (~1));
37991         this_arg_conv.is_owned = false;
37992         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37993         jboolean ret_conv = InitFeatures_requires_upfront_shutdown_script(&this_arg_conv);
37994         return ret_conv;
37995 }
37996
37997 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_upfront_shutdown_script"))) TS_NodeFeatures_requires_upfront_shutdown_script(uint32_t this_arg) {
37998         LDKNodeFeatures this_arg_conv;
37999         this_arg_conv.inner = (void*)(this_arg & (~1));
38000         this_arg_conv.is_owned = false;
38001         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38002         jboolean ret_conv = NodeFeatures_requires_upfront_shutdown_script(&this_arg_conv);
38003         return ret_conv;
38004 }
38005
38006 void  __attribute__((export_name("TS_InitFeatures_set_gossip_queries_optional"))) TS_InitFeatures_set_gossip_queries_optional(uint32_t this_arg) {
38007         LDKInitFeatures this_arg_conv;
38008         this_arg_conv.inner = (void*)(this_arg & (~1));
38009         this_arg_conv.is_owned = false;
38010         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38011         InitFeatures_set_gossip_queries_optional(&this_arg_conv);
38012 }
38013
38014 void  __attribute__((export_name("TS_InitFeatures_set_gossip_queries_required"))) TS_InitFeatures_set_gossip_queries_required(uint32_t this_arg) {
38015         LDKInitFeatures this_arg_conv;
38016         this_arg_conv.inner = (void*)(this_arg & (~1));
38017         this_arg_conv.is_owned = false;
38018         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38019         InitFeatures_set_gossip_queries_required(&this_arg_conv);
38020 }
38021
38022 jboolean  __attribute__((export_name("TS_InitFeatures_supports_gossip_queries"))) TS_InitFeatures_supports_gossip_queries(uint32_t this_arg) {
38023         LDKInitFeatures this_arg_conv;
38024         this_arg_conv.inner = (void*)(this_arg & (~1));
38025         this_arg_conv.is_owned = false;
38026         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38027         jboolean ret_conv = InitFeatures_supports_gossip_queries(&this_arg_conv);
38028         return ret_conv;
38029 }
38030
38031 void  __attribute__((export_name("TS_NodeFeatures_set_gossip_queries_optional"))) TS_NodeFeatures_set_gossip_queries_optional(uint32_t this_arg) {
38032         LDKNodeFeatures this_arg_conv;
38033         this_arg_conv.inner = (void*)(this_arg & (~1));
38034         this_arg_conv.is_owned = false;
38035         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38036         NodeFeatures_set_gossip_queries_optional(&this_arg_conv);
38037 }
38038
38039 void  __attribute__((export_name("TS_NodeFeatures_set_gossip_queries_required"))) TS_NodeFeatures_set_gossip_queries_required(uint32_t this_arg) {
38040         LDKNodeFeatures this_arg_conv;
38041         this_arg_conv.inner = (void*)(this_arg & (~1));
38042         this_arg_conv.is_owned = false;
38043         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38044         NodeFeatures_set_gossip_queries_required(&this_arg_conv);
38045 }
38046
38047 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_gossip_queries"))) TS_NodeFeatures_supports_gossip_queries(uint32_t this_arg) {
38048         LDKNodeFeatures this_arg_conv;
38049         this_arg_conv.inner = (void*)(this_arg & (~1));
38050         this_arg_conv.is_owned = false;
38051         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38052         jboolean ret_conv = NodeFeatures_supports_gossip_queries(&this_arg_conv);
38053         return ret_conv;
38054 }
38055
38056 jboolean  __attribute__((export_name("TS_InitFeatures_requires_gossip_queries"))) TS_InitFeatures_requires_gossip_queries(uint32_t this_arg) {
38057         LDKInitFeatures this_arg_conv;
38058         this_arg_conv.inner = (void*)(this_arg & (~1));
38059         this_arg_conv.is_owned = false;
38060         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38061         jboolean ret_conv = InitFeatures_requires_gossip_queries(&this_arg_conv);
38062         return ret_conv;
38063 }
38064
38065 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_gossip_queries"))) TS_NodeFeatures_requires_gossip_queries(uint32_t this_arg) {
38066         LDKNodeFeatures this_arg_conv;
38067         this_arg_conv.inner = (void*)(this_arg & (~1));
38068         this_arg_conv.is_owned = false;
38069         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38070         jboolean ret_conv = NodeFeatures_requires_gossip_queries(&this_arg_conv);
38071         return ret_conv;
38072 }
38073
38074 void  __attribute__((export_name("TS_InitFeatures_set_variable_length_onion_optional"))) TS_InitFeatures_set_variable_length_onion_optional(uint32_t this_arg) {
38075         LDKInitFeatures this_arg_conv;
38076         this_arg_conv.inner = (void*)(this_arg & (~1));
38077         this_arg_conv.is_owned = false;
38078         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38079         InitFeatures_set_variable_length_onion_optional(&this_arg_conv);
38080 }
38081
38082 void  __attribute__((export_name("TS_InitFeatures_set_variable_length_onion_required"))) TS_InitFeatures_set_variable_length_onion_required(uint32_t this_arg) {
38083         LDKInitFeatures this_arg_conv;
38084         this_arg_conv.inner = (void*)(this_arg & (~1));
38085         this_arg_conv.is_owned = false;
38086         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38087         InitFeatures_set_variable_length_onion_required(&this_arg_conv);
38088 }
38089
38090 jboolean  __attribute__((export_name("TS_InitFeatures_supports_variable_length_onion"))) TS_InitFeatures_supports_variable_length_onion(uint32_t this_arg) {
38091         LDKInitFeatures this_arg_conv;
38092         this_arg_conv.inner = (void*)(this_arg & (~1));
38093         this_arg_conv.is_owned = false;
38094         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38095         jboolean ret_conv = InitFeatures_supports_variable_length_onion(&this_arg_conv);
38096         return ret_conv;
38097 }
38098
38099 void  __attribute__((export_name("TS_NodeFeatures_set_variable_length_onion_optional"))) TS_NodeFeatures_set_variable_length_onion_optional(uint32_t this_arg) {
38100         LDKNodeFeatures this_arg_conv;
38101         this_arg_conv.inner = (void*)(this_arg & (~1));
38102         this_arg_conv.is_owned = false;
38103         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38104         NodeFeatures_set_variable_length_onion_optional(&this_arg_conv);
38105 }
38106
38107 void  __attribute__((export_name("TS_NodeFeatures_set_variable_length_onion_required"))) TS_NodeFeatures_set_variable_length_onion_required(uint32_t this_arg) {
38108         LDKNodeFeatures this_arg_conv;
38109         this_arg_conv.inner = (void*)(this_arg & (~1));
38110         this_arg_conv.is_owned = false;
38111         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38112         NodeFeatures_set_variable_length_onion_required(&this_arg_conv);
38113 }
38114
38115 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_variable_length_onion"))) TS_NodeFeatures_supports_variable_length_onion(uint32_t this_arg) {
38116         LDKNodeFeatures this_arg_conv;
38117         this_arg_conv.inner = (void*)(this_arg & (~1));
38118         this_arg_conv.is_owned = false;
38119         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38120         jboolean ret_conv = NodeFeatures_supports_variable_length_onion(&this_arg_conv);
38121         return ret_conv;
38122 }
38123
38124 void  __attribute__((export_name("TS_InvoiceFeatures_set_variable_length_onion_optional"))) TS_InvoiceFeatures_set_variable_length_onion_optional(uint32_t this_arg) {
38125         LDKInvoiceFeatures this_arg_conv;
38126         this_arg_conv.inner = (void*)(this_arg & (~1));
38127         this_arg_conv.is_owned = false;
38128         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38129         InvoiceFeatures_set_variable_length_onion_optional(&this_arg_conv);
38130 }
38131
38132 void  __attribute__((export_name("TS_InvoiceFeatures_set_variable_length_onion_required"))) TS_InvoiceFeatures_set_variable_length_onion_required(uint32_t this_arg) {
38133         LDKInvoiceFeatures this_arg_conv;
38134         this_arg_conv.inner = (void*)(this_arg & (~1));
38135         this_arg_conv.is_owned = false;
38136         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38137         InvoiceFeatures_set_variable_length_onion_required(&this_arg_conv);
38138 }
38139
38140 jboolean  __attribute__((export_name("TS_InvoiceFeatures_supports_variable_length_onion"))) TS_InvoiceFeatures_supports_variable_length_onion(uint32_t this_arg) {
38141         LDKInvoiceFeatures this_arg_conv;
38142         this_arg_conv.inner = (void*)(this_arg & (~1));
38143         this_arg_conv.is_owned = false;
38144         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38145         jboolean ret_conv = InvoiceFeatures_supports_variable_length_onion(&this_arg_conv);
38146         return ret_conv;
38147 }
38148
38149 jboolean  __attribute__((export_name("TS_InitFeatures_requires_variable_length_onion"))) TS_InitFeatures_requires_variable_length_onion(uint32_t this_arg) {
38150         LDKInitFeatures this_arg_conv;
38151         this_arg_conv.inner = (void*)(this_arg & (~1));
38152         this_arg_conv.is_owned = false;
38153         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38154         jboolean ret_conv = InitFeatures_requires_variable_length_onion(&this_arg_conv);
38155         return ret_conv;
38156 }
38157
38158 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_variable_length_onion"))) TS_NodeFeatures_requires_variable_length_onion(uint32_t this_arg) {
38159         LDKNodeFeatures this_arg_conv;
38160         this_arg_conv.inner = (void*)(this_arg & (~1));
38161         this_arg_conv.is_owned = false;
38162         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38163         jboolean ret_conv = NodeFeatures_requires_variable_length_onion(&this_arg_conv);
38164         return ret_conv;
38165 }
38166
38167 jboolean  __attribute__((export_name("TS_InvoiceFeatures_requires_variable_length_onion"))) TS_InvoiceFeatures_requires_variable_length_onion(uint32_t this_arg) {
38168         LDKInvoiceFeatures this_arg_conv;
38169         this_arg_conv.inner = (void*)(this_arg & (~1));
38170         this_arg_conv.is_owned = false;
38171         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38172         jboolean ret_conv = InvoiceFeatures_requires_variable_length_onion(&this_arg_conv);
38173         return ret_conv;
38174 }
38175
38176 void  __attribute__((export_name("TS_InitFeatures_set_static_remote_key_optional"))) TS_InitFeatures_set_static_remote_key_optional(uint32_t this_arg) {
38177         LDKInitFeatures this_arg_conv;
38178         this_arg_conv.inner = (void*)(this_arg & (~1));
38179         this_arg_conv.is_owned = false;
38180         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38181         InitFeatures_set_static_remote_key_optional(&this_arg_conv);
38182 }
38183
38184 void  __attribute__((export_name("TS_InitFeatures_set_static_remote_key_required"))) TS_InitFeatures_set_static_remote_key_required(uint32_t this_arg) {
38185         LDKInitFeatures this_arg_conv;
38186         this_arg_conv.inner = (void*)(this_arg & (~1));
38187         this_arg_conv.is_owned = false;
38188         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38189         InitFeatures_set_static_remote_key_required(&this_arg_conv);
38190 }
38191
38192 jboolean  __attribute__((export_name("TS_InitFeatures_supports_static_remote_key"))) TS_InitFeatures_supports_static_remote_key(uint32_t this_arg) {
38193         LDKInitFeatures this_arg_conv;
38194         this_arg_conv.inner = (void*)(this_arg & (~1));
38195         this_arg_conv.is_owned = false;
38196         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38197         jboolean ret_conv = InitFeatures_supports_static_remote_key(&this_arg_conv);
38198         return ret_conv;
38199 }
38200
38201 void  __attribute__((export_name("TS_NodeFeatures_set_static_remote_key_optional"))) TS_NodeFeatures_set_static_remote_key_optional(uint32_t this_arg) {
38202         LDKNodeFeatures this_arg_conv;
38203         this_arg_conv.inner = (void*)(this_arg & (~1));
38204         this_arg_conv.is_owned = false;
38205         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38206         NodeFeatures_set_static_remote_key_optional(&this_arg_conv);
38207 }
38208
38209 void  __attribute__((export_name("TS_NodeFeatures_set_static_remote_key_required"))) TS_NodeFeatures_set_static_remote_key_required(uint32_t this_arg) {
38210         LDKNodeFeatures this_arg_conv;
38211         this_arg_conv.inner = (void*)(this_arg & (~1));
38212         this_arg_conv.is_owned = false;
38213         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38214         NodeFeatures_set_static_remote_key_required(&this_arg_conv);
38215 }
38216
38217 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_static_remote_key"))) TS_NodeFeatures_supports_static_remote_key(uint32_t this_arg) {
38218         LDKNodeFeatures this_arg_conv;
38219         this_arg_conv.inner = (void*)(this_arg & (~1));
38220         this_arg_conv.is_owned = false;
38221         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38222         jboolean ret_conv = NodeFeatures_supports_static_remote_key(&this_arg_conv);
38223         return ret_conv;
38224 }
38225
38226 void  __attribute__((export_name("TS_ChannelTypeFeatures_set_static_remote_key_optional"))) TS_ChannelTypeFeatures_set_static_remote_key_optional(uint32_t this_arg) {
38227         LDKChannelTypeFeatures this_arg_conv;
38228         this_arg_conv.inner = (void*)(this_arg & (~1));
38229         this_arg_conv.is_owned = false;
38230         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38231         ChannelTypeFeatures_set_static_remote_key_optional(&this_arg_conv);
38232 }
38233
38234 void  __attribute__((export_name("TS_ChannelTypeFeatures_set_static_remote_key_required"))) TS_ChannelTypeFeatures_set_static_remote_key_required(uint32_t this_arg) {
38235         LDKChannelTypeFeatures this_arg_conv;
38236         this_arg_conv.inner = (void*)(this_arg & (~1));
38237         this_arg_conv.is_owned = false;
38238         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38239         ChannelTypeFeatures_set_static_remote_key_required(&this_arg_conv);
38240 }
38241
38242 jboolean  __attribute__((export_name("TS_ChannelTypeFeatures_supports_static_remote_key"))) TS_ChannelTypeFeatures_supports_static_remote_key(uint32_t this_arg) {
38243         LDKChannelTypeFeatures this_arg_conv;
38244         this_arg_conv.inner = (void*)(this_arg & (~1));
38245         this_arg_conv.is_owned = false;
38246         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38247         jboolean ret_conv = ChannelTypeFeatures_supports_static_remote_key(&this_arg_conv);
38248         return ret_conv;
38249 }
38250
38251 jboolean  __attribute__((export_name("TS_InitFeatures_requires_static_remote_key"))) TS_InitFeatures_requires_static_remote_key(uint32_t this_arg) {
38252         LDKInitFeatures this_arg_conv;
38253         this_arg_conv.inner = (void*)(this_arg & (~1));
38254         this_arg_conv.is_owned = false;
38255         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38256         jboolean ret_conv = InitFeatures_requires_static_remote_key(&this_arg_conv);
38257         return ret_conv;
38258 }
38259
38260 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_static_remote_key"))) TS_NodeFeatures_requires_static_remote_key(uint32_t this_arg) {
38261         LDKNodeFeatures this_arg_conv;
38262         this_arg_conv.inner = (void*)(this_arg & (~1));
38263         this_arg_conv.is_owned = false;
38264         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38265         jboolean ret_conv = NodeFeatures_requires_static_remote_key(&this_arg_conv);
38266         return ret_conv;
38267 }
38268
38269 jboolean  __attribute__((export_name("TS_ChannelTypeFeatures_requires_static_remote_key"))) TS_ChannelTypeFeatures_requires_static_remote_key(uint32_t this_arg) {
38270         LDKChannelTypeFeatures this_arg_conv;
38271         this_arg_conv.inner = (void*)(this_arg & (~1));
38272         this_arg_conv.is_owned = false;
38273         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38274         jboolean ret_conv = ChannelTypeFeatures_requires_static_remote_key(&this_arg_conv);
38275         return ret_conv;
38276 }
38277
38278 void  __attribute__((export_name("TS_InitFeatures_set_payment_secret_optional"))) TS_InitFeatures_set_payment_secret_optional(uint32_t this_arg) {
38279         LDKInitFeatures this_arg_conv;
38280         this_arg_conv.inner = (void*)(this_arg & (~1));
38281         this_arg_conv.is_owned = false;
38282         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38283         InitFeatures_set_payment_secret_optional(&this_arg_conv);
38284 }
38285
38286 void  __attribute__((export_name("TS_InitFeatures_set_payment_secret_required"))) TS_InitFeatures_set_payment_secret_required(uint32_t this_arg) {
38287         LDKInitFeatures this_arg_conv;
38288         this_arg_conv.inner = (void*)(this_arg & (~1));
38289         this_arg_conv.is_owned = false;
38290         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38291         InitFeatures_set_payment_secret_required(&this_arg_conv);
38292 }
38293
38294 jboolean  __attribute__((export_name("TS_InitFeatures_supports_payment_secret"))) TS_InitFeatures_supports_payment_secret(uint32_t this_arg) {
38295         LDKInitFeatures this_arg_conv;
38296         this_arg_conv.inner = (void*)(this_arg & (~1));
38297         this_arg_conv.is_owned = false;
38298         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38299         jboolean ret_conv = InitFeatures_supports_payment_secret(&this_arg_conv);
38300         return ret_conv;
38301 }
38302
38303 void  __attribute__((export_name("TS_NodeFeatures_set_payment_secret_optional"))) TS_NodeFeatures_set_payment_secret_optional(uint32_t this_arg) {
38304         LDKNodeFeatures this_arg_conv;
38305         this_arg_conv.inner = (void*)(this_arg & (~1));
38306         this_arg_conv.is_owned = false;
38307         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38308         NodeFeatures_set_payment_secret_optional(&this_arg_conv);
38309 }
38310
38311 void  __attribute__((export_name("TS_NodeFeatures_set_payment_secret_required"))) TS_NodeFeatures_set_payment_secret_required(uint32_t this_arg) {
38312         LDKNodeFeatures this_arg_conv;
38313         this_arg_conv.inner = (void*)(this_arg & (~1));
38314         this_arg_conv.is_owned = false;
38315         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38316         NodeFeatures_set_payment_secret_required(&this_arg_conv);
38317 }
38318
38319 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_payment_secret"))) TS_NodeFeatures_supports_payment_secret(uint32_t this_arg) {
38320         LDKNodeFeatures this_arg_conv;
38321         this_arg_conv.inner = (void*)(this_arg & (~1));
38322         this_arg_conv.is_owned = false;
38323         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38324         jboolean ret_conv = NodeFeatures_supports_payment_secret(&this_arg_conv);
38325         return ret_conv;
38326 }
38327
38328 void  __attribute__((export_name("TS_InvoiceFeatures_set_payment_secret_optional"))) TS_InvoiceFeatures_set_payment_secret_optional(uint32_t this_arg) {
38329         LDKInvoiceFeatures this_arg_conv;
38330         this_arg_conv.inner = (void*)(this_arg & (~1));
38331         this_arg_conv.is_owned = false;
38332         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38333         InvoiceFeatures_set_payment_secret_optional(&this_arg_conv);
38334 }
38335
38336 void  __attribute__((export_name("TS_InvoiceFeatures_set_payment_secret_required"))) TS_InvoiceFeatures_set_payment_secret_required(uint32_t this_arg) {
38337         LDKInvoiceFeatures this_arg_conv;
38338         this_arg_conv.inner = (void*)(this_arg & (~1));
38339         this_arg_conv.is_owned = false;
38340         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38341         InvoiceFeatures_set_payment_secret_required(&this_arg_conv);
38342 }
38343
38344 jboolean  __attribute__((export_name("TS_InvoiceFeatures_supports_payment_secret"))) TS_InvoiceFeatures_supports_payment_secret(uint32_t this_arg) {
38345         LDKInvoiceFeatures this_arg_conv;
38346         this_arg_conv.inner = (void*)(this_arg & (~1));
38347         this_arg_conv.is_owned = false;
38348         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38349         jboolean ret_conv = InvoiceFeatures_supports_payment_secret(&this_arg_conv);
38350         return ret_conv;
38351 }
38352
38353 jboolean  __attribute__((export_name("TS_InitFeatures_requires_payment_secret"))) TS_InitFeatures_requires_payment_secret(uint32_t this_arg) {
38354         LDKInitFeatures this_arg_conv;
38355         this_arg_conv.inner = (void*)(this_arg & (~1));
38356         this_arg_conv.is_owned = false;
38357         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38358         jboolean ret_conv = InitFeatures_requires_payment_secret(&this_arg_conv);
38359         return ret_conv;
38360 }
38361
38362 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_payment_secret"))) TS_NodeFeatures_requires_payment_secret(uint32_t this_arg) {
38363         LDKNodeFeatures this_arg_conv;
38364         this_arg_conv.inner = (void*)(this_arg & (~1));
38365         this_arg_conv.is_owned = false;
38366         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38367         jboolean ret_conv = NodeFeatures_requires_payment_secret(&this_arg_conv);
38368         return ret_conv;
38369 }
38370
38371 jboolean  __attribute__((export_name("TS_InvoiceFeatures_requires_payment_secret"))) TS_InvoiceFeatures_requires_payment_secret(uint32_t this_arg) {
38372         LDKInvoiceFeatures this_arg_conv;
38373         this_arg_conv.inner = (void*)(this_arg & (~1));
38374         this_arg_conv.is_owned = false;
38375         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38376         jboolean ret_conv = InvoiceFeatures_requires_payment_secret(&this_arg_conv);
38377         return ret_conv;
38378 }
38379
38380 void  __attribute__((export_name("TS_InitFeatures_set_basic_mpp_optional"))) TS_InitFeatures_set_basic_mpp_optional(uint32_t this_arg) {
38381         LDKInitFeatures this_arg_conv;
38382         this_arg_conv.inner = (void*)(this_arg & (~1));
38383         this_arg_conv.is_owned = false;
38384         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38385         InitFeatures_set_basic_mpp_optional(&this_arg_conv);
38386 }
38387
38388 void  __attribute__((export_name("TS_InitFeatures_set_basic_mpp_required"))) TS_InitFeatures_set_basic_mpp_required(uint32_t this_arg) {
38389         LDKInitFeatures this_arg_conv;
38390         this_arg_conv.inner = (void*)(this_arg & (~1));
38391         this_arg_conv.is_owned = false;
38392         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38393         InitFeatures_set_basic_mpp_required(&this_arg_conv);
38394 }
38395
38396 jboolean  __attribute__((export_name("TS_InitFeatures_supports_basic_mpp"))) TS_InitFeatures_supports_basic_mpp(uint32_t this_arg) {
38397         LDKInitFeatures this_arg_conv;
38398         this_arg_conv.inner = (void*)(this_arg & (~1));
38399         this_arg_conv.is_owned = false;
38400         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38401         jboolean ret_conv = InitFeatures_supports_basic_mpp(&this_arg_conv);
38402         return ret_conv;
38403 }
38404
38405 void  __attribute__((export_name("TS_NodeFeatures_set_basic_mpp_optional"))) TS_NodeFeatures_set_basic_mpp_optional(uint32_t this_arg) {
38406         LDKNodeFeatures this_arg_conv;
38407         this_arg_conv.inner = (void*)(this_arg & (~1));
38408         this_arg_conv.is_owned = false;
38409         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38410         NodeFeatures_set_basic_mpp_optional(&this_arg_conv);
38411 }
38412
38413 void  __attribute__((export_name("TS_NodeFeatures_set_basic_mpp_required"))) TS_NodeFeatures_set_basic_mpp_required(uint32_t this_arg) {
38414         LDKNodeFeatures this_arg_conv;
38415         this_arg_conv.inner = (void*)(this_arg & (~1));
38416         this_arg_conv.is_owned = false;
38417         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38418         NodeFeatures_set_basic_mpp_required(&this_arg_conv);
38419 }
38420
38421 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_basic_mpp"))) TS_NodeFeatures_supports_basic_mpp(uint32_t this_arg) {
38422         LDKNodeFeatures this_arg_conv;
38423         this_arg_conv.inner = (void*)(this_arg & (~1));
38424         this_arg_conv.is_owned = false;
38425         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38426         jboolean ret_conv = NodeFeatures_supports_basic_mpp(&this_arg_conv);
38427         return ret_conv;
38428 }
38429
38430 void  __attribute__((export_name("TS_InvoiceFeatures_set_basic_mpp_optional"))) TS_InvoiceFeatures_set_basic_mpp_optional(uint32_t this_arg) {
38431         LDKInvoiceFeatures this_arg_conv;
38432         this_arg_conv.inner = (void*)(this_arg & (~1));
38433         this_arg_conv.is_owned = false;
38434         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38435         InvoiceFeatures_set_basic_mpp_optional(&this_arg_conv);
38436 }
38437
38438 void  __attribute__((export_name("TS_InvoiceFeatures_set_basic_mpp_required"))) TS_InvoiceFeatures_set_basic_mpp_required(uint32_t this_arg) {
38439         LDKInvoiceFeatures this_arg_conv;
38440         this_arg_conv.inner = (void*)(this_arg & (~1));
38441         this_arg_conv.is_owned = false;
38442         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38443         InvoiceFeatures_set_basic_mpp_required(&this_arg_conv);
38444 }
38445
38446 jboolean  __attribute__((export_name("TS_InvoiceFeatures_supports_basic_mpp"))) TS_InvoiceFeatures_supports_basic_mpp(uint32_t this_arg) {
38447         LDKInvoiceFeatures this_arg_conv;
38448         this_arg_conv.inner = (void*)(this_arg & (~1));
38449         this_arg_conv.is_owned = false;
38450         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38451         jboolean ret_conv = InvoiceFeatures_supports_basic_mpp(&this_arg_conv);
38452         return ret_conv;
38453 }
38454
38455 jboolean  __attribute__((export_name("TS_InitFeatures_requires_basic_mpp"))) TS_InitFeatures_requires_basic_mpp(uint32_t this_arg) {
38456         LDKInitFeatures this_arg_conv;
38457         this_arg_conv.inner = (void*)(this_arg & (~1));
38458         this_arg_conv.is_owned = false;
38459         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38460         jboolean ret_conv = InitFeatures_requires_basic_mpp(&this_arg_conv);
38461         return ret_conv;
38462 }
38463
38464 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_basic_mpp"))) TS_NodeFeatures_requires_basic_mpp(uint32_t this_arg) {
38465         LDKNodeFeatures this_arg_conv;
38466         this_arg_conv.inner = (void*)(this_arg & (~1));
38467         this_arg_conv.is_owned = false;
38468         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38469         jboolean ret_conv = NodeFeatures_requires_basic_mpp(&this_arg_conv);
38470         return ret_conv;
38471 }
38472
38473 jboolean  __attribute__((export_name("TS_InvoiceFeatures_requires_basic_mpp"))) TS_InvoiceFeatures_requires_basic_mpp(uint32_t this_arg) {
38474         LDKInvoiceFeatures this_arg_conv;
38475         this_arg_conv.inner = (void*)(this_arg & (~1));
38476         this_arg_conv.is_owned = false;
38477         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38478         jboolean ret_conv = InvoiceFeatures_requires_basic_mpp(&this_arg_conv);
38479         return ret_conv;
38480 }
38481
38482 void  __attribute__((export_name("TS_InitFeatures_set_wumbo_optional"))) TS_InitFeatures_set_wumbo_optional(uint32_t this_arg) {
38483         LDKInitFeatures this_arg_conv;
38484         this_arg_conv.inner = (void*)(this_arg & (~1));
38485         this_arg_conv.is_owned = false;
38486         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38487         InitFeatures_set_wumbo_optional(&this_arg_conv);
38488 }
38489
38490 void  __attribute__((export_name("TS_InitFeatures_set_wumbo_required"))) TS_InitFeatures_set_wumbo_required(uint32_t this_arg) {
38491         LDKInitFeatures this_arg_conv;
38492         this_arg_conv.inner = (void*)(this_arg & (~1));
38493         this_arg_conv.is_owned = false;
38494         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38495         InitFeatures_set_wumbo_required(&this_arg_conv);
38496 }
38497
38498 jboolean  __attribute__((export_name("TS_InitFeatures_supports_wumbo"))) TS_InitFeatures_supports_wumbo(uint32_t this_arg) {
38499         LDKInitFeatures this_arg_conv;
38500         this_arg_conv.inner = (void*)(this_arg & (~1));
38501         this_arg_conv.is_owned = false;
38502         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38503         jboolean ret_conv = InitFeatures_supports_wumbo(&this_arg_conv);
38504         return ret_conv;
38505 }
38506
38507 void  __attribute__((export_name("TS_NodeFeatures_set_wumbo_optional"))) TS_NodeFeatures_set_wumbo_optional(uint32_t this_arg) {
38508         LDKNodeFeatures this_arg_conv;
38509         this_arg_conv.inner = (void*)(this_arg & (~1));
38510         this_arg_conv.is_owned = false;
38511         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38512         NodeFeatures_set_wumbo_optional(&this_arg_conv);
38513 }
38514
38515 void  __attribute__((export_name("TS_NodeFeatures_set_wumbo_required"))) TS_NodeFeatures_set_wumbo_required(uint32_t this_arg) {
38516         LDKNodeFeatures this_arg_conv;
38517         this_arg_conv.inner = (void*)(this_arg & (~1));
38518         this_arg_conv.is_owned = false;
38519         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38520         NodeFeatures_set_wumbo_required(&this_arg_conv);
38521 }
38522
38523 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_wumbo"))) TS_NodeFeatures_supports_wumbo(uint32_t this_arg) {
38524         LDKNodeFeatures this_arg_conv;
38525         this_arg_conv.inner = (void*)(this_arg & (~1));
38526         this_arg_conv.is_owned = false;
38527         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38528         jboolean ret_conv = NodeFeatures_supports_wumbo(&this_arg_conv);
38529         return ret_conv;
38530 }
38531
38532 jboolean  __attribute__((export_name("TS_InitFeatures_requires_wumbo"))) TS_InitFeatures_requires_wumbo(uint32_t this_arg) {
38533         LDKInitFeatures this_arg_conv;
38534         this_arg_conv.inner = (void*)(this_arg & (~1));
38535         this_arg_conv.is_owned = false;
38536         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38537         jboolean ret_conv = InitFeatures_requires_wumbo(&this_arg_conv);
38538         return ret_conv;
38539 }
38540
38541 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_wumbo"))) TS_NodeFeatures_requires_wumbo(uint32_t this_arg) {
38542         LDKNodeFeatures this_arg_conv;
38543         this_arg_conv.inner = (void*)(this_arg & (~1));
38544         this_arg_conv.is_owned = false;
38545         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38546         jboolean ret_conv = NodeFeatures_requires_wumbo(&this_arg_conv);
38547         return ret_conv;
38548 }
38549
38550 void  __attribute__((export_name("TS_InitFeatures_set_shutdown_any_segwit_optional"))) TS_InitFeatures_set_shutdown_any_segwit_optional(uint32_t this_arg) {
38551         LDKInitFeatures this_arg_conv;
38552         this_arg_conv.inner = (void*)(this_arg & (~1));
38553         this_arg_conv.is_owned = false;
38554         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38555         InitFeatures_set_shutdown_any_segwit_optional(&this_arg_conv);
38556 }
38557
38558 void  __attribute__((export_name("TS_InitFeatures_set_shutdown_any_segwit_required"))) TS_InitFeatures_set_shutdown_any_segwit_required(uint32_t this_arg) {
38559         LDKInitFeatures this_arg_conv;
38560         this_arg_conv.inner = (void*)(this_arg & (~1));
38561         this_arg_conv.is_owned = false;
38562         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38563         InitFeatures_set_shutdown_any_segwit_required(&this_arg_conv);
38564 }
38565
38566 jboolean  __attribute__((export_name("TS_InitFeatures_supports_shutdown_anysegwit"))) TS_InitFeatures_supports_shutdown_anysegwit(uint32_t this_arg) {
38567         LDKInitFeatures this_arg_conv;
38568         this_arg_conv.inner = (void*)(this_arg & (~1));
38569         this_arg_conv.is_owned = false;
38570         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38571         jboolean ret_conv = InitFeatures_supports_shutdown_anysegwit(&this_arg_conv);
38572         return ret_conv;
38573 }
38574
38575 void  __attribute__((export_name("TS_NodeFeatures_set_shutdown_any_segwit_optional"))) TS_NodeFeatures_set_shutdown_any_segwit_optional(uint32_t this_arg) {
38576         LDKNodeFeatures this_arg_conv;
38577         this_arg_conv.inner = (void*)(this_arg & (~1));
38578         this_arg_conv.is_owned = false;
38579         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38580         NodeFeatures_set_shutdown_any_segwit_optional(&this_arg_conv);
38581 }
38582
38583 void  __attribute__((export_name("TS_NodeFeatures_set_shutdown_any_segwit_required"))) TS_NodeFeatures_set_shutdown_any_segwit_required(uint32_t this_arg) {
38584         LDKNodeFeatures this_arg_conv;
38585         this_arg_conv.inner = (void*)(this_arg & (~1));
38586         this_arg_conv.is_owned = false;
38587         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38588         NodeFeatures_set_shutdown_any_segwit_required(&this_arg_conv);
38589 }
38590
38591 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_shutdown_anysegwit"))) TS_NodeFeatures_supports_shutdown_anysegwit(uint32_t this_arg) {
38592         LDKNodeFeatures this_arg_conv;
38593         this_arg_conv.inner = (void*)(this_arg & (~1));
38594         this_arg_conv.is_owned = false;
38595         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38596         jboolean ret_conv = NodeFeatures_supports_shutdown_anysegwit(&this_arg_conv);
38597         return ret_conv;
38598 }
38599
38600 jboolean  __attribute__((export_name("TS_InitFeatures_requires_shutdown_anysegwit"))) TS_InitFeatures_requires_shutdown_anysegwit(uint32_t this_arg) {
38601         LDKInitFeatures this_arg_conv;
38602         this_arg_conv.inner = (void*)(this_arg & (~1));
38603         this_arg_conv.is_owned = false;
38604         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38605         jboolean ret_conv = InitFeatures_requires_shutdown_anysegwit(&this_arg_conv);
38606         return ret_conv;
38607 }
38608
38609 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_shutdown_anysegwit"))) TS_NodeFeatures_requires_shutdown_anysegwit(uint32_t this_arg) {
38610         LDKNodeFeatures this_arg_conv;
38611         this_arg_conv.inner = (void*)(this_arg & (~1));
38612         this_arg_conv.is_owned = false;
38613         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38614         jboolean ret_conv = NodeFeatures_requires_shutdown_anysegwit(&this_arg_conv);
38615         return ret_conv;
38616 }
38617
38618 void  __attribute__((export_name("TS_InitFeatures_set_channel_type_optional"))) TS_InitFeatures_set_channel_type_optional(uint32_t this_arg) {
38619         LDKInitFeatures this_arg_conv;
38620         this_arg_conv.inner = (void*)(this_arg & (~1));
38621         this_arg_conv.is_owned = false;
38622         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38623         InitFeatures_set_channel_type_optional(&this_arg_conv);
38624 }
38625
38626 void  __attribute__((export_name("TS_InitFeatures_set_channel_type_required"))) TS_InitFeatures_set_channel_type_required(uint32_t this_arg) {
38627         LDKInitFeatures this_arg_conv;
38628         this_arg_conv.inner = (void*)(this_arg & (~1));
38629         this_arg_conv.is_owned = false;
38630         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38631         InitFeatures_set_channel_type_required(&this_arg_conv);
38632 }
38633
38634 jboolean  __attribute__((export_name("TS_InitFeatures_supports_channel_type"))) TS_InitFeatures_supports_channel_type(uint32_t this_arg) {
38635         LDKInitFeatures this_arg_conv;
38636         this_arg_conv.inner = (void*)(this_arg & (~1));
38637         this_arg_conv.is_owned = false;
38638         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38639         jboolean ret_conv = InitFeatures_supports_channel_type(&this_arg_conv);
38640         return ret_conv;
38641 }
38642
38643 void  __attribute__((export_name("TS_NodeFeatures_set_channel_type_optional"))) TS_NodeFeatures_set_channel_type_optional(uint32_t this_arg) {
38644         LDKNodeFeatures this_arg_conv;
38645         this_arg_conv.inner = (void*)(this_arg & (~1));
38646         this_arg_conv.is_owned = false;
38647         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38648         NodeFeatures_set_channel_type_optional(&this_arg_conv);
38649 }
38650
38651 void  __attribute__((export_name("TS_NodeFeatures_set_channel_type_required"))) TS_NodeFeatures_set_channel_type_required(uint32_t this_arg) {
38652         LDKNodeFeatures this_arg_conv;
38653         this_arg_conv.inner = (void*)(this_arg & (~1));
38654         this_arg_conv.is_owned = false;
38655         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38656         NodeFeatures_set_channel_type_required(&this_arg_conv);
38657 }
38658
38659 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_channel_type"))) TS_NodeFeatures_supports_channel_type(uint32_t this_arg) {
38660         LDKNodeFeatures this_arg_conv;
38661         this_arg_conv.inner = (void*)(this_arg & (~1));
38662         this_arg_conv.is_owned = false;
38663         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38664         jboolean ret_conv = NodeFeatures_supports_channel_type(&this_arg_conv);
38665         return ret_conv;
38666 }
38667
38668 jboolean  __attribute__((export_name("TS_InitFeatures_requires_channel_type"))) TS_InitFeatures_requires_channel_type(uint32_t this_arg) {
38669         LDKInitFeatures this_arg_conv;
38670         this_arg_conv.inner = (void*)(this_arg & (~1));
38671         this_arg_conv.is_owned = false;
38672         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38673         jboolean ret_conv = InitFeatures_requires_channel_type(&this_arg_conv);
38674         return ret_conv;
38675 }
38676
38677 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_channel_type"))) TS_NodeFeatures_requires_channel_type(uint32_t this_arg) {
38678         LDKNodeFeatures this_arg_conv;
38679         this_arg_conv.inner = (void*)(this_arg & (~1));
38680         this_arg_conv.is_owned = false;
38681         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38682         jboolean ret_conv = NodeFeatures_requires_channel_type(&this_arg_conv);
38683         return ret_conv;
38684 }
38685
38686 void  __attribute__((export_name("TS_InitFeatures_set_scid_privacy_optional"))) TS_InitFeatures_set_scid_privacy_optional(uint32_t this_arg) {
38687         LDKInitFeatures this_arg_conv;
38688         this_arg_conv.inner = (void*)(this_arg & (~1));
38689         this_arg_conv.is_owned = false;
38690         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38691         InitFeatures_set_scid_privacy_optional(&this_arg_conv);
38692 }
38693
38694 void  __attribute__((export_name("TS_InitFeatures_set_scid_privacy_required"))) TS_InitFeatures_set_scid_privacy_required(uint32_t this_arg) {
38695         LDKInitFeatures this_arg_conv;
38696         this_arg_conv.inner = (void*)(this_arg & (~1));
38697         this_arg_conv.is_owned = false;
38698         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38699         InitFeatures_set_scid_privacy_required(&this_arg_conv);
38700 }
38701
38702 jboolean  __attribute__((export_name("TS_InitFeatures_supports_scid_privacy"))) TS_InitFeatures_supports_scid_privacy(uint32_t this_arg) {
38703         LDKInitFeatures this_arg_conv;
38704         this_arg_conv.inner = (void*)(this_arg & (~1));
38705         this_arg_conv.is_owned = false;
38706         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38707         jboolean ret_conv = InitFeatures_supports_scid_privacy(&this_arg_conv);
38708         return ret_conv;
38709 }
38710
38711 void  __attribute__((export_name("TS_NodeFeatures_set_scid_privacy_optional"))) TS_NodeFeatures_set_scid_privacy_optional(uint32_t this_arg) {
38712         LDKNodeFeatures this_arg_conv;
38713         this_arg_conv.inner = (void*)(this_arg & (~1));
38714         this_arg_conv.is_owned = false;
38715         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38716         NodeFeatures_set_scid_privacy_optional(&this_arg_conv);
38717 }
38718
38719 void  __attribute__((export_name("TS_NodeFeatures_set_scid_privacy_required"))) TS_NodeFeatures_set_scid_privacy_required(uint32_t this_arg) {
38720         LDKNodeFeatures this_arg_conv;
38721         this_arg_conv.inner = (void*)(this_arg & (~1));
38722         this_arg_conv.is_owned = false;
38723         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38724         NodeFeatures_set_scid_privacy_required(&this_arg_conv);
38725 }
38726
38727 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_scid_privacy"))) TS_NodeFeatures_supports_scid_privacy(uint32_t this_arg) {
38728         LDKNodeFeatures this_arg_conv;
38729         this_arg_conv.inner = (void*)(this_arg & (~1));
38730         this_arg_conv.is_owned = false;
38731         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38732         jboolean ret_conv = NodeFeatures_supports_scid_privacy(&this_arg_conv);
38733         return ret_conv;
38734 }
38735
38736 void  __attribute__((export_name("TS_ChannelTypeFeatures_set_scid_privacy_optional"))) TS_ChannelTypeFeatures_set_scid_privacy_optional(uint32_t this_arg) {
38737         LDKChannelTypeFeatures this_arg_conv;
38738         this_arg_conv.inner = (void*)(this_arg & (~1));
38739         this_arg_conv.is_owned = false;
38740         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38741         ChannelTypeFeatures_set_scid_privacy_optional(&this_arg_conv);
38742 }
38743
38744 void  __attribute__((export_name("TS_ChannelTypeFeatures_set_scid_privacy_required"))) TS_ChannelTypeFeatures_set_scid_privacy_required(uint32_t this_arg) {
38745         LDKChannelTypeFeatures this_arg_conv;
38746         this_arg_conv.inner = (void*)(this_arg & (~1));
38747         this_arg_conv.is_owned = false;
38748         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38749         ChannelTypeFeatures_set_scid_privacy_required(&this_arg_conv);
38750 }
38751
38752 jboolean  __attribute__((export_name("TS_ChannelTypeFeatures_supports_scid_privacy"))) TS_ChannelTypeFeatures_supports_scid_privacy(uint32_t this_arg) {
38753         LDKChannelTypeFeatures this_arg_conv;
38754         this_arg_conv.inner = (void*)(this_arg & (~1));
38755         this_arg_conv.is_owned = false;
38756         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38757         jboolean ret_conv = ChannelTypeFeatures_supports_scid_privacy(&this_arg_conv);
38758         return ret_conv;
38759 }
38760
38761 jboolean  __attribute__((export_name("TS_InitFeatures_requires_scid_privacy"))) TS_InitFeatures_requires_scid_privacy(uint32_t this_arg) {
38762         LDKInitFeatures this_arg_conv;
38763         this_arg_conv.inner = (void*)(this_arg & (~1));
38764         this_arg_conv.is_owned = false;
38765         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38766         jboolean ret_conv = InitFeatures_requires_scid_privacy(&this_arg_conv);
38767         return ret_conv;
38768 }
38769
38770 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_scid_privacy"))) TS_NodeFeatures_requires_scid_privacy(uint32_t this_arg) {
38771         LDKNodeFeatures this_arg_conv;
38772         this_arg_conv.inner = (void*)(this_arg & (~1));
38773         this_arg_conv.is_owned = false;
38774         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38775         jboolean ret_conv = NodeFeatures_requires_scid_privacy(&this_arg_conv);
38776         return ret_conv;
38777 }
38778
38779 jboolean  __attribute__((export_name("TS_ChannelTypeFeatures_requires_scid_privacy"))) TS_ChannelTypeFeatures_requires_scid_privacy(uint32_t this_arg) {
38780         LDKChannelTypeFeatures this_arg_conv;
38781         this_arg_conv.inner = (void*)(this_arg & (~1));
38782         this_arg_conv.is_owned = false;
38783         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38784         jboolean ret_conv = ChannelTypeFeatures_requires_scid_privacy(&this_arg_conv);
38785         return ret_conv;
38786 }
38787
38788 void  __attribute__((export_name("TS_InitFeatures_set_zero_conf_optional"))) TS_InitFeatures_set_zero_conf_optional(uint32_t this_arg) {
38789         LDKInitFeatures this_arg_conv;
38790         this_arg_conv.inner = (void*)(this_arg & (~1));
38791         this_arg_conv.is_owned = false;
38792         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38793         InitFeatures_set_zero_conf_optional(&this_arg_conv);
38794 }
38795
38796 void  __attribute__((export_name("TS_InitFeatures_set_zero_conf_required"))) TS_InitFeatures_set_zero_conf_required(uint32_t this_arg) {
38797         LDKInitFeatures this_arg_conv;
38798         this_arg_conv.inner = (void*)(this_arg & (~1));
38799         this_arg_conv.is_owned = false;
38800         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38801         InitFeatures_set_zero_conf_required(&this_arg_conv);
38802 }
38803
38804 jboolean  __attribute__((export_name("TS_InitFeatures_supports_zero_conf"))) TS_InitFeatures_supports_zero_conf(uint32_t this_arg) {
38805         LDKInitFeatures this_arg_conv;
38806         this_arg_conv.inner = (void*)(this_arg & (~1));
38807         this_arg_conv.is_owned = false;
38808         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38809         jboolean ret_conv = InitFeatures_supports_zero_conf(&this_arg_conv);
38810         return ret_conv;
38811 }
38812
38813 void  __attribute__((export_name("TS_NodeFeatures_set_zero_conf_optional"))) TS_NodeFeatures_set_zero_conf_optional(uint32_t this_arg) {
38814         LDKNodeFeatures this_arg_conv;
38815         this_arg_conv.inner = (void*)(this_arg & (~1));
38816         this_arg_conv.is_owned = false;
38817         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38818         NodeFeatures_set_zero_conf_optional(&this_arg_conv);
38819 }
38820
38821 void  __attribute__((export_name("TS_NodeFeatures_set_zero_conf_required"))) TS_NodeFeatures_set_zero_conf_required(uint32_t this_arg) {
38822         LDKNodeFeatures this_arg_conv;
38823         this_arg_conv.inner = (void*)(this_arg & (~1));
38824         this_arg_conv.is_owned = false;
38825         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38826         NodeFeatures_set_zero_conf_required(&this_arg_conv);
38827 }
38828
38829 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_zero_conf"))) TS_NodeFeatures_supports_zero_conf(uint32_t this_arg) {
38830         LDKNodeFeatures this_arg_conv;
38831         this_arg_conv.inner = (void*)(this_arg & (~1));
38832         this_arg_conv.is_owned = false;
38833         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38834         jboolean ret_conv = NodeFeatures_supports_zero_conf(&this_arg_conv);
38835         return ret_conv;
38836 }
38837
38838 void  __attribute__((export_name("TS_ChannelTypeFeatures_set_zero_conf_optional"))) TS_ChannelTypeFeatures_set_zero_conf_optional(uint32_t this_arg) {
38839         LDKChannelTypeFeatures this_arg_conv;
38840         this_arg_conv.inner = (void*)(this_arg & (~1));
38841         this_arg_conv.is_owned = false;
38842         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38843         ChannelTypeFeatures_set_zero_conf_optional(&this_arg_conv);
38844 }
38845
38846 void  __attribute__((export_name("TS_ChannelTypeFeatures_set_zero_conf_required"))) TS_ChannelTypeFeatures_set_zero_conf_required(uint32_t this_arg) {
38847         LDKChannelTypeFeatures this_arg_conv;
38848         this_arg_conv.inner = (void*)(this_arg & (~1));
38849         this_arg_conv.is_owned = false;
38850         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38851         ChannelTypeFeatures_set_zero_conf_required(&this_arg_conv);
38852 }
38853
38854 jboolean  __attribute__((export_name("TS_ChannelTypeFeatures_supports_zero_conf"))) TS_ChannelTypeFeatures_supports_zero_conf(uint32_t this_arg) {
38855         LDKChannelTypeFeatures this_arg_conv;
38856         this_arg_conv.inner = (void*)(this_arg & (~1));
38857         this_arg_conv.is_owned = false;
38858         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38859         jboolean ret_conv = ChannelTypeFeatures_supports_zero_conf(&this_arg_conv);
38860         return ret_conv;
38861 }
38862
38863 jboolean  __attribute__((export_name("TS_InitFeatures_requires_zero_conf"))) TS_InitFeatures_requires_zero_conf(uint32_t this_arg) {
38864         LDKInitFeatures this_arg_conv;
38865         this_arg_conv.inner = (void*)(this_arg & (~1));
38866         this_arg_conv.is_owned = false;
38867         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38868         jboolean ret_conv = InitFeatures_requires_zero_conf(&this_arg_conv);
38869         return ret_conv;
38870 }
38871
38872 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_zero_conf"))) TS_NodeFeatures_requires_zero_conf(uint32_t this_arg) {
38873         LDKNodeFeatures this_arg_conv;
38874         this_arg_conv.inner = (void*)(this_arg & (~1));
38875         this_arg_conv.is_owned = false;
38876         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38877         jboolean ret_conv = NodeFeatures_requires_zero_conf(&this_arg_conv);
38878         return ret_conv;
38879 }
38880
38881 jboolean  __attribute__((export_name("TS_ChannelTypeFeatures_requires_zero_conf"))) TS_ChannelTypeFeatures_requires_zero_conf(uint32_t this_arg) {
38882         LDKChannelTypeFeatures this_arg_conv;
38883         this_arg_conv.inner = (void*)(this_arg & (~1));
38884         this_arg_conv.is_owned = false;
38885         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38886         jboolean ret_conv = ChannelTypeFeatures_requires_zero_conf(&this_arg_conv);
38887         return ret_conv;
38888 }
38889
38890 void  __attribute__((export_name("TS_NodeFeatures_set_keysend_optional"))) TS_NodeFeatures_set_keysend_optional(uint32_t this_arg) {
38891         LDKNodeFeatures this_arg_conv;
38892         this_arg_conv.inner = (void*)(this_arg & (~1));
38893         this_arg_conv.is_owned = false;
38894         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38895         NodeFeatures_set_keysend_optional(&this_arg_conv);
38896 }
38897
38898 void  __attribute__((export_name("TS_NodeFeatures_set_keysend_required"))) TS_NodeFeatures_set_keysend_required(uint32_t this_arg) {
38899         LDKNodeFeatures this_arg_conv;
38900         this_arg_conv.inner = (void*)(this_arg & (~1));
38901         this_arg_conv.is_owned = false;
38902         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38903         NodeFeatures_set_keysend_required(&this_arg_conv);
38904 }
38905
38906 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_keysend"))) TS_NodeFeatures_supports_keysend(uint32_t this_arg) {
38907         LDKNodeFeatures this_arg_conv;
38908         this_arg_conv.inner = (void*)(this_arg & (~1));
38909         this_arg_conv.is_owned = false;
38910         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38911         jboolean ret_conv = NodeFeatures_supports_keysend(&this_arg_conv);
38912         return ret_conv;
38913 }
38914
38915 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_keysend"))) TS_NodeFeatures_requires_keysend(uint32_t this_arg) {
38916         LDKNodeFeatures this_arg_conv;
38917         this_arg_conv.inner = (void*)(this_arg & (~1));
38918         this_arg_conv.is_owned = false;
38919         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38920         jboolean ret_conv = NodeFeatures_requires_keysend(&this_arg_conv);
38921         return ret_conv;
38922 }
38923
38924 void  __attribute__((export_name("TS_ShutdownScript_free"))) TS_ShutdownScript_free(uint32_t this_obj) {
38925         LDKShutdownScript this_obj_conv;
38926         this_obj_conv.inner = (void*)(this_obj & (~1));
38927         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38928         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38929         ShutdownScript_free(this_obj_conv);
38930 }
38931
38932 static inline uintptr_t ShutdownScript_clone_ptr(LDKShutdownScript *NONNULL_PTR arg) {
38933         LDKShutdownScript ret_var = ShutdownScript_clone(arg);
38934 uint32_t ret_ref = 0;
38935 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38936 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38937 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38938 ret_ref = (uintptr_t)ret_var.inner;
38939 if (ret_var.is_owned) {
38940         ret_ref |= 1;
38941 }
38942         return ret_ref;
38943 }
38944 uint32_t  __attribute__((export_name("TS_ShutdownScript_clone_ptr"))) TS_ShutdownScript_clone_ptr(uint32_t arg) {
38945         LDKShutdownScript arg_conv;
38946         arg_conv.inner = (void*)(arg & (~1));
38947         arg_conv.is_owned = false;
38948         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38949         uint32_t ret_conv = ShutdownScript_clone_ptr(&arg_conv);
38950         return ret_conv;
38951 }
38952
38953 uint32_t  __attribute__((export_name("TS_ShutdownScript_clone"))) TS_ShutdownScript_clone(uint32_t orig) {
38954         LDKShutdownScript orig_conv;
38955         orig_conv.inner = (void*)(orig & (~1));
38956         orig_conv.is_owned = false;
38957         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38958         LDKShutdownScript ret_var = ShutdownScript_clone(&orig_conv);
38959         uint32_t ret_ref = 0;
38960         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38961         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38962         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38963         ret_ref = (uintptr_t)ret_var.inner;
38964         if (ret_var.is_owned) {
38965                 ret_ref |= 1;
38966         }
38967         return ret_ref;
38968 }
38969
38970 void  __attribute__((export_name("TS_InvalidShutdownScript_free"))) TS_InvalidShutdownScript_free(uint32_t this_obj) {
38971         LDKInvalidShutdownScript this_obj_conv;
38972         this_obj_conv.inner = (void*)(this_obj & (~1));
38973         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38974         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38975         InvalidShutdownScript_free(this_obj_conv);
38976 }
38977
38978 int8_tArray  __attribute__((export_name("TS_InvalidShutdownScript_get_script"))) TS_InvalidShutdownScript_get_script(uint32_t this_ptr) {
38979         LDKInvalidShutdownScript this_ptr_conv;
38980         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38981         this_ptr_conv.is_owned = false;
38982         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38983         LDKu8slice ret_var = InvalidShutdownScript_get_script(&this_ptr_conv);
38984         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
38985         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
38986         return ret_arr;
38987 }
38988
38989 void  __attribute__((export_name("TS_InvalidShutdownScript_set_script"))) TS_InvalidShutdownScript_set_script(uint32_t this_ptr, int8_tArray val) {
38990         LDKInvalidShutdownScript this_ptr_conv;
38991         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38992         this_ptr_conv.is_owned = false;
38993         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38994         LDKCVec_u8Z val_ref;
38995         val_ref.datalen = val->arr_len;
38996         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
38997         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
38998         InvalidShutdownScript_set_script(&this_ptr_conv, val_ref);
38999 }
39000
39001 uint32_t  __attribute__((export_name("TS_InvalidShutdownScript_new"))) TS_InvalidShutdownScript_new(int8_tArray script_arg) {
39002         LDKCVec_u8Z script_arg_ref;
39003         script_arg_ref.datalen = script_arg->arr_len;
39004         script_arg_ref.data = MALLOC(script_arg_ref.datalen, "LDKCVec_u8Z Bytes");
39005         memcpy(script_arg_ref.data, script_arg->elems, script_arg_ref.datalen); FREE(script_arg);
39006         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_new(script_arg_ref);
39007         uint32_t ret_ref = 0;
39008         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39009         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39010         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39011         ret_ref = (uintptr_t)ret_var.inner;
39012         if (ret_var.is_owned) {
39013                 ret_ref |= 1;
39014         }
39015         return ret_ref;
39016 }
39017
39018 static inline uintptr_t InvalidShutdownScript_clone_ptr(LDKInvalidShutdownScript *NONNULL_PTR arg) {
39019         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(arg);
39020 uint32_t ret_ref = 0;
39021 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39022 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39023 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39024 ret_ref = (uintptr_t)ret_var.inner;
39025 if (ret_var.is_owned) {
39026         ret_ref |= 1;
39027 }
39028         return ret_ref;
39029 }
39030 uint32_t  __attribute__((export_name("TS_InvalidShutdownScript_clone_ptr"))) TS_InvalidShutdownScript_clone_ptr(uint32_t arg) {
39031         LDKInvalidShutdownScript arg_conv;
39032         arg_conv.inner = (void*)(arg & (~1));
39033         arg_conv.is_owned = false;
39034         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39035         uint32_t ret_conv = InvalidShutdownScript_clone_ptr(&arg_conv);
39036         return ret_conv;
39037 }
39038
39039 uint32_t  __attribute__((export_name("TS_InvalidShutdownScript_clone"))) TS_InvalidShutdownScript_clone(uint32_t orig) {
39040         LDKInvalidShutdownScript orig_conv;
39041         orig_conv.inner = (void*)(orig & (~1));
39042         orig_conv.is_owned = false;
39043         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39044         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(&orig_conv);
39045         uint32_t ret_ref = 0;
39046         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39047         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39048         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39049         ret_ref = (uintptr_t)ret_var.inner;
39050         if (ret_var.is_owned) {
39051                 ret_ref |= 1;
39052         }
39053         return ret_ref;
39054 }
39055
39056 int8_tArray  __attribute__((export_name("TS_ShutdownScript_write"))) TS_ShutdownScript_write(uint32_t obj) {
39057         LDKShutdownScript obj_conv;
39058         obj_conv.inner = (void*)(obj & (~1));
39059         obj_conv.is_owned = false;
39060         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39061         LDKCVec_u8Z ret_var = ShutdownScript_write(&obj_conv);
39062         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
39063         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
39064         CVec_u8Z_free(ret_var);
39065         return ret_arr;
39066 }
39067
39068 uint32_t  __attribute__((export_name("TS_ShutdownScript_read"))) TS_ShutdownScript_read(int8_tArray ser) {
39069         LDKu8slice ser_ref;
39070         ser_ref.datalen = ser->arr_len;
39071         ser_ref.data = ser->elems;
39072         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
39073         *ret_conv = ShutdownScript_read(ser_ref);
39074         FREE(ser);
39075         return (uint32_t)ret_conv;
39076 }
39077
39078 uint32_t  __attribute__((export_name("TS_ShutdownScript_new_p2wpkh"))) TS_ShutdownScript_new_p2wpkh(int8_tArray pubkey_hash) {
39079         unsigned char pubkey_hash_arr[20];
39080         CHECK(pubkey_hash->arr_len == 20);
39081         memcpy(pubkey_hash_arr, pubkey_hash->elems, 20); FREE(pubkey_hash);
39082         unsigned char (*pubkey_hash_ref)[20] = &pubkey_hash_arr;
39083         LDKShutdownScript ret_var = ShutdownScript_new_p2wpkh(pubkey_hash_ref);
39084         uint32_t ret_ref = 0;
39085         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39086         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39087         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39088         ret_ref = (uintptr_t)ret_var.inner;
39089         if (ret_var.is_owned) {
39090                 ret_ref |= 1;
39091         }
39092         return ret_ref;
39093 }
39094
39095 uint32_t  __attribute__((export_name("TS_ShutdownScript_new_p2wsh"))) TS_ShutdownScript_new_p2wsh(int8_tArray script_hash) {
39096         unsigned char script_hash_arr[32];
39097         CHECK(script_hash->arr_len == 32);
39098         memcpy(script_hash_arr, script_hash->elems, 32); FREE(script_hash);
39099         unsigned char (*script_hash_ref)[32] = &script_hash_arr;
39100         LDKShutdownScript ret_var = ShutdownScript_new_p2wsh(script_hash_ref);
39101         uint32_t ret_ref = 0;
39102         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39103         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39104         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39105         ret_ref = (uintptr_t)ret_var.inner;
39106         if (ret_var.is_owned) {
39107                 ret_ref |= 1;
39108         }
39109         return ret_ref;
39110 }
39111
39112 uint32_t  __attribute__((export_name("TS_ShutdownScript_new_witness_program"))) TS_ShutdownScript_new_witness_program(int8_t version, int8_tArray program) {
39113         
39114         LDKu8slice program_ref;
39115         program_ref.datalen = program->arr_len;
39116         program_ref.data = program->elems;
39117         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
39118         *ret_conv = ShutdownScript_new_witness_program((LDKWitnessVersion){ ._0 = version }, program_ref);
39119         FREE(program);
39120         return (uint32_t)ret_conv;
39121 }
39122
39123 int8_tArray  __attribute__((export_name("TS_ShutdownScript_into_inner"))) TS_ShutdownScript_into_inner(uint32_t this_arg) {
39124         LDKShutdownScript this_arg_conv;
39125         this_arg_conv.inner = (void*)(this_arg & (~1));
39126         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
39127         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39128         this_arg_conv = ShutdownScript_clone(&this_arg_conv);
39129         LDKCVec_u8Z ret_var = ShutdownScript_into_inner(this_arg_conv);
39130         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
39131         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
39132         CVec_u8Z_free(ret_var);
39133         return ret_arr;
39134 }
39135
39136 int8_tArray  __attribute__((export_name("TS_ShutdownScript_as_legacy_pubkey"))) TS_ShutdownScript_as_legacy_pubkey(uint32_t this_arg) {
39137         LDKShutdownScript this_arg_conv;
39138         this_arg_conv.inner = (void*)(this_arg & (~1));
39139         this_arg_conv.is_owned = false;
39140         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39141         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
39142         memcpy(ret_arr->elems, ShutdownScript_as_legacy_pubkey(&this_arg_conv).compressed_form, 33);
39143         return ret_arr;
39144 }
39145
39146 jboolean  __attribute__((export_name("TS_ShutdownScript_is_compatible"))) TS_ShutdownScript_is_compatible(uint32_t this_arg, uint32_t features) {
39147         LDKShutdownScript this_arg_conv;
39148         this_arg_conv.inner = (void*)(this_arg & (~1));
39149         this_arg_conv.is_owned = false;
39150         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39151         LDKInitFeatures features_conv;
39152         features_conv.inner = (void*)(features & (~1));
39153         features_conv.is_owned = false;
39154         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
39155         jboolean ret_conv = ShutdownScript_is_compatible(&this_arg_conv, &features_conv);
39156         return ret_conv;
39157 }
39158
39159 void  __attribute__((export_name("TS_CustomMessageReader_free"))) TS_CustomMessageReader_free(uint32_t this_ptr) {
39160         if ((this_ptr & 1) != 0) return;
39161         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
39162         CHECK_ACCESS(this_ptr_ptr);
39163         LDKCustomMessageReader this_ptr_conv = *(LDKCustomMessageReader*)(this_ptr_ptr);
39164         FREE((void*)this_ptr);
39165         CustomMessageReader_free(this_ptr_conv);
39166 }
39167
39168 static inline uintptr_t Type_clone_ptr(LDKType *NONNULL_PTR arg) {
39169         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
39170         *ret_ret = Type_clone(arg);
39171         return (uint32_t)ret_ret;
39172 }
39173 uint32_t  __attribute__((export_name("TS_Type_clone_ptr"))) TS_Type_clone_ptr(uint32_t arg) {
39174         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
39175         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
39176         LDKType* arg_conv = (LDKType*)arg_ptr;
39177         uint32_t ret_conv = Type_clone_ptr(arg_conv);
39178         return ret_conv;
39179 }
39180
39181 uint32_t  __attribute__((export_name("TS_Type_clone"))) TS_Type_clone(uint32_t orig) {
39182         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
39183         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
39184         LDKType* orig_conv = (LDKType*)orig_ptr;
39185         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
39186         *ret_ret = Type_clone(orig_conv);
39187         return (uint32_t)ret_ret;
39188 }
39189
39190 void  __attribute__((export_name("TS_Type_free"))) TS_Type_free(uint32_t this_ptr) {
39191         if ((this_ptr & 1) != 0) return;
39192         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
39193         CHECK_ACCESS(this_ptr_ptr);
39194         LDKType this_ptr_conv = *(LDKType*)(this_ptr_ptr);
39195         FREE((void*)this_ptr);
39196         Type_free(this_ptr_conv);
39197 }
39198
39199 void  __attribute__((export_name("TS_NodeId_free"))) TS_NodeId_free(uint32_t this_obj) {
39200         LDKNodeId this_obj_conv;
39201         this_obj_conv.inner = (void*)(this_obj & (~1));
39202         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39203         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39204         NodeId_free(this_obj_conv);
39205 }
39206
39207 static inline uintptr_t NodeId_clone_ptr(LDKNodeId *NONNULL_PTR arg) {
39208         LDKNodeId ret_var = NodeId_clone(arg);
39209 uint32_t ret_ref = 0;
39210 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39211 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39212 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39213 ret_ref = (uintptr_t)ret_var.inner;
39214 if (ret_var.is_owned) {
39215         ret_ref |= 1;
39216 }
39217         return ret_ref;
39218 }
39219 uint32_t  __attribute__((export_name("TS_NodeId_clone_ptr"))) TS_NodeId_clone_ptr(uint32_t arg) {
39220         LDKNodeId arg_conv;
39221         arg_conv.inner = (void*)(arg & (~1));
39222         arg_conv.is_owned = false;
39223         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39224         uint32_t ret_conv = NodeId_clone_ptr(&arg_conv);
39225         return ret_conv;
39226 }
39227
39228 uint32_t  __attribute__((export_name("TS_NodeId_clone"))) TS_NodeId_clone(uint32_t orig) {
39229         LDKNodeId orig_conv;
39230         orig_conv.inner = (void*)(orig & (~1));
39231         orig_conv.is_owned = false;
39232         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39233         LDKNodeId ret_var = NodeId_clone(&orig_conv);
39234         uint32_t ret_ref = 0;
39235         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39236         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39237         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39238         ret_ref = (uintptr_t)ret_var.inner;
39239         if (ret_var.is_owned) {
39240                 ret_ref |= 1;
39241         }
39242         return ret_ref;
39243 }
39244
39245 uint32_t  __attribute__((export_name("TS_NodeId_from_pubkey"))) TS_NodeId_from_pubkey(int8_tArray pubkey) {
39246         LDKPublicKey pubkey_ref;
39247         CHECK(pubkey->arr_len == 33);
39248         memcpy(pubkey_ref.compressed_form, pubkey->elems, 33); FREE(pubkey);
39249         LDKNodeId ret_var = NodeId_from_pubkey(pubkey_ref);
39250         uint32_t ret_ref = 0;
39251         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39252         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39253         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39254         ret_ref = (uintptr_t)ret_var.inner;
39255         if (ret_var.is_owned) {
39256                 ret_ref |= 1;
39257         }
39258         return ret_ref;
39259 }
39260
39261 int8_tArray  __attribute__((export_name("TS_NodeId_as_slice"))) TS_NodeId_as_slice(uint32_t this_arg) {
39262         LDKNodeId this_arg_conv;
39263         this_arg_conv.inner = (void*)(this_arg & (~1));
39264         this_arg_conv.is_owned = false;
39265         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39266         LDKu8slice ret_var = NodeId_as_slice(&this_arg_conv);
39267         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
39268         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
39269         return ret_arr;
39270 }
39271
39272 int64_t  __attribute__((export_name("TS_NodeId_hash"))) TS_NodeId_hash(uint32_t o) {
39273         LDKNodeId o_conv;
39274         o_conv.inner = (void*)(o & (~1));
39275         o_conv.is_owned = false;
39276         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
39277         int64_t ret_conv = NodeId_hash(&o_conv);
39278         return ret_conv;
39279 }
39280
39281 int8_tArray  __attribute__((export_name("TS_NodeId_write"))) TS_NodeId_write(uint32_t obj) {
39282         LDKNodeId obj_conv;
39283         obj_conv.inner = (void*)(obj & (~1));
39284         obj_conv.is_owned = false;
39285         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39286         LDKCVec_u8Z ret_var = NodeId_write(&obj_conv);
39287         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
39288         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
39289         CVec_u8Z_free(ret_var);
39290         return ret_arr;
39291 }
39292
39293 uint32_t  __attribute__((export_name("TS_NodeId_read"))) TS_NodeId_read(int8_tArray ser) {
39294         LDKu8slice ser_ref;
39295         ser_ref.datalen = ser->arr_len;
39296         ser_ref.data = ser->elems;
39297         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
39298         *ret_conv = NodeId_read(ser_ref);
39299         FREE(ser);
39300         return (uint32_t)ret_conv;
39301 }
39302
39303 void  __attribute__((export_name("TS_NetworkGraph_free"))) TS_NetworkGraph_free(uint32_t this_obj) {
39304         LDKNetworkGraph this_obj_conv;
39305         this_obj_conv.inner = (void*)(this_obj & (~1));
39306         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39307         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39308         NetworkGraph_free(this_obj_conv);
39309 }
39310
39311 void  __attribute__((export_name("TS_ReadOnlyNetworkGraph_free"))) TS_ReadOnlyNetworkGraph_free(uint32_t this_obj) {
39312         LDKReadOnlyNetworkGraph this_obj_conv;
39313         this_obj_conv.inner = (void*)(this_obj & (~1));
39314         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39315         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39316         ReadOnlyNetworkGraph_free(this_obj_conv);
39317 }
39318
39319 void  __attribute__((export_name("TS_NetworkUpdate_free"))) TS_NetworkUpdate_free(uint32_t this_ptr) {
39320         if ((this_ptr & 1) != 0) return;
39321         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
39322         CHECK_ACCESS(this_ptr_ptr);
39323         LDKNetworkUpdate this_ptr_conv = *(LDKNetworkUpdate*)(this_ptr_ptr);
39324         FREE((void*)this_ptr);
39325         NetworkUpdate_free(this_ptr_conv);
39326 }
39327
39328 static inline uintptr_t NetworkUpdate_clone_ptr(LDKNetworkUpdate *NONNULL_PTR arg) {
39329         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
39330         *ret_copy = NetworkUpdate_clone(arg);
39331 uint32_t ret_ref = (uintptr_t)ret_copy;
39332         return ret_ref;
39333 }
39334 uint32_t  __attribute__((export_name("TS_NetworkUpdate_clone_ptr"))) TS_NetworkUpdate_clone_ptr(uint32_t arg) {
39335         LDKNetworkUpdate* arg_conv = (LDKNetworkUpdate*)arg;
39336         uint32_t ret_conv = NetworkUpdate_clone_ptr(arg_conv);
39337         return ret_conv;
39338 }
39339
39340 uint32_t  __attribute__((export_name("TS_NetworkUpdate_clone"))) TS_NetworkUpdate_clone(uint32_t orig) {
39341         LDKNetworkUpdate* orig_conv = (LDKNetworkUpdate*)orig;
39342         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
39343         *ret_copy = NetworkUpdate_clone(orig_conv);
39344         uint32_t ret_ref = (uintptr_t)ret_copy;
39345         return ret_ref;
39346 }
39347
39348 uint32_t  __attribute__((export_name("TS_NetworkUpdate_channel_update_message"))) TS_NetworkUpdate_channel_update_message(uint32_t msg) {
39349         LDKChannelUpdate msg_conv;
39350         msg_conv.inner = (void*)(msg & (~1));
39351         msg_conv.is_owned = (msg & 1) || (msg == 0);
39352         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
39353         msg_conv = ChannelUpdate_clone(&msg_conv);
39354         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
39355         *ret_copy = NetworkUpdate_channel_update_message(msg_conv);
39356         uint32_t ret_ref = (uintptr_t)ret_copy;
39357         return ret_ref;
39358 }
39359
39360 uint32_t  __attribute__((export_name("TS_NetworkUpdate_channel_failure"))) TS_NetworkUpdate_channel_failure(int64_t short_channel_id, jboolean is_permanent) {
39361         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
39362         *ret_copy = NetworkUpdate_channel_failure(short_channel_id, is_permanent);
39363         uint32_t ret_ref = (uintptr_t)ret_copy;
39364         return ret_ref;
39365 }
39366
39367 uint32_t  __attribute__((export_name("TS_NetworkUpdate_node_failure"))) TS_NetworkUpdate_node_failure(int8_tArray node_id, jboolean is_permanent) {
39368         LDKPublicKey node_id_ref;
39369         CHECK(node_id->arr_len == 33);
39370         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
39371         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
39372         *ret_copy = NetworkUpdate_node_failure(node_id_ref, is_permanent);
39373         uint32_t ret_ref = (uintptr_t)ret_copy;
39374         return ret_ref;
39375 }
39376
39377 int8_tArray  __attribute__((export_name("TS_NetworkUpdate_write"))) TS_NetworkUpdate_write(uint32_t obj) {
39378         LDKNetworkUpdate* obj_conv = (LDKNetworkUpdate*)obj;
39379         LDKCVec_u8Z ret_var = NetworkUpdate_write(obj_conv);
39380         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
39381         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
39382         CVec_u8Z_free(ret_var);
39383         return ret_arr;
39384 }
39385
39386 uint32_t  __attribute__((export_name("TS_NetworkUpdate_read"))) TS_NetworkUpdate_read(int8_tArray ser) {
39387         LDKu8slice ser_ref;
39388         ser_ref.datalen = ser->arr_len;
39389         ser_ref.data = ser->elems;
39390         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
39391         *ret_conv = NetworkUpdate_read(ser_ref);
39392         FREE(ser);
39393         return (uint32_t)ret_conv;
39394 }
39395
39396 void  __attribute__((export_name("TS_P2PGossipSync_free"))) TS_P2PGossipSync_free(uint32_t this_obj) {
39397         LDKP2PGossipSync this_obj_conv;
39398         this_obj_conv.inner = (void*)(this_obj & (~1));
39399         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39400         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39401         P2PGossipSync_free(this_obj_conv);
39402 }
39403
39404 uint32_t  __attribute__((export_name("TS_P2PGossipSync_new"))) TS_P2PGossipSync_new(uint32_t network_graph, uint32_t chain_access, uint32_t logger) {
39405         LDKNetworkGraph network_graph_conv;
39406         network_graph_conv.inner = (void*)(network_graph & (~1));
39407         network_graph_conv.is_owned = false;
39408         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
39409         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
39410         CHECK_ACCESS(chain_access_ptr);
39411         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
39412         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
39413         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
39414                 // Manually implement clone for Java trait instances
39415                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
39416                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
39417                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
39418                 }
39419         }
39420         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
39421         CHECK_ACCESS(logger_ptr);
39422         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
39423         if (logger_conv.free == LDKLogger_JCalls_free) {
39424                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
39425                 LDKLogger_JCalls_cloned(&logger_conv);
39426         }
39427         LDKP2PGossipSync ret_var = P2PGossipSync_new(&network_graph_conv, chain_access_conv, logger_conv);
39428         uint32_t ret_ref = 0;
39429         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39430         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39431         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39432         ret_ref = (uintptr_t)ret_var.inner;
39433         if (ret_var.is_owned) {
39434                 ret_ref |= 1;
39435         }
39436         return ret_ref;
39437 }
39438
39439 void  __attribute__((export_name("TS_P2PGossipSync_add_chain_access"))) TS_P2PGossipSync_add_chain_access(uint32_t this_arg, uint32_t chain_access) {
39440         LDKP2PGossipSync this_arg_conv;
39441         this_arg_conv.inner = (void*)(this_arg & (~1));
39442         this_arg_conv.is_owned = false;
39443         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39444         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
39445         CHECK_ACCESS(chain_access_ptr);
39446         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
39447         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
39448         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
39449                 // Manually implement clone for Java trait instances
39450                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
39451                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
39452                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
39453                 }
39454         }
39455         P2PGossipSync_add_chain_access(&this_arg_conv, chain_access_conv);
39456 }
39457
39458 uint32_t  __attribute__((export_name("TS_NetworkGraph_as_EventHandler"))) TS_NetworkGraph_as_EventHandler(uint32_t this_arg) {
39459         LDKNetworkGraph this_arg_conv;
39460         this_arg_conv.inner = (void*)(this_arg & (~1));
39461         this_arg_conv.is_owned = false;
39462         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39463         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
39464         *ret_ret = NetworkGraph_as_EventHandler(&this_arg_conv);
39465         return (uint32_t)ret_ret;
39466 }
39467
39468 uint32_t  __attribute__((export_name("TS_P2PGossipSync_as_RoutingMessageHandler"))) TS_P2PGossipSync_as_RoutingMessageHandler(uint32_t this_arg) {
39469         LDKP2PGossipSync this_arg_conv;
39470         this_arg_conv.inner = (void*)(this_arg & (~1));
39471         this_arg_conv.is_owned = false;
39472         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39473         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
39474         *ret_ret = P2PGossipSync_as_RoutingMessageHandler(&this_arg_conv);
39475         return (uint32_t)ret_ret;
39476 }
39477
39478 uint32_t  __attribute__((export_name("TS_P2PGossipSync_as_MessageSendEventsProvider"))) TS_P2PGossipSync_as_MessageSendEventsProvider(uint32_t this_arg) {
39479         LDKP2PGossipSync this_arg_conv;
39480         this_arg_conv.inner = (void*)(this_arg & (~1));
39481         this_arg_conv.is_owned = false;
39482         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39483         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
39484         *ret_ret = P2PGossipSync_as_MessageSendEventsProvider(&this_arg_conv);
39485         return (uint32_t)ret_ret;
39486 }
39487
39488 void  __attribute__((export_name("TS_ChannelUpdateInfo_free"))) TS_ChannelUpdateInfo_free(uint32_t this_obj) {
39489         LDKChannelUpdateInfo this_obj_conv;
39490         this_obj_conv.inner = (void*)(this_obj & (~1));
39491         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39492         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39493         ChannelUpdateInfo_free(this_obj_conv);
39494 }
39495
39496 int32_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_last_update"))) TS_ChannelUpdateInfo_get_last_update(uint32_t this_ptr) {
39497         LDKChannelUpdateInfo this_ptr_conv;
39498         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39499         this_ptr_conv.is_owned = false;
39500         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39501         int32_t ret_conv = ChannelUpdateInfo_get_last_update(&this_ptr_conv);
39502         return ret_conv;
39503 }
39504
39505 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_last_update"))) TS_ChannelUpdateInfo_set_last_update(uint32_t this_ptr, int32_t val) {
39506         LDKChannelUpdateInfo this_ptr_conv;
39507         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39508         this_ptr_conv.is_owned = false;
39509         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39510         ChannelUpdateInfo_set_last_update(&this_ptr_conv, val);
39511 }
39512
39513 jboolean  __attribute__((export_name("TS_ChannelUpdateInfo_get_enabled"))) TS_ChannelUpdateInfo_get_enabled(uint32_t this_ptr) {
39514         LDKChannelUpdateInfo this_ptr_conv;
39515         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39516         this_ptr_conv.is_owned = false;
39517         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39518         jboolean ret_conv = ChannelUpdateInfo_get_enabled(&this_ptr_conv);
39519         return ret_conv;
39520 }
39521
39522 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_enabled"))) TS_ChannelUpdateInfo_set_enabled(uint32_t this_ptr, jboolean val) {
39523         LDKChannelUpdateInfo this_ptr_conv;
39524         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39525         this_ptr_conv.is_owned = false;
39526         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39527         ChannelUpdateInfo_set_enabled(&this_ptr_conv, val);
39528 }
39529
39530 int16_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_cltv_expiry_delta"))) TS_ChannelUpdateInfo_get_cltv_expiry_delta(uint32_t this_ptr) {
39531         LDKChannelUpdateInfo this_ptr_conv;
39532         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39533         this_ptr_conv.is_owned = false;
39534         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39535         int16_t ret_conv = ChannelUpdateInfo_get_cltv_expiry_delta(&this_ptr_conv);
39536         return ret_conv;
39537 }
39538
39539 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_cltv_expiry_delta"))) TS_ChannelUpdateInfo_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
39540         LDKChannelUpdateInfo this_ptr_conv;
39541         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39542         this_ptr_conv.is_owned = false;
39543         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39544         ChannelUpdateInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
39545 }
39546
39547 int64_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_htlc_minimum_msat"))) TS_ChannelUpdateInfo_get_htlc_minimum_msat(uint32_t this_ptr) {
39548         LDKChannelUpdateInfo this_ptr_conv;
39549         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39550         this_ptr_conv.is_owned = false;
39551         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39552         int64_t ret_conv = ChannelUpdateInfo_get_htlc_minimum_msat(&this_ptr_conv);
39553         return ret_conv;
39554 }
39555
39556 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_htlc_minimum_msat"))) TS_ChannelUpdateInfo_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
39557         LDKChannelUpdateInfo this_ptr_conv;
39558         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39559         this_ptr_conv.is_owned = false;
39560         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39561         ChannelUpdateInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
39562 }
39563
39564 int64_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_htlc_maximum_msat"))) TS_ChannelUpdateInfo_get_htlc_maximum_msat(uint32_t this_ptr) {
39565         LDKChannelUpdateInfo this_ptr_conv;
39566         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39567         this_ptr_conv.is_owned = false;
39568         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39569         int64_t ret_conv = ChannelUpdateInfo_get_htlc_maximum_msat(&this_ptr_conv);
39570         return ret_conv;
39571 }
39572
39573 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_htlc_maximum_msat"))) TS_ChannelUpdateInfo_set_htlc_maximum_msat(uint32_t this_ptr, int64_t val) {
39574         LDKChannelUpdateInfo this_ptr_conv;
39575         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39576         this_ptr_conv.is_owned = false;
39577         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39578         ChannelUpdateInfo_set_htlc_maximum_msat(&this_ptr_conv, val);
39579 }
39580
39581 uint32_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_fees"))) TS_ChannelUpdateInfo_get_fees(uint32_t this_ptr) {
39582         LDKChannelUpdateInfo this_ptr_conv;
39583         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39584         this_ptr_conv.is_owned = false;
39585         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39586         LDKRoutingFees ret_var = ChannelUpdateInfo_get_fees(&this_ptr_conv);
39587         uint32_t ret_ref = 0;
39588         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39589         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39590         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39591         ret_ref = (uintptr_t)ret_var.inner;
39592         if (ret_var.is_owned) {
39593                 ret_ref |= 1;
39594         }
39595         return ret_ref;
39596 }
39597
39598 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_fees"))) TS_ChannelUpdateInfo_set_fees(uint32_t this_ptr, uint32_t val) {
39599         LDKChannelUpdateInfo this_ptr_conv;
39600         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39601         this_ptr_conv.is_owned = false;
39602         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39603         LDKRoutingFees val_conv;
39604         val_conv.inner = (void*)(val & (~1));
39605         val_conv.is_owned = (val & 1) || (val == 0);
39606         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39607         val_conv = RoutingFees_clone(&val_conv);
39608         ChannelUpdateInfo_set_fees(&this_ptr_conv, val_conv);
39609 }
39610
39611 uint32_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_last_update_message"))) TS_ChannelUpdateInfo_get_last_update_message(uint32_t this_ptr) {
39612         LDKChannelUpdateInfo this_ptr_conv;
39613         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39614         this_ptr_conv.is_owned = false;
39615         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39616         LDKChannelUpdate ret_var = ChannelUpdateInfo_get_last_update_message(&this_ptr_conv);
39617         uint32_t ret_ref = 0;
39618         if ((uintptr_t)ret_var.inner > 4096) {
39619                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39620                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39621         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39622                 ret_ref = (uintptr_t)ret_var.inner;
39623                 if (ret_var.is_owned) {
39624                         ret_ref |= 1;
39625                 }
39626         }
39627         return ret_ref;
39628 }
39629
39630 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_last_update_message"))) TS_ChannelUpdateInfo_set_last_update_message(uint32_t this_ptr, uint32_t val) {
39631         LDKChannelUpdateInfo this_ptr_conv;
39632         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39633         this_ptr_conv.is_owned = false;
39634         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39635         LDKChannelUpdate val_conv;
39636         val_conv.inner = (void*)(val & (~1));
39637         val_conv.is_owned = (val & 1) || (val == 0);
39638         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39639         val_conv = ChannelUpdate_clone(&val_conv);
39640         ChannelUpdateInfo_set_last_update_message(&this_ptr_conv, val_conv);
39641 }
39642
39643 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) {
39644         LDKRoutingFees fees_arg_conv;
39645         fees_arg_conv.inner = (void*)(fees_arg & (~1));
39646         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
39647         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
39648         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
39649         LDKChannelUpdate last_update_message_arg_conv;
39650         last_update_message_arg_conv.inner = (void*)(last_update_message_arg & (~1));
39651         last_update_message_arg_conv.is_owned = (last_update_message_arg & 1) || (last_update_message_arg == 0);
39652         CHECK_INNER_FIELD_ACCESS_OR_NULL(last_update_message_arg_conv);
39653         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
39654         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);
39655         uint32_t ret_ref = 0;
39656         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39657         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39658         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39659         ret_ref = (uintptr_t)ret_var.inner;
39660         if (ret_var.is_owned) {
39661                 ret_ref |= 1;
39662         }
39663         return ret_ref;
39664 }
39665
39666 static inline uintptr_t ChannelUpdateInfo_clone_ptr(LDKChannelUpdateInfo *NONNULL_PTR arg) {
39667         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(arg);
39668 uint32_t ret_ref = 0;
39669 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39670 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39671 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39672 ret_ref = (uintptr_t)ret_var.inner;
39673 if (ret_var.is_owned) {
39674         ret_ref |= 1;
39675 }
39676         return ret_ref;
39677 }
39678 uint32_t  __attribute__((export_name("TS_ChannelUpdateInfo_clone_ptr"))) TS_ChannelUpdateInfo_clone_ptr(uint32_t arg) {
39679         LDKChannelUpdateInfo arg_conv;
39680         arg_conv.inner = (void*)(arg & (~1));
39681         arg_conv.is_owned = false;
39682         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39683         uint32_t ret_conv = ChannelUpdateInfo_clone_ptr(&arg_conv);
39684         return ret_conv;
39685 }
39686
39687 uint32_t  __attribute__((export_name("TS_ChannelUpdateInfo_clone"))) TS_ChannelUpdateInfo_clone(uint32_t orig) {
39688         LDKChannelUpdateInfo orig_conv;
39689         orig_conv.inner = (void*)(orig & (~1));
39690         orig_conv.is_owned = false;
39691         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39692         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(&orig_conv);
39693         uint32_t ret_ref = 0;
39694         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39695         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39696         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39697         ret_ref = (uintptr_t)ret_var.inner;
39698         if (ret_var.is_owned) {
39699                 ret_ref |= 1;
39700         }
39701         return ret_ref;
39702 }
39703
39704 int8_tArray  __attribute__((export_name("TS_ChannelUpdateInfo_write"))) TS_ChannelUpdateInfo_write(uint32_t obj) {
39705         LDKChannelUpdateInfo obj_conv;
39706         obj_conv.inner = (void*)(obj & (~1));
39707         obj_conv.is_owned = false;
39708         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39709         LDKCVec_u8Z ret_var = ChannelUpdateInfo_write(&obj_conv);
39710         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
39711         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
39712         CVec_u8Z_free(ret_var);
39713         return ret_arr;
39714 }
39715
39716 uint32_t  __attribute__((export_name("TS_ChannelUpdateInfo_read"))) TS_ChannelUpdateInfo_read(int8_tArray ser) {
39717         LDKu8slice ser_ref;
39718         ser_ref.datalen = ser->arr_len;
39719         ser_ref.data = ser->elems;
39720         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
39721         *ret_conv = ChannelUpdateInfo_read(ser_ref);
39722         FREE(ser);
39723         return (uint32_t)ret_conv;
39724 }
39725
39726 void  __attribute__((export_name("TS_ChannelInfo_free"))) TS_ChannelInfo_free(uint32_t this_obj) {
39727         LDKChannelInfo this_obj_conv;
39728         this_obj_conv.inner = (void*)(this_obj & (~1));
39729         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39730         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39731         ChannelInfo_free(this_obj_conv);
39732 }
39733
39734 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_features"))) TS_ChannelInfo_get_features(uint32_t this_ptr) {
39735         LDKChannelInfo this_ptr_conv;
39736         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39737         this_ptr_conv.is_owned = false;
39738         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39739         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
39740         uint32_t ret_ref = 0;
39741         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39742         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39743         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39744         ret_ref = (uintptr_t)ret_var.inner;
39745         if (ret_var.is_owned) {
39746                 ret_ref |= 1;
39747         }
39748         return ret_ref;
39749 }
39750
39751 void  __attribute__((export_name("TS_ChannelInfo_set_features"))) TS_ChannelInfo_set_features(uint32_t this_ptr, uint32_t val) {
39752         LDKChannelInfo this_ptr_conv;
39753         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39754         this_ptr_conv.is_owned = false;
39755         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39756         LDKChannelFeatures val_conv;
39757         val_conv.inner = (void*)(val & (~1));
39758         val_conv.is_owned = (val & 1) || (val == 0);
39759         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39760         val_conv = ChannelFeatures_clone(&val_conv);
39761         ChannelInfo_set_features(&this_ptr_conv, val_conv);
39762 }
39763
39764 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_node_one"))) TS_ChannelInfo_get_node_one(uint32_t this_ptr) {
39765         LDKChannelInfo this_ptr_conv;
39766         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39767         this_ptr_conv.is_owned = false;
39768         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39769         LDKNodeId ret_var = ChannelInfo_get_node_one(&this_ptr_conv);
39770         uint32_t ret_ref = 0;
39771         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39772         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39773         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39774         ret_ref = (uintptr_t)ret_var.inner;
39775         if (ret_var.is_owned) {
39776                 ret_ref |= 1;
39777         }
39778         return ret_ref;
39779 }
39780
39781 void  __attribute__((export_name("TS_ChannelInfo_set_node_one"))) TS_ChannelInfo_set_node_one(uint32_t this_ptr, uint32_t val) {
39782         LDKChannelInfo this_ptr_conv;
39783         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39784         this_ptr_conv.is_owned = false;
39785         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39786         LDKNodeId val_conv;
39787         val_conv.inner = (void*)(val & (~1));
39788         val_conv.is_owned = (val & 1) || (val == 0);
39789         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39790         val_conv = NodeId_clone(&val_conv);
39791         ChannelInfo_set_node_one(&this_ptr_conv, val_conv);
39792 }
39793
39794 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_one_to_two"))) TS_ChannelInfo_get_one_to_two(uint32_t this_ptr) {
39795         LDKChannelInfo this_ptr_conv;
39796         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39797         this_ptr_conv.is_owned = false;
39798         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39799         LDKChannelUpdateInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
39800         uint32_t ret_ref = 0;
39801         if ((uintptr_t)ret_var.inner > 4096) {
39802                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39803                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39804         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39805                 ret_ref = (uintptr_t)ret_var.inner;
39806                 if (ret_var.is_owned) {
39807                         ret_ref |= 1;
39808                 }
39809         }
39810         return ret_ref;
39811 }
39812
39813 void  __attribute__((export_name("TS_ChannelInfo_set_one_to_two"))) TS_ChannelInfo_set_one_to_two(uint32_t this_ptr, uint32_t val) {
39814         LDKChannelInfo this_ptr_conv;
39815         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39816         this_ptr_conv.is_owned = false;
39817         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39818         LDKChannelUpdateInfo val_conv;
39819         val_conv.inner = (void*)(val & (~1));
39820         val_conv.is_owned = (val & 1) || (val == 0);
39821         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39822         val_conv = ChannelUpdateInfo_clone(&val_conv);
39823         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
39824 }
39825
39826 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_node_two"))) TS_ChannelInfo_get_node_two(uint32_t this_ptr) {
39827         LDKChannelInfo this_ptr_conv;
39828         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39829         this_ptr_conv.is_owned = false;
39830         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39831         LDKNodeId ret_var = ChannelInfo_get_node_two(&this_ptr_conv);
39832         uint32_t ret_ref = 0;
39833         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39834         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39835         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39836         ret_ref = (uintptr_t)ret_var.inner;
39837         if (ret_var.is_owned) {
39838                 ret_ref |= 1;
39839         }
39840         return ret_ref;
39841 }
39842
39843 void  __attribute__((export_name("TS_ChannelInfo_set_node_two"))) TS_ChannelInfo_set_node_two(uint32_t this_ptr, uint32_t val) {
39844         LDKChannelInfo this_ptr_conv;
39845         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39846         this_ptr_conv.is_owned = false;
39847         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39848         LDKNodeId val_conv;
39849         val_conv.inner = (void*)(val & (~1));
39850         val_conv.is_owned = (val & 1) || (val == 0);
39851         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39852         val_conv = NodeId_clone(&val_conv);
39853         ChannelInfo_set_node_two(&this_ptr_conv, val_conv);
39854 }
39855
39856 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_two_to_one"))) TS_ChannelInfo_get_two_to_one(uint32_t this_ptr) {
39857         LDKChannelInfo this_ptr_conv;
39858         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39859         this_ptr_conv.is_owned = false;
39860         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39861         LDKChannelUpdateInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
39862         uint32_t ret_ref = 0;
39863         if ((uintptr_t)ret_var.inner > 4096) {
39864                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39865                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39866         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39867                 ret_ref = (uintptr_t)ret_var.inner;
39868                 if (ret_var.is_owned) {
39869                         ret_ref |= 1;
39870                 }
39871         }
39872         return ret_ref;
39873 }
39874
39875 void  __attribute__((export_name("TS_ChannelInfo_set_two_to_one"))) TS_ChannelInfo_set_two_to_one(uint32_t this_ptr, uint32_t val) {
39876         LDKChannelInfo this_ptr_conv;
39877         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39878         this_ptr_conv.is_owned = false;
39879         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39880         LDKChannelUpdateInfo val_conv;
39881         val_conv.inner = (void*)(val & (~1));
39882         val_conv.is_owned = (val & 1) || (val == 0);
39883         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39884         val_conv = ChannelUpdateInfo_clone(&val_conv);
39885         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
39886 }
39887
39888 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_capacity_sats"))) TS_ChannelInfo_get_capacity_sats(uint32_t this_ptr) {
39889         LDKChannelInfo this_ptr_conv;
39890         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39891         this_ptr_conv.is_owned = false;
39892         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39893         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
39894         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
39895         uint32_t ret_ref = (uintptr_t)ret_copy;
39896         return ret_ref;
39897 }
39898
39899 void  __attribute__((export_name("TS_ChannelInfo_set_capacity_sats"))) TS_ChannelInfo_set_capacity_sats(uint32_t this_ptr, uint32_t val) {
39900         LDKChannelInfo this_ptr_conv;
39901         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39902         this_ptr_conv.is_owned = false;
39903         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39904         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
39905         CHECK_ACCESS(val_ptr);
39906         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
39907         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
39908         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
39909 }
39910
39911 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_announcement_message"))) TS_ChannelInfo_get_announcement_message(uint32_t this_ptr) {
39912         LDKChannelInfo this_ptr_conv;
39913         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39914         this_ptr_conv.is_owned = false;
39915         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39916         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
39917         uint32_t ret_ref = 0;
39918         if ((uintptr_t)ret_var.inner > 4096) {
39919                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39920                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39921         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39922                 ret_ref = (uintptr_t)ret_var.inner;
39923                 if (ret_var.is_owned) {
39924                         ret_ref |= 1;
39925                 }
39926         }
39927         return ret_ref;
39928 }
39929
39930 void  __attribute__((export_name("TS_ChannelInfo_set_announcement_message"))) TS_ChannelInfo_set_announcement_message(uint32_t this_ptr, uint32_t val) {
39931         LDKChannelInfo this_ptr_conv;
39932         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39933         this_ptr_conv.is_owned = false;
39934         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39935         LDKChannelAnnouncement val_conv;
39936         val_conv.inner = (void*)(val & (~1));
39937         val_conv.is_owned = (val & 1) || (val == 0);
39938         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39939         val_conv = ChannelAnnouncement_clone(&val_conv);
39940         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
39941 }
39942
39943 static inline uintptr_t ChannelInfo_clone_ptr(LDKChannelInfo *NONNULL_PTR arg) {
39944         LDKChannelInfo ret_var = ChannelInfo_clone(arg);
39945 uint32_t ret_ref = 0;
39946 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39947 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39948 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39949 ret_ref = (uintptr_t)ret_var.inner;
39950 if (ret_var.is_owned) {
39951         ret_ref |= 1;
39952 }
39953         return ret_ref;
39954 }
39955 uint32_t  __attribute__((export_name("TS_ChannelInfo_clone_ptr"))) TS_ChannelInfo_clone_ptr(uint32_t arg) {
39956         LDKChannelInfo arg_conv;
39957         arg_conv.inner = (void*)(arg & (~1));
39958         arg_conv.is_owned = false;
39959         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39960         uint32_t ret_conv = ChannelInfo_clone_ptr(&arg_conv);
39961         return ret_conv;
39962 }
39963
39964 uint32_t  __attribute__((export_name("TS_ChannelInfo_clone"))) TS_ChannelInfo_clone(uint32_t orig) {
39965         LDKChannelInfo orig_conv;
39966         orig_conv.inner = (void*)(orig & (~1));
39967         orig_conv.is_owned = false;
39968         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39969         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
39970         uint32_t ret_ref = 0;
39971         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39972         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39973         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39974         ret_ref = (uintptr_t)ret_var.inner;
39975         if (ret_var.is_owned) {
39976                 ret_ref |= 1;
39977         }
39978         return ret_ref;
39979 }
39980
39981 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_directional_info"))) TS_ChannelInfo_get_directional_info(uint32_t this_arg, int8_t channel_flags) {
39982         LDKChannelInfo this_arg_conv;
39983         this_arg_conv.inner = (void*)(this_arg & (~1));
39984         this_arg_conv.is_owned = false;
39985         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39986         LDKChannelUpdateInfo ret_var = ChannelInfo_get_directional_info(&this_arg_conv, channel_flags);
39987         uint32_t ret_ref = 0;
39988         if ((uintptr_t)ret_var.inner > 4096) {
39989                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39990                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39991         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39992                 ret_ref = (uintptr_t)ret_var.inner;
39993                 if (ret_var.is_owned) {
39994                         ret_ref |= 1;
39995                 }
39996         }
39997         return ret_ref;
39998 }
39999
40000 int8_tArray  __attribute__((export_name("TS_ChannelInfo_write"))) TS_ChannelInfo_write(uint32_t obj) {
40001         LDKChannelInfo obj_conv;
40002         obj_conv.inner = (void*)(obj & (~1));
40003         obj_conv.is_owned = false;
40004         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40005         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
40006         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
40007         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
40008         CVec_u8Z_free(ret_var);
40009         return ret_arr;
40010 }
40011
40012 uint32_t  __attribute__((export_name("TS_ChannelInfo_read"))) TS_ChannelInfo_read(int8_tArray ser) {
40013         LDKu8slice ser_ref;
40014         ser_ref.datalen = ser->arr_len;
40015         ser_ref.data = ser->elems;
40016         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
40017         *ret_conv = ChannelInfo_read(ser_ref);
40018         FREE(ser);
40019         return (uint32_t)ret_conv;
40020 }
40021
40022 void  __attribute__((export_name("TS_DirectedChannelInfo_free"))) TS_DirectedChannelInfo_free(uint32_t this_obj) {
40023         LDKDirectedChannelInfo this_obj_conv;
40024         this_obj_conv.inner = (void*)(this_obj & (~1));
40025         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40026         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40027         DirectedChannelInfo_free(this_obj_conv);
40028 }
40029
40030 static inline uintptr_t DirectedChannelInfo_clone_ptr(LDKDirectedChannelInfo *NONNULL_PTR arg) {
40031         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(arg);
40032 uint32_t ret_ref = 0;
40033 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40034 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40035 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40036 ret_ref = (uintptr_t)ret_var.inner;
40037 if (ret_var.is_owned) {
40038         ret_ref |= 1;
40039 }
40040         return ret_ref;
40041 }
40042 uint32_t  __attribute__((export_name("TS_DirectedChannelInfo_clone_ptr"))) TS_DirectedChannelInfo_clone_ptr(uint32_t arg) {
40043         LDKDirectedChannelInfo arg_conv;
40044         arg_conv.inner = (void*)(arg & (~1));
40045         arg_conv.is_owned = false;
40046         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40047         uint32_t ret_conv = DirectedChannelInfo_clone_ptr(&arg_conv);
40048         return ret_conv;
40049 }
40050
40051 uint32_t  __attribute__((export_name("TS_DirectedChannelInfo_clone"))) TS_DirectedChannelInfo_clone(uint32_t orig) {
40052         LDKDirectedChannelInfo orig_conv;
40053         orig_conv.inner = (void*)(orig & (~1));
40054         orig_conv.is_owned = false;
40055         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40056         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(&orig_conv);
40057         uint32_t ret_ref = 0;
40058         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40059         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40060         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40061         ret_ref = (uintptr_t)ret_var.inner;
40062         if (ret_var.is_owned) {
40063                 ret_ref |= 1;
40064         }
40065         return ret_ref;
40066 }
40067
40068 uint32_t  __attribute__((export_name("TS_DirectedChannelInfo_channel"))) TS_DirectedChannelInfo_channel(uint32_t this_arg) {
40069         LDKDirectedChannelInfo this_arg_conv;
40070         this_arg_conv.inner = (void*)(this_arg & (~1));
40071         this_arg_conv.is_owned = false;
40072         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40073         LDKChannelInfo ret_var = DirectedChannelInfo_channel(&this_arg_conv);
40074         uint32_t ret_ref = 0;
40075         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40076         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40077         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40078         ret_ref = (uintptr_t)ret_var.inner;
40079         if (ret_var.is_owned) {
40080                 ret_ref |= 1;
40081         }
40082         return ret_ref;
40083 }
40084
40085 uint32_t  __attribute__((export_name("TS_DirectedChannelInfo_direction"))) TS_DirectedChannelInfo_direction(uint32_t this_arg) {
40086         LDKDirectedChannelInfo this_arg_conv;
40087         this_arg_conv.inner = (void*)(this_arg & (~1));
40088         this_arg_conv.is_owned = false;
40089         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40090         LDKChannelUpdateInfo ret_var = DirectedChannelInfo_direction(&this_arg_conv);
40091         uint32_t ret_ref = 0;
40092         if ((uintptr_t)ret_var.inner > 4096) {
40093                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40094                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40095         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40096                 ret_ref = (uintptr_t)ret_var.inner;
40097                 if (ret_var.is_owned) {
40098                         ret_ref |= 1;
40099                 }
40100         }
40101         return ret_ref;
40102 }
40103
40104 int64_t  __attribute__((export_name("TS_DirectedChannelInfo_htlc_maximum_msat"))) TS_DirectedChannelInfo_htlc_maximum_msat(uint32_t this_arg) {
40105         LDKDirectedChannelInfo this_arg_conv;
40106         this_arg_conv.inner = (void*)(this_arg & (~1));
40107         this_arg_conv.is_owned = false;
40108         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40109         int64_t ret_conv = DirectedChannelInfo_htlc_maximum_msat(&this_arg_conv);
40110         return ret_conv;
40111 }
40112
40113 uint32_t  __attribute__((export_name("TS_DirectedChannelInfo_effective_capacity"))) TS_DirectedChannelInfo_effective_capacity(uint32_t this_arg) {
40114         LDKDirectedChannelInfo this_arg_conv;
40115         this_arg_conv.inner = (void*)(this_arg & (~1));
40116         this_arg_conv.is_owned = false;
40117         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40118         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
40119         *ret_copy = DirectedChannelInfo_effective_capacity(&this_arg_conv);
40120         uint32_t ret_ref = (uintptr_t)ret_copy;
40121         return ret_ref;
40122 }
40123
40124 void  __attribute__((export_name("TS_EffectiveCapacity_free"))) TS_EffectiveCapacity_free(uint32_t this_ptr) {
40125         if ((this_ptr & 1) != 0) return;
40126         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
40127         CHECK_ACCESS(this_ptr_ptr);
40128         LDKEffectiveCapacity this_ptr_conv = *(LDKEffectiveCapacity*)(this_ptr_ptr);
40129         FREE((void*)this_ptr);
40130         EffectiveCapacity_free(this_ptr_conv);
40131 }
40132
40133 static inline uintptr_t EffectiveCapacity_clone_ptr(LDKEffectiveCapacity *NONNULL_PTR arg) {
40134         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
40135         *ret_copy = EffectiveCapacity_clone(arg);
40136 uint32_t ret_ref = (uintptr_t)ret_copy;
40137         return ret_ref;
40138 }
40139 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_clone_ptr"))) TS_EffectiveCapacity_clone_ptr(uint32_t arg) {
40140         LDKEffectiveCapacity* arg_conv = (LDKEffectiveCapacity*)arg;
40141         uint32_t ret_conv = EffectiveCapacity_clone_ptr(arg_conv);
40142         return ret_conv;
40143 }
40144
40145 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_clone"))) TS_EffectiveCapacity_clone(uint32_t orig) {
40146         LDKEffectiveCapacity* orig_conv = (LDKEffectiveCapacity*)orig;
40147         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
40148         *ret_copy = EffectiveCapacity_clone(orig_conv);
40149         uint32_t ret_ref = (uintptr_t)ret_copy;
40150         return ret_ref;
40151 }
40152
40153 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_exact_liquidity"))) TS_EffectiveCapacity_exact_liquidity(int64_t liquidity_msat) {
40154         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
40155         *ret_copy = EffectiveCapacity_exact_liquidity(liquidity_msat);
40156         uint32_t ret_ref = (uintptr_t)ret_copy;
40157         return ret_ref;
40158 }
40159
40160 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_maximum_htlc"))) TS_EffectiveCapacity_maximum_htlc(int64_t amount_msat) {
40161         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
40162         *ret_copy = EffectiveCapacity_maximum_htlc(amount_msat);
40163         uint32_t ret_ref = (uintptr_t)ret_copy;
40164         return ret_ref;
40165 }
40166
40167 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_total"))) TS_EffectiveCapacity_total(int64_t capacity_msat, uint32_t htlc_maximum_msat) {
40168         void* htlc_maximum_msat_ptr = (void*)(((uintptr_t)htlc_maximum_msat) & ~1);
40169         CHECK_ACCESS(htlc_maximum_msat_ptr);
40170         LDKCOption_u64Z htlc_maximum_msat_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_ptr);
40171         htlc_maximum_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_maximum_msat) & ~1));
40172         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
40173         *ret_copy = EffectiveCapacity_total(capacity_msat, htlc_maximum_msat_conv);
40174         uint32_t ret_ref = (uintptr_t)ret_copy;
40175         return ret_ref;
40176 }
40177
40178 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_infinite"))) TS_EffectiveCapacity_infinite() {
40179         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
40180         *ret_copy = EffectiveCapacity_infinite();
40181         uint32_t ret_ref = (uintptr_t)ret_copy;
40182         return ret_ref;
40183 }
40184
40185 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_unknown"))) TS_EffectiveCapacity_unknown() {
40186         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
40187         *ret_copy = EffectiveCapacity_unknown();
40188         uint32_t ret_ref = (uintptr_t)ret_copy;
40189         return ret_ref;
40190 }
40191
40192 int64_t  __attribute__((export_name("TS_EffectiveCapacity_as_msat"))) TS_EffectiveCapacity_as_msat(uint32_t this_arg) {
40193         LDKEffectiveCapacity* this_arg_conv = (LDKEffectiveCapacity*)this_arg;
40194         int64_t ret_conv = EffectiveCapacity_as_msat(this_arg_conv);
40195         return ret_conv;
40196 }
40197
40198 void  __attribute__((export_name("TS_RoutingFees_free"))) TS_RoutingFees_free(uint32_t this_obj) {
40199         LDKRoutingFees this_obj_conv;
40200         this_obj_conv.inner = (void*)(this_obj & (~1));
40201         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40202         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40203         RoutingFees_free(this_obj_conv);
40204 }
40205
40206 int32_t  __attribute__((export_name("TS_RoutingFees_get_base_msat"))) TS_RoutingFees_get_base_msat(uint32_t this_ptr) {
40207         LDKRoutingFees this_ptr_conv;
40208         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40209         this_ptr_conv.is_owned = false;
40210         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40211         int32_t ret_conv = RoutingFees_get_base_msat(&this_ptr_conv);
40212         return ret_conv;
40213 }
40214
40215 void  __attribute__((export_name("TS_RoutingFees_set_base_msat"))) TS_RoutingFees_set_base_msat(uint32_t this_ptr, int32_t val) {
40216         LDKRoutingFees this_ptr_conv;
40217         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40218         this_ptr_conv.is_owned = false;
40219         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40220         RoutingFees_set_base_msat(&this_ptr_conv, val);
40221 }
40222
40223 int32_t  __attribute__((export_name("TS_RoutingFees_get_proportional_millionths"))) TS_RoutingFees_get_proportional_millionths(uint32_t this_ptr) {
40224         LDKRoutingFees this_ptr_conv;
40225         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40226         this_ptr_conv.is_owned = false;
40227         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40228         int32_t ret_conv = RoutingFees_get_proportional_millionths(&this_ptr_conv);
40229         return ret_conv;
40230 }
40231
40232 void  __attribute__((export_name("TS_RoutingFees_set_proportional_millionths"))) TS_RoutingFees_set_proportional_millionths(uint32_t this_ptr, int32_t val) {
40233         LDKRoutingFees this_ptr_conv;
40234         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40235         this_ptr_conv.is_owned = false;
40236         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40237         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
40238 }
40239
40240 uint32_t  __attribute__((export_name("TS_RoutingFees_new"))) TS_RoutingFees_new(int32_t base_msat_arg, int32_t proportional_millionths_arg) {
40241         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
40242         uint32_t ret_ref = 0;
40243         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40244         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40245         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40246         ret_ref = (uintptr_t)ret_var.inner;
40247         if (ret_var.is_owned) {
40248                 ret_ref |= 1;
40249         }
40250         return ret_ref;
40251 }
40252
40253 jboolean  __attribute__((export_name("TS_RoutingFees_eq"))) TS_RoutingFees_eq(uint32_t a, uint32_t b) {
40254         LDKRoutingFees a_conv;
40255         a_conv.inner = (void*)(a & (~1));
40256         a_conv.is_owned = false;
40257         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40258         LDKRoutingFees b_conv;
40259         b_conv.inner = (void*)(b & (~1));
40260         b_conv.is_owned = false;
40261         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40262         jboolean ret_conv = RoutingFees_eq(&a_conv, &b_conv);
40263         return ret_conv;
40264 }
40265
40266 static inline uintptr_t RoutingFees_clone_ptr(LDKRoutingFees *NONNULL_PTR arg) {
40267         LDKRoutingFees ret_var = RoutingFees_clone(arg);
40268 uint32_t ret_ref = 0;
40269 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40270 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40271 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40272 ret_ref = (uintptr_t)ret_var.inner;
40273 if (ret_var.is_owned) {
40274         ret_ref |= 1;
40275 }
40276         return ret_ref;
40277 }
40278 uint32_t  __attribute__((export_name("TS_RoutingFees_clone_ptr"))) TS_RoutingFees_clone_ptr(uint32_t arg) {
40279         LDKRoutingFees arg_conv;
40280         arg_conv.inner = (void*)(arg & (~1));
40281         arg_conv.is_owned = false;
40282         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40283         uint32_t ret_conv = RoutingFees_clone_ptr(&arg_conv);
40284         return ret_conv;
40285 }
40286
40287 uint32_t  __attribute__((export_name("TS_RoutingFees_clone"))) TS_RoutingFees_clone(uint32_t orig) {
40288         LDKRoutingFees orig_conv;
40289         orig_conv.inner = (void*)(orig & (~1));
40290         orig_conv.is_owned = false;
40291         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40292         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
40293         uint32_t ret_ref = 0;
40294         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40295         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40296         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40297         ret_ref = (uintptr_t)ret_var.inner;
40298         if (ret_var.is_owned) {
40299                 ret_ref |= 1;
40300         }
40301         return ret_ref;
40302 }
40303
40304 int64_t  __attribute__((export_name("TS_RoutingFees_hash"))) TS_RoutingFees_hash(uint32_t o) {
40305         LDKRoutingFees o_conv;
40306         o_conv.inner = (void*)(o & (~1));
40307         o_conv.is_owned = false;
40308         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
40309         int64_t ret_conv = RoutingFees_hash(&o_conv);
40310         return ret_conv;
40311 }
40312
40313 int8_tArray  __attribute__((export_name("TS_RoutingFees_write"))) TS_RoutingFees_write(uint32_t obj) {
40314         LDKRoutingFees obj_conv;
40315         obj_conv.inner = (void*)(obj & (~1));
40316         obj_conv.is_owned = false;
40317         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40318         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
40319         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
40320         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
40321         CVec_u8Z_free(ret_var);
40322         return ret_arr;
40323 }
40324
40325 uint32_t  __attribute__((export_name("TS_RoutingFees_read"))) TS_RoutingFees_read(int8_tArray ser) {
40326         LDKu8slice ser_ref;
40327         ser_ref.datalen = ser->arr_len;
40328         ser_ref.data = ser->elems;
40329         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
40330         *ret_conv = RoutingFees_read(ser_ref);
40331         FREE(ser);
40332         return (uint32_t)ret_conv;
40333 }
40334
40335 void  __attribute__((export_name("TS_NodeAnnouncementInfo_free"))) TS_NodeAnnouncementInfo_free(uint32_t this_obj) {
40336         LDKNodeAnnouncementInfo this_obj_conv;
40337         this_obj_conv.inner = (void*)(this_obj & (~1));
40338         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40339         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40340         NodeAnnouncementInfo_free(this_obj_conv);
40341 }
40342
40343 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_get_features"))) TS_NodeAnnouncementInfo_get_features(uint32_t this_ptr) {
40344         LDKNodeAnnouncementInfo this_ptr_conv;
40345         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40346         this_ptr_conv.is_owned = false;
40347         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40348         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
40349         uint32_t ret_ref = 0;
40350         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40351         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40352         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40353         ret_ref = (uintptr_t)ret_var.inner;
40354         if (ret_var.is_owned) {
40355                 ret_ref |= 1;
40356         }
40357         return ret_ref;
40358 }
40359
40360 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_features"))) TS_NodeAnnouncementInfo_set_features(uint32_t this_ptr, uint32_t val) {
40361         LDKNodeAnnouncementInfo this_ptr_conv;
40362         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40363         this_ptr_conv.is_owned = false;
40364         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40365         LDKNodeFeatures val_conv;
40366         val_conv.inner = (void*)(val & (~1));
40367         val_conv.is_owned = (val & 1) || (val == 0);
40368         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40369         val_conv = NodeFeatures_clone(&val_conv);
40370         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
40371 }
40372
40373 int32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_get_last_update"))) TS_NodeAnnouncementInfo_get_last_update(uint32_t this_ptr) {
40374         LDKNodeAnnouncementInfo this_ptr_conv;
40375         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40376         this_ptr_conv.is_owned = false;
40377         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40378         int32_t ret_conv = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
40379         return ret_conv;
40380 }
40381
40382 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_last_update"))) TS_NodeAnnouncementInfo_set_last_update(uint32_t this_ptr, int32_t val) {
40383         LDKNodeAnnouncementInfo this_ptr_conv;
40384         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40385         this_ptr_conv.is_owned = false;
40386         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40387         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
40388 }
40389
40390 int8_tArray  __attribute__((export_name("TS_NodeAnnouncementInfo_get_rgb"))) TS_NodeAnnouncementInfo_get_rgb(uint32_t this_ptr) {
40391         LDKNodeAnnouncementInfo this_ptr_conv;
40392         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40393         this_ptr_conv.is_owned = false;
40394         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40395         int8_tArray ret_arr = init_int8_tArray(3, __LINE__);
40396         memcpy(ret_arr->elems, *NodeAnnouncementInfo_get_rgb(&this_ptr_conv), 3);
40397         return ret_arr;
40398 }
40399
40400 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_rgb"))) TS_NodeAnnouncementInfo_set_rgb(uint32_t this_ptr, int8_tArray val) {
40401         LDKNodeAnnouncementInfo this_ptr_conv;
40402         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40403         this_ptr_conv.is_owned = false;
40404         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40405         LDKThreeBytes val_ref;
40406         CHECK(val->arr_len == 3);
40407         memcpy(val_ref.data, val->elems, 3); FREE(val);
40408         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
40409 }
40410
40411 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_get_alias"))) TS_NodeAnnouncementInfo_get_alias(uint32_t this_ptr) {
40412         LDKNodeAnnouncementInfo this_ptr_conv;
40413         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40414         this_ptr_conv.is_owned = false;
40415         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40416         LDKNodeAlias ret_var = NodeAnnouncementInfo_get_alias(&this_ptr_conv);
40417         uint32_t ret_ref = 0;
40418         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40419         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40420         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40421         ret_ref = (uintptr_t)ret_var.inner;
40422         if (ret_var.is_owned) {
40423                 ret_ref |= 1;
40424         }
40425         return ret_ref;
40426 }
40427
40428 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_alias"))) TS_NodeAnnouncementInfo_set_alias(uint32_t this_ptr, uint32_t val) {
40429         LDKNodeAnnouncementInfo this_ptr_conv;
40430         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40431         this_ptr_conv.is_owned = false;
40432         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40433         LDKNodeAlias val_conv;
40434         val_conv.inner = (void*)(val & (~1));
40435         val_conv.is_owned = (val & 1) || (val == 0);
40436         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40437         val_conv = NodeAlias_clone(&val_conv);
40438         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_conv);
40439 }
40440
40441 uint32_tArray  __attribute__((export_name("TS_NodeAnnouncementInfo_get_addresses"))) TS_NodeAnnouncementInfo_get_addresses(uint32_t this_ptr) {
40442         LDKNodeAnnouncementInfo this_ptr_conv;
40443         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40444         this_ptr_conv.is_owned = false;
40445         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40446         LDKCVec_NetAddressZ ret_var = NodeAnnouncementInfo_get_addresses(&this_ptr_conv);
40447         uint32_tArray ret_arr = NULL;
40448         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
40449         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 8);
40450         for (size_t m = 0; m < ret_var.datalen; m++) {
40451                 LDKNetAddress *ret_conv_12_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
40452                 *ret_conv_12_copy = ret_var.data[m];
40453                 uint32_t ret_conv_12_ref = (uintptr_t)ret_conv_12_copy;
40454                 ret_arr_ptr[m] = ret_conv_12_ref;
40455         }
40456         
40457         FREE(ret_var.data);
40458         return ret_arr;
40459 }
40460
40461 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_addresses"))) TS_NodeAnnouncementInfo_set_addresses(uint32_t this_ptr, uint32_tArray val) {
40462         LDKNodeAnnouncementInfo this_ptr_conv;
40463         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40464         this_ptr_conv.is_owned = false;
40465         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40466         LDKCVec_NetAddressZ val_constr;
40467         val_constr.datalen = val->arr_len;
40468         if (val_constr.datalen > 0)
40469                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
40470         else
40471                 val_constr.data = NULL;
40472         uint32_t* val_vals = val->elems;
40473         for (size_t m = 0; m < val_constr.datalen; m++) {
40474                 uint32_t val_conv_12 = val_vals[m];
40475                 void* val_conv_12_ptr = (void*)(((uintptr_t)val_conv_12) & ~1);
40476                 CHECK_ACCESS(val_conv_12_ptr);
40477                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
40478                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)val_conv_12) & ~1));
40479                 val_constr.data[m] = val_conv_12_conv;
40480         }
40481         FREE(val);
40482         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
40483 }
40484
40485 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_get_announcement_message"))) TS_NodeAnnouncementInfo_get_announcement_message(uint32_t this_ptr) {
40486         LDKNodeAnnouncementInfo this_ptr_conv;
40487         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40488         this_ptr_conv.is_owned = false;
40489         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40490         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
40491         uint32_t ret_ref = 0;
40492         if ((uintptr_t)ret_var.inner > 4096) {
40493                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40494                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40495         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40496                 ret_ref = (uintptr_t)ret_var.inner;
40497                 if (ret_var.is_owned) {
40498                         ret_ref |= 1;
40499                 }
40500         }
40501         return ret_ref;
40502 }
40503
40504 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_announcement_message"))) TS_NodeAnnouncementInfo_set_announcement_message(uint32_t this_ptr, uint32_t val) {
40505         LDKNodeAnnouncementInfo this_ptr_conv;
40506         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40507         this_ptr_conv.is_owned = false;
40508         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40509         LDKNodeAnnouncement val_conv;
40510         val_conv.inner = (void*)(val & (~1));
40511         val_conv.is_owned = (val & 1) || (val == 0);
40512         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40513         val_conv = NodeAnnouncement_clone(&val_conv);
40514         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
40515 }
40516
40517 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) {
40518         LDKNodeFeatures features_arg_conv;
40519         features_arg_conv.inner = (void*)(features_arg & (~1));
40520         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
40521         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
40522         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
40523         LDKThreeBytes rgb_arg_ref;
40524         CHECK(rgb_arg->arr_len == 3);
40525         memcpy(rgb_arg_ref.data, rgb_arg->elems, 3); FREE(rgb_arg);
40526         LDKNodeAlias alias_arg_conv;
40527         alias_arg_conv.inner = (void*)(alias_arg & (~1));
40528         alias_arg_conv.is_owned = (alias_arg & 1) || (alias_arg == 0);
40529         CHECK_INNER_FIELD_ACCESS_OR_NULL(alias_arg_conv);
40530         alias_arg_conv = NodeAlias_clone(&alias_arg_conv);
40531         LDKCVec_NetAddressZ addresses_arg_constr;
40532         addresses_arg_constr.datalen = addresses_arg->arr_len;
40533         if (addresses_arg_constr.datalen > 0)
40534                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
40535         else
40536                 addresses_arg_constr.data = NULL;
40537         uint32_t* addresses_arg_vals = addresses_arg->elems;
40538         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
40539                 uint32_t addresses_arg_conv_12 = addresses_arg_vals[m];
40540                 void* addresses_arg_conv_12_ptr = (void*)(((uintptr_t)addresses_arg_conv_12) & ~1);
40541                 CHECK_ACCESS(addresses_arg_conv_12_ptr);
40542                 LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(addresses_arg_conv_12_ptr);
40543                 addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
40544         }
40545         FREE(addresses_arg);
40546         LDKNodeAnnouncement announcement_message_arg_conv;
40547         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
40548         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
40549         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_message_arg_conv);
40550         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
40551         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_conv, addresses_arg_constr, announcement_message_arg_conv);
40552         uint32_t ret_ref = 0;
40553         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40554         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40555         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40556         ret_ref = (uintptr_t)ret_var.inner;
40557         if (ret_var.is_owned) {
40558                 ret_ref |= 1;
40559         }
40560         return ret_ref;
40561 }
40562
40563 static inline uintptr_t NodeAnnouncementInfo_clone_ptr(LDKNodeAnnouncementInfo *NONNULL_PTR arg) {
40564         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(arg);
40565 uint32_t ret_ref = 0;
40566 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40567 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40568 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40569 ret_ref = (uintptr_t)ret_var.inner;
40570 if (ret_var.is_owned) {
40571         ret_ref |= 1;
40572 }
40573         return ret_ref;
40574 }
40575 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_clone_ptr"))) TS_NodeAnnouncementInfo_clone_ptr(uint32_t arg) {
40576         LDKNodeAnnouncementInfo arg_conv;
40577         arg_conv.inner = (void*)(arg & (~1));
40578         arg_conv.is_owned = false;
40579         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40580         uint32_t ret_conv = NodeAnnouncementInfo_clone_ptr(&arg_conv);
40581         return ret_conv;
40582 }
40583
40584 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_clone"))) TS_NodeAnnouncementInfo_clone(uint32_t orig) {
40585         LDKNodeAnnouncementInfo orig_conv;
40586         orig_conv.inner = (void*)(orig & (~1));
40587         orig_conv.is_owned = false;
40588         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40589         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
40590         uint32_t ret_ref = 0;
40591         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40592         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40593         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40594         ret_ref = (uintptr_t)ret_var.inner;
40595         if (ret_var.is_owned) {
40596                 ret_ref |= 1;
40597         }
40598         return ret_ref;
40599 }
40600
40601 int8_tArray  __attribute__((export_name("TS_NodeAnnouncementInfo_write"))) TS_NodeAnnouncementInfo_write(uint32_t obj) {
40602         LDKNodeAnnouncementInfo obj_conv;
40603         obj_conv.inner = (void*)(obj & (~1));
40604         obj_conv.is_owned = false;
40605         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40606         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
40607         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
40608         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
40609         CVec_u8Z_free(ret_var);
40610         return ret_arr;
40611 }
40612
40613 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_read"))) TS_NodeAnnouncementInfo_read(int8_tArray ser) {
40614         LDKu8slice ser_ref;
40615         ser_ref.datalen = ser->arr_len;
40616         ser_ref.data = ser->elems;
40617         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
40618         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
40619         FREE(ser);
40620         return (uint32_t)ret_conv;
40621 }
40622
40623 void  __attribute__((export_name("TS_NodeAlias_free"))) TS_NodeAlias_free(uint32_t this_obj) {
40624         LDKNodeAlias this_obj_conv;
40625         this_obj_conv.inner = (void*)(this_obj & (~1));
40626         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40627         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40628         NodeAlias_free(this_obj_conv);
40629 }
40630
40631 int8_tArray  __attribute__((export_name("TS_NodeAlias_get_a"))) TS_NodeAlias_get_a(uint32_t this_ptr) {
40632         LDKNodeAlias this_ptr_conv;
40633         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40634         this_ptr_conv.is_owned = false;
40635         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40636         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
40637         memcpy(ret_arr->elems, *NodeAlias_get_a(&this_ptr_conv), 32);
40638         return ret_arr;
40639 }
40640
40641 void  __attribute__((export_name("TS_NodeAlias_set_a"))) TS_NodeAlias_set_a(uint32_t this_ptr, int8_tArray val) {
40642         LDKNodeAlias this_ptr_conv;
40643         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40644         this_ptr_conv.is_owned = false;
40645         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40646         LDKThirtyTwoBytes val_ref;
40647         CHECK(val->arr_len == 32);
40648         memcpy(val_ref.data, val->elems, 32); FREE(val);
40649         NodeAlias_set_a(&this_ptr_conv, val_ref);
40650 }
40651
40652 uint32_t  __attribute__((export_name("TS_NodeAlias_new"))) TS_NodeAlias_new(int8_tArray a_arg) {
40653         LDKThirtyTwoBytes a_arg_ref;
40654         CHECK(a_arg->arr_len == 32);
40655         memcpy(a_arg_ref.data, a_arg->elems, 32); FREE(a_arg);
40656         LDKNodeAlias ret_var = NodeAlias_new(a_arg_ref);
40657         uint32_t ret_ref = 0;
40658         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40659         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40660         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40661         ret_ref = (uintptr_t)ret_var.inner;
40662         if (ret_var.is_owned) {
40663                 ret_ref |= 1;
40664         }
40665         return ret_ref;
40666 }
40667
40668 static inline uintptr_t NodeAlias_clone_ptr(LDKNodeAlias *NONNULL_PTR arg) {
40669         LDKNodeAlias ret_var = NodeAlias_clone(arg);
40670 uint32_t ret_ref = 0;
40671 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40672 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40673 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40674 ret_ref = (uintptr_t)ret_var.inner;
40675 if (ret_var.is_owned) {
40676         ret_ref |= 1;
40677 }
40678         return ret_ref;
40679 }
40680 uint32_t  __attribute__((export_name("TS_NodeAlias_clone_ptr"))) TS_NodeAlias_clone_ptr(uint32_t arg) {
40681         LDKNodeAlias arg_conv;
40682         arg_conv.inner = (void*)(arg & (~1));
40683         arg_conv.is_owned = false;
40684         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40685         uint32_t ret_conv = NodeAlias_clone_ptr(&arg_conv);
40686         return ret_conv;
40687 }
40688
40689 uint32_t  __attribute__((export_name("TS_NodeAlias_clone"))) TS_NodeAlias_clone(uint32_t orig) {
40690         LDKNodeAlias orig_conv;
40691         orig_conv.inner = (void*)(orig & (~1));
40692         orig_conv.is_owned = false;
40693         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40694         LDKNodeAlias ret_var = NodeAlias_clone(&orig_conv);
40695         uint32_t ret_ref = 0;
40696         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40697         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40698         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40699         ret_ref = (uintptr_t)ret_var.inner;
40700         if (ret_var.is_owned) {
40701                 ret_ref |= 1;
40702         }
40703         return ret_ref;
40704 }
40705
40706 int8_tArray  __attribute__((export_name("TS_NodeAlias_write"))) TS_NodeAlias_write(uint32_t obj) {
40707         LDKNodeAlias obj_conv;
40708         obj_conv.inner = (void*)(obj & (~1));
40709         obj_conv.is_owned = false;
40710         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40711         LDKCVec_u8Z ret_var = NodeAlias_write(&obj_conv);
40712         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
40713         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
40714         CVec_u8Z_free(ret_var);
40715         return ret_arr;
40716 }
40717
40718 uint32_t  __attribute__((export_name("TS_NodeAlias_read"))) TS_NodeAlias_read(int8_tArray ser) {
40719         LDKu8slice ser_ref;
40720         ser_ref.datalen = ser->arr_len;
40721         ser_ref.data = ser->elems;
40722         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
40723         *ret_conv = NodeAlias_read(ser_ref);
40724         FREE(ser);
40725         return (uint32_t)ret_conv;
40726 }
40727
40728 void  __attribute__((export_name("TS_NodeInfo_free"))) TS_NodeInfo_free(uint32_t this_obj) {
40729         LDKNodeInfo this_obj_conv;
40730         this_obj_conv.inner = (void*)(this_obj & (~1));
40731         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40732         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40733         NodeInfo_free(this_obj_conv);
40734 }
40735
40736 int64_tArray  __attribute__((export_name("TS_NodeInfo_get_channels"))) TS_NodeInfo_get_channels(uint32_t this_ptr) {
40737         LDKNodeInfo this_ptr_conv;
40738         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40739         this_ptr_conv.is_owned = false;
40740         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40741         LDKCVec_u64Z ret_var = NodeInfo_get_channels(&this_ptr_conv);
40742         int64_tArray ret_arr = NULL;
40743         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
40744         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
40745         for (size_t i = 0; i < ret_var.datalen; i++) {
40746                 int64_t ret_conv_8_conv = ret_var.data[i];
40747                 ret_arr_ptr[i] = ret_conv_8_conv;
40748         }
40749         
40750         FREE(ret_var.data);
40751         return ret_arr;
40752 }
40753
40754 void  __attribute__((export_name("TS_NodeInfo_set_channels"))) TS_NodeInfo_set_channels(uint32_t this_ptr, int64_tArray val) {
40755         LDKNodeInfo this_ptr_conv;
40756         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40757         this_ptr_conv.is_owned = false;
40758         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40759         LDKCVec_u64Z val_constr;
40760         val_constr.datalen = val->arr_len;
40761         if (val_constr.datalen > 0)
40762                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
40763         else
40764                 val_constr.data = NULL;
40765         int64_t* val_vals = val->elems;
40766         for (size_t i = 0; i < val_constr.datalen; i++) {
40767                 int64_t val_conv_8 = val_vals[i];
40768                 val_constr.data[i] = val_conv_8;
40769         }
40770         FREE(val);
40771         NodeInfo_set_channels(&this_ptr_conv, val_constr);
40772 }
40773
40774 uint32_t  __attribute__((export_name("TS_NodeInfo_get_lowest_inbound_channel_fees"))) TS_NodeInfo_get_lowest_inbound_channel_fees(uint32_t this_ptr) {
40775         LDKNodeInfo this_ptr_conv;
40776         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40777         this_ptr_conv.is_owned = false;
40778         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40779         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
40780         uint32_t ret_ref = 0;
40781         if ((uintptr_t)ret_var.inner > 4096) {
40782                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40783                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40784         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40785                 ret_ref = (uintptr_t)ret_var.inner;
40786                 if (ret_var.is_owned) {
40787                         ret_ref |= 1;
40788                 }
40789         }
40790         return ret_ref;
40791 }
40792
40793 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) {
40794         LDKNodeInfo this_ptr_conv;
40795         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40796         this_ptr_conv.is_owned = false;
40797         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40798         LDKRoutingFees val_conv;
40799         val_conv.inner = (void*)(val & (~1));
40800         val_conv.is_owned = (val & 1) || (val == 0);
40801         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40802         val_conv = RoutingFees_clone(&val_conv);
40803         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
40804 }
40805
40806 uint32_t  __attribute__((export_name("TS_NodeInfo_get_announcement_info"))) TS_NodeInfo_get_announcement_info(uint32_t this_ptr) {
40807         LDKNodeInfo this_ptr_conv;
40808         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40809         this_ptr_conv.is_owned = false;
40810         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40811         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
40812         uint32_t ret_ref = 0;
40813         if ((uintptr_t)ret_var.inner > 4096) {
40814                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40815                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40816         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40817                 ret_ref = (uintptr_t)ret_var.inner;
40818                 if (ret_var.is_owned) {
40819                         ret_ref |= 1;
40820                 }
40821         }
40822         return ret_ref;
40823 }
40824
40825 void  __attribute__((export_name("TS_NodeInfo_set_announcement_info"))) TS_NodeInfo_set_announcement_info(uint32_t this_ptr, uint32_t val) {
40826         LDKNodeInfo this_ptr_conv;
40827         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40828         this_ptr_conv.is_owned = false;
40829         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40830         LDKNodeAnnouncementInfo val_conv;
40831         val_conv.inner = (void*)(val & (~1));
40832         val_conv.is_owned = (val & 1) || (val == 0);
40833         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40834         val_conv = NodeAnnouncementInfo_clone(&val_conv);
40835         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
40836 }
40837
40838 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) {
40839         LDKCVec_u64Z channels_arg_constr;
40840         channels_arg_constr.datalen = channels_arg->arr_len;
40841         if (channels_arg_constr.datalen > 0)
40842                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
40843         else
40844                 channels_arg_constr.data = NULL;
40845         int64_t* channels_arg_vals = channels_arg->elems;
40846         for (size_t i = 0; i < channels_arg_constr.datalen; i++) {
40847                 int64_t channels_arg_conv_8 = channels_arg_vals[i];
40848                 channels_arg_constr.data[i] = channels_arg_conv_8;
40849         }
40850         FREE(channels_arg);
40851         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
40852         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
40853         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
40854         CHECK_INNER_FIELD_ACCESS_OR_NULL(lowest_inbound_channel_fees_arg_conv);
40855         lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
40856         LDKNodeAnnouncementInfo announcement_info_arg_conv;
40857         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
40858         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
40859         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_info_arg_conv);
40860         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
40861         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
40862         uint32_t ret_ref = 0;
40863         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40864         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40865         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40866         ret_ref = (uintptr_t)ret_var.inner;
40867         if (ret_var.is_owned) {
40868                 ret_ref |= 1;
40869         }
40870         return ret_ref;
40871 }
40872
40873 static inline uintptr_t NodeInfo_clone_ptr(LDKNodeInfo *NONNULL_PTR arg) {
40874         LDKNodeInfo ret_var = NodeInfo_clone(arg);
40875 uint32_t ret_ref = 0;
40876 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40877 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40878 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40879 ret_ref = (uintptr_t)ret_var.inner;
40880 if (ret_var.is_owned) {
40881         ret_ref |= 1;
40882 }
40883         return ret_ref;
40884 }
40885 uint32_t  __attribute__((export_name("TS_NodeInfo_clone_ptr"))) TS_NodeInfo_clone_ptr(uint32_t arg) {
40886         LDKNodeInfo arg_conv;
40887         arg_conv.inner = (void*)(arg & (~1));
40888         arg_conv.is_owned = false;
40889         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40890         uint32_t ret_conv = NodeInfo_clone_ptr(&arg_conv);
40891         return ret_conv;
40892 }
40893
40894 uint32_t  __attribute__((export_name("TS_NodeInfo_clone"))) TS_NodeInfo_clone(uint32_t orig) {
40895         LDKNodeInfo orig_conv;
40896         orig_conv.inner = (void*)(orig & (~1));
40897         orig_conv.is_owned = false;
40898         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40899         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
40900         uint32_t ret_ref = 0;
40901         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40902         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40903         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40904         ret_ref = (uintptr_t)ret_var.inner;
40905         if (ret_var.is_owned) {
40906                 ret_ref |= 1;
40907         }
40908         return ret_ref;
40909 }
40910
40911 int8_tArray  __attribute__((export_name("TS_NodeInfo_write"))) TS_NodeInfo_write(uint32_t obj) {
40912         LDKNodeInfo obj_conv;
40913         obj_conv.inner = (void*)(obj & (~1));
40914         obj_conv.is_owned = false;
40915         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40916         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
40917         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
40918         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
40919         CVec_u8Z_free(ret_var);
40920         return ret_arr;
40921 }
40922
40923 uint32_t  __attribute__((export_name("TS_NodeInfo_read"))) TS_NodeInfo_read(int8_tArray ser) {
40924         LDKu8slice ser_ref;
40925         ser_ref.datalen = ser->arr_len;
40926         ser_ref.data = ser->elems;
40927         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
40928         *ret_conv = NodeInfo_read(ser_ref);
40929         FREE(ser);
40930         return (uint32_t)ret_conv;
40931 }
40932
40933 int8_tArray  __attribute__((export_name("TS_NetworkGraph_write"))) TS_NetworkGraph_write(uint32_t obj) {
40934         LDKNetworkGraph obj_conv;
40935         obj_conv.inner = (void*)(obj & (~1));
40936         obj_conv.is_owned = false;
40937         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40938         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
40939         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
40940         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
40941         CVec_u8Z_free(ret_var);
40942         return ret_arr;
40943 }
40944
40945 uint32_t  __attribute__((export_name("TS_NetworkGraph_read"))) TS_NetworkGraph_read(int8_tArray ser, uint32_t arg) {
40946         LDKu8slice ser_ref;
40947         ser_ref.datalen = ser->arr_len;
40948         ser_ref.data = ser->elems;
40949         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
40950         CHECK_ACCESS(arg_ptr);
40951         LDKLogger arg_conv = *(LDKLogger*)(arg_ptr);
40952         if (arg_conv.free == LDKLogger_JCalls_free) {
40953                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
40954                 LDKLogger_JCalls_cloned(&arg_conv);
40955         }
40956         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
40957         *ret_conv = NetworkGraph_read(ser_ref, arg_conv);
40958         FREE(ser);
40959         return (uint32_t)ret_conv;
40960 }
40961
40962 uint32_t  __attribute__((export_name("TS_NetworkGraph_new"))) TS_NetworkGraph_new(int8_tArray genesis_hash, uint32_t logger) {
40963         LDKThirtyTwoBytes genesis_hash_ref;
40964         CHECK(genesis_hash->arr_len == 32);
40965         memcpy(genesis_hash_ref.data, genesis_hash->elems, 32); FREE(genesis_hash);
40966         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
40967         CHECK_ACCESS(logger_ptr);
40968         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
40969         if (logger_conv.free == LDKLogger_JCalls_free) {
40970                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
40971                 LDKLogger_JCalls_cloned(&logger_conv);
40972         }
40973         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref, logger_conv);
40974         uint32_t ret_ref = 0;
40975         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40976         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40977         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40978         ret_ref = (uintptr_t)ret_var.inner;
40979         if (ret_var.is_owned) {
40980                 ret_ref |= 1;
40981         }
40982         return ret_ref;
40983 }
40984
40985 uint32_t  __attribute__((export_name("TS_NetworkGraph_read_only"))) TS_NetworkGraph_read_only(uint32_t this_arg) {
40986         LDKNetworkGraph this_arg_conv;
40987         this_arg_conv.inner = (void*)(this_arg & (~1));
40988         this_arg_conv.is_owned = false;
40989         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40990         LDKReadOnlyNetworkGraph ret_var = NetworkGraph_read_only(&this_arg_conv);
40991         uint32_t ret_ref = 0;
40992         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40993         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40994         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40995         ret_ref = (uintptr_t)ret_var.inner;
40996         if (ret_var.is_owned) {
40997                 ret_ref |= 1;
40998         }
40999         return ret_ref;
41000 }
41001
41002 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) {
41003         LDKNetworkGraph this_arg_conv;
41004         this_arg_conv.inner = (void*)(this_arg & (~1));
41005         this_arg_conv.is_owned = false;
41006         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41007         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
41008         *ret_copy = NetworkGraph_get_last_rapid_gossip_sync_timestamp(&this_arg_conv);
41009         uint32_t ret_ref = (uintptr_t)ret_copy;
41010         return ret_ref;
41011 }
41012
41013 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) {
41014         LDKNetworkGraph this_arg_conv;
41015         this_arg_conv.inner = (void*)(this_arg & (~1));
41016         this_arg_conv.is_owned = false;
41017         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41018         NetworkGraph_set_last_rapid_gossip_sync_timestamp(&this_arg_conv, last_rapid_gossip_sync_timestamp);
41019 }
41020
41021 uint32_t  __attribute__((export_name("TS_NetworkGraph_update_node_from_announcement"))) TS_NetworkGraph_update_node_from_announcement(uint32_t this_arg, uint32_t msg) {
41022         LDKNetworkGraph this_arg_conv;
41023         this_arg_conv.inner = (void*)(this_arg & (~1));
41024         this_arg_conv.is_owned = false;
41025         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41026         LDKNodeAnnouncement msg_conv;
41027         msg_conv.inner = (void*)(msg & (~1));
41028         msg_conv.is_owned = false;
41029         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
41030         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
41031         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
41032         return (uint32_t)ret_conv;
41033 }
41034
41035 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) {
41036         LDKNetworkGraph this_arg_conv;
41037         this_arg_conv.inner = (void*)(this_arg & (~1));
41038         this_arg_conv.is_owned = false;
41039         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41040         LDKUnsignedNodeAnnouncement msg_conv;
41041         msg_conv.inner = (void*)(msg & (~1));
41042         msg_conv.is_owned = false;
41043         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
41044         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
41045         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
41046         return (uint32_t)ret_conv;
41047 }
41048
41049 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) {
41050         LDKNetworkGraph this_arg_conv;
41051         this_arg_conv.inner = (void*)(this_arg & (~1));
41052         this_arg_conv.is_owned = false;
41053         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41054         LDKChannelAnnouncement msg_conv;
41055         msg_conv.inner = (void*)(msg & (~1));
41056         msg_conv.is_owned = false;
41057         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
41058         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
41059         CHECK_ACCESS(chain_access_ptr);
41060         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
41061         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
41062         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
41063                 // Manually implement clone for Java trait instances
41064                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
41065                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41066                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
41067                 }
41068         }
41069         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
41070         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
41071         return (uint32_t)ret_conv;
41072 }
41073
41074 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) {
41075         LDKNetworkGraph this_arg_conv;
41076         this_arg_conv.inner = (void*)(this_arg & (~1));
41077         this_arg_conv.is_owned = false;
41078         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41079         LDKUnsignedChannelAnnouncement msg_conv;
41080         msg_conv.inner = (void*)(msg & (~1));
41081         msg_conv.is_owned = false;
41082         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
41083         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
41084         CHECK_ACCESS(chain_access_ptr);
41085         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
41086         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
41087         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
41088                 // Manually implement clone for Java trait instances
41089                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
41090                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41091                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
41092                 }
41093         }
41094         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
41095         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
41096         return (uint32_t)ret_conv;
41097 }
41098
41099 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) {
41100         LDKNetworkGraph this_arg_conv;
41101         this_arg_conv.inner = (void*)(this_arg & (~1));
41102         this_arg_conv.is_owned = false;
41103         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41104         LDKChannelFeatures features_conv;
41105         features_conv.inner = (void*)(features & (~1));
41106         features_conv.is_owned = (features & 1) || (features == 0);
41107         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
41108         features_conv = ChannelFeatures_clone(&features_conv);
41109         LDKPublicKey node_id_1_ref;
41110         CHECK(node_id_1->arr_len == 33);
41111         memcpy(node_id_1_ref.compressed_form, node_id_1->elems, 33); FREE(node_id_1);
41112         LDKPublicKey node_id_2_ref;
41113         CHECK(node_id_2->arr_len == 33);
41114         memcpy(node_id_2_ref.compressed_form, node_id_2->elems, 33); FREE(node_id_2);
41115         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
41116         *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);
41117         return (uint32_t)ret_conv;
41118 }
41119
41120 void  __attribute__((export_name("TS_NetworkGraph_channel_failed"))) TS_NetworkGraph_channel_failed(uint32_t this_arg, int64_t short_channel_id, jboolean is_permanent) {
41121         LDKNetworkGraph this_arg_conv;
41122         this_arg_conv.inner = (void*)(this_arg & (~1));
41123         this_arg_conv.is_owned = false;
41124         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41125         NetworkGraph_channel_failed(&this_arg_conv, short_channel_id, is_permanent);
41126 }
41127
41128 void  __attribute__((export_name("TS_NetworkGraph_node_failed"))) TS_NetworkGraph_node_failed(uint32_t this_arg, int8_tArray _node_id, jboolean is_permanent) {
41129         LDKNetworkGraph this_arg_conv;
41130         this_arg_conv.inner = (void*)(this_arg & (~1));
41131         this_arg_conv.is_owned = false;
41132         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41133         LDKPublicKey _node_id_ref;
41134         CHECK(_node_id->arr_len == 33);
41135         memcpy(_node_id_ref.compressed_form, _node_id->elems, 33); FREE(_node_id);
41136         NetworkGraph_node_failed(&this_arg_conv, _node_id_ref, is_permanent);
41137 }
41138
41139 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) {
41140         LDKNetworkGraph this_arg_conv;
41141         this_arg_conv.inner = (void*)(this_arg & (~1));
41142         this_arg_conv.is_owned = false;
41143         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41144         NetworkGraph_remove_stale_channels_with_time(&this_arg_conv, current_time_unix);
41145 }
41146
41147 uint32_t  __attribute__((export_name("TS_NetworkGraph_update_channel"))) TS_NetworkGraph_update_channel(uint32_t this_arg, uint32_t msg) {
41148         LDKNetworkGraph this_arg_conv;
41149         this_arg_conv.inner = (void*)(this_arg & (~1));
41150         this_arg_conv.is_owned = false;
41151         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41152         LDKChannelUpdate msg_conv;
41153         msg_conv.inner = (void*)(msg & (~1));
41154         msg_conv.is_owned = false;
41155         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
41156         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
41157         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
41158         return (uint32_t)ret_conv;
41159 }
41160
41161 uint32_t  __attribute__((export_name("TS_NetworkGraph_update_channel_unsigned"))) TS_NetworkGraph_update_channel_unsigned(uint32_t this_arg, uint32_t msg) {
41162         LDKNetworkGraph this_arg_conv;
41163         this_arg_conv.inner = (void*)(this_arg & (~1));
41164         this_arg_conv.is_owned = false;
41165         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41166         LDKUnsignedChannelUpdate msg_conv;
41167         msg_conv.inner = (void*)(msg & (~1));
41168         msg_conv.is_owned = false;
41169         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
41170         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
41171         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
41172         return (uint32_t)ret_conv;
41173 }
41174
41175 uint32_t  __attribute__((export_name("TS_ReadOnlyNetworkGraph_channel"))) TS_ReadOnlyNetworkGraph_channel(uint32_t this_arg, int64_t short_channel_id) {
41176         LDKReadOnlyNetworkGraph this_arg_conv;
41177         this_arg_conv.inner = (void*)(this_arg & (~1));
41178         this_arg_conv.is_owned = false;
41179         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41180         LDKChannelInfo ret_var = ReadOnlyNetworkGraph_channel(&this_arg_conv, short_channel_id);
41181         uint32_t ret_ref = 0;
41182         if ((uintptr_t)ret_var.inner > 4096) {
41183                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41184                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41185         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41186                 ret_ref = (uintptr_t)ret_var.inner;
41187                 if (ret_var.is_owned) {
41188                         ret_ref |= 1;
41189                 }
41190         }
41191         return ret_ref;
41192 }
41193
41194 int64_tArray  __attribute__((export_name("TS_ReadOnlyNetworkGraph_list_channels"))) TS_ReadOnlyNetworkGraph_list_channels(uint32_t this_arg) {
41195         LDKReadOnlyNetworkGraph this_arg_conv;
41196         this_arg_conv.inner = (void*)(this_arg & (~1));
41197         this_arg_conv.is_owned = false;
41198         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41199         LDKCVec_u64Z ret_var = ReadOnlyNetworkGraph_list_channels(&this_arg_conv);
41200         int64_tArray ret_arr = NULL;
41201         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
41202         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
41203         for (size_t i = 0; i < ret_var.datalen; i++) {
41204                 int64_t ret_conv_8_conv = ret_var.data[i];
41205                 ret_arr_ptr[i] = ret_conv_8_conv;
41206         }
41207         
41208         FREE(ret_var.data);
41209         return ret_arr;
41210 }
41211
41212 uint32_t  __attribute__((export_name("TS_ReadOnlyNetworkGraph_node"))) TS_ReadOnlyNetworkGraph_node(uint32_t this_arg, uint32_t node_id) {
41213         LDKReadOnlyNetworkGraph this_arg_conv;
41214         this_arg_conv.inner = (void*)(this_arg & (~1));
41215         this_arg_conv.is_owned = false;
41216         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41217         LDKNodeId node_id_conv;
41218         node_id_conv.inner = (void*)(node_id & (~1));
41219         node_id_conv.is_owned = false;
41220         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
41221         LDKNodeInfo ret_var = ReadOnlyNetworkGraph_node(&this_arg_conv, &node_id_conv);
41222         uint32_t ret_ref = 0;
41223         if ((uintptr_t)ret_var.inner > 4096) {
41224                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41225                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41226         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41227                 ret_ref = (uintptr_t)ret_var.inner;
41228                 if (ret_var.is_owned) {
41229                         ret_ref |= 1;
41230                 }
41231         }
41232         return ret_ref;
41233 }
41234
41235 uint32_tArray  __attribute__((export_name("TS_ReadOnlyNetworkGraph_list_nodes"))) TS_ReadOnlyNetworkGraph_list_nodes(uint32_t this_arg) {
41236         LDKReadOnlyNetworkGraph this_arg_conv;
41237         this_arg_conv.inner = (void*)(this_arg & (~1));
41238         this_arg_conv.is_owned = false;
41239         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41240         LDKCVec_NodeIdZ ret_var = ReadOnlyNetworkGraph_list_nodes(&this_arg_conv);
41241         uint32_tArray ret_arr = NULL;
41242         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
41243         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 8);
41244         for (size_t i = 0; i < ret_var.datalen; i++) {
41245                 LDKNodeId ret_conv_8_var = ret_var.data[i];
41246                 uint32_t ret_conv_8_ref = 0;
41247                 CHECK((((uintptr_t)ret_conv_8_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41248                 CHECK((((uintptr_t)&ret_conv_8_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41249                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_8_var);
41250                 ret_conv_8_ref = (uintptr_t)ret_conv_8_var.inner;
41251                 if (ret_conv_8_var.is_owned) {
41252                         ret_conv_8_ref |= 1;
41253                 }
41254                 ret_arr_ptr[i] = ret_conv_8_ref;
41255         }
41256         
41257         FREE(ret_var.data);
41258         return ret_arr;
41259 }
41260
41261 uint32_t  __attribute__((export_name("TS_ReadOnlyNetworkGraph_get_addresses"))) TS_ReadOnlyNetworkGraph_get_addresses(uint32_t this_arg, int8_tArray pubkey) {
41262         LDKReadOnlyNetworkGraph this_arg_conv;
41263         this_arg_conv.inner = (void*)(this_arg & (~1));
41264         this_arg_conv.is_owned = false;
41265         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41266         LDKPublicKey pubkey_ref;
41267         CHECK(pubkey->arr_len == 33);
41268         memcpy(pubkey_ref.compressed_form, pubkey->elems, 33); FREE(pubkey);
41269         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
41270         *ret_copy = ReadOnlyNetworkGraph_get_addresses(&this_arg_conv, pubkey_ref);
41271         uint32_t ret_ref = (uintptr_t)ret_copy;
41272         return ret_ref;
41273 }
41274
41275 void  __attribute__((export_name("TS_RouteHop_free"))) TS_RouteHop_free(uint32_t this_obj) {
41276         LDKRouteHop this_obj_conv;
41277         this_obj_conv.inner = (void*)(this_obj & (~1));
41278         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41279         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41280         RouteHop_free(this_obj_conv);
41281 }
41282
41283 int8_tArray  __attribute__((export_name("TS_RouteHop_get_pubkey"))) TS_RouteHop_get_pubkey(uint32_t this_ptr) {
41284         LDKRouteHop this_ptr_conv;
41285         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41286         this_ptr_conv.is_owned = false;
41287         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41288         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
41289         memcpy(ret_arr->elems, RouteHop_get_pubkey(&this_ptr_conv).compressed_form, 33);
41290         return ret_arr;
41291 }
41292
41293 void  __attribute__((export_name("TS_RouteHop_set_pubkey"))) TS_RouteHop_set_pubkey(uint32_t this_ptr, int8_tArray val) {
41294         LDKRouteHop this_ptr_conv;
41295         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41296         this_ptr_conv.is_owned = false;
41297         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41298         LDKPublicKey val_ref;
41299         CHECK(val->arr_len == 33);
41300         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
41301         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
41302 }
41303
41304 uint32_t  __attribute__((export_name("TS_RouteHop_get_node_features"))) TS_RouteHop_get_node_features(uint32_t this_ptr) {
41305         LDKRouteHop this_ptr_conv;
41306         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41307         this_ptr_conv.is_owned = false;
41308         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41309         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
41310         uint32_t ret_ref = 0;
41311         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41312         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41313         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41314         ret_ref = (uintptr_t)ret_var.inner;
41315         if (ret_var.is_owned) {
41316                 ret_ref |= 1;
41317         }
41318         return ret_ref;
41319 }
41320
41321 void  __attribute__((export_name("TS_RouteHop_set_node_features"))) TS_RouteHop_set_node_features(uint32_t this_ptr, uint32_t val) {
41322         LDKRouteHop this_ptr_conv;
41323         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41324         this_ptr_conv.is_owned = false;
41325         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41326         LDKNodeFeatures val_conv;
41327         val_conv.inner = (void*)(val & (~1));
41328         val_conv.is_owned = (val & 1) || (val == 0);
41329         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
41330         val_conv = NodeFeatures_clone(&val_conv);
41331         RouteHop_set_node_features(&this_ptr_conv, val_conv);
41332 }
41333
41334 int64_t  __attribute__((export_name("TS_RouteHop_get_short_channel_id"))) TS_RouteHop_get_short_channel_id(uint32_t this_ptr) {
41335         LDKRouteHop this_ptr_conv;
41336         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41337         this_ptr_conv.is_owned = false;
41338         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41339         int64_t ret_conv = RouteHop_get_short_channel_id(&this_ptr_conv);
41340         return ret_conv;
41341 }
41342
41343 void  __attribute__((export_name("TS_RouteHop_set_short_channel_id"))) TS_RouteHop_set_short_channel_id(uint32_t this_ptr, int64_t val) {
41344         LDKRouteHop this_ptr_conv;
41345         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41346         this_ptr_conv.is_owned = false;
41347         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41348         RouteHop_set_short_channel_id(&this_ptr_conv, val);
41349 }
41350
41351 uint32_t  __attribute__((export_name("TS_RouteHop_get_channel_features"))) TS_RouteHop_get_channel_features(uint32_t this_ptr) {
41352         LDKRouteHop this_ptr_conv;
41353         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41354         this_ptr_conv.is_owned = false;
41355         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41356         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
41357         uint32_t ret_ref = 0;
41358         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41359         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41360         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41361         ret_ref = (uintptr_t)ret_var.inner;
41362         if (ret_var.is_owned) {
41363                 ret_ref |= 1;
41364         }
41365         return ret_ref;
41366 }
41367
41368 void  __attribute__((export_name("TS_RouteHop_set_channel_features"))) TS_RouteHop_set_channel_features(uint32_t this_ptr, uint32_t val) {
41369         LDKRouteHop this_ptr_conv;
41370         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41371         this_ptr_conv.is_owned = false;
41372         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41373         LDKChannelFeatures val_conv;
41374         val_conv.inner = (void*)(val & (~1));
41375         val_conv.is_owned = (val & 1) || (val == 0);
41376         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
41377         val_conv = ChannelFeatures_clone(&val_conv);
41378         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
41379 }
41380
41381 int64_t  __attribute__((export_name("TS_RouteHop_get_fee_msat"))) TS_RouteHop_get_fee_msat(uint32_t this_ptr) {
41382         LDKRouteHop this_ptr_conv;
41383         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41384         this_ptr_conv.is_owned = false;
41385         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41386         int64_t ret_conv = RouteHop_get_fee_msat(&this_ptr_conv);
41387         return ret_conv;
41388 }
41389
41390 void  __attribute__((export_name("TS_RouteHop_set_fee_msat"))) TS_RouteHop_set_fee_msat(uint32_t this_ptr, int64_t val) {
41391         LDKRouteHop this_ptr_conv;
41392         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41393         this_ptr_conv.is_owned = false;
41394         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41395         RouteHop_set_fee_msat(&this_ptr_conv, val);
41396 }
41397
41398 int32_t  __attribute__((export_name("TS_RouteHop_get_cltv_expiry_delta"))) TS_RouteHop_get_cltv_expiry_delta(uint32_t this_ptr) {
41399         LDKRouteHop this_ptr_conv;
41400         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41401         this_ptr_conv.is_owned = false;
41402         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41403         int32_t ret_conv = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
41404         return ret_conv;
41405 }
41406
41407 void  __attribute__((export_name("TS_RouteHop_set_cltv_expiry_delta"))) TS_RouteHop_set_cltv_expiry_delta(uint32_t this_ptr, int32_t val) {
41408         LDKRouteHop this_ptr_conv;
41409         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41410         this_ptr_conv.is_owned = false;
41411         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41412         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
41413 }
41414
41415 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) {
41416         LDKPublicKey pubkey_arg_ref;
41417         CHECK(pubkey_arg->arr_len == 33);
41418         memcpy(pubkey_arg_ref.compressed_form, pubkey_arg->elems, 33); FREE(pubkey_arg);
41419         LDKNodeFeatures node_features_arg_conv;
41420         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
41421         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
41422         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_features_arg_conv);
41423         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
41424         LDKChannelFeatures channel_features_arg_conv;
41425         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
41426         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
41427         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_features_arg_conv);
41428         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
41429         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);
41430         uint32_t ret_ref = 0;
41431         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41432         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41433         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41434         ret_ref = (uintptr_t)ret_var.inner;
41435         if (ret_var.is_owned) {
41436                 ret_ref |= 1;
41437         }
41438         return ret_ref;
41439 }
41440
41441 static inline uintptr_t RouteHop_clone_ptr(LDKRouteHop *NONNULL_PTR arg) {
41442         LDKRouteHop ret_var = RouteHop_clone(arg);
41443 uint32_t ret_ref = 0;
41444 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41445 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41446 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41447 ret_ref = (uintptr_t)ret_var.inner;
41448 if (ret_var.is_owned) {
41449         ret_ref |= 1;
41450 }
41451         return ret_ref;
41452 }
41453 uint32_t  __attribute__((export_name("TS_RouteHop_clone_ptr"))) TS_RouteHop_clone_ptr(uint32_t arg) {
41454         LDKRouteHop arg_conv;
41455         arg_conv.inner = (void*)(arg & (~1));
41456         arg_conv.is_owned = false;
41457         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41458         uint32_t ret_conv = RouteHop_clone_ptr(&arg_conv);
41459         return ret_conv;
41460 }
41461
41462 uint32_t  __attribute__((export_name("TS_RouteHop_clone"))) TS_RouteHop_clone(uint32_t orig) {
41463         LDKRouteHop orig_conv;
41464         orig_conv.inner = (void*)(orig & (~1));
41465         orig_conv.is_owned = false;
41466         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41467         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
41468         uint32_t ret_ref = 0;
41469         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41470         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41471         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41472         ret_ref = (uintptr_t)ret_var.inner;
41473         if (ret_var.is_owned) {
41474                 ret_ref |= 1;
41475         }
41476         return ret_ref;
41477 }
41478
41479 int64_t  __attribute__((export_name("TS_RouteHop_hash"))) TS_RouteHop_hash(uint32_t o) {
41480         LDKRouteHop o_conv;
41481         o_conv.inner = (void*)(o & (~1));
41482         o_conv.is_owned = false;
41483         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
41484         int64_t ret_conv = RouteHop_hash(&o_conv);
41485         return ret_conv;
41486 }
41487
41488 jboolean  __attribute__((export_name("TS_RouteHop_eq"))) TS_RouteHop_eq(uint32_t a, uint32_t b) {
41489         LDKRouteHop a_conv;
41490         a_conv.inner = (void*)(a & (~1));
41491         a_conv.is_owned = false;
41492         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
41493         LDKRouteHop b_conv;
41494         b_conv.inner = (void*)(b & (~1));
41495         b_conv.is_owned = false;
41496         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
41497         jboolean ret_conv = RouteHop_eq(&a_conv, &b_conv);
41498         return ret_conv;
41499 }
41500
41501 int8_tArray  __attribute__((export_name("TS_RouteHop_write"))) TS_RouteHop_write(uint32_t obj) {
41502         LDKRouteHop obj_conv;
41503         obj_conv.inner = (void*)(obj & (~1));
41504         obj_conv.is_owned = false;
41505         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41506         LDKCVec_u8Z ret_var = RouteHop_write(&obj_conv);
41507         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
41508         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
41509         CVec_u8Z_free(ret_var);
41510         return ret_arr;
41511 }
41512
41513 uint32_t  __attribute__((export_name("TS_RouteHop_read"))) TS_RouteHop_read(int8_tArray ser) {
41514         LDKu8slice ser_ref;
41515         ser_ref.datalen = ser->arr_len;
41516         ser_ref.data = ser->elems;
41517         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
41518         *ret_conv = RouteHop_read(ser_ref);
41519         FREE(ser);
41520         return (uint32_t)ret_conv;
41521 }
41522
41523 void  __attribute__((export_name("TS_Route_free"))) TS_Route_free(uint32_t this_obj) {
41524         LDKRoute this_obj_conv;
41525         this_obj_conv.inner = (void*)(this_obj & (~1));
41526         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41527         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41528         Route_free(this_obj_conv);
41529 }
41530
41531 ptrArray  __attribute__((export_name("TS_Route_get_paths"))) TS_Route_get_paths(uint32_t this_ptr) {
41532         LDKRoute this_ptr_conv;
41533         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41534         this_ptr_conv.is_owned = false;
41535         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41536         LDKCVec_CVec_RouteHopZZ ret_var = Route_get_paths(&this_ptr_conv);
41537         ptrArray ret_arr = NULL;
41538         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
41539         uint32_tArray *ret_arr_ptr = (uint32_tArray*)(((uint8_t*)ret_arr) + 8);
41540         for (size_t m = 0; m < ret_var.datalen; m++) {
41541                 LDKCVec_RouteHopZ ret_conv_12_var = ret_var.data[m];
41542                 uint32_tArray ret_conv_12_arr = NULL;
41543                 ret_conv_12_arr = init_uint32_tArray(ret_conv_12_var.datalen, __LINE__);
41544                 uint32_t *ret_conv_12_arr_ptr = (uint32_t*)(((uint8_t*)ret_conv_12_arr) + 8);
41545                 for (size_t k = 0; k < ret_conv_12_var.datalen; k++) {
41546                         LDKRouteHop ret_conv_12_conv_10_var = ret_conv_12_var.data[k];
41547                         uint32_t ret_conv_12_conv_10_ref = 0;
41548                         CHECK((((uintptr_t)ret_conv_12_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41549                         CHECK((((uintptr_t)&ret_conv_12_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41550                         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_12_conv_10_var);
41551                         ret_conv_12_conv_10_ref = (uintptr_t)ret_conv_12_conv_10_var.inner;
41552                         if (ret_conv_12_conv_10_var.is_owned) {
41553                                 ret_conv_12_conv_10_ref |= 1;
41554                         }
41555                         ret_conv_12_arr_ptr[k] = ret_conv_12_conv_10_ref;
41556                 }
41557                 
41558                 FREE(ret_conv_12_var.data);
41559                 ret_arr_ptr[m] = ret_conv_12_arr;
41560         }
41561         
41562         FREE(ret_var.data);
41563         return ret_arr;
41564 }
41565
41566 void  __attribute__((export_name("TS_Route_set_paths"))) TS_Route_set_paths(uint32_t this_ptr, ptrArray val) {
41567         LDKRoute this_ptr_conv;
41568         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41569         this_ptr_conv.is_owned = false;
41570         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41571         LDKCVec_CVec_RouteHopZZ val_constr;
41572         val_constr.datalen = val->arr_len;
41573         if (val_constr.datalen > 0)
41574                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
41575         else
41576                 val_constr.data = NULL;
41577         uint32_tArray* val_vals = (void*) val->elems;
41578         for (size_t m = 0; m < val_constr.datalen; m++) {
41579                 uint32_tArray val_conv_12 = val_vals[m];
41580                 LDKCVec_RouteHopZ val_conv_12_constr;
41581                 val_conv_12_constr.datalen = val_conv_12->arr_len;
41582                 if (val_conv_12_constr.datalen > 0)
41583                         val_conv_12_constr.data = MALLOC(val_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
41584                 else
41585                         val_conv_12_constr.data = NULL;
41586                 uint32_t* val_conv_12_vals = val_conv_12->elems;
41587                 for (size_t k = 0; k < val_conv_12_constr.datalen; k++) {
41588                         uint32_t val_conv_12_conv_10 = val_conv_12_vals[k];
41589                         LDKRouteHop val_conv_12_conv_10_conv;
41590                         val_conv_12_conv_10_conv.inner = (void*)(val_conv_12_conv_10 & (~1));
41591                         val_conv_12_conv_10_conv.is_owned = (val_conv_12_conv_10 & 1) || (val_conv_12_conv_10 == 0);
41592                         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_12_conv_10_conv);
41593                         val_conv_12_conv_10_conv = RouteHop_clone(&val_conv_12_conv_10_conv);
41594                         val_conv_12_constr.data[k] = val_conv_12_conv_10_conv;
41595                 }
41596                 FREE(val_conv_12);
41597                 val_constr.data[m] = val_conv_12_constr;
41598         }
41599         FREE(val);
41600         Route_set_paths(&this_ptr_conv, val_constr);
41601 }
41602
41603 uint32_t  __attribute__((export_name("TS_Route_get_payment_params"))) TS_Route_get_payment_params(uint32_t this_ptr) {
41604         LDKRoute this_ptr_conv;
41605         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41606         this_ptr_conv.is_owned = false;
41607         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41608         LDKPaymentParameters ret_var = Route_get_payment_params(&this_ptr_conv);
41609         uint32_t ret_ref = 0;
41610         if ((uintptr_t)ret_var.inner > 4096) {
41611                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41612                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41613         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41614                 ret_ref = (uintptr_t)ret_var.inner;
41615                 if (ret_var.is_owned) {
41616                         ret_ref |= 1;
41617                 }
41618         }
41619         return ret_ref;
41620 }
41621
41622 void  __attribute__((export_name("TS_Route_set_payment_params"))) TS_Route_set_payment_params(uint32_t this_ptr, uint32_t val) {
41623         LDKRoute this_ptr_conv;
41624         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41625         this_ptr_conv.is_owned = false;
41626         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41627         LDKPaymentParameters val_conv;
41628         val_conv.inner = (void*)(val & (~1));
41629         val_conv.is_owned = (val & 1) || (val == 0);
41630         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
41631         val_conv = PaymentParameters_clone(&val_conv);
41632         Route_set_payment_params(&this_ptr_conv, val_conv);
41633 }
41634
41635 uint32_t  __attribute__((export_name("TS_Route_new"))) TS_Route_new(ptrArray paths_arg, uint32_t payment_params_arg) {
41636         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
41637         paths_arg_constr.datalen = paths_arg->arr_len;
41638         if (paths_arg_constr.datalen > 0)
41639                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
41640         else
41641                 paths_arg_constr.data = NULL;
41642         uint32_tArray* paths_arg_vals = (void*) paths_arg->elems;
41643         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
41644                 uint32_tArray paths_arg_conv_12 = paths_arg_vals[m];
41645                 LDKCVec_RouteHopZ paths_arg_conv_12_constr;
41646                 paths_arg_conv_12_constr.datalen = paths_arg_conv_12->arr_len;
41647                 if (paths_arg_conv_12_constr.datalen > 0)
41648                         paths_arg_conv_12_constr.data = MALLOC(paths_arg_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
41649                 else
41650                         paths_arg_conv_12_constr.data = NULL;
41651                 uint32_t* paths_arg_conv_12_vals = paths_arg_conv_12->elems;
41652                 for (size_t k = 0; k < paths_arg_conv_12_constr.datalen; k++) {
41653                         uint32_t paths_arg_conv_12_conv_10 = paths_arg_conv_12_vals[k];
41654                         LDKRouteHop paths_arg_conv_12_conv_10_conv;
41655                         paths_arg_conv_12_conv_10_conv.inner = (void*)(paths_arg_conv_12_conv_10 & (~1));
41656                         paths_arg_conv_12_conv_10_conv.is_owned = (paths_arg_conv_12_conv_10 & 1) || (paths_arg_conv_12_conv_10 == 0);
41657                         CHECK_INNER_FIELD_ACCESS_OR_NULL(paths_arg_conv_12_conv_10_conv);
41658                         paths_arg_conv_12_conv_10_conv = RouteHop_clone(&paths_arg_conv_12_conv_10_conv);
41659                         paths_arg_conv_12_constr.data[k] = paths_arg_conv_12_conv_10_conv;
41660                 }
41661                 FREE(paths_arg_conv_12);
41662                 paths_arg_constr.data[m] = paths_arg_conv_12_constr;
41663         }
41664         FREE(paths_arg);
41665         LDKPaymentParameters payment_params_arg_conv;
41666         payment_params_arg_conv.inner = (void*)(payment_params_arg & (~1));
41667         payment_params_arg_conv.is_owned = (payment_params_arg & 1) || (payment_params_arg == 0);
41668         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_arg_conv);
41669         payment_params_arg_conv = PaymentParameters_clone(&payment_params_arg_conv);
41670         LDKRoute ret_var = Route_new(paths_arg_constr, payment_params_arg_conv);
41671         uint32_t ret_ref = 0;
41672         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41673         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41674         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41675         ret_ref = (uintptr_t)ret_var.inner;
41676         if (ret_var.is_owned) {
41677                 ret_ref |= 1;
41678         }
41679         return ret_ref;
41680 }
41681
41682 static inline uintptr_t Route_clone_ptr(LDKRoute *NONNULL_PTR arg) {
41683         LDKRoute ret_var = Route_clone(arg);
41684 uint32_t ret_ref = 0;
41685 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41686 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41687 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41688 ret_ref = (uintptr_t)ret_var.inner;
41689 if (ret_var.is_owned) {
41690         ret_ref |= 1;
41691 }
41692         return ret_ref;
41693 }
41694 uint32_t  __attribute__((export_name("TS_Route_clone_ptr"))) TS_Route_clone_ptr(uint32_t arg) {
41695         LDKRoute arg_conv;
41696         arg_conv.inner = (void*)(arg & (~1));
41697         arg_conv.is_owned = false;
41698         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41699         uint32_t ret_conv = Route_clone_ptr(&arg_conv);
41700         return ret_conv;
41701 }
41702
41703 uint32_t  __attribute__((export_name("TS_Route_clone"))) TS_Route_clone(uint32_t orig) {
41704         LDKRoute orig_conv;
41705         orig_conv.inner = (void*)(orig & (~1));
41706         orig_conv.is_owned = false;
41707         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41708         LDKRoute ret_var = Route_clone(&orig_conv);
41709         uint32_t ret_ref = 0;
41710         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41711         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41712         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41713         ret_ref = (uintptr_t)ret_var.inner;
41714         if (ret_var.is_owned) {
41715                 ret_ref |= 1;
41716         }
41717         return ret_ref;
41718 }
41719
41720 int64_t  __attribute__((export_name("TS_Route_hash"))) TS_Route_hash(uint32_t o) {
41721         LDKRoute o_conv;
41722         o_conv.inner = (void*)(o & (~1));
41723         o_conv.is_owned = false;
41724         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
41725         int64_t ret_conv = Route_hash(&o_conv);
41726         return ret_conv;
41727 }
41728
41729 jboolean  __attribute__((export_name("TS_Route_eq"))) TS_Route_eq(uint32_t a, uint32_t b) {
41730         LDKRoute a_conv;
41731         a_conv.inner = (void*)(a & (~1));
41732         a_conv.is_owned = false;
41733         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
41734         LDKRoute b_conv;
41735         b_conv.inner = (void*)(b & (~1));
41736         b_conv.is_owned = false;
41737         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
41738         jboolean ret_conv = Route_eq(&a_conv, &b_conv);
41739         return ret_conv;
41740 }
41741
41742 int64_t  __attribute__((export_name("TS_Route_get_total_fees"))) TS_Route_get_total_fees(uint32_t this_arg) {
41743         LDKRoute this_arg_conv;
41744         this_arg_conv.inner = (void*)(this_arg & (~1));
41745         this_arg_conv.is_owned = false;
41746         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41747         int64_t ret_conv = Route_get_total_fees(&this_arg_conv);
41748         return ret_conv;
41749 }
41750
41751 int64_t  __attribute__((export_name("TS_Route_get_total_amount"))) TS_Route_get_total_amount(uint32_t this_arg) {
41752         LDKRoute this_arg_conv;
41753         this_arg_conv.inner = (void*)(this_arg & (~1));
41754         this_arg_conv.is_owned = false;
41755         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41756         int64_t ret_conv = Route_get_total_amount(&this_arg_conv);
41757         return ret_conv;
41758 }
41759
41760 int8_tArray  __attribute__((export_name("TS_Route_write"))) TS_Route_write(uint32_t obj) {
41761         LDKRoute obj_conv;
41762         obj_conv.inner = (void*)(obj & (~1));
41763         obj_conv.is_owned = false;
41764         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41765         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
41766         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
41767         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
41768         CVec_u8Z_free(ret_var);
41769         return ret_arr;
41770 }
41771
41772 uint32_t  __attribute__((export_name("TS_Route_read"))) TS_Route_read(int8_tArray ser) {
41773         LDKu8slice ser_ref;
41774         ser_ref.datalen = ser->arr_len;
41775         ser_ref.data = ser->elems;
41776         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
41777         *ret_conv = Route_read(ser_ref);
41778         FREE(ser);
41779         return (uint32_t)ret_conv;
41780 }
41781
41782 void  __attribute__((export_name("TS_RouteParameters_free"))) TS_RouteParameters_free(uint32_t this_obj) {
41783         LDKRouteParameters this_obj_conv;
41784         this_obj_conv.inner = (void*)(this_obj & (~1));
41785         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41786         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41787         RouteParameters_free(this_obj_conv);
41788 }
41789
41790 uint32_t  __attribute__((export_name("TS_RouteParameters_get_payment_params"))) TS_RouteParameters_get_payment_params(uint32_t this_ptr) {
41791         LDKRouteParameters this_ptr_conv;
41792         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41793         this_ptr_conv.is_owned = false;
41794         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41795         LDKPaymentParameters ret_var = RouteParameters_get_payment_params(&this_ptr_conv);
41796         uint32_t ret_ref = 0;
41797         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41798         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41799         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41800         ret_ref = (uintptr_t)ret_var.inner;
41801         if (ret_var.is_owned) {
41802                 ret_ref |= 1;
41803         }
41804         return ret_ref;
41805 }
41806
41807 void  __attribute__((export_name("TS_RouteParameters_set_payment_params"))) TS_RouteParameters_set_payment_params(uint32_t this_ptr, uint32_t val) {
41808         LDKRouteParameters this_ptr_conv;
41809         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41810         this_ptr_conv.is_owned = false;
41811         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41812         LDKPaymentParameters val_conv;
41813         val_conv.inner = (void*)(val & (~1));
41814         val_conv.is_owned = (val & 1) || (val == 0);
41815         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
41816         val_conv = PaymentParameters_clone(&val_conv);
41817         RouteParameters_set_payment_params(&this_ptr_conv, val_conv);
41818 }
41819
41820 int64_t  __attribute__((export_name("TS_RouteParameters_get_final_value_msat"))) TS_RouteParameters_get_final_value_msat(uint32_t this_ptr) {
41821         LDKRouteParameters this_ptr_conv;
41822         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41823         this_ptr_conv.is_owned = false;
41824         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41825         int64_t ret_conv = RouteParameters_get_final_value_msat(&this_ptr_conv);
41826         return ret_conv;
41827 }
41828
41829 void  __attribute__((export_name("TS_RouteParameters_set_final_value_msat"))) TS_RouteParameters_set_final_value_msat(uint32_t this_ptr, int64_t val) {
41830         LDKRouteParameters this_ptr_conv;
41831         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41832         this_ptr_conv.is_owned = false;
41833         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41834         RouteParameters_set_final_value_msat(&this_ptr_conv, val);
41835 }
41836
41837 int32_t  __attribute__((export_name("TS_RouteParameters_get_final_cltv_expiry_delta"))) TS_RouteParameters_get_final_cltv_expiry_delta(uint32_t this_ptr) {
41838         LDKRouteParameters this_ptr_conv;
41839         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41840         this_ptr_conv.is_owned = false;
41841         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41842         int32_t ret_conv = RouteParameters_get_final_cltv_expiry_delta(&this_ptr_conv);
41843         return ret_conv;
41844 }
41845
41846 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) {
41847         LDKRouteParameters this_ptr_conv;
41848         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41849         this_ptr_conv.is_owned = false;
41850         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41851         RouteParameters_set_final_cltv_expiry_delta(&this_ptr_conv, val);
41852 }
41853
41854 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) {
41855         LDKPaymentParameters payment_params_arg_conv;
41856         payment_params_arg_conv.inner = (void*)(payment_params_arg & (~1));
41857         payment_params_arg_conv.is_owned = (payment_params_arg & 1) || (payment_params_arg == 0);
41858         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_arg_conv);
41859         payment_params_arg_conv = PaymentParameters_clone(&payment_params_arg_conv);
41860         LDKRouteParameters ret_var = RouteParameters_new(payment_params_arg_conv, final_value_msat_arg, final_cltv_expiry_delta_arg);
41861         uint32_t ret_ref = 0;
41862         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41863         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41864         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41865         ret_ref = (uintptr_t)ret_var.inner;
41866         if (ret_var.is_owned) {
41867                 ret_ref |= 1;
41868         }
41869         return ret_ref;
41870 }
41871
41872 static inline uintptr_t RouteParameters_clone_ptr(LDKRouteParameters *NONNULL_PTR arg) {
41873         LDKRouteParameters ret_var = RouteParameters_clone(arg);
41874 uint32_t ret_ref = 0;
41875 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41876 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41877 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41878 ret_ref = (uintptr_t)ret_var.inner;
41879 if (ret_var.is_owned) {
41880         ret_ref |= 1;
41881 }
41882         return ret_ref;
41883 }
41884 uint32_t  __attribute__((export_name("TS_RouteParameters_clone_ptr"))) TS_RouteParameters_clone_ptr(uint32_t arg) {
41885         LDKRouteParameters arg_conv;
41886         arg_conv.inner = (void*)(arg & (~1));
41887         arg_conv.is_owned = false;
41888         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41889         uint32_t ret_conv = RouteParameters_clone_ptr(&arg_conv);
41890         return ret_conv;
41891 }
41892
41893 uint32_t  __attribute__((export_name("TS_RouteParameters_clone"))) TS_RouteParameters_clone(uint32_t orig) {
41894         LDKRouteParameters orig_conv;
41895         orig_conv.inner = (void*)(orig & (~1));
41896         orig_conv.is_owned = false;
41897         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41898         LDKRouteParameters ret_var = RouteParameters_clone(&orig_conv);
41899         uint32_t ret_ref = 0;
41900         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41901         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41902         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41903         ret_ref = (uintptr_t)ret_var.inner;
41904         if (ret_var.is_owned) {
41905                 ret_ref |= 1;
41906         }
41907         return ret_ref;
41908 }
41909
41910 int8_tArray  __attribute__((export_name("TS_RouteParameters_write"))) TS_RouteParameters_write(uint32_t obj) {
41911         LDKRouteParameters obj_conv;
41912         obj_conv.inner = (void*)(obj & (~1));
41913         obj_conv.is_owned = false;
41914         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41915         LDKCVec_u8Z ret_var = RouteParameters_write(&obj_conv);
41916         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
41917         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
41918         CVec_u8Z_free(ret_var);
41919         return ret_arr;
41920 }
41921
41922 uint32_t  __attribute__((export_name("TS_RouteParameters_read"))) TS_RouteParameters_read(int8_tArray ser) {
41923         LDKu8slice ser_ref;
41924         ser_ref.datalen = ser->arr_len;
41925         ser_ref.data = ser->elems;
41926         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
41927         *ret_conv = RouteParameters_read(ser_ref);
41928         FREE(ser);
41929         return (uint32_t)ret_conv;
41930 }
41931
41932 void  __attribute__((export_name("TS_PaymentParameters_free"))) TS_PaymentParameters_free(uint32_t this_obj) {
41933         LDKPaymentParameters this_obj_conv;
41934         this_obj_conv.inner = (void*)(this_obj & (~1));
41935         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41936         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41937         PaymentParameters_free(this_obj_conv);
41938 }
41939
41940 int8_tArray  __attribute__((export_name("TS_PaymentParameters_get_payee_pubkey"))) TS_PaymentParameters_get_payee_pubkey(uint32_t this_ptr) {
41941         LDKPaymentParameters this_ptr_conv;
41942         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41943         this_ptr_conv.is_owned = false;
41944         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41945         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
41946         memcpy(ret_arr->elems, PaymentParameters_get_payee_pubkey(&this_ptr_conv).compressed_form, 33);
41947         return ret_arr;
41948 }
41949
41950 void  __attribute__((export_name("TS_PaymentParameters_set_payee_pubkey"))) TS_PaymentParameters_set_payee_pubkey(uint32_t this_ptr, int8_tArray val) {
41951         LDKPaymentParameters this_ptr_conv;
41952         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41953         this_ptr_conv.is_owned = false;
41954         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41955         LDKPublicKey val_ref;
41956         CHECK(val->arr_len == 33);
41957         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
41958         PaymentParameters_set_payee_pubkey(&this_ptr_conv, val_ref);
41959 }
41960
41961 uint32_t  __attribute__((export_name("TS_PaymentParameters_get_features"))) TS_PaymentParameters_get_features(uint32_t this_ptr) {
41962         LDKPaymentParameters this_ptr_conv;
41963         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41964         this_ptr_conv.is_owned = false;
41965         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41966         LDKInvoiceFeatures ret_var = PaymentParameters_get_features(&this_ptr_conv);
41967         uint32_t ret_ref = 0;
41968         if ((uintptr_t)ret_var.inner > 4096) {
41969                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41970                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41971         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41972                 ret_ref = (uintptr_t)ret_var.inner;
41973                 if (ret_var.is_owned) {
41974                         ret_ref |= 1;
41975                 }
41976         }
41977         return ret_ref;
41978 }
41979
41980 void  __attribute__((export_name("TS_PaymentParameters_set_features"))) TS_PaymentParameters_set_features(uint32_t this_ptr, uint32_t val) {
41981         LDKPaymentParameters this_ptr_conv;
41982         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41983         this_ptr_conv.is_owned = false;
41984         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41985         LDKInvoiceFeatures val_conv;
41986         val_conv.inner = (void*)(val & (~1));
41987         val_conv.is_owned = (val & 1) || (val == 0);
41988         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
41989         val_conv = InvoiceFeatures_clone(&val_conv);
41990         PaymentParameters_set_features(&this_ptr_conv, val_conv);
41991 }
41992
41993 uint32_tArray  __attribute__((export_name("TS_PaymentParameters_get_route_hints"))) TS_PaymentParameters_get_route_hints(uint32_t this_ptr) {
41994         LDKPaymentParameters this_ptr_conv;
41995         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41996         this_ptr_conv.is_owned = false;
41997         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41998         LDKCVec_RouteHintZ ret_var = PaymentParameters_get_route_hints(&this_ptr_conv);
41999         uint32_tArray ret_arr = NULL;
42000         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
42001         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 8);
42002         for (size_t l = 0; l < ret_var.datalen; l++) {
42003                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
42004                 uint32_t ret_conv_11_ref = 0;
42005                 CHECK((((uintptr_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42006                 CHECK((((uintptr_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42007                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
42008                 ret_conv_11_ref = (uintptr_t)ret_conv_11_var.inner;
42009                 if (ret_conv_11_var.is_owned) {
42010                         ret_conv_11_ref |= 1;
42011                 }
42012                 ret_arr_ptr[l] = ret_conv_11_ref;
42013         }
42014         
42015         FREE(ret_var.data);
42016         return ret_arr;
42017 }
42018
42019 void  __attribute__((export_name("TS_PaymentParameters_set_route_hints"))) TS_PaymentParameters_set_route_hints(uint32_t this_ptr, uint32_tArray val) {
42020         LDKPaymentParameters this_ptr_conv;
42021         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42022         this_ptr_conv.is_owned = false;
42023         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42024         LDKCVec_RouteHintZ val_constr;
42025         val_constr.datalen = val->arr_len;
42026         if (val_constr.datalen > 0)
42027                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
42028         else
42029                 val_constr.data = NULL;
42030         uint32_t* val_vals = val->elems;
42031         for (size_t l = 0; l < val_constr.datalen; l++) {
42032                 uint32_t val_conv_11 = val_vals[l];
42033                 LDKRouteHint val_conv_11_conv;
42034                 val_conv_11_conv.inner = (void*)(val_conv_11 & (~1));
42035                 val_conv_11_conv.is_owned = (val_conv_11 & 1) || (val_conv_11 == 0);
42036                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_11_conv);
42037                 val_conv_11_conv = RouteHint_clone(&val_conv_11_conv);
42038                 val_constr.data[l] = val_conv_11_conv;
42039         }
42040         FREE(val);
42041         PaymentParameters_set_route_hints(&this_ptr_conv, val_constr);
42042 }
42043
42044 uint32_t  __attribute__((export_name("TS_PaymentParameters_get_expiry_time"))) TS_PaymentParameters_get_expiry_time(uint32_t this_ptr) {
42045         LDKPaymentParameters this_ptr_conv;
42046         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42047         this_ptr_conv.is_owned = false;
42048         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42049         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
42050         *ret_copy = PaymentParameters_get_expiry_time(&this_ptr_conv);
42051         uint32_t ret_ref = (uintptr_t)ret_copy;
42052         return ret_ref;
42053 }
42054
42055 void  __attribute__((export_name("TS_PaymentParameters_set_expiry_time"))) TS_PaymentParameters_set_expiry_time(uint32_t this_ptr, uint32_t val) {
42056         LDKPaymentParameters this_ptr_conv;
42057         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42058         this_ptr_conv.is_owned = false;
42059         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42060         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
42061         CHECK_ACCESS(val_ptr);
42062         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
42063         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
42064         PaymentParameters_set_expiry_time(&this_ptr_conv, val_conv);
42065 }
42066
42067 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) {
42068         LDKPaymentParameters this_ptr_conv;
42069         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42070         this_ptr_conv.is_owned = false;
42071         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42072         int32_t ret_conv = PaymentParameters_get_max_total_cltv_expiry_delta(&this_ptr_conv);
42073         return ret_conv;
42074 }
42075
42076 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) {
42077         LDKPaymentParameters this_ptr_conv;
42078         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42079         this_ptr_conv.is_owned = false;
42080         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42081         PaymentParameters_set_max_total_cltv_expiry_delta(&this_ptr_conv, val);
42082 }
42083
42084 int8_t  __attribute__((export_name("TS_PaymentParameters_get_max_path_count"))) TS_PaymentParameters_get_max_path_count(uint32_t this_ptr) {
42085         LDKPaymentParameters this_ptr_conv;
42086         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42087         this_ptr_conv.is_owned = false;
42088         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42089         int8_t ret_conv = PaymentParameters_get_max_path_count(&this_ptr_conv);
42090         return ret_conv;
42091 }
42092
42093 void  __attribute__((export_name("TS_PaymentParameters_set_max_path_count"))) TS_PaymentParameters_set_max_path_count(uint32_t this_ptr, int8_t val) {
42094         LDKPaymentParameters this_ptr_conv;
42095         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42096         this_ptr_conv.is_owned = false;
42097         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42098         PaymentParameters_set_max_path_count(&this_ptr_conv, val);
42099 }
42100
42101 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) {
42102         LDKPaymentParameters this_ptr_conv;
42103         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42104         this_ptr_conv.is_owned = false;
42105         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42106         int8_t ret_conv = PaymentParameters_get_max_channel_saturation_power_of_half(&this_ptr_conv);
42107         return ret_conv;
42108 }
42109
42110 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) {
42111         LDKPaymentParameters this_ptr_conv;
42112         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42113         this_ptr_conv.is_owned = false;
42114         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42115         PaymentParameters_set_max_channel_saturation_power_of_half(&this_ptr_conv, val);
42116 }
42117
42118 int64_tArray  __attribute__((export_name("TS_PaymentParameters_get_previously_failed_channels"))) TS_PaymentParameters_get_previously_failed_channels(uint32_t this_ptr) {
42119         LDKPaymentParameters this_ptr_conv;
42120         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42121         this_ptr_conv.is_owned = false;
42122         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42123         LDKCVec_u64Z ret_var = PaymentParameters_get_previously_failed_channels(&this_ptr_conv);
42124         int64_tArray ret_arr = NULL;
42125         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
42126         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
42127         for (size_t i = 0; i < ret_var.datalen; i++) {
42128                 int64_t ret_conv_8_conv = ret_var.data[i];
42129                 ret_arr_ptr[i] = ret_conv_8_conv;
42130         }
42131         
42132         FREE(ret_var.data);
42133         return ret_arr;
42134 }
42135
42136 void  __attribute__((export_name("TS_PaymentParameters_set_previously_failed_channels"))) TS_PaymentParameters_set_previously_failed_channels(uint32_t this_ptr, int64_tArray val) {
42137         LDKPaymentParameters this_ptr_conv;
42138         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42139         this_ptr_conv.is_owned = false;
42140         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42141         LDKCVec_u64Z val_constr;
42142         val_constr.datalen = val->arr_len;
42143         if (val_constr.datalen > 0)
42144                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
42145         else
42146                 val_constr.data = NULL;
42147         int64_t* val_vals = val->elems;
42148         for (size_t i = 0; i < val_constr.datalen; i++) {
42149                 int64_t val_conv_8 = val_vals[i];
42150                 val_constr.data[i] = val_conv_8;
42151         }
42152         FREE(val);
42153         PaymentParameters_set_previously_failed_channels(&this_ptr_conv, val_constr);
42154 }
42155
42156 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) {
42157         LDKPublicKey payee_pubkey_arg_ref;
42158         CHECK(payee_pubkey_arg->arr_len == 33);
42159         memcpy(payee_pubkey_arg_ref.compressed_form, payee_pubkey_arg->elems, 33); FREE(payee_pubkey_arg);
42160         LDKInvoiceFeatures features_arg_conv;
42161         features_arg_conv.inner = (void*)(features_arg & (~1));
42162         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
42163         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
42164         features_arg_conv = InvoiceFeatures_clone(&features_arg_conv);
42165         LDKCVec_RouteHintZ route_hints_arg_constr;
42166         route_hints_arg_constr.datalen = route_hints_arg->arr_len;
42167         if (route_hints_arg_constr.datalen > 0)
42168                 route_hints_arg_constr.data = MALLOC(route_hints_arg_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
42169         else
42170                 route_hints_arg_constr.data = NULL;
42171         uint32_t* route_hints_arg_vals = route_hints_arg->elems;
42172         for (size_t l = 0; l < route_hints_arg_constr.datalen; l++) {
42173                 uint32_t route_hints_arg_conv_11 = route_hints_arg_vals[l];
42174                 LDKRouteHint route_hints_arg_conv_11_conv;
42175                 route_hints_arg_conv_11_conv.inner = (void*)(route_hints_arg_conv_11 & (~1));
42176                 route_hints_arg_conv_11_conv.is_owned = (route_hints_arg_conv_11 & 1) || (route_hints_arg_conv_11 == 0);
42177                 CHECK_INNER_FIELD_ACCESS_OR_NULL(route_hints_arg_conv_11_conv);
42178                 route_hints_arg_conv_11_conv = RouteHint_clone(&route_hints_arg_conv_11_conv);
42179                 route_hints_arg_constr.data[l] = route_hints_arg_conv_11_conv;
42180         }
42181         FREE(route_hints_arg);
42182         void* expiry_time_arg_ptr = (void*)(((uintptr_t)expiry_time_arg) & ~1);
42183         CHECK_ACCESS(expiry_time_arg_ptr);
42184         LDKCOption_u64Z expiry_time_arg_conv = *(LDKCOption_u64Z*)(expiry_time_arg_ptr);
42185         expiry_time_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)expiry_time_arg) & ~1));
42186         LDKCVec_u64Z previously_failed_channels_arg_constr;
42187         previously_failed_channels_arg_constr.datalen = previously_failed_channels_arg->arr_len;
42188         if (previously_failed_channels_arg_constr.datalen > 0)
42189                 previously_failed_channels_arg_constr.data = MALLOC(previously_failed_channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
42190         else
42191                 previously_failed_channels_arg_constr.data = NULL;
42192         int64_t* previously_failed_channels_arg_vals = previously_failed_channels_arg->elems;
42193         for (size_t i = 0; i < previously_failed_channels_arg_constr.datalen; i++) {
42194                 int64_t previously_failed_channels_arg_conv_8 = previously_failed_channels_arg_vals[i];
42195                 previously_failed_channels_arg_constr.data[i] = previously_failed_channels_arg_conv_8;
42196         }
42197         FREE(previously_failed_channels_arg);
42198         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);
42199         uint32_t ret_ref = 0;
42200         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42201         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42202         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42203         ret_ref = (uintptr_t)ret_var.inner;
42204         if (ret_var.is_owned) {
42205                 ret_ref |= 1;
42206         }
42207         return ret_ref;
42208 }
42209
42210 static inline uintptr_t PaymentParameters_clone_ptr(LDKPaymentParameters *NONNULL_PTR arg) {
42211         LDKPaymentParameters ret_var = PaymentParameters_clone(arg);
42212 uint32_t ret_ref = 0;
42213 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42214 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42215 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42216 ret_ref = (uintptr_t)ret_var.inner;
42217 if (ret_var.is_owned) {
42218         ret_ref |= 1;
42219 }
42220         return ret_ref;
42221 }
42222 uint32_t  __attribute__((export_name("TS_PaymentParameters_clone_ptr"))) TS_PaymentParameters_clone_ptr(uint32_t arg) {
42223         LDKPaymentParameters arg_conv;
42224         arg_conv.inner = (void*)(arg & (~1));
42225         arg_conv.is_owned = false;
42226         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42227         uint32_t ret_conv = PaymentParameters_clone_ptr(&arg_conv);
42228         return ret_conv;
42229 }
42230
42231 uint32_t  __attribute__((export_name("TS_PaymentParameters_clone"))) TS_PaymentParameters_clone(uint32_t orig) {
42232         LDKPaymentParameters orig_conv;
42233         orig_conv.inner = (void*)(orig & (~1));
42234         orig_conv.is_owned = false;
42235         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42236         LDKPaymentParameters ret_var = PaymentParameters_clone(&orig_conv);
42237         uint32_t ret_ref = 0;
42238         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42239         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42240         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42241         ret_ref = (uintptr_t)ret_var.inner;
42242         if (ret_var.is_owned) {
42243                 ret_ref |= 1;
42244         }
42245         return ret_ref;
42246 }
42247
42248 int64_t  __attribute__((export_name("TS_PaymentParameters_hash"))) TS_PaymentParameters_hash(uint32_t o) {
42249         LDKPaymentParameters o_conv;
42250         o_conv.inner = (void*)(o & (~1));
42251         o_conv.is_owned = false;
42252         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
42253         int64_t ret_conv = PaymentParameters_hash(&o_conv);
42254         return ret_conv;
42255 }
42256
42257 jboolean  __attribute__((export_name("TS_PaymentParameters_eq"))) TS_PaymentParameters_eq(uint32_t a, uint32_t b) {
42258         LDKPaymentParameters a_conv;
42259         a_conv.inner = (void*)(a & (~1));
42260         a_conv.is_owned = false;
42261         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42262         LDKPaymentParameters b_conv;
42263         b_conv.inner = (void*)(b & (~1));
42264         b_conv.is_owned = false;
42265         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42266         jboolean ret_conv = PaymentParameters_eq(&a_conv, &b_conv);
42267         return ret_conv;
42268 }
42269
42270 int8_tArray  __attribute__((export_name("TS_PaymentParameters_write"))) TS_PaymentParameters_write(uint32_t obj) {
42271         LDKPaymentParameters obj_conv;
42272         obj_conv.inner = (void*)(obj & (~1));
42273         obj_conv.is_owned = false;
42274         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42275         LDKCVec_u8Z ret_var = PaymentParameters_write(&obj_conv);
42276         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
42277         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
42278         CVec_u8Z_free(ret_var);
42279         return ret_arr;
42280 }
42281
42282 uint32_t  __attribute__((export_name("TS_PaymentParameters_read"))) TS_PaymentParameters_read(int8_tArray ser) {
42283         LDKu8slice ser_ref;
42284         ser_ref.datalen = ser->arr_len;
42285         ser_ref.data = ser->elems;
42286         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
42287         *ret_conv = PaymentParameters_read(ser_ref);
42288         FREE(ser);
42289         return (uint32_t)ret_conv;
42290 }
42291
42292 uint32_t  __attribute__((export_name("TS_PaymentParameters_from_node_id"))) TS_PaymentParameters_from_node_id(int8_tArray payee_pubkey) {
42293         LDKPublicKey payee_pubkey_ref;
42294         CHECK(payee_pubkey->arr_len == 33);
42295         memcpy(payee_pubkey_ref.compressed_form, payee_pubkey->elems, 33); FREE(payee_pubkey);
42296         LDKPaymentParameters ret_var = PaymentParameters_from_node_id(payee_pubkey_ref);
42297         uint32_t ret_ref = 0;
42298         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42299         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42300         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42301         ret_ref = (uintptr_t)ret_var.inner;
42302         if (ret_var.is_owned) {
42303                 ret_ref |= 1;
42304         }
42305         return ret_ref;
42306 }
42307
42308 uint32_t  __attribute__((export_name("TS_PaymentParameters_for_keysend"))) TS_PaymentParameters_for_keysend(int8_tArray payee_pubkey) {
42309         LDKPublicKey payee_pubkey_ref;
42310         CHECK(payee_pubkey->arr_len == 33);
42311         memcpy(payee_pubkey_ref.compressed_form, payee_pubkey->elems, 33); FREE(payee_pubkey);
42312         LDKPaymentParameters ret_var = PaymentParameters_for_keysend(payee_pubkey_ref);
42313         uint32_t ret_ref = 0;
42314         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42315         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42316         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42317         ret_ref = (uintptr_t)ret_var.inner;
42318         if (ret_var.is_owned) {
42319                 ret_ref |= 1;
42320         }
42321         return ret_ref;
42322 }
42323
42324 void  __attribute__((export_name("TS_RouteHint_free"))) TS_RouteHint_free(uint32_t this_obj) {
42325         LDKRouteHint this_obj_conv;
42326         this_obj_conv.inner = (void*)(this_obj & (~1));
42327         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42328         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42329         RouteHint_free(this_obj_conv);
42330 }
42331
42332 uint32_tArray  __attribute__((export_name("TS_RouteHint_get_a"))) TS_RouteHint_get_a(uint32_t this_ptr) {
42333         LDKRouteHint this_ptr_conv;
42334         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42335         this_ptr_conv.is_owned = false;
42336         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42337         LDKCVec_RouteHintHopZ ret_var = RouteHint_get_a(&this_ptr_conv);
42338         uint32_tArray ret_arr = NULL;
42339         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
42340         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 8);
42341         for (size_t o = 0; o < ret_var.datalen; o++) {
42342                 LDKRouteHintHop ret_conv_14_var = ret_var.data[o];
42343                 uint32_t ret_conv_14_ref = 0;
42344                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42345                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42346                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
42347                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
42348                 if (ret_conv_14_var.is_owned) {
42349                         ret_conv_14_ref |= 1;
42350                 }
42351                 ret_arr_ptr[o] = ret_conv_14_ref;
42352         }
42353         
42354         FREE(ret_var.data);
42355         return ret_arr;
42356 }
42357
42358 void  __attribute__((export_name("TS_RouteHint_set_a"))) TS_RouteHint_set_a(uint32_t this_ptr, uint32_tArray val) {
42359         LDKRouteHint this_ptr_conv;
42360         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42361         this_ptr_conv.is_owned = false;
42362         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42363         LDKCVec_RouteHintHopZ val_constr;
42364         val_constr.datalen = val->arr_len;
42365         if (val_constr.datalen > 0)
42366                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
42367         else
42368                 val_constr.data = NULL;
42369         uint32_t* val_vals = val->elems;
42370         for (size_t o = 0; o < val_constr.datalen; o++) {
42371                 uint32_t val_conv_14 = val_vals[o];
42372                 LDKRouteHintHop val_conv_14_conv;
42373                 val_conv_14_conv.inner = (void*)(val_conv_14 & (~1));
42374                 val_conv_14_conv.is_owned = (val_conv_14 & 1) || (val_conv_14 == 0);
42375                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_14_conv);
42376                 val_conv_14_conv = RouteHintHop_clone(&val_conv_14_conv);
42377                 val_constr.data[o] = val_conv_14_conv;
42378         }
42379         FREE(val);
42380         RouteHint_set_a(&this_ptr_conv, val_constr);
42381 }
42382
42383 uint32_t  __attribute__((export_name("TS_RouteHint_new"))) TS_RouteHint_new(uint32_tArray a_arg) {
42384         LDKCVec_RouteHintHopZ a_arg_constr;
42385         a_arg_constr.datalen = a_arg->arr_len;
42386         if (a_arg_constr.datalen > 0)
42387                 a_arg_constr.data = MALLOC(a_arg_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
42388         else
42389                 a_arg_constr.data = NULL;
42390         uint32_t* a_arg_vals = a_arg->elems;
42391         for (size_t o = 0; o < a_arg_constr.datalen; o++) {
42392                 uint32_t a_arg_conv_14 = a_arg_vals[o];
42393                 LDKRouteHintHop a_arg_conv_14_conv;
42394                 a_arg_conv_14_conv.inner = (void*)(a_arg_conv_14 & (~1));
42395                 a_arg_conv_14_conv.is_owned = (a_arg_conv_14 & 1) || (a_arg_conv_14 == 0);
42396                 CHECK_INNER_FIELD_ACCESS_OR_NULL(a_arg_conv_14_conv);
42397                 a_arg_conv_14_conv = RouteHintHop_clone(&a_arg_conv_14_conv);
42398                 a_arg_constr.data[o] = a_arg_conv_14_conv;
42399         }
42400         FREE(a_arg);
42401         LDKRouteHint ret_var = RouteHint_new(a_arg_constr);
42402         uint32_t ret_ref = 0;
42403         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42404         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42405         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42406         ret_ref = (uintptr_t)ret_var.inner;
42407         if (ret_var.is_owned) {
42408                 ret_ref |= 1;
42409         }
42410         return ret_ref;
42411 }
42412
42413 static inline uintptr_t RouteHint_clone_ptr(LDKRouteHint *NONNULL_PTR arg) {
42414         LDKRouteHint ret_var = RouteHint_clone(arg);
42415 uint32_t ret_ref = 0;
42416 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42417 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42418 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42419 ret_ref = (uintptr_t)ret_var.inner;
42420 if (ret_var.is_owned) {
42421         ret_ref |= 1;
42422 }
42423         return ret_ref;
42424 }
42425 uint32_t  __attribute__((export_name("TS_RouteHint_clone_ptr"))) TS_RouteHint_clone_ptr(uint32_t arg) {
42426         LDKRouteHint arg_conv;
42427         arg_conv.inner = (void*)(arg & (~1));
42428         arg_conv.is_owned = false;
42429         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42430         uint32_t ret_conv = RouteHint_clone_ptr(&arg_conv);
42431         return ret_conv;
42432 }
42433
42434 uint32_t  __attribute__((export_name("TS_RouteHint_clone"))) TS_RouteHint_clone(uint32_t orig) {
42435         LDKRouteHint orig_conv;
42436         orig_conv.inner = (void*)(orig & (~1));
42437         orig_conv.is_owned = false;
42438         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42439         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
42440         uint32_t ret_ref = 0;
42441         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42442         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42443         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42444         ret_ref = (uintptr_t)ret_var.inner;
42445         if (ret_var.is_owned) {
42446                 ret_ref |= 1;
42447         }
42448         return ret_ref;
42449 }
42450
42451 int64_t  __attribute__((export_name("TS_RouteHint_hash"))) TS_RouteHint_hash(uint32_t o) {
42452         LDKRouteHint o_conv;
42453         o_conv.inner = (void*)(o & (~1));
42454         o_conv.is_owned = false;
42455         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
42456         int64_t ret_conv = RouteHint_hash(&o_conv);
42457         return ret_conv;
42458 }
42459
42460 jboolean  __attribute__((export_name("TS_RouteHint_eq"))) TS_RouteHint_eq(uint32_t a, uint32_t b) {
42461         LDKRouteHint a_conv;
42462         a_conv.inner = (void*)(a & (~1));
42463         a_conv.is_owned = false;
42464         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42465         LDKRouteHint b_conv;
42466         b_conv.inner = (void*)(b & (~1));
42467         b_conv.is_owned = false;
42468         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42469         jboolean ret_conv = RouteHint_eq(&a_conv, &b_conv);
42470         return ret_conv;
42471 }
42472
42473 int8_tArray  __attribute__((export_name("TS_RouteHint_write"))) TS_RouteHint_write(uint32_t obj) {
42474         LDKRouteHint obj_conv;
42475         obj_conv.inner = (void*)(obj & (~1));
42476         obj_conv.is_owned = false;
42477         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42478         LDKCVec_u8Z ret_var = RouteHint_write(&obj_conv);
42479         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
42480         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
42481         CVec_u8Z_free(ret_var);
42482         return ret_arr;
42483 }
42484
42485 uint32_t  __attribute__((export_name("TS_RouteHint_read"))) TS_RouteHint_read(int8_tArray ser) {
42486         LDKu8slice ser_ref;
42487         ser_ref.datalen = ser->arr_len;
42488         ser_ref.data = ser->elems;
42489         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
42490         *ret_conv = RouteHint_read(ser_ref);
42491         FREE(ser);
42492         return (uint32_t)ret_conv;
42493 }
42494
42495 void  __attribute__((export_name("TS_RouteHintHop_free"))) TS_RouteHintHop_free(uint32_t this_obj) {
42496         LDKRouteHintHop this_obj_conv;
42497         this_obj_conv.inner = (void*)(this_obj & (~1));
42498         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42499         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42500         RouteHintHop_free(this_obj_conv);
42501 }
42502
42503 int8_tArray  __attribute__((export_name("TS_RouteHintHop_get_src_node_id"))) TS_RouteHintHop_get_src_node_id(uint32_t this_ptr) {
42504         LDKRouteHintHop this_ptr_conv;
42505         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42506         this_ptr_conv.is_owned = false;
42507         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42508         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
42509         memcpy(ret_arr->elems, RouteHintHop_get_src_node_id(&this_ptr_conv).compressed_form, 33);
42510         return ret_arr;
42511 }
42512
42513 void  __attribute__((export_name("TS_RouteHintHop_set_src_node_id"))) TS_RouteHintHop_set_src_node_id(uint32_t this_ptr, int8_tArray val) {
42514         LDKRouteHintHop this_ptr_conv;
42515         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42516         this_ptr_conv.is_owned = false;
42517         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42518         LDKPublicKey val_ref;
42519         CHECK(val->arr_len == 33);
42520         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
42521         RouteHintHop_set_src_node_id(&this_ptr_conv, val_ref);
42522 }
42523
42524 int64_t  __attribute__((export_name("TS_RouteHintHop_get_short_channel_id"))) TS_RouteHintHop_get_short_channel_id(uint32_t this_ptr) {
42525         LDKRouteHintHop this_ptr_conv;
42526         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42527         this_ptr_conv.is_owned = false;
42528         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42529         int64_t ret_conv = RouteHintHop_get_short_channel_id(&this_ptr_conv);
42530         return ret_conv;
42531 }
42532
42533 void  __attribute__((export_name("TS_RouteHintHop_set_short_channel_id"))) TS_RouteHintHop_set_short_channel_id(uint32_t this_ptr, int64_t val) {
42534         LDKRouteHintHop this_ptr_conv;
42535         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42536         this_ptr_conv.is_owned = false;
42537         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42538         RouteHintHop_set_short_channel_id(&this_ptr_conv, val);
42539 }
42540
42541 uint32_t  __attribute__((export_name("TS_RouteHintHop_get_fees"))) TS_RouteHintHop_get_fees(uint32_t this_ptr) {
42542         LDKRouteHintHop this_ptr_conv;
42543         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42544         this_ptr_conv.is_owned = false;
42545         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42546         LDKRoutingFees ret_var = RouteHintHop_get_fees(&this_ptr_conv);
42547         uint32_t ret_ref = 0;
42548         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42549         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42550         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42551         ret_ref = (uintptr_t)ret_var.inner;
42552         if (ret_var.is_owned) {
42553                 ret_ref |= 1;
42554         }
42555         return ret_ref;
42556 }
42557
42558 void  __attribute__((export_name("TS_RouteHintHop_set_fees"))) TS_RouteHintHop_set_fees(uint32_t this_ptr, uint32_t val) {
42559         LDKRouteHintHop this_ptr_conv;
42560         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42561         this_ptr_conv.is_owned = false;
42562         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42563         LDKRoutingFees val_conv;
42564         val_conv.inner = (void*)(val & (~1));
42565         val_conv.is_owned = (val & 1) || (val == 0);
42566         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
42567         val_conv = RoutingFees_clone(&val_conv);
42568         RouteHintHop_set_fees(&this_ptr_conv, val_conv);
42569 }
42570
42571 int16_t  __attribute__((export_name("TS_RouteHintHop_get_cltv_expiry_delta"))) TS_RouteHintHop_get_cltv_expiry_delta(uint32_t this_ptr) {
42572         LDKRouteHintHop this_ptr_conv;
42573         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42574         this_ptr_conv.is_owned = false;
42575         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42576         int16_t ret_conv = RouteHintHop_get_cltv_expiry_delta(&this_ptr_conv);
42577         return ret_conv;
42578 }
42579
42580 void  __attribute__((export_name("TS_RouteHintHop_set_cltv_expiry_delta"))) TS_RouteHintHop_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
42581         LDKRouteHintHop this_ptr_conv;
42582         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42583         this_ptr_conv.is_owned = false;
42584         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42585         RouteHintHop_set_cltv_expiry_delta(&this_ptr_conv, val);
42586 }
42587
42588 uint32_t  __attribute__((export_name("TS_RouteHintHop_get_htlc_minimum_msat"))) TS_RouteHintHop_get_htlc_minimum_msat(uint32_t this_ptr) {
42589         LDKRouteHintHop this_ptr_conv;
42590         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42591         this_ptr_conv.is_owned = false;
42592         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42593         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
42594         *ret_copy = RouteHintHop_get_htlc_minimum_msat(&this_ptr_conv);
42595         uint32_t ret_ref = (uintptr_t)ret_copy;
42596         return ret_ref;
42597 }
42598
42599 void  __attribute__((export_name("TS_RouteHintHop_set_htlc_minimum_msat"))) TS_RouteHintHop_set_htlc_minimum_msat(uint32_t this_ptr, uint32_t val) {
42600         LDKRouteHintHop this_ptr_conv;
42601         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42602         this_ptr_conv.is_owned = false;
42603         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42604         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
42605         CHECK_ACCESS(val_ptr);
42606         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
42607         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
42608         RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
42609 }
42610
42611 uint32_t  __attribute__((export_name("TS_RouteHintHop_get_htlc_maximum_msat"))) TS_RouteHintHop_get_htlc_maximum_msat(uint32_t this_ptr) {
42612         LDKRouteHintHop this_ptr_conv;
42613         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42614         this_ptr_conv.is_owned = false;
42615         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42616         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
42617         *ret_copy = RouteHintHop_get_htlc_maximum_msat(&this_ptr_conv);
42618         uint32_t ret_ref = (uintptr_t)ret_copy;
42619         return ret_ref;
42620 }
42621
42622 void  __attribute__((export_name("TS_RouteHintHop_set_htlc_maximum_msat"))) TS_RouteHintHop_set_htlc_maximum_msat(uint32_t this_ptr, uint32_t val) {
42623         LDKRouteHintHop this_ptr_conv;
42624         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42625         this_ptr_conv.is_owned = false;
42626         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42627         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
42628         CHECK_ACCESS(val_ptr);
42629         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
42630         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
42631         RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
42632 }
42633
42634 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) {
42635         LDKPublicKey src_node_id_arg_ref;
42636         CHECK(src_node_id_arg->arr_len == 33);
42637         memcpy(src_node_id_arg_ref.compressed_form, src_node_id_arg->elems, 33); FREE(src_node_id_arg);
42638         LDKRoutingFees fees_arg_conv;
42639         fees_arg_conv.inner = (void*)(fees_arg & (~1));
42640         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
42641         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
42642         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
42643         void* htlc_minimum_msat_arg_ptr = (void*)(((uintptr_t)htlc_minimum_msat_arg) & ~1);
42644         CHECK_ACCESS(htlc_minimum_msat_arg_ptr);
42645         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_minimum_msat_arg_ptr);
42646         htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_minimum_msat_arg) & ~1));
42647         void* htlc_maximum_msat_arg_ptr = (void*)(((uintptr_t)htlc_maximum_msat_arg) & ~1);
42648         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
42649         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
42650         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_maximum_msat_arg) & ~1));
42651         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);
42652         uint32_t ret_ref = 0;
42653         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42654         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42655         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42656         ret_ref = (uintptr_t)ret_var.inner;
42657         if (ret_var.is_owned) {
42658                 ret_ref |= 1;
42659         }
42660         return ret_ref;
42661 }
42662
42663 static inline uintptr_t RouteHintHop_clone_ptr(LDKRouteHintHop *NONNULL_PTR arg) {
42664         LDKRouteHintHop ret_var = RouteHintHop_clone(arg);
42665 uint32_t ret_ref = 0;
42666 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42667 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42668 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42669 ret_ref = (uintptr_t)ret_var.inner;
42670 if (ret_var.is_owned) {
42671         ret_ref |= 1;
42672 }
42673         return ret_ref;
42674 }
42675 uint32_t  __attribute__((export_name("TS_RouteHintHop_clone_ptr"))) TS_RouteHintHop_clone_ptr(uint32_t arg) {
42676         LDKRouteHintHop arg_conv;
42677         arg_conv.inner = (void*)(arg & (~1));
42678         arg_conv.is_owned = false;
42679         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42680         uint32_t ret_conv = RouteHintHop_clone_ptr(&arg_conv);
42681         return ret_conv;
42682 }
42683
42684 uint32_t  __attribute__((export_name("TS_RouteHintHop_clone"))) TS_RouteHintHop_clone(uint32_t orig) {
42685         LDKRouteHintHop orig_conv;
42686         orig_conv.inner = (void*)(orig & (~1));
42687         orig_conv.is_owned = false;
42688         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42689         LDKRouteHintHop ret_var = RouteHintHop_clone(&orig_conv);
42690         uint32_t ret_ref = 0;
42691         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42692         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42693         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42694         ret_ref = (uintptr_t)ret_var.inner;
42695         if (ret_var.is_owned) {
42696                 ret_ref |= 1;
42697         }
42698         return ret_ref;
42699 }
42700
42701 int64_t  __attribute__((export_name("TS_RouteHintHop_hash"))) TS_RouteHintHop_hash(uint32_t o) {
42702         LDKRouteHintHop o_conv;
42703         o_conv.inner = (void*)(o & (~1));
42704         o_conv.is_owned = false;
42705         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
42706         int64_t ret_conv = RouteHintHop_hash(&o_conv);
42707         return ret_conv;
42708 }
42709
42710 jboolean  __attribute__((export_name("TS_RouteHintHop_eq"))) TS_RouteHintHop_eq(uint32_t a, uint32_t b) {
42711         LDKRouteHintHop a_conv;
42712         a_conv.inner = (void*)(a & (~1));
42713         a_conv.is_owned = false;
42714         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42715         LDKRouteHintHop b_conv;
42716         b_conv.inner = (void*)(b & (~1));
42717         b_conv.is_owned = false;
42718         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42719         jboolean ret_conv = RouteHintHop_eq(&a_conv, &b_conv);
42720         return ret_conv;
42721 }
42722
42723 int8_tArray  __attribute__((export_name("TS_RouteHintHop_write"))) TS_RouteHintHop_write(uint32_t obj) {
42724         LDKRouteHintHop obj_conv;
42725         obj_conv.inner = (void*)(obj & (~1));
42726         obj_conv.is_owned = false;
42727         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42728         LDKCVec_u8Z ret_var = RouteHintHop_write(&obj_conv);
42729         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
42730         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
42731         CVec_u8Z_free(ret_var);
42732         return ret_arr;
42733 }
42734
42735 uint32_t  __attribute__((export_name("TS_RouteHintHop_read"))) TS_RouteHintHop_read(int8_tArray ser) {
42736         LDKu8slice ser_ref;
42737         ser_ref.datalen = ser->arr_len;
42738         ser_ref.data = ser->elems;
42739         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
42740         *ret_conv = RouteHintHop_read(ser_ref);
42741         FREE(ser);
42742         return (uint32_t)ret_conv;
42743 }
42744
42745 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) {
42746         LDKPublicKey our_node_pubkey_ref;
42747         CHECK(our_node_pubkey->arr_len == 33);
42748         memcpy(our_node_pubkey_ref.compressed_form, our_node_pubkey->elems, 33); FREE(our_node_pubkey);
42749         LDKRouteParameters route_params_conv;
42750         route_params_conv.inner = (void*)(route_params & (~1));
42751         route_params_conv.is_owned = false;
42752         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
42753         LDKNetworkGraph network_graph_conv;
42754         network_graph_conv.inner = (void*)(network_graph & (~1));
42755         network_graph_conv.is_owned = false;
42756         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
42757         LDKCVec_ChannelDetailsZ first_hops_constr;
42758         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
42759         if (first_hops != 0) {
42760                 first_hops_constr.datalen = first_hops->arr_len;
42761                 if (first_hops_constr.datalen > 0)
42762                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
42763                 else
42764                         first_hops_constr.data = NULL;
42765                 uint32_t* first_hops_vals = first_hops->elems;
42766                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
42767                         uint32_t first_hops_conv_16 = first_hops_vals[q];
42768                         LDKChannelDetails first_hops_conv_16_conv;
42769                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
42770                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
42771                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
42772                         first_hops_constr.data[q] = first_hops_conv_16_conv;
42773                 }
42774                 FREE(first_hops);
42775                 first_hops_ptr = &first_hops_constr;
42776         }
42777         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
42778         CHECK_ACCESS(logger_ptr);
42779         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
42780         if (logger_conv.free == LDKLogger_JCalls_free) {
42781                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
42782                 LDKLogger_JCalls_cloned(&logger_conv);
42783         }
42784         void* scorer_ptr = (void*)(((uintptr_t)scorer) & ~1);
42785         if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
42786         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
42787         unsigned char random_seed_bytes_arr[32];
42788         CHECK(random_seed_bytes->arr_len == 32);
42789         memcpy(random_seed_bytes_arr, random_seed_bytes->elems, 32); FREE(random_seed_bytes);
42790         unsigned char (*random_seed_bytes_ref)[32] = &random_seed_bytes_arr;
42791         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
42792         *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);
42793         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
42794         return (uint32_t)ret_conv;
42795 }
42796
42797 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) {
42798         LDKPublicKey our_node_pubkey_ref;
42799         CHECK(our_node_pubkey->arr_len == 33);
42800         memcpy(our_node_pubkey_ref.compressed_form, our_node_pubkey->elems, 33); FREE(our_node_pubkey);
42801         LDKCVec_PublicKeyZ hops_constr;
42802         hops_constr.datalen = hops->arr_len;
42803         if (hops_constr.datalen > 0)
42804                 hops_constr.data = MALLOC(hops_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
42805         else
42806                 hops_constr.data = NULL;
42807         int8_tArray* hops_vals = (void*) hops->elems;
42808         for (size_t m = 0; m < hops_constr.datalen; m++) {
42809                 int8_tArray hops_conv_12 = hops_vals[m];
42810                 LDKPublicKey hops_conv_12_ref;
42811                 CHECK(hops_conv_12->arr_len == 33);
42812                 memcpy(hops_conv_12_ref.compressed_form, hops_conv_12->elems, 33); FREE(hops_conv_12);
42813                 hops_constr.data[m] = hops_conv_12_ref;
42814         }
42815         FREE(hops);
42816         LDKRouteParameters route_params_conv;
42817         route_params_conv.inner = (void*)(route_params & (~1));
42818         route_params_conv.is_owned = false;
42819         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
42820         LDKNetworkGraph network_graph_conv;
42821         network_graph_conv.inner = (void*)(network_graph & (~1));
42822         network_graph_conv.is_owned = false;
42823         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
42824         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
42825         CHECK_ACCESS(logger_ptr);
42826         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
42827         if (logger_conv.free == LDKLogger_JCalls_free) {
42828                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
42829                 LDKLogger_JCalls_cloned(&logger_conv);
42830         }
42831         unsigned char random_seed_bytes_arr[32];
42832         CHECK(random_seed_bytes->arr_len == 32);
42833         memcpy(random_seed_bytes_arr, random_seed_bytes->elems, 32); FREE(random_seed_bytes);
42834         unsigned char (*random_seed_bytes_ref)[32] = &random_seed_bytes_arr;
42835         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
42836         *ret_conv = build_route_from_hops(our_node_pubkey_ref, hops_constr, &route_params_conv, &network_graph_conv, logger_conv, random_seed_bytes_ref);
42837         return (uint32_t)ret_conv;
42838 }
42839
42840 void  __attribute__((export_name("TS_Score_free"))) TS_Score_free(uint32_t this_ptr) {
42841         if ((this_ptr & 1) != 0) return;
42842         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
42843         CHECK_ACCESS(this_ptr_ptr);
42844         LDKScore this_ptr_conv = *(LDKScore*)(this_ptr_ptr);
42845         FREE((void*)this_ptr);
42846         Score_free(this_ptr_conv);
42847 }
42848
42849 void  __attribute__((export_name("TS_LockableScore_free"))) TS_LockableScore_free(uint32_t this_ptr) {
42850         if ((this_ptr & 1) != 0) return;
42851         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
42852         CHECK_ACCESS(this_ptr_ptr);
42853         LDKLockableScore this_ptr_conv = *(LDKLockableScore*)(this_ptr_ptr);
42854         FREE((void*)this_ptr);
42855         LockableScore_free(this_ptr_conv);
42856 }
42857
42858 void  __attribute__((export_name("TS_MultiThreadedLockableScore_free"))) TS_MultiThreadedLockableScore_free(uint32_t this_obj) {
42859         LDKMultiThreadedLockableScore this_obj_conv;
42860         this_obj_conv.inner = (void*)(this_obj & (~1));
42861         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42862         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42863         MultiThreadedLockableScore_free(this_obj_conv);
42864 }
42865
42866 int8_tArray  __attribute__((export_name("TS_MultiThreadedLockableScore_write"))) TS_MultiThreadedLockableScore_write(uint32_t obj) {
42867         LDKMultiThreadedLockableScore obj_conv;
42868         obj_conv.inner = (void*)(obj & (~1));
42869         obj_conv.is_owned = false;
42870         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42871         LDKCVec_u8Z ret_var = MultiThreadedLockableScore_write(&obj_conv);
42872         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
42873         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
42874         CVec_u8Z_free(ret_var);
42875         return ret_arr;
42876 }
42877
42878 uint32_t  __attribute__((export_name("TS_MultiThreadedLockableScore_new"))) TS_MultiThreadedLockableScore_new(uint32_t score) {
42879         void* score_ptr = (void*)(((uintptr_t)score) & ~1);
42880         CHECK_ACCESS(score_ptr);
42881         LDKScore score_conv = *(LDKScore*)(score_ptr);
42882         if (score_conv.free == LDKScore_JCalls_free) {
42883                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
42884                 LDKScore_JCalls_cloned(&score_conv);
42885         }
42886         LDKMultiThreadedLockableScore ret_var = MultiThreadedLockableScore_new(score_conv);
42887         uint32_t ret_ref = 0;
42888         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42889         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42890         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42891         ret_ref = (uintptr_t)ret_var.inner;
42892         if (ret_var.is_owned) {
42893                 ret_ref |= 1;
42894         }
42895         return ret_ref;
42896 }
42897
42898 void  __attribute__((export_name("TS_ChannelUsage_free"))) TS_ChannelUsage_free(uint32_t this_obj) {
42899         LDKChannelUsage this_obj_conv;
42900         this_obj_conv.inner = (void*)(this_obj & (~1));
42901         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42902         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42903         ChannelUsage_free(this_obj_conv);
42904 }
42905
42906 int64_t  __attribute__((export_name("TS_ChannelUsage_get_amount_msat"))) TS_ChannelUsage_get_amount_msat(uint32_t this_ptr) {
42907         LDKChannelUsage this_ptr_conv;
42908         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42909         this_ptr_conv.is_owned = false;
42910         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42911         int64_t ret_conv = ChannelUsage_get_amount_msat(&this_ptr_conv);
42912         return ret_conv;
42913 }
42914
42915 void  __attribute__((export_name("TS_ChannelUsage_set_amount_msat"))) TS_ChannelUsage_set_amount_msat(uint32_t this_ptr, int64_t val) {
42916         LDKChannelUsage this_ptr_conv;
42917         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42918         this_ptr_conv.is_owned = false;
42919         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42920         ChannelUsage_set_amount_msat(&this_ptr_conv, val);
42921 }
42922
42923 int64_t  __attribute__((export_name("TS_ChannelUsage_get_inflight_htlc_msat"))) TS_ChannelUsage_get_inflight_htlc_msat(uint32_t this_ptr) {
42924         LDKChannelUsage this_ptr_conv;
42925         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42926         this_ptr_conv.is_owned = false;
42927         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42928         int64_t ret_conv = ChannelUsage_get_inflight_htlc_msat(&this_ptr_conv);
42929         return ret_conv;
42930 }
42931
42932 void  __attribute__((export_name("TS_ChannelUsage_set_inflight_htlc_msat"))) TS_ChannelUsage_set_inflight_htlc_msat(uint32_t this_ptr, int64_t val) {
42933         LDKChannelUsage this_ptr_conv;
42934         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42935         this_ptr_conv.is_owned = false;
42936         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42937         ChannelUsage_set_inflight_htlc_msat(&this_ptr_conv, val);
42938 }
42939
42940 uint32_t  __attribute__((export_name("TS_ChannelUsage_get_effective_capacity"))) TS_ChannelUsage_get_effective_capacity(uint32_t this_ptr) {
42941         LDKChannelUsage this_ptr_conv;
42942         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42943         this_ptr_conv.is_owned = false;
42944         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42945         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
42946         *ret_copy = ChannelUsage_get_effective_capacity(&this_ptr_conv);
42947         uint32_t ret_ref = (uintptr_t)ret_copy;
42948         return ret_ref;
42949 }
42950
42951 void  __attribute__((export_name("TS_ChannelUsage_set_effective_capacity"))) TS_ChannelUsage_set_effective_capacity(uint32_t this_ptr, uint32_t val) {
42952         LDKChannelUsage this_ptr_conv;
42953         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42954         this_ptr_conv.is_owned = false;
42955         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42956         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
42957         CHECK_ACCESS(val_ptr);
42958         LDKEffectiveCapacity val_conv = *(LDKEffectiveCapacity*)(val_ptr);
42959         val_conv = EffectiveCapacity_clone((LDKEffectiveCapacity*)(((uintptr_t)val) & ~1));
42960         ChannelUsage_set_effective_capacity(&this_ptr_conv, val_conv);
42961 }
42962
42963 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) {
42964         void* effective_capacity_arg_ptr = (void*)(((uintptr_t)effective_capacity_arg) & ~1);
42965         CHECK_ACCESS(effective_capacity_arg_ptr);
42966         LDKEffectiveCapacity effective_capacity_arg_conv = *(LDKEffectiveCapacity*)(effective_capacity_arg_ptr);
42967         effective_capacity_arg_conv = EffectiveCapacity_clone((LDKEffectiveCapacity*)(((uintptr_t)effective_capacity_arg) & ~1));
42968         LDKChannelUsage ret_var = ChannelUsage_new(amount_msat_arg, inflight_htlc_msat_arg, effective_capacity_arg_conv);
42969         uint32_t ret_ref = 0;
42970         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42971         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42972         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42973         ret_ref = (uintptr_t)ret_var.inner;
42974         if (ret_var.is_owned) {
42975                 ret_ref |= 1;
42976         }
42977         return ret_ref;
42978 }
42979
42980 static inline uintptr_t ChannelUsage_clone_ptr(LDKChannelUsage *NONNULL_PTR arg) {
42981         LDKChannelUsage ret_var = ChannelUsage_clone(arg);
42982 uint32_t ret_ref = 0;
42983 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42984 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42985 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42986 ret_ref = (uintptr_t)ret_var.inner;
42987 if (ret_var.is_owned) {
42988         ret_ref |= 1;
42989 }
42990         return ret_ref;
42991 }
42992 uint32_t  __attribute__((export_name("TS_ChannelUsage_clone_ptr"))) TS_ChannelUsage_clone_ptr(uint32_t arg) {
42993         LDKChannelUsage arg_conv;
42994         arg_conv.inner = (void*)(arg & (~1));
42995         arg_conv.is_owned = false;
42996         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42997         uint32_t ret_conv = ChannelUsage_clone_ptr(&arg_conv);
42998         return ret_conv;
42999 }
43000
43001 uint32_t  __attribute__((export_name("TS_ChannelUsage_clone"))) TS_ChannelUsage_clone(uint32_t orig) {
43002         LDKChannelUsage orig_conv;
43003         orig_conv.inner = (void*)(orig & (~1));
43004         orig_conv.is_owned = false;
43005         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43006         LDKChannelUsage ret_var = ChannelUsage_clone(&orig_conv);
43007         uint32_t ret_ref = 0;
43008         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43009         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43010         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43011         ret_ref = (uintptr_t)ret_var.inner;
43012         if (ret_var.is_owned) {
43013                 ret_ref |= 1;
43014         }
43015         return ret_ref;
43016 }
43017
43018 void  __attribute__((export_name("TS_FixedPenaltyScorer_free"))) TS_FixedPenaltyScorer_free(uint32_t this_obj) {
43019         LDKFixedPenaltyScorer this_obj_conv;
43020         this_obj_conv.inner = (void*)(this_obj & (~1));
43021         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43022         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43023         FixedPenaltyScorer_free(this_obj_conv);
43024 }
43025
43026 static inline uintptr_t FixedPenaltyScorer_clone_ptr(LDKFixedPenaltyScorer *NONNULL_PTR arg) {
43027         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(arg);
43028 uint32_t ret_ref = 0;
43029 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43030 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43031 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43032 ret_ref = (uintptr_t)ret_var.inner;
43033 if (ret_var.is_owned) {
43034         ret_ref |= 1;
43035 }
43036         return ret_ref;
43037 }
43038 uint32_t  __attribute__((export_name("TS_FixedPenaltyScorer_clone_ptr"))) TS_FixedPenaltyScorer_clone_ptr(uint32_t arg) {
43039         LDKFixedPenaltyScorer arg_conv;
43040         arg_conv.inner = (void*)(arg & (~1));
43041         arg_conv.is_owned = false;
43042         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43043         uint32_t ret_conv = FixedPenaltyScorer_clone_ptr(&arg_conv);
43044         return ret_conv;
43045 }
43046
43047 uint32_t  __attribute__((export_name("TS_FixedPenaltyScorer_clone"))) TS_FixedPenaltyScorer_clone(uint32_t orig) {
43048         LDKFixedPenaltyScorer orig_conv;
43049         orig_conv.inner = (void*)(orig & (~1));
43050         orig_conv.is_owned = false;
43051         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43052         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(&orig_conv);
43053         uint32_t ret_ref = 0;
43054         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43055         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43056         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43057         ret_ref = (uintptr_t)ret_var.inner;
43058         if (ret_var.is_owned) {
43059                 ret_ref |= 1;
43060         }
43061         return ret_ref;
43062 }
43063
43064 uint32_t  __attribute__((export_name("TS_FixedPenaltyScorer_with_penalty"))) TS_FixedPenaltyScorer_with_penalty(int64_t penalty_msat) {
43065         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_with_penalty(penalty_msat);
43066         uint32_t ret_ref = 0;
43067         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43068         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43069         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43070         ret_ref = (uintptr_t)ret_var.inner;
43071         if (ret_var.is_owned) {
43072                 ret_ref |= 1;
43073         }
43074         return ret_ref;
43075 }
43076
43077 uint32_t  __attribute__((export_name("TS_FixedPenaltyScorer_as_Score"))) TS_FixedPenaltyScorer_as_Score(uint32_t this_arg) {
43078         LDKFixedPenaltyScorer this_arg_conv;
43079         this_arg_conv.inner = (void*)(this_arg & (~1));
43080         this_arg_conv.is_owned = false;
43081         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43082         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
43083         *ret_ret = FixedPenaltyScorer_as_Score(&this_arg_conv);
43084         return (uint32_t)ret_ret;
43085 }
43086
43087 int8_tArray  __attribute__((export_name("TS_FixedPenaltyScorer_write"))) TS_FixedPenaltyScorer_write(uint32_t obj) {
43088         LDKFixedPenaltyScorer obj_conv;
43089         obj_conv.inner = (void*)(obj & (~1));
43090         obj_conv.is_owned = false;
43091         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43092         LDKCVec_u8Z ret_var = FixedPenaltyScorer_write(&obj_conv);
43093         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
43094         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
43095         CVec_u8Z_free(ret_var);
43096         return ret_arr;
43097 }
43098
43099 uint32_t  __attribute__((export_name("TS_FixedPenaltyScorer_read"))) TS_FixedPenaltyScorer_read(int8_tArray ser, int64_t arg) {
43100         LDKu8slice ser_ref;
43101         ser_ref.datalen = ser->arr_len;
43102         ser_ref.data = ser->elems;
43103         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
43104         *ret_conv = FixedPenaltyScorer_read(ser_ref, arg);
43105         FREE(ser);
43106         return (uint32_t)ret_conv;
43107 }
43108
43109 void  __attribute__((export_name("TS_ProbabilisticScorer_free"))) TS_ProbabilisticScorer_free(uint32_t this_obj) {
43110         LDKProbabilisticScorer this_obj_conv;
43111         this_obj_conv.inner = (void*)(this_obj & (~1));
43112         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43113         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43114         ProbabilisticScorer_free(this_obj_conv);
43115 }
43116
43117 void  __attribute__((export_name("TS_ProbabilisticScoringParameters_free"))) TS_ProbabilisticScoringParameters_free(uint32_t this_obj) {
43118         LDKProbabilisticScoringParameters this_obj_conv;
43119         this_obj_conv.inner = (void*)(this_obj & (~1));
43120         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43121         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43122         ProbabilisticScoringParameters_free(this_obj_conv);
43123 }
43124
43125 int64_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_get_base_penalty_msat"))) TS_ProbabilisticScoringParameters_get_base_penalty_msat(uint32_t this_ptr) {
43126         LDKProbabilisticScoringParameters this_ptr_conv;
43127         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43128         this_ptr_conv.is_owned = false;
43129         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43130         int64_t ret_conv = ProbabilisticScoringParameters_get_base_penalty_msat(&this_ptr_conv);
43131         return ret_conv;
43132 }
43133
43134 void  __attribute__((export_name("TS_ProbabilisticScoringParameters_set_base_penalty_msat"))) TS_ProbabilisticScoringParameters_set_base_penalty_msat(uint32_t this_ptr, int64_t val) {
43135         LDKProbabilisticScoringParameters this_ptr_conv;
43136         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43137         this_ptr_conv.is_owned = false;
43138         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43139         ProbabilisticScoringParameters_set_base_penalty_msat(&this_ptr_conv, val);
43140 }
43141
43142 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) {
43143         LDKProbabilisticScoringParameters this_ptr_conv;
43144         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43145         this_ptr_conv.is_owned = false;
43146         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43147         int64_t ret_conv = ProbabilisticScoringParameters_get_base_penalty_amount_multiplier_msat(&this_ptr_conv);
43148         return ret_conv;
43149 }
43150
43151 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) {
43152         LDKProbabilisticScoringParameters this_ptr_conv;
43153         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43154         this_ptr_conv.is_owned = false;
43155         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43156         ProbabilisticScoringParameters_set_base_penalty_amount_multiplier_msat(&this_ptr_conv, val);
43157 }
43158
43159 int64_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat"))) TS_ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat(uint32_t this_ptr) {
43160         LDKProbabilisticScoringParameters this_ptr_conv;
43161         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43162         this_ptr_conv.is_owned = false;
43163         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43164         int64_t ret_conv = ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat(&this_ptr_conv);
43165         return ret_conv;
43166 }
43167
43168 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) {
43169         LDKProbabilisticScoringParameters this_ptr_conv;
43170         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43171         this_ptr_conv.is_owned = false;
43172         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43173         ProbabilisticScoringParameters_set_liquidity_penalty_multiplier_msat(&this_ptr_conv, val);
43174 }
43175
43176 int64_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_get_liquidity_offset_half_life"))) TS_ProbabilisticScoringParameters_get_liquidity_offset_half_life(uint32_t this_ptr) {
43177         LDKProbabilisticScoringParameters this_ptr_conv;
43178         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43179         this_ptr_conv.is_owned = false;
43180         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43181         int64_t ret_conv = ProbabilisticScoringParameters_get_liquidity_offset_half_life(&this_ptr_conv);
43182         return ret_conv;
43183 }
43184
43185 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) {
43186         LDKProbabilisticScoringParameters this_ptr_conv;
43187         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43188         this_ptr_conv.is_owned = false;
43189         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43190         ProbabilisticScoringParameters_set_liquidity_offset_half_life(&this_ptr_conv, val);
43191 }
43192
43193 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) {
43194         LDKProbabilisticScoringParameters this_ptr_conv;
43195         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43196         this_ptr_conv.is_owned = false;
43197         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43198         int64_t ret_conv = ProbabilisticScoringParameters_get_liquidity_penalty_amount_multiplier_msat(&this_ptr_conv);
43199         return ret_conv;
43200 }
43201
43202 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) {
43203         LDKProbabilisticScoringParameters this_ptr_conv;
43204         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43205         this_ptr_conv.is_owned = false;
43206         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43207         ProbabilisticScoringParameters_set_liquidity_penalty_amount_multiplier_msat(&this_ptr_conv, val);
43208 }
43209
43210 int64_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_get_anti_probing_penalty_msat"))) TS_ProbabilisticScoringParameters_get_anti_probing_penalty_msat(uint32_t this_ptr) {
43211         LDKProbabilisticScoringParameters this_ptr_conv;
43212         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43213         this_ptr_conv.is_owned = false;
43214         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43215         int64_t ret_conv = ProbabilisticScoringParameters_get_anti_probing_penalty_msat(&this_ptr_conv);
43216         return ret_conv;
43217 }
43218
43219 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) {
43220         LDKProbabilisticScoringParameters this_ptr_conv;
43221         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43222         this_ptr_conv.is_owned = false;
43223         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43224         ProbabilisticScoringParameters_set_anti_probing_penalty_msat(&this_ptr_conv, val);
43225 }
43226
43227 int64_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_get_considered_impossible_penalty_msat"))) TS_ProbabilisticScoringParameters_get_considered_impossible_penalty_msat(uint32_t this_ptr) {
43228         LDKProbabilisticScoringParameters this_ptr_conv;
43229         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43230         this_ptr_conv.is_owned = false;
43231         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43232         int64_t ret_conv = ProbabilisticScoringParameters_get_considered_impossible_penalty_msat(&this_ptr_conv);
43233         return ret_conv;
43234 }
43235
43236 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) {
43237         LDKProbabilisticScoringParameters this_ptr_conv;
43238         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43239         this_ptr_conv.is_owned = false;
43240         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43241         ProbabilisticScoringParameters_set_considered_impossible_penalty_msat(&this_ptr_conv, val);
43242 }
43243
43244 static inline uintptr_t ProbabilisticScoringParameters_clone_ptr(LDKProbabilisticScoringParameters *NONNULL_PTR arg) {
43245         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_clone(arg);
43246 uint32_t ret_ref = 0;
43247 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43248 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43249 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43250 ret_ref = (uintptr_t)ret_var.inner;
43251 if (ret_var.is_owned) {
43252         ret_ref |= 1;
43253 }
43254         return ret_ref;
43255 }
43256 uint32_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_clone_ptr"))) TS_ProbabilisticScoringParameters_clone_ptr(uint32_t arg) {
43257         LDKProbabilisticScoringParameters arg_conv;
43258         arg_conv.inner = (void*)(arg & (~1));
43259         arg_conv.is_owned = false;
43260         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43261         uint32_t ret_conv = ProbabilisticScoringParameters_clone_ptr(&arg_conv);
43262         return ret_conv;
43263 }
43264
43265 uint32_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_clone"))) TS_ProbabilisticScoringParameters_clone(uint32_t orig) {
43266         LDKProbabilisticScoringParameters orig_conv;
43267         orig_conv.inner = (void*)(orig & (~1));
43268         orig_conv.is_owned = false;
43269         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43270         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_clone(&orig_conv);
43271         uint32_t ret_ref = 0;
43272         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43273         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43274         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43275         ret_ref = (uintptr_t)ret_var.inner;
43276         if (ret_var.is_owned) {
43277                 ret_ref |= 1;
43278         }
43279         return ret_ref;
43280 }
43281
43282 uint32_t  __attribute__((export_name("TS_ProbabilisticScorer_new"))) TS_ProbabilisticScorer_new(uint32_t params, uint32_t network_graph, uint32_t logger) {
43283         LDKProbabilisticScoringParameters params_conv;
43284         params_conv.inner = (void*)(params & (~1));
43285         params_conv.is_owned = (params & 1) || (params == 0);
43286         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
43287         params_conv = ProbabilisticScoringParameters_clone(&params_conv);
43288         LDKNetworkGraph network_graph_conv;
43289         network_graph_conv.inner = (void*)(network_graph & (~1));
43290         network_graph_conv.is_owned = false;
43291         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
43292         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
43293         CHECK_ACCESS(logger_ptr);
43294         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
43295         if (logger_conv.free == LDKLogger_JCalls_free) {
43296                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
43297                 LDKLogger_JCalls_cloned(&logger_conv);
43298         }
43299         LDKProbabilisticScorer ret_var = ProbabilisticScorer_new(params_conv, &network_graph_conv, logger_conv);
43300         uint32_t ret_ref = 0;
43301         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43302         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43303         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43304         ret_ref = (uintptr_t)ret_var.inner;
43305         if (ret_var.is_owned) {
43306                 ret_ref |= 1;
43307         }
43308         return ret_ref;
43309 }
43310
43311 void  __attribute__((export_name("TS_ProbabilisticScorer_debug_log_liquidity_stats"))) TS_ProbabilisticScorer_debug_log_liquidity_stats(uint32_t this_arg) {
43312         LDKProbabilisticScorer this_arg_conv;
43313         this_arg_conv.inner = (void*)(this_arg & (~1));
43314         this_arg_conv.is_owned = false;
43315         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43316         ProbabilisticScorer_debug_log_liquidity_stats(&this_arg_conv);
43317 }
43318
43319 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) {
43320         LDKProbabilisticScorer this_arg_conv;
43321         this_arg_conv.inner = (void*)(this_arg & (~1));
43322         this_arg_conv.is_owned = false;
43323         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43324         LDKNodeId target_conv;
43325         target_conv.inner = (void*)(target & (~1));
43326         target_conv.is_owned = false;
43327         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
43328         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
43329         *ret_copy = ProbabilisticScorer_estimated_channel_liquidity_range(&this_arg_conv, scid, &target_conv);
43330         uint32_t ret_ref = (uintptr_t)ret_copy;
43331         return ret_ref;
43332 }
43333
43334 void  __attribute__((export_name("TS_ProbabilisticScorer_add_banned"))) TS_ProbabilisticScorer_add_banned(uint32_t this_arg, uint32_t node_id) {
43335         LDKProbabilisticScorer this_arg_conv;
43336         this_arg_conv.inner = (void*)(this_arg & (~1));
43337         this_arg_conv.is_owned = false;
43338         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43339         LDKNodeId node_id_conv;
43340         node_id_conv.inner = (void*)(node_id & (~1));
43341         node_id_conv.is_owned = false;
43342         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
43343         ProbabilisticScorer_add_banned(&this_arg_conv, &node_id_conv);
43344 }
43345
43346 void  __attribute__((export_name("TS_ProbabilisticScorer_remove_banned"))) TS_ProbabilisticScorer_remove_banned(uint32_t this_arg, uint32_t node_id) {
43347         LDKProbabilisticScorer this_arg_conv;
43348         this_arg_conv.inner = (void*)(this_arg & (~1));
43349         this_arg_conv.is_owned = false;
43350         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43351         LDKNodeId node_id_conv;
43352         node_id_conv.inner = (void*)(node_id & (~1));
43353         node_id_conv.is_owned = false;
43354         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
43355         ProbabilisticScorer_remove_banned(&this_arg_conv, &node_id_conv);
43356 }
43357
43358 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) {
43359         LDKProbabilisticScorer this_arg_conv;
43360         this_arg_conv.inner = (void*)(this_arg & (~1));
43361         this_arg_conv.is_owned = false;
43362         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43363         LDKNodeId node_id_conv;
43364         node_id_conv.inner = (void*)(node_id & (~1));
43365         node_id_conv.is_owned = false;
43366         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
43367         ProbabilisticScorer_set_manual_penalty(&this_arg_conv, &node_id_conv, penalty);
43368 }
43369
43370 void  __attribute__((export_name("TS_ProbabilisticScorer_remove_manual_penalty"))) TS_ProbabilisticScorer_remove_manual_penalty(uint32_t this_arg, uint32_t node_id) {
43371         LDKProbabilisticScorer this_arg_conv;
43372         this_arg_conv.inner = (void*)(this_arg & (~1));
43373         this_arg_conv.is_owned = false;
43374         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43375         LDKNodeId node_id_conv;
43376         node_id_conv.inner = (void*)(node_id & (~1));
43377         node_id_conv.is_owned = false;
43378         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
43379         ProbabilisticScorer_remove_manual_penalty(&this_arg_conv, &node_id_conv);
43380 }
43381
43382 void  __attribute__((export_name("TS_ProbabilisticScorer_clear_manual_penalties"))) TS_ProbabilisticScorer_clear_manual_penalties(uint32_t this_arg) {
43383         LDKProbabilisticScorer this_arg_conv;
43384         this_arg_conv.inner = (void*)(this_arg & (~1));
43385         this_arg_conv.is_owned = false;
43386         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43387         ProbabilisticScorer_clear_manual_penalties(&this_arg_conv);
43388 }
43389
43390 void  __attribute__((export_name("TS_ProbabilisticScoringParameters_add_banned_from_list"))) TS_ProbabilisticScoringParameters_add_banned_from_list(uint32_t this_arg, uint32_tArray node_ids) {
43391         LDKProbabilisticScoringParameters this_arg_conv;
43392         this_arg_conv.inner = (void*)(this_arg & (~1));
43393         this_arg_conv.is_owned = false;
43394         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43395         LDKCVec_NodeIdZ node_ids_constr;
43396         node_ids_constr.datalen = node_ids->arr_len;
43397         if (node_ids_constr.datalen > 0)
43398                 node_ids_constr.data = MALLOC(node_ids_constr.datalen * sizeof(LDKNodeId), "LDKCVec_NodeIdZ Elements");
43399         else
43400                 node_ids_constr.data = NULL;
43401         uint32_t* node_ids_vals = node_ids->elems;
43402         for (size_t i = 0; i < node_ids_constr.datalen; i++) {
43403                 uint32_t node_ids_conv_8 = node_ids_vals[i];
43404                 LDKNodeId node_ids_conv_8_conv;
43405                 node_ids_conv_8_conv.inner = (void*)(node_ids_conv_8 & (~1));
43406                 node_ids_conv_8_conv.is_owned = (node_ids_conv_8 & 1) || (node_ids_conv_8 == 0);
43407                 CHECK_INNER_FIELD_ACCESS_OR_NULL(node_ids_conv_8_conv);
43408                 node_ids_conv_8_conv = NodeId_clone(&node_ids_conv_8_conv);
43409                 node_ids_constr.data[i] = node_ids_conv_8_conv;
43410         }
43411         FREE(node_ids);
43412         ProbabilisticScoringParameters_add_banned_from_list(&this_arg_conv, node_ids_constr);
43413 }
43414
43415 uint32_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_default"))) TS_ProbabilisticScoringParameters_default() {
43416         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_default();
43417         uint32_t ret_ref = 0;
43418         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43419         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43420         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43421         ret_ref = (uintptr_t)ret_var.inner;
43422         if (ret_var.is_owned) {
43423                 ret_ref |= 1;
43424         }
43425         return ret_ref;
43426 }
43427
43428 uint32_t  __attribute__((export_name("TS_ProbabilisticScorer_as_Score"))) TS_ProbabilisticScorer_as_Score(uint32_t this_arg) {
43429         LDKProbabilisticScorer this_arg_conv;
43430         this_arg_conv.inner = (void*)(this_arg & (~1));
43431         this_arg_conv.is_owned = false;
43432         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43433         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
43434         *ret_ret = ProbabilisticScorer_as_Score(&this_arg_conv);
43435         return (uint32_t)ret_ret;
43436 }
43437
43438 int8_tArray  __attribute__((export_name("TS_ProbabilisticScorer_write"))) TS_ProbabilisticScorer_write(uint32_t obj) {
43439         LDKProbabilisticScorer obj_conv;
43440         obj_conv.inner = (void*)(obj & (~1));
43441         obj_conv.is_owned = false;
43442         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43443         LDKCVec_u8Z ret_var = ProbabilisticScorer_write(&obj_conv);
43444         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
43445         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
43446         CVec_u8Z_free(ret_var);
43447         return ret_arr;
43448 }
43449
43450 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) {
43451         LDKu8slice ser_ref;
43452         ser_ref.datalen = ser->arr_len;
43453         ser_ref.data = ser->elems;
43454         LDKProbabilisticScoringParameters arg_a_conv;
43455         arg_a_conv.inner = (void*)(arg_a & (~1));
43456         arg_a_conv.is_owned = (arg_a & 1) || (arg_a == 0);
43457         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_a_conv);
43458         arg_a_conv = ProbabilisticScoringParameters_clone(&arg_a_conv);
43459         LDKNetworkGraph arg_b_conv;
43460         arg_b_conv.inner = (void*)(arg_b & (~1));
43461         arg_b_conv.is_owned = false;
43462         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_b_conv);
43463         void* arg_c_ptr = (void*)(((uintptr_t)arg_c) & ~1);
43464         CHECK_ACCESS(arg_c_ptr);
43465         LDKLogger arg_c_conv = *(LDKLogger*)(arg_c_ptr);
43466         if (arg_c_conv.free == LDKLogger_JCalls_free) {
43467                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
43468                 LDKLogger_JCalls_cloned(&arg_c_conv);
43469         }
43470         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
43471         *ret_conv = ProbabilisticScorer_read(ser_ref, arg_a_conv, &arg_b_conv, arg_c_conv);
43472         FREE(ser);
43473         return (uint32_t)ret_conv;
43474 }
43475
43476 void  __attribute__((export_name("TS_ParseError_free"))) TS_ParseError_free(uint32_t this_ptr) {
43477         if ((this_ptr & 1) != 0) return;
43478         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
43479         CHECK_ACCESS(this_ptr_ptr);
43480         LDKParseError this_ptr_conv = *(LDKParseError*)(this_ptr_ptr);
43481         FREE((void*)this_ptr);
43482         ParseError_free(this_ptr_conv);
43483 }
43484
43485 static inline uintptr_t ParseError_clone_ptr(LDKParseError *NONNULL_PTR arg) {
43486         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43487         *ret_copy = ParseError_clone(arg);
43488 uint32_t ret_ref = (uintptr_t)ret_copy;
43489         return ret_ref;
43490 }
43491 uint32_t  __attribute__((export_name("TS_ParseError_clone_ptr"))) TS_ParseError_clone_ptr(uint32_t arg) {
43492         LDKParseError* arg_conv = (LDKParseError*)arg;
43493         uint32_t ret_conv = ParseError_clone_ptr(arg_conv);
43494         return ret_conv;
43495 }
43496
43497 uint32_t  __attribute__((export_name("TS_ParseError_clone"))) TS_ParseError_clone(uint32_t orig) {
43498         LDKParseError* orig_conv = (LDKParseError*)orig;
43499         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43500         *ret_copy = ParseError_clone(orig_conv);
43501         uint32_t ret_ref = (uintptr_t)ret_copy;
43502         return ret_ref;
43503 }
43504
43505 uint32_t  __attribute__((export_name("TS_ParseError_bech32_error"))) TS_ParseError_bech32_error(uint32_t a) {
43506         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
43507         CHECK_ACCESS(a_ptr);
43508         LDKBech32Error a_conv = *(LDKBech32Error*)(a_ptr);
43509         a_conv = Bech32Error_clone((LDKBech32Error*)(((uintptr_t)a) & ~1));
43510         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43511         *ret_copy = ParseError_bech32_error(a_conv);
43512         uint32_t ret_ref = (uintptr_t)ret_copy;
43513         return ret_ref;
43514 }
43515
43516 uint32_t  __attribute__((export_name("TS_ParseError_parse_amount_error"))) TS_ParseError_parse_amount_error(int32_t a) {
43517         
43518         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43519         *ret_copy = ParseError_parse_amount_error((LDKError){ ._dummy = 0 });
43520         uint32_t ret_ref = (uintptr_t)ret_copy;
43521         return ret_ref;
43522 }
43523
43524 uint32_t  __attribute__((export_name("TS_ParseError_malformed_signature"))) TS_ParseError_malformed_signature(uint32_t a) {
43525         LDKSecp256k1Error a_conv = LDKSecp256k1Error_from_js(a);
43526         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43527         *ret_copy = ParseError_malformed_signature(a_conv);
43528         uint32_t ret_ref = (uintptr_t)ret_copy;
43529         return ret_ref;
43530 }
43531
43532 uint32_t  __attribute__((export_name("TS_ParseError_bad_prefix"))) TS_ParseError_bad_prefix() {
43533         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43534         *ret_copy = ParseError_bad_prefix();
43535         uint32_t ret_ref = (uintptr_t)ret_copy;
43536         return ret_ref;
43537 }
43538
43539 uint32_t  __attribute__((export_name("TS_ParseError_unknown_currency"))) TS_ParseError_unknown_currency() {
43540         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43541         *ret_copy = ParseError_unknown_currency();
43542         uint32_t ret_ref = (uintptr_t)ret_copy;
43543         return ret_ref;
43544 }
43545
43546 uint32_t  __attribute__((export_name("TS_ParseError_unknown_si_prefix"))) TS_ParseError_unknown_si_prefix() {
43547         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43548         *ret_copy = ParseError_unknown_si_prefix();
43549         uint32_t ret_ref = (uintptr_t)ret_copy;
43550         return ret_ref;
43551 }
43552
43553 uint32_t  __attribute__((export_name("TS_ParseError_malformed_hrp"))) TS_ParseError_malformed_hrp() {
43554         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43555         *ret_copy = ParseError_malformed_hrp();
43556         uint32_t ret_ref = (uintptr_t)ret_copy;
43557         return ret_ref;
43558 }
43559
43560 uint32_t  __attribute__((export_name("TS_ParseError_too_short_data_part"))) TS_ParseError_too_short_data_part() {
43561         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43562         *ret_copy = ParseError_too_short_data_part();
43563         uint32_t ret_ref = (uintptr_t)ret_copy;
43564         return ret_ref;
43565 }
43566
43567 uint32_t  __attribute__((export_name("TS_ParseError_unexpected_end_of_tagged_fields"))) TS_ParseError_unexpected_end_of_tagged_fields() {
43568         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43569         *ret_copy = ParseError_unexpected_end_of_tagged_fields();
43570         uint32_t ret_ref = (uintptr_t)ret_copy;
43571         return ret_ref;
43572 }
43573
43574 uint32_t  __attribute__((export_name("TS_ParseError_description_decode_error"))) TS_ParseError_description_decode_error(int32_t a) {
43575         
43576         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43577         *ret_copy = ParseError_description_decode_error((LDKError){ ._dummy = 0 });
43578         uint32_t ret_ref = (uintptr_t)ret_copy;
43579         return ret_ref;
43580 }
43581
43582 uint32_t  __attribute__((export_name("TS_ParseError_padding_error"))) TS_ParseError_padding_error() {
43583         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43584         *ret_copy = ParseError_padding_error();
43585         uint32_t ret_ref = (uintptr_t)ret_copy;
43586         return ret_ref;
43587 }
43588
43589 uint32_t  __attribute__((export_name("TS_ParseError_integer_overflow_error"))) TS_ParseError_integer_overflow_error() {
43590         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43591         *ret_copy = ParseError_integer_overflow_error();
43592         uint32_t ret_ref = (uintptr_t)ret_copy;
43593         return ret_ref;
43594 }
43595
43596 uint32_t  __attribute__((export_name("TS_ParseError_invalid_seg_wit_program_length"))) TS_ParseError_invalid_seg_wit_program_length() {
43597         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43598         *ret_copy = ParseError_invalid_seg_wit_program_length();
43599         uint32_t ret_ref = (uintptr_t)ret_copy;
43600         return ret_ref;
43601 }
43602
43603 uint32_t  __attribute__((export_name("TS_ParseError_invalid_pub_key_hash_length"))) TS_ParseError_invalid_pub_key_hash_length() {
43604         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43605         *ret_copy = ParseError_invalid_pub_key_hash_length();
43606         uint32_t ret_ref = (uintptr_t)ret_copy;
43607         return ret_ref;
43608 }
43609
43610 uint32_t  __attribute__((export_name("TS_ParseError_invalid_script_hash_length"))) TS_ParseError_invalid_script_hash_length() {
43611         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43612         *ret_copy = ParseError_invalid_script_hash_length();
43613         uint32_t ret_ref = (uintptr_t)ret_copy;
43614         return ret_ref;
43615 }
43616
43617 uint32_t  __attribute__((export_name("TS_ParseError_invalid_recovery_id"))) TS_ParseError_invalid_recovery_id() {
43618         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43619         *ret_copy = ParseError_invalid_recovery_id();
43620         uint32_t ret_ref = (uintptr_t)ret_copy;
43621         return ret_ref;
43622 }
43623
43624 uint32_t  __attribute__((export_name("TS_ParseError_invalid_slice_length"))) TS_ParseError_invalid_slice_length(jstring a) {
43625         LDKStr a_conv = str_ref_to_owned_c(a);
43626         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43627         *ret_copy = ParseError_invalid_slice_length(a_conv);
43628         uint32_t ret_ref = (uintptr_t)ret_copy;
43629         return ret_ref;
43630 }
43631
43632 uint32_t  __attribute__((export_name("TS_ParseError_skip"))) TS_ParseError_skip() {
43633         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43634         *ret_copy = ParseError_skip();
43635         uint32_t ret_ref = (uintptr_t)ret_copy;
43636         return ret_ref;
43637 }
43638
43639 void  __attribute__((export_name("TS_ParseOrSemanticError_free"))) TS_ParseOrSemanticError_free(uint32_t this_ptr) {
43640         if ((this_ptr & 1) != 0) return;
43641         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
43642         CHECK_ACCESS(this_ptr_ptr);
43643         LDKParseOrSemanticError this_ptr_conv = *(LDKParseOrSemanticError*)(this_ptr_ptr);
43644         FREE((void*)this_ptr);
43645         ParseOrSemanticError_free(this_ptr_conv);
43646 }
43647
43648 static inline uintptr_t ParseOrSemanticError_clone_ptr(LDKParseOrSemanticError *NONNULL_PTR arg) {
43649         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
43650         *ret_copy = ParseOrSemanticError_clone(arg);
43651 uint32_t ret_ref = (uintptr_t)ret_copy;
43652         return ret_ref;
43653 }
43654 uint32_t  __attribute__((export_name("TS_ParseOrSemanticError_clone_ptr"))) TS_ParseOrSemanticError_clone_ptr(uint32_t arg) {
43655         LDKParseOrSemanticError* arg_conv = (LDKParseOrSemanticError*)arg;
43656         uint32_t ret_conv = ParseOrSemanticError_clone_ptr(arg_conv);
43657         return ret_conv;
43658 }
43659
43660 uint32_t  __attribute__((export_name("TS_ParseOrSemanticError_clone"))) TS_ParseOrSemanticError_clone(uint32_t orig) {
43661         LDKParseOrSemanticError* orig_conv = (LDKParseOrSemanticError*)orig;
43662         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
43663         *ret_copy = ParseOrSemanticError_clone(orig_conv);
43664         uint32_t ret_ref = (uintptr_t)ret_copy;
43665         return ret_ref;
43666 }
43667
43668 uint32_t  __attribute__((export_name("TS_ParseOrSemanticError_parse_error"))) TS_ParseOrSemanticError_parse_error(uint32_t a) {
43669         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
43670         CHECK_ACCESS(a_ptr);
43671         LDKParseError a_conv = *(LDKParseError*)(a_ptr);
43672         a_conv = ParseError_clone((LDKParseError*)(((uintptr_t)a) & ~1));
43673         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
43674         *ret_copy = ParseOrSemanticError_parse_error(a_conv);
43675         uint32_t ret_ref = (uintptr_t)ret_copy;
43676         return ret_ref;
43677 }
43678
43679 uint32_t  __attribute__((export_name("TS_ParseOrSemanticError_semantic_error"))) TS_ParseOrSemanticError_semantic_error(uint32_t a) {
43680         LDKSemanticError a_conv = LDKSemanticError_from_js(a);
43681         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
43682         *ret_copy = ParseOrSemanticError_semantic_error(a_conv);
43683         uint32_t ret_ref = (uintptr_t)ret_copy;
43684         return ret_ref;
43685 }
43686
43687 void  __attribute__((export_name("TS_Invoice_free"))) TS_Invoice_free(uint32_t this_obj) {
43688         LDKInvoice this_obj_conv;
43689         this_obj_conv.inner = (void*)(this_obj & (~1));
43690         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43691         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43692         Invoice_free(this_obj_conv);
43693 }
43694
43695 jboolean  __attribute__((export_name("TS_Invoice_eq"))) TS_Invoice_eq(uint32_t a, uint32_t b) {
43696         LDKInvoice a_conv;
43697         a_conv.inner = (void*)(a & (~1));
43698         a_conv.is_owned = false;
43699         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43700         LDKInvoice b_conv;
43701         b_conv.inner = (void*)(b & (~1));
43702         b_conv.is_owned = false;
43703         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43704         jboolean ret_conv = Invoice_eq(&a_conv, &b_conv);
43705         return ret_conv;
43706 }
43707
43708 static inline uintptr_t Invoice_clone_ptr(LDKInvoice *NONNULL_PTR arg) {
43709         LDKInvoice ret_var = Invoice_clone(arg);
43710 uint32_t ret_ref = 0;
43711 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43712 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43713 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43714 ret_ref = (uintptr_t)ret_var.inner;
43715 if (ret_var.is_owned) {
43716         ret_ref |= 1;
43717 }
43718         return ret_ref;
43719 }
43720 uint32_t  __attribute__((export_name("TS_Invoice_clone_ptr"))) TS_Invoice_clone_ptr(uint32_t arg) {
43721         LDKInvoice arg_conv;
43722         arg_conv.inner = (void*)(arg & (~1));
43723         arg_conv.is_owned = false;
43724         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43725         uint32_t ret_conv = Invoice_clone_ptr(&arg_conv);
43726         return ret_conv;
43727 }
43728
43729 uint32_t  __attribute__((export_name("TS_Invoice_clone"))) TS_Invoice_clone(uint32_t orig) {
43730         LDKInvoice orig_conv;
43731         orig_conv.inner = (void*)(orig & (~1));
43732         orig_conv.is_owned = false;
43733         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43734         LDKInvoice ret_var = Invoice_clone(&orig_conv);
43735         uint32_t ret_ref = 0;
43736         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43737         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43738         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43739         ret_ref = (uintptr_t)ret_var.inner;
43740         if (ret_var.is_owned) {
43741                 ret_ref |= 1;
43742         }
43743         return ret_ref;
43744 }
43745
43746 void  __attribute__((export_name("TS_SignedRawInvoice_free"))) TS_SignedRawInvoice_free(uint32_t this_obj) {
43747         LDKSignedRawInvoice this_obj_conv;
43748         this_obj_conv.inner = (void*)(this_obj & (~1));
43749         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43750         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43751         SignedRawInvoice_free(this_obj_conv);
43752 }
43753
43754 jboolean  __attribute__((export_name("TS_SignedRawInvoice_eq"))) TS_SignedRawInvoice_eq(uint32_t a, uint32_t b) {
43755         LDKSignedRawInvoice a_conv;
43756         a_conv.inner = (void*)(a & (~1));
43757         a_conv.is_owned = false;
43758         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43759         LDKSignedRawInvoice b_conv;
43760         b_conv.inner = (void*)(b & (~1));
43761         b_conv.is_owned = false;
43762         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43763         jboolean ret_conv = SignedRawInvoice_eq(&a_conv, &b_conv);
43764         return ret_conv;
43765 }
43766
43767 static inline uintptr_t SignedRawInvoice_clone_ptr(LDKSignedRawInvoice *NONNULL_PTR arg) {
43768         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(arg);
43769 uint32_t ret_ref = 0;
43770 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43771 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43772 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43773 ret_ref = (uintptr_t)ret_var.inner;
43774 if (ret_var.is_owned) {
43775         ret_ref |= 1;
43776 }
43777         return ret_ref;
43778 }
43779 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_clone_ptr"))) TS_SignedRawInvoice_clone_ptr(uint32_t arg) {
43780         LDKSignedRawInvoice arg_conv;
43781         arg_conv.inner = (void*)(arg & (~1));
43782         arg_conv.is_owned = false;
43783         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43784         uint32_t ret_conv = SignedRawInvoice_clone_ptr(&arg_conv);
43785         return ret_conv;
43786 }
43787
43788 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_clone"))) TS_SignedRawInvoice_clone(uint32_t orig) {
43789         LDKSignedRawInvoice orig_conv;
43790         orig_conv.inner = (void*)(orig & (~1));
43791         orig_conv.is_owned = false;
43792         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43793         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(&orig_conv);
43794         uint32_t ret_ref = 0;
43795         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43796         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43797         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43798         ret_ref = (uintptr_t)ret_var.inner;
43799         if (ret_var.is_owned) {
43800                 ret_ref |= 1;
43801         }
43802         return ret_ref;
43803 }
43804
43805 void  __attribute__((export_name("TS_RawInvoice_free"))) TS_RawInvoice_free(uint32_t this_obj) {
43806         LDKRawInvoice this_obj_conv;
43807         this_obj_conv.inner = (void*)(this_obj & (~1));
43808         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43809         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43810         RawInvoice_free(this_obj_conv);
43811 }
43812
43813 uint32_t  __attribute__((export_name("TS_RawInvoice_get_data"))) TS_RawInvoice_get_data(uint32_t this_ptr) {
43814         LDKRawInvoice this_ptr_conv;
43815         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43816         this_ptr_conv.is_owned = false;
43817         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43818         LDKRawDataPart ret_var = RawInvoice_get_data(&this_ptr_conv);
43819         uint32_t ret_ref = 0;
43820         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43821         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43822         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43823         ret_ref = (uintptr_t)ret_var.inner;
43824         if (ret_var.is_owned) {
43825                 ret_ref |= 1;
43826         }
43827         return ret_ref;
43828 }
43829
43830 void  __attribute__((export_name("TS_RawInvoice_set_data"))) TS_RawInvoice_set_data(uint32_t this_ptr, uint32_t val) {
43831         LDKRawInvoice this_ptr_conv;
43832         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43833         this_ptr_conv.is_owned = false;
43834         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43835         LDKRawDataPart val_conv;
43836         val_conv.inner = (void*)(val & (~1));
43837         val_conv.is_owned = (val & 1) || (val == 0);
43838         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43839         val_conv = RawDataPart_clone(&val_conv);
43840         RawInvoice_set_data(&this_ptr_conv, val_conv);
43841 }
43842
43843 jboolean  __attribute__((export_name("TS_RawInvoice_eq"))) TS_RawInvoice_eq(uint32_t a, uint32_t b) {
43844         LDKRawInvoice a_conv;
43845         a_conv.inner = (void*)(a & (~1));
43846         a_conv.is_owned = false;
43847         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43848         LDKRawInvoice b_conv;
43849         b_conv.inner = (void*)(b & (~1));
43850         b_conv.is_owned = false;
43851         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43852         jboolean ret_conv = RawInvoice_eq(&a_conv, &b_conv);
43853         return ret_conv;
43854 }
43855
43856 static inline uintptr_t RawInvoice_clone_ptr(LDKRawInvoice *NONNULL_PTR arg) {
43857         LDKRawInvoice ret_var = RawInvoice_clone(arg);
43858 uint32_t ret_ref = 0;
43859 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43860 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43861 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43862 ret_ref = (uintptr_t)ret_var.inner;
43863 if (ret_var.is_owned) {
43864         ret_ref |= 1;
43865 }
43866         return ret_ref;
43867 }
43868 uint32_t  __attribute__((export_name("TS_RawInvoice_clone_ptr"))) TS_RawInvoice_clone_ptr(uint32_t arg) {
43869         LDKRawInvoice arg_conv;
43870         arg_conv.inner = (void*)(arg & (~1));
43871         arg_conv.is_owned = false;
43872         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43873         uint32_t ret_conv = RawInvoice_clone_ptr(&arg_conv);
43874         return ret_conv;
43875 }
43876
43877 uint32_t  __attribute__((export_name("TS_RawInvoice_clone"))) TS_RawInvoice_clone(uint32_t orig) {
43878         LDKRawInvoice orig_conv;
43879         orig_conv.inner = (void*)(orig & (~1));
43880         orig_conv.is_owned = false;
43881         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43882         LDKRawInvoice ret_var = RawInvoice_clone(&orig_conv);
43883         uint32_t ret_ref = 0;
43884         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43885         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43886         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43887         ret_ref = (uintptr_t)ret_var.inner;
43888         if (ret_var.is_owned) {
43889                 ret_ref |= 1;
43890         }
43891         return ret_ref;
43892 }
43893
43894 void  __attribute__((export_name("TS_RawDataPart_free"))) TS_RawDataPart_free(uint32_t this_obj) {
43895         LDKRawDataPart this_obj_conv;
43896         this_obj_conv.inner = (void*)(this_obj & (~1));
43897         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43898         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43899         RawDataPart_free(this_obj_conv);
43900 }
43901
43902 uint32_t  __attribute__((export_name("TS_RawDataPart_get_timestamp"))) TS_RawDataPart_get_timestamp(uint32_t this_ptr) {
43903         LDKRawDataPart this_ptr_conv;
43904         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43905         this_ptr_conv.is_owned = false;
43906         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43907         LDKPositiveTimestamp ret_var = RawDataPart_get_timestamp(&this_ptr_conv);
43908         uint32_t ret_ref = 0;
43909         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43910         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43911         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43912         ret_ref = (uintptr_t)ret_var.inner;
43913         if (ret_var.is_owned) {
43914                 ret_ref |= 1;
43915         }
43916         return ret_ref;
43917 }
43918
43919 void  __attribute__((export_name("TS_RawDataPart_set_timestamp"))) TS_RawDataPart_set_timestamp(uint32_t this_ptr, uint32_t val) {
43920         LDKRawDataPart this_ptr_conv;
43921         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43922         this_ptr_conv.is_owned = false;
43923         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43924         LDKPositiveTimestamp val_conv;
43925         val_conv.inner = (void*)(val & (~1));
43926         val_conv.is_owned = (val & 1) || (val == 0);
43927         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43928         val_conv = PositiveTimestamp_clone(&val_conv);
43929         RawDataPart_set_timestamp(&this_ptr_conv, val_conv);
43930 }
43931
43932 jboolean  __attribute__((export_name("TS_RawDataPart_eq"))) TS_RawDataPart_eq(uint32_t a, uint32_t b) {
43933         LDKRawDataPart a_conv;
43934         a_conv.inner = (void*)(a & (~1));
43935         a_conv.is_owned = false;
43936         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43937         LDKRawDataPart b_conv;
43938         b_conv.inner = (void*)(b & (~1));
43939         b_conv.is_owned = false;
43940         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43941         jboolean ret_conv = RawDataPart_eq(&a_conv, &b_conv);
43942         return ret_conv;
43943 }
43944
43945 static inline uintptr_t RawDataPart_clone_ptr(LDKRawDataPart *NONNULL_PTR arg) {
43946         LDKRawDataPart ret_var = RawDataPart_clone(arg);
43947 uint32_t ret_ref = 0;
43948 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43949 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43950 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43951 ret_ref = (uintptr_t)ret_var.inner;
43952 if (ret_var.is_owned) {
43953         ret_ref |= 1;
43954 }
43955         return ret_ref;
43956 }
43957 uint32_t  __attribute__((export_name("TS_RawDataPart_clone_ptr"))) TS_RawDataPart_clone_ptr(uint32_t arg) {
43958         LDKRawDataPart arg_conv;
43959         arg_conv.inner = (void*)(arg & (~1));
43960         arg_conv.is_owned = false;
43961         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43962         uint32_t ret_conv = RawDataPart_clone_ptr(&arg_conv);
43963         return ret_conv;
43964 }
43965
43966 uint32_t  __attribute__((export_name("TS_RawDataPart_clone"))) TS_RawDataPart_clone(uint32_t orig) {
43967         LDKRawDataPart orig_conv;
43968         orig_conv.inner = (void*)(orig & (~1));
43969         orig_conv.is_owned = false;
43970         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43971         LDKRawDataPart ret_var = RawDataPart_clone(&orig_conv);
43972         uint32_t ret_ref = 0;
43973         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43974         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43975         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43976         ret_ref = (uintptr_t)ret_var.inner;
43977         if (ret_var.is_owned) {
43978                 ret_ref |= 1;
43979         }
43980         return ret_ref;
43981 }
43982
43983 void  __attribute__((export_name("TS_PositiveTimestamp_free"))) TS_PositiveTimestamp_free(uint32_t this_obj) {
43984         LDKPositiveTimestamp this_obj_conv;
43985         this_obj_conv.inner = (void*)(this_obj & (~1));
43986         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43987         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43988         PositiveTimestamp_free(this_obj_conv);
43989 }
43990
43991 jboolean  __attribute__((export_name("TS_PositiveTimestamp_eq"))) TS_PositiveTimestamp_eq(uint32_t a, uint32_t b) {
43992         LDKPositiveTimestamp a_conv;
43993         a_conv.inner = (void*)(a & (~1));
43994         a_conv.is_owned = false;
43995         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43996         LDKPositiveTimestamp b_conv;
43997         b_conv.inner = (void*)(b & (~1));
43998         b_conv.is_owned = false;
43999         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44000         jboolean ret_conv = PositiveTimestamp_eq(&a_conv, &b_conv);
44001         return ret_conv;
44002 }
44003
44004 static inline uintptr_t PositiveTimestamp_clone_ptr(LDKPositiveTimestamp *NONNULL_PTR arg) {
44005         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(arg);
44006 uint32_t ret_ref = 0;
44007 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44008 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44009 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44010 ret_ref = (uintptr_t)ret_var.inner;
44011 if (ret_var.is_owned) {
44012         ret_ref |= 1;
44013 }
44014         return ret_ref;
44015 }
44016 uint32_t  __attribute__((export_name("TS_PositiveTimestamp_clone_ptr"))) TS_PositiveTimestamp_clone_ptr(uint32_t arg) {
44017         LDKPositiveTimestamp arg_conv;
44018         arg_conv.inner = (void*)(arg & (~1));
44019         arg_conv.is_owned = false;
44020         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44021         uint32_t ret_conv = PositiveTimestamp_clone_ptr(&arg_conv);
44022         return ret_conv;
44023 }
44024
44025 uint32_t  __attribute__((export_name("TS_PositiveTimestamp_clone"))) TS_PositiveTimestamp_clone(uint32_t orig) {
44026         LDKPositiveTimestamp orig_conv;
44027         orig_conv.inner = (void*)(orig & (~1));
44028         orig_conv.is_owned = false;
44029         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44030         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(&orig_conv);
44031         uint32_t ret_ref = 0;
44032         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44033         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44034         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44035         ret_ref = (uintptr_t)ret_var.inner;
44036         if (ret_var.is_owned) {
44037                 ret_ref |= 1;
44038         }
44039         return ret_ref;
44040 }
44041
44042 uint32_t  __attribute__((export_name("TS_SiPrefix_clone"))) TS_SiPrefix_clone(uint32_t orig) {
44043         LDKSiPrefix* orig_conv = (LDKSiPrefix*)(orig & ~1);
44044         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_clone(orig_conv));
44045         return ret_conv;
44046 }
44047
44048 uint32_t  __attribute__((export_name("TS_SiPrefix_milli"))) TS_SiPrefix_milli() {
44049         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_milli());
44050         return ret_conv;
44051 }
44052
44053 uint32_t  __attribute__((export_name("TS_SiPrefix_micro"))) TS_SiPrefix_micro() {
44054         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_micro());
44055         return ret_conv;
44056 }
44057
44058 uint32_t  __attribute__((export_name("TS_SiPrefix_nano"))) TS_SiPrefix_nano() {
44059         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_nano());
44060         return ret_conv;
44061 }
44062
44063 uint32_t  __attribute__((export_name("TS_SiPrefix_pico"))) TS_SiPrefix_pico() {
44064         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_pico());
44065         return ret_conv;
44066 }
44067
44068 jboolean  __attribute__((export_name("TS_SiPrefix_eq"))) TS_SiPrefix_eq(uint32_t a, uint32_t b) {
44069         LDKSiPrefix* a_conv = (LDKSiPrefix*)(a & ~1);
44070         LDKSiPrefix* b_conv = (LDKSiPrefix*)(b & ~1);
44071         jboolean ret_conv = SiPrefix_eq(a_conv, b_conv);
44072         return ret_conv;
44073 }
44074
44075 int64_t  __attribute__((export_name("TS_SiPrefix_multiplier"))) TS_SiPrefix_multiplier(uint32_t this_arg) {
44076         LDKSiPrefix* this_arg_conv = (LDKSiPrefix*)(this_arg & ~1);
44077         int64_t ret_conv = SiPrefix_multiplier(this_arg_conv);
44078         return ret_conv;
44079 }
44080
44081 uint32_t  __attribute__((export_name("TS_Currency_clone"))) TS_Currency_clone(uint32_t orig) {
44082         LDKCurrency* orig_conv = (LDKCurrency*)(orig & ~1);
44083         uint32_t ret_conv = LDKCurrency_to_js(Currency_clone(orig_conv));
44084         return ret_conv;
44085 }
44086
44087 uint32_t  __attribute__((export_name("TS_Currency_bitcoin"))) TS_Currency_bitcoin() {
44088         uint32_t ret_conv = LDKCurrency_to_js(Currency_bitcoin());
44089         return ret_conv;
44090 }
44091
44092 uint32_t  __attribute__((export_name("TS_Currency_bitcoin_testnet"))) TS_Currency_bitcoin_testnet() {
44093         uint32_t ret_conv = LDKCurrency_to_js(Currency_bitcoin_testnet());
44094         return ret_conv;
44095 }
44096
44097 uint32_t  __attribute__((export_name("TS_Currency_regtest"))) TS_Currency_regtest() {
44098         uint32_t ret_conv = LDKCurrency_to_js(Currency_regtest());
44099         return ret_conv;
44100 }
44101
44102 uint32_t  __attribute__((export_name("TS_Currency_simnet"))) TS_Currency_simnet() {
44103         uint32_t ret_conv = LDKCurrency_to_js(Currency_simnet());
44104         return ret_conv;
44105 }
44106
44107 uint32_t  __attribute__((export_name("TS_Currency_signet"))) TS_Currency_signet() {
44108         uint32_t ret_conv = LDKCurrency_to_js(Currency_signet());
44109         return ret_conv;
44110 }
44111
44112 int64_t  __attribute__((export_name("TS_Currency_hash"))) TS_Currency_hash(uint32_t o) {
44113         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
44114         int64_t ret_conv = Currency_hash(o_conv);
44115         return ret_conv;
44116 }
44117
44118 jboolean  __attribute__((export_name("TS_Currency_eq"))) TS_Currency_eq(uint32_t a, uint32_t b) {
44119         LDKCurrency* a_conv = (LDKCurrency*)(a & ~1);
44120         LDKCurrency* b_conv = (LDKCurrency*)(b & ~1);
44121         jboolean ret_conv = Currency_eq(a_conv, b_conv);
44122         return ret_conv;
44123 }
44124
44125 void  __attribute__((export_name("TS_Sha256_free"))) TS_Sha256_free(uint32_t this_obj) {
44126         LDKSha256 this_obj_conv;
44127         this_obj_conv.inner = (void*)(this_obj & (~1));
44128         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44129         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44130         Sha256_free(this_obj_conv);
44131 }
44132
44133 static inline uintptr_t Sha256_clone_ptr(LDKSha256 *NONNULL_PTR arg) {
44134         LDKSha256 ret_var = Sha256_clone(arg);
44135 uint32_t ret_ref = 0;
44136 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44137 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44138 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44139 ret_ref = (uintptr_t)ret_var.inner;
44140 if (ret_var.is_owned) {
44141         ret_ref |= 1;
44142 }
44143         return ret_ref;
44144 }
44145 uint32_t  __attribute__((export_name("TS_Sha256_clone_ptr"))) TS_Sha256_clone_ptr(uint32_t arg) {
44146         LDKSha256 arg_conv;
44147         arg_conv.inner = (void*)(arg & (~1));
44148         arg_conv.is_owned = false;
44149         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44150         uint32_t ret_conv = Sha256_clone_ptr(&arg_conv);
44151         return ret_conv;
44152 }
44153
44154 uint32_t  __attribute__((export_name("TS_Sha256_clone"))) TS_Sha256_clone(uint32_t orig) {
44155         LDKSha256 orig_conv;
44156         orig_conv.inner = (void*)(orig & (~1));
44157         orig_conv.is_owned = false;
44158         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44159         LDKSha256 ret_var = Sha256_clone(&orig_conv);
44160         uint32_t ret_ref = 0;
44161         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44162         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44163         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44164         ret_ref = (uintptr_t)ret_var.inner;
44165         if (ret_var.is_owned) {
44166                 ret_ref |= 1;
44167         }
44168         return ret_ref;
44169 }
44170
44171 int64_t  __attribute__((export_name("TS_Sha256_hash"))) TS_Sha256_hash(uint32_t o) {
44172         LDKSha256 o_conv;
44173         o_conv.inner = (void*)(o & (~1));
44174         o_conv.is_owned = false;
44175         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
44176         int64_t ret_conv = Sha256_hash(&o_conv);
44177         return ret_conv;
44178 }
44179
44180 jboolean  __attribute__((export_name("TS_Sha256_eq"))) TS_Sha256_eq(uint32_t a, uint32_t b) {
44181         LDKSha256 a_conv;
44182         a_conv.inner = (void*)(a & (~1));
44183         a_conv.is_owned = false;
44184         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44185         LDKSha256 b_conv;
44186         b_conv.inner = (void*)(b & (~1));
44187         b_conv.is_owned = false;
44188         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44189         jboolean ret_conv = Sha256_eq(&a_conv, &b_conv);
44190         return ret_conv;
44191 }
44192
44193 void  __attribute__((export_name("TS_Description_free"))) TS_Description_free(uint32_t this_obj) {
44194         LDKDescription this_obj_conv;
44195         this_obj_conv.inner = (void*)(this_obj & (~1));
44196         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44197         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44198         Description_free(this_obj_conv);
44199 }
44200
44201 static inline uintptr_t Description_clone_ptr(LDKDescription *NONNULL_PTR arg) {
44202         LDKDescription ret_var = Description_clone(arg);
44203 uint32_t ret_ref = 0;
44204 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44205 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44206 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44207 ret_ref = (uintptr_t)ret_var.inner;
44208 if (ret_var.is_owned) {
44209         ret_ref |= 1;
44210 }
44211         return ret_ref;
44212 }
44213 uint32_t  __attribute__((export_name("TS_Description_clone_ptr"))) TS_Description_clone_ptr(uint32_t arg) {
44214         LDKDescription arg_conv;
44215         arg_conv.inner = (void*)(arg & (~1));
44216         arg_conv.is_owned = false;
44217         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44218         uint32_t ret_conv = Description_clone_ptr(&arg_conv);
44219         return ret_conv;
44220 }
44221
44222 uint32_t  __attribute__((export_name("TS_Description_clone"))) TS_Description_clone(uint32_t orig) {
44223         LDKDescription orig_conv;
44224         orig_conv.inner = (void*)(orig & (~1));
44225         orig_conv.is_owned = false;
44226         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44227         LDKDescription ret_var = Description_clone(&orig_conv);
44228         uint32_t ret_ref = 0;
44229         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44230         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44231         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44232         ret_ref = (uintptr_t)ret_var.inner;
44233         if (ret_var.is_owned) {
44234                 ret_ref |= 1;
44235         }
44236         return ret_ref;
44237 }
44238
44239 int64_t  __attribute__((export_name("TS_Description_hash"))) TS_Description_hash(uint32_t o) {
44240         LDKDescription o_conv;
44241         o_conv.inner = (void*)(o & (~1));
44242         o_conv.is_owned = false;
44243         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
44244         int64_t ret_conv = Description_hash(&o_conv);
44245         return ret_conv;
44246 }
44247
44248 jboolean  __attribute__((export_name("TS_Description_eq"))) TS_Description_eq(uint32_t a, uint32_t b) {
44249         LDKDescription a_conv;
44250         a_conv.inner = (void*)(a & (~1));
44251         a_conv.is_owned = false;
44252         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44253         LDKDescription b_conv;
44254         b_conv.inner = (void*)(b & (~1));
44255         b_conv.is_owned = false;
44256         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44257         jboolean ret_conv = Description_eq(&a_conv, &b_conv);
44258         return ret_conv;
44259 }
44260
44261 void  __attribute__((export_name("TS_PayeePubKey_free"))) TS_PayeePubKey_free(uint32_t this_obj) {
44262         LDKPayeePubKey this_obj_conv;
44263         this_obj_conv.inner = (void*)(this_obj & (~1));
44264         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44265         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44266         PayeePubKey_free(this_obj_conv);
44267 }
44268
44269 int8_tArray  __attribute__((export_name("TS_PayeePubKey_get_a"))) TS_PayeePubKey_get_a(uint32_t this_ptr) {
44270         LDKPayeePubKey this_ptr_conv;
44271         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44272         this_ptr_conv.is_owned = false;
44273         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44274         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
44275         memcpy(ret_arr->elems, PayeePubKey_get_a(&this_ptr_conv).compressed_form, 33);
44276         return ret_arr;
44277 }
44278
44279 void  __attribute__((export_name("TS_PayeePubKey_set_a"))) TS_PayeePubKey_set_a(uint32_t this_ptr, int8_tArray val) {
44280         LDKPayeePubKey this_ptr_conv;
44281         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44282         this_ptr_conv.is_owned = false;
44283         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44284         LDKPublicKey val_ref;
44285         CHECK(val->arr_len == 33);
44286         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
44287         PayeePubKey_set_a(&this_ptr_conv, val_ref);
44288 }
44289
44290 uint32_t  __attribute__((export_name("TS_PayeePubKey_new"))) TS_PayeePubKey_new(int8_tArray a_arg) {
44291         LDKPublicKey a_arg_ref;
44292         CHECK(a_arg->arr_len == 33);
44293         memcpy(a_arg_ref.compressed_form, a_arg->elems, 33); FREE(a_arg);
44294         LDKPayeePubKey ret_var = PayeePubKey_new(a_arg_ref);
44295         uint32_t ret_ref = 0;
44296         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44297         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44298         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44299         ret_ref = (uintptr_t)ret_var.inner;
44300         if (ret_var.is_owned) {
44301                 ret_ref |= 1;
44302         }
44303         return ret_ref;
44304 }
44305
44306 static inline uintptr_t PayeePubKey_clone_ptr(LDKPayeePubKey *NONNULL_PTR arg) {
44307         LDKPayeePubKey ret_var = PayeePubKey_clone(arg);
44308 uint32_t ret_ref = 0;
44309 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44310 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44311 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44312 ret_ref = (uintptr_t)ret_var.inner;
44313 if (ret_var.is_owned) {
44314         ret_ref |= 1;
44315 }
44316         return ret_ref;
44317 }
44318 uint32_t  __attribute__((export_name("TS_PayeePubKey_clone_ptr"))) TS_PayeePubKey_clone_ptr(uint32_t arg) {
44319         LDKPayeePubKey arg_conv;
44320         arg_conv.inner = (void*)(arg & (~1));
44321         arg_conv.is_owned = false;
44322         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44323         uint32_t ret_conv = PayeePubKey_clone_ptr(&arg_conv);
44324         return ret_conv;
44325 }
44326
44327 uint32_t  __attribute__((export_name("TS_PayeePubKey_clone"))) TS_PayeePubKey_clone(uint32_t orig) {
44328         LDKPayeePubKey orig_conv;
44329         orig_conv.inner = (void*)(orig & (~1));
44330         orig_conv.is_owned = false;
44331         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44332         LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv);
44333         uint32_t ret_ref = 0;
44334         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44335         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44336         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44337         ret_ref = (uintptr_t)ret_var.inner;
44338         if (ret_var.is_owned) {
44339                 ret_ref |= 1;
44340         }
44341         return ret_ref;
44342 }
44343
44344 int64_t  __attribute__((export_name("TS_PayeePubKey_hash"))) TS_PayeePubKey_hash(uint32_t o) {
44345         LDKPayeePubKey o_conv;
44346         o_conv.inner = (void*)(o & (~1));
44347         o_conv.is_owned = false;
44348         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
44349         int64_t ret_conv = PayeePubKey_hash(&o_conv);
44350         return ret_conv;
44351 }
44352
44353 jboolean  __attribute__((export_name("TS_PayeePubKey_eq"))) TS_PayeePubKey_eq(uint32_t a, uint32_t b) {
44354         LDKPayeePubKey a_conv;
44355         a_conv.inner = (void*)(a & (~1));
44356         a_conv.is_owned = false;
44357         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44358         LDKPayeePubKey b_conv;
44359         b_conv.inner = (void*)(b & (~1));
44360         b_conv.is_owned = false;
44361         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44362         jboolean ret_conv = PayeePubKey_eq(&a_conv, &b_conv);
44363         return ret_conv;
44364 }
44365
44366 void  __attribute__((export_name("TS_ExpiryTime_free"))) TS_ExpiryTime_free(uint32_t this_obj) {
44367         LDKExpiryTime this_obj_conv;
44368         this_obj_conv.inner = (void*)(this_obj & (~1));
44369         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44370         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44371         ExpiryTime_free(this_obj_conv);
44372 }
44373
44374 static inline uintptr_t ExpiryTime_clone_ptr(LDKExpiryTime *NONNULL_PTR arg) {
44375         LDKExpiryTime ret_var = ExpiryTime_clone(arg);
44376 uint32_t ret_ref = 0;
44377 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44378 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44379 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44380 ret_ref = (uintptr_t)ret_var.inner;
44381 if (ret_var.is_owned) {
44382         ret_ref |= 1;
44383 }
44384         return ret_ref;
44385 }
44386 uint32_t  __attribute__((export_name("TS_ExpiryTime_clone_ptr"))) TS_ExpiryTime_clone_ptr(uint32_t arg) {
44387         LDKExpiryTime arg_conv;
44388         arg_conv.inner = (void*)(arg & (~1));
44389         arg_conv.is_owned = false;
44390         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44391         uint32_t ret_conv = ExpiryTime_clone_ptr(&arg_conv);
44392         return ret_conv;
44393 }
44394
44395 uint32_t  __attribute__((export_name("TS_ExpiryTime_clone"))) TS_ExpiryTime_clone(uint32_t orig) {
44396         LDKExpiryTime orig_conv;
44397         orig_conv.inner = (void*)(orig & (~1));
44398         orig_conv.is_owned = false;
44399         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44400         LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv);
44401         uint32_t ret_ref = 0;
44402         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44403         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44404         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44405         ret_ref = (uintptr_t)ret_var.inner;
44406         if (ret_var.is_owned) {
44407                 ret_ref |= 1;
44408         }
44409         return ret_ref;
44410 }
44411
44412 int64_t  __attribute__((export_name("TS_ExpiryTime_hash"))) TS_ExpiryTime_hash(uint32_t o) {
44413         LDKExpiryTime o_conv;
44414         o_conv.inner = (void*)(o & (~1));
44415         o_conv.is_owned = false;
44416         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
44417         int64_t ret_conv = ExpiryTime_hash(&o_conv);
44418         return ret_conv;
44419 }
44420
44421 jboolean  __attribute__((export_name("TS_ExpiryTime_eq"))) TS_ExpiryTime_eq(uint32_t a, uint32_t b) {
44422         LDKExpiryTime a_conv;
44423         a_conv.inner = (void*)(a & (~1));
44424         a_conv.is_owned = false;
44425         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44426         LDKExpiryTime b_conv;
44427         b_conv.inner = (void*)(b & (~1));
44428         b_conv.is_owned = false;
44429         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44430         jboolean ret_conv = ExpiryTime_eq(&a_conv, &b_conv);
44431         return ret_conv;
44432 }
44433
44434 void  __attribute__((export_name("TS_MinFinalCltvExpiry_free"))) TS_MinFinalCltvExpiry_free(uint32_t this_obj) {
44435         LDKMinFinalCltvExpiry this_obj_conv;
44436         this_obj_conv.inner = (void*)(this_obj & (~1));
44437         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44438         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44439         MinFinalCltvExpiry_free(this_obj_conv);
44440 }
44441
44442 int64_t  __attribute__((export_name("TS_MinFinalCltvExpiry_get_a"))) TS_MinFinalCltvExpiry_get_a(uint32_t this_ptr) {
44443         LDKMinFinalCltvExpiry this_ptr_conv;
44444         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44445         this_ptr_conv.is_owned = false;
44446         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44447         int64_t ret_conv = MinFinalCltvExpiry_get_a(&this_ptr_conv);
44448         return ret_conv;
44449 }
44450
44451 void  __attribute__((export_name("TS_MinFinalCltvExpiry_set_a"))) TS_MinFinalCltvExpiry_set_a(uint32_t this_ptr, int64_t val) {
44452         LDKMinFinalCltvExpiry this_ptr_conv;
44453         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44454         this_ptr_conv.is_owned = false;
44455         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44456         MinFinalCltvExpiry_set_a(&this_ptr_conv, val);
44457 }
44458
44459 uint32_t  __attribute__((export_name("TS_MinFinalCltvExpiry_new"))) TS_MinFinalCltvExpiry_new(int64_t a_arg) {
44460         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_new(a_arg);
44461         uint32_t ret_ref = 0;
44462         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44463         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44464         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44465         ret_ref = (uintptr_t)ret_var.inner;
44466         if (ret_var.is_owned) {
44467                 ret_ref |= 1;
44468         }
44469         return ret_ref;
44470 }
44471
44472 static inline uintptr_t MinFinalCltvExpiry_clone_ptr(LDKMinFinalCltvExpiry *NONNULL_PTR arg) {
44473         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(arg);
44474 uint32_t ret_ref = 0;
44475 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44476 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44477 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44478 ret_ref = (uintptr_t)ret_var.inner;
44479 if (ret_var.is_owned) {
44480         ret_ref |= 1;
44481 }
44482         return ret_ref;
44483 }
44484 uint32_t  __attribute__((export_name("TS_MinFinalCltvExpiry_clone_ptr"))) TS_MinFinalCltvExpiry_clone_ptr(uint32_t arg) {
44485         LDKMinFinalCltvExpiry arg_conv;
44486         arg_conv.inner = (void*)(arg & (~1));
44487         arg_conv.is_owned = false;
44488         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44489         uint32_t ret_conv = MinFinalCltvExpiry_clone_ptr(&arg_conv);
44490         return ret_conv;
44491 }
44492
44493 uint32_t  __attribute__((export_name("TS_MinFinalCltvExpiry_clone"))) TS_MinFinalCltvExpiry_clone(uint32_t orig) {
44494         LDKMinFinalCltvExpiry orig_conv;
44495         orig_conv.inner = (void*)(orig & (~1));
44496         orig_conv.is_owned = false;
44497         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44498         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(&orig_conv);
44499         uint32_t ret_ref = 0;
44500         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44501         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44502         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44503         ret_ref = (uintptr_t)ret_var.inner;
44504         if (ret_var.is_owned) {
44505                 ret_ref |= 1;
44506         }
44507         return ret_ref;
44508 }
44509
44510 int64_t  __attribute__((export_name("TS_MinFinalCltvExpiry_hash"))) TS_MinFinalCltvExpiry_hash(uint32_t o) {
44511         LDKMinFinalCltvExpiry o_conv;
44512         o_conv.inner = (void*)(o & (~1));
44513         o_conv.is_owned = false;
44514         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
44515         int64_t ret_conv = MinFinalCltvExpiry_hash(&o_conv);
44516         return ret_conv;
44517 }
44518
44519 jboolean  __attribute__((export_name("TS_MinFinalCltvExpiry_eq"))) TS_MinFinalCltvExpiry_eq(uint32_t a, uint32_t b) {
44520         LDKMinFinalCltvExpiry a_conv;
44521         a_conv.inner = (void*)(a & (~1));
44522         a_conv.is_owned = false;
44523         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44524         LDKMinFinalCltvExpiry b_conv;
44525         b_conv.inner = (void*)(b & (~1));
44526         b_conv.is_owned = false;
44527         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44528         jboolean ret_conv = MinFinalCltvExpiry_eq(&a_conv, &b_conv);
44529         return ret_conv;
44530 }
44531
44532 void  __attribute__((export_name("TS_Fallback_free"))) TS_Fallback_free(uint32_t this_ptr) {
44533         if ((this_ptr & 1) != 0) return;
44534         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
44535         CHECK_ACCESS(this_ptr_ptr);
44536         LDKFallback this_ptr_conv = *(LDKFallback*)(this_ptr_ptr);
44537         FREE((void*)this_ptr);
44538         Fallback_free(this_ptr_conv);
44539 }
44540
44541 static inline uintptr_t Fallback_clone_ptr(LDKFallback *NONNULL_PTR arg) {
44542         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
44543         *ret_copy = Fallback_clone(arg);
44544 uint32_t ret_ref = (uintptr_t)ret_copy;
44545         return ret_ref;
44546 }
44547 uint32_t  __attribute__((export_name("TS_Fallback_clone_ptr"))) TS_Fallback_clone_ptr(uint32_t arg) {
44548         LDKFallback* arg_conv = (LDKFallback*)arg;
44549         uint32_t ret_conv = Fallback_clone_ptr(arg_conv);
44550         return ret_conv;
44551 }
44552
44553 uint32_t  __attribute__((export_name("TS_Fallback_clone"))) TS_Fallback_clone(uint32_t orig) {
44554         LDKFallback* orig_conv = (LDKFallback*)orig;
44555         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
44556         *ret_copy = Fallback_clone(orig_conv);
44557         uint32_t ret_ref = (uintptr_t)ret_copy;
44558         return ret_ref;
44559 }
44560
44561 uint32_t  __attribute__((export_name("TS_Fallback_seg_wit_program"))) TS_Fallback_seg_wit_program(int8_t version, int8_tArray program) {
44562         
44563         LDKCVec_u8Z program_ref;
44564         program_ref.datalen = program->arr_len;
44565         program_ref.data = MALLOC(program_ref.datalen, "LDKCVec_u8Z Bytes");
44566         memcpy(program_ref.data, program->elems, program_ref.datalen); FREE(program);
44567         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
44568         *ret_copy = Fallback_seg_wit_program((LDKu5){ ._0 = version }, program_ref);
44569         uint32_t ret_ref = (uintptr_t)ret_copy;
44570         return ret_ref;
44571 }
44572
44573 uint32_t  __attribute__((export_name("TS_Fallback_pub_key_hash"))) TS_Fallback_pub_key_hash(int8_tArray a) {
44574         LDKTwentyBytes a_ref;
44575         CHECK(a->arr_len == 20);
44576         memcpy(a_ref.data, a->elems, 20); FREE(a);
44577         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
44578         *ret_copy = Fallback_pub_key_hash(a_ref);
44579         uint32_t ret_ref = (uintptr_t)ret_copy;
44580         return ret_ref;
44581 }
44582
44583 uint32_t  __attribute__((export_name("TS_Fallback_script_hash"))) TS_Fallback_script_hash(int8_tArray a) {
44584         LDKTwentyBytes a_ref;
44585         CHECK(a->arr_len == 20);
44586         memcpy(a_ref.data, a->elems, 20); FREE(a);
44587         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
44588         *ret_copy = Fallback_script_hash(a_ref);
44589         uint32_t ret_ref = (uintptr_t)ret_copy;
44590         return ret_ref;
44591 }
44592
44593 int64_t  __attribute__((export_name("TS_Fallback_hash"))) TS_Fallback_hash(uint32_t o) {
44594         LDKFallback* o_conv = (LDKFallback*)o;
44595         int64_t ret_conv = Fallback_hash(o_conv);
44596         return ret_conv;
44597 }
44598
44599 jboolean  __attribute__((export_name("TS_Fallback_eq"))) TS_Fallback_eq(uint32_t a, uint32_t b) {
44600         LDKFallback* a_conv = (LDKFallback*)a;
44601         LDKFallback* b_conv = (LDKFallback*)b;
44602         jboolean ret_conv = Fallback_eq(a_conv, b_conv);
44603         return ret_conv;
44604 }
44605
44606 void  __attribute__((export_name("TS_InvoiceSignature_free"))) TS_InvoiceSignature_free(uint32_t this_obj) {
44607         LDKInvoiceSignature this_obj_conv;
44608         this_obj_conv.inner = (void*)(this_obj & (~1));
44609         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44610         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44611         InvoiceSignature_free(this_obj_conv);
44612 }
44613
44614 static inline uintptr_t InvoiceSignature_clone_ptr(LDKInvoiceSignature *NONNULL_PTR arg) {
44615         LDKInvoiceSignature ret_var = InvoiceSignature_clone(arg);
44616 uint32_t ret_ref = 0;
44617 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44618 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44619 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44620 ret_ref = (uintptr_t)ret_var.inner;
44621 if (ret_var.is_owned) {
44622         ret_ref |= 1;
44623 }
44624         return ret_ref;
44625 }
44626 uint32_t  __attribute__((export_name("TS_InvoiceSignature_clone_ptr"))) TS_InvoiceSignature_clone_ptr(uint32_t arg) {
44627         LDKInvoiceSignature arg_conv;
44628         arg_conv.inner = (void*)(arg & (~1));
44629         arg_conv.is_owned = false;
44630         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44631         uint32_t ret_conv = InvoiceSignature_clone_ptr(&arg_conv);
44632         return ret_conv;
44633 }
44634
44635 uint32_t  __attribute__((export_name("TS_InvoiceSignature_clone"))) TS_InvoiceSignature_clone(uint32_t orig) {
44636         LDKInvoiceSignature orig_conv;
44637         orig_conv.inner = (void*)(orig & (~1));
44638         orig_conv.is_owned = false;
44639         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44640         LDKInvoiceSignature ret_var = InvoiceSignature_clone(&orig_conv);
44641         uint32_t ret_ref = 0;
44642         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44643         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44644         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44645         ret_ref = (uintptr_t)ret_var.inner;
44646         if (ret_var.is_owned) {
44647                 ret_ref |= 1;
44648         }
44649         return ret_ref;
44650 }
44651
44652 jboolean  __attribute__((export_name("TS_InvoiceSignature_eq"))) TS_InvoiceSignature_eq(uint32_t a, uint32_t b) {
44653         LDKInvoiceSignature a_conv;
44654         a_conv.inner = (void*)(a & (~1));
44655         a_conv.is_owned = false;
44656         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44657         LDKInvoiceSignature b_conv;
44658         b_conv.inner = (void*)(b & (~1));
44659         b_conv.is_owned = false;
44660         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44661         jboolean ret_conv = InvoiceSignature_eq(&a_conv, &b_conv);
44662         return ret_conv;
44663 }
44664
44665 void  __attribute__((export_name("TS_PrivateRoute_free"))) TS_PrivateRoute_free(uint32_t this_obj) {
44666         LDKPrivateRoute this_obj_conv;
44667         this_obj_conv.inner = (void*)(this_obj & (~1));
44668         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44669         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44670         PrivateRoute_free(this_obj_conv);
44671 }
44672
44673 static inline uintptr_t PrivateRoute_clone_ptr(LDKPrivateRoute *NONNULL_PTR arg) {
44674         LDKPrivateRoute ret_var = PrivateRoute_clone(arg);
44675 uint32_t ret_ref = 0;
44676 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44677 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44678 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44679 ret_ref = (uintptr_t)ret_var.inner;
44680 if (ret_var.is_owned) {
44681         ret_ref |= 1;
44682 }
44683         return ret_ref;
44684 }
44685 uint32_t  __attribute__((export_name("TS_PrivateRoute_clone_ptr"))) TS_PrivateRoute_clone_ptr(uint32_t arg) {
44686         LDKPrivateRoute arg_conv;
44687         arg_conv.inner = (void*)(arg & (~1));
44688         arg_conv.is_owned = false;
44689         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44690         uint32_t ret_conv = PrivateRoute_clone_ptr(&arg_conv);
44691         return ret_conv;
44692 }
44693
44694 uint32_t  __attribute__((export_name("TS_PrivateRoute_clone"))) TS_PrivateRoute_clone(uint32_t orig) {
44695         LDKPrivateRoute orig_conv;
44696         orig_conv.inner = (void*)(orig & (~1));
44697         orig_conv.is_owned = false;
44698         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44699         LDKPrivateRoute ret_var = PrivateRoute_clone(&orig_conv);
44700         uint32_t ret_ref = 0;
44701         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44702         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44703         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44704         ret_ref = (uintptr_t)ret_var.inner;
44705         if (ret_var.is_owned) {
44706                 ret_ref |= 1;
44707         }
44708         return ret_ref;
44709 }
44710
44711 int64_t  __attribute__((export_name("TS_PrivateRoute_hash"))) TS_PrivateRoute_hash(uint32_t o) {
44712         LDKPrivateRoute o_conv;
44713         o_conv.inner = (void*)(o & (~1));
44714         o_conv.is_owned = false;
44715         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
44716         int64_t ret_conv = PrivateRoute_hash(&o_conv);
44717         return ret_conv;
44718 }
44719
44720 jboolean  __attribute__((export_name("TS_PrivateRoute_eq"))) TS_PrivateRoute_eq(uint32_t a, uint32_t b) {
44721         LDKPrivateRoute a_conv;
44722         a_conv.inner = (void*)(a & (~1));
44723         a_conv.is_owned = false;
44724         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44725         LDKPrivateRoute b_conv;
44726         b_conv.inner = (void*)(b & (~1));
44727         b_conv.is_owned = false;
44728         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44729         jboolean ret_conv = PrivateRoute_eq(&a_conv, &b_conv);
44730         return ret_conv;
44731 }
44732
44733 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_into_parts"))) TS_SignedRawInvoice_into_parts(uint32_t this_arg) {
44734         LDKSignedRawInvoice this_arg_conv;
44735         this_arg_conv.inner = (void*)(this_arg & (~1));
44736         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
44737         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44738         this_arg_conv = SignedRawInvoice_clone(&this_arg_conv);
44739         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
44740         *ret_conv = SignedRawInvoice_into_parts(this_arg_conv);
44741         return ((uint32_t)ret_conv);
44742 }
44743
44744 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_raw_invoice"))) TS_SignedRawInvoice_raw_invoice(uint32_t this_arg) {
44745         LDKSignedRawInvoice this_arg_conv;
44746         this_arg_conv.inner = (void*)(this_arg & (~1));
44747         this_arg_conv.is_owned = false;
44748         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44749         LDKRawInvoice ret_var = SignedRawInvoice_raw_invoice(&this_arg_conv);
44750         uint32_t ret_ref = 0;
44751         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44752         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44753         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44754         ret_ref = (uintptr_t)ret_var.inner;
44755         if (ret_var.is_owned) {
44756                 ret_ref |= 1;
44757         }
44758         return ret_ref;
44759 }
44760
44761 int8_tArray  __attribute__((export_name("TS_SignedRawInvoice_hash"))) TS_SignedRawInvoice_hash(uint32_t this_arg) {
44762         LDKSignedRawInvoice this_arg_conv;
44763         this_arg_conv.inner = (void*)(this_arg & (~1));
44764         this_arg_conv.is_owned = false;
44765         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44766         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
44767         memcpy(ret_arr->elems, *SignedRawInvoice_hash(&this_arg_conv), 32);
44768         return ret_arr;
44769 }
44770
44771 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_signature"))) TS_SignedRawInvoice_signature(uint32_t this_arg) {
44772         LDKSignedRawInvoice this_arg_conv;
44773         this_arg_conv.inner = (void*)(this_arg & (~1));
44774         this_arg_conv.is_owned = false;
44775         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44776         LDKInvoiceSignature ret_var = SignedRawInvoice_signature(&this_arg_conv);
44777         uint32_t ret_ref = 0;
44778         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44779         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44780         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44781         ret_ref = (uintptr_t)ret_var.inner;
44782         if (ret_var.is_owned) {
44783                 ret_ref |= 1;
44784         }
44785         return ret_ref;
44786 }
44787
44788 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_recover_payee_pub_key"))) TS_SignedRawInvoice_recover_payee_pub_key(uint32_t this_arg) {
44789         LDKSignedRawInvoice this_arg_conv;
44790         this_arg_conv.inner = (void*)(this_arg & (~1));
44791         this_arg_conv.is_owned = false;
44792         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44793         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
44794         *ret_conv = SignedRawInvoice_recover_payee_pub_key(&this_arg_conv);
44795         return (uint32_t)ret_conv;
44796 }
44797
44798 jboolean  __attribute__((export_name("TS_SignedRawInvoice_check_signature"))) TS_SignedRawInvoice_check_signature(uint32_t this_arg) {
44799         LDKSignedRawInvoice this_arg_conv;
44800         this_arg_conv.inner = (void*)(this_arg & (~1));
44801         this_arg_conv.is_owned = false;
44802         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44803         jboolean ret_conv = SignedRawInvoice_check_signature(&this_arg_conv);
44804         return ret_conv;
44805 }
44806
44807 int8_tArray  __attribute__((export_name("TS_RawInvoice_hash"))) TS_RawInvoice_hash(uint32_t this_arg) {
44808         LDKRawInvoice this_arg_conv;
44809         this_arg_conv.inner = (void*)(this_arg & (~1));
44810         this_arg_conv.is_owned = false;
44811         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44812         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
44813         memcpy(ret_arr->elems, RawInvoice_hash(&this_arg_conv).data, 32);
44814         return ret_arr;
44815 }
44816
44817 uint32_t  __attribute__((export_name("TS_RawInvoice_payment_hash"))) TS_RawInvoice_payment_hash(uint32_t this_arg) {
44818         LDKRawInvoice this_arg_conv;
44819         this_arg_conv.inner = (void*)(this_arg & (~1));
44820         this_arg_conv.is_owned = false;
44821         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44822         LDKSha256 ret_var = RawInvoice_payment_hash(&this_arg_conv);
44823         uint32_t ret_ref = 0;
44824         if ((uintptr_t)ret_var.inner > 4096) {
44825                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44826                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44827         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44828                 ret_ref = (uintptr_t)ret_var.inner;
44829                 if (ret_var.is_owned) {
44830                         ret_ref |= 1;
44831                 }
44832         }
44833         return ret_ref;
44834 }
44835
44836 uint32_t  __attribute__((export_name("TS_RawInvoice_description"))) TS_RawInvoice_description(uint32_t this_arg) {
44837         LDKRawInvoice this_arg_conv;
44838         this_arg_conv.inner = (void*)(this_arg & (~1));
44839         this_arg_conv.is_owned = false;
44840         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44841         LDKDescription ret_var = RawInvoice_description(&this_arg_conv);
44842         uint32_t ret_ref = 0;
44843         if ((uintptr_t)ret_var.inner > 4096) {
44844                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44845                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44846         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44847                 ret_ref = (uintptr_t)ret_var.inner;
44848                 if (ret_var.is_owned) {
44849                         ret_ref |= 1;
44850                 }
44851         }
44852         return ret_ref;
44853 }
44854
44855 uint32_t  __attribute__((export_name("TS_RawInvoice_payee_pub_key"))) TS_RawInvoice_payee_pub_key(uint32_t this_arg) {
44856         LDKRawInvoice this_arg_conv;
44857         this_arg_conv.inner = (void*)(this_arg & (~1));
44858         this_arg_conv.is_owned = false;
44859         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44860         LDKPayeePubKey ret_var = RawInvoice_payee_pub_key(&this_arg_conv);
44861         uint32_t ret_ref = 0;
44862         if ((uintptr_t)ret_var.inner > 4096) {
44863                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44864                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44865         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44866                 ret_ref = (uintptr_t)ret_var.inner;
44867                 if (ret_var.is_owned) {
44868                         ret_ref |= 1;
44869                 }
44870         }
44871         return ret_ref;
44872 }
44873
44874 uint32_t  __attribute__((export_name("TS_RawInvoice_description_hash"))) TS_RawInvoice_description_hash(uint32_t this_arg) {
44875         LDKRawInvoice this_arg_conv;
44876         this_arg_conv.inner = (void*)(this_arg & (~1));
44877         this_arg_conv.is_owned = false;
44878         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44879         LDKSha256 ret_var = RawInvoice_description_hash(&this_arg_conv);
44880         uint32_t ret_ref = 0;
44881         if ((uintptr_t)ret_var.inner > 4096) {
44882                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44883                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44884         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44885                 ret_ref = (uintptr_t)ret_var.inner;
44886                 if (ret_var.is_owned) {
44887                         ret_ref |= 1;
44888                 }
44889         }
44890         return ret_ref;
44891 }
44892
44893 uint32_t  __attribute__((export_name("TS_RawInvoice_expiry_time"))) TS_RawInvoice_expiry_time(uint32_t this_arg) {
44894         LDKRawInvoice this_arg_conv;
44895         this_arg_conv.inner = (void*)(this_arg & (~1));
44896         this_arg_conv.is_owned = false;
44897         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44898         LDKExpiryTime ret_var = RawInvoice_expiry_time(&this_arg_conv);
44899         uint32_t ret_ref = 0;
44900         if ((uintptr_t)ret_var.inner > 4096) {
44901                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44902                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44903         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44904                 ret_ref = (uintptr_t)ret_var.inner;
44905                 if (ret_var.is_owned) {
44906                         ret_ref |= 1;
44907                 }
44908         }
44909         return ret_ref;
44910 }
44911
44912 uint32_t  __attribute__((export_name("TS_RawInvoice_min_final_cltv_expiry"))) TS_RawInvoice_min_final_cltv_expiry(uint32_t this_arg) {
44913         LDKRawInvoice this_arg_conv;
44914         this_arg_conv.inner = (void*)(this_arg & (~1));
44915         this_arg_conv.is_owned = false;
44916         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44917         LDKMinFinalCltvExpiry ret_var = RawInvoice_min_final_cltv_expiry(&this_arg_conv);
44918         uint32_t ret_ref = 0;
44919         if ((uintptr_t)ret_var.inner > 4096) {
44920                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44921                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44922         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44923                 ret_ref = (uintptr_t)ret_var.inner;
44924                 if (ret_var.is_owned) {
44925                         ret_ref |= 1;
44926                 }
44927         }
44928         return ret_ref;
44929 }
44930
44931 int8_tArray  __attribute__((export_name("TS_RawInvoice_payment_secret"))) TS_RawInvoice_payment_secret(uint32_t this_arg) {
44932         LDKRawInvoice this_arg_conv;
44933         this_arg_conv.inner = (void*)(this_arg & (~1));
44934         this_arg_conv.is_owned = false;
44935         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44936         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
44937         memcpy(ret_arr->elems, RawInvoice_payment_secret(&this_arg_conv).data, 32);
44938         return ret_arr;
44939 }
44940
44941 uint32_t  __attribute__((export_name("TS_RawInvoice_features"))) TS_RawInvoice_features(uint32_t this_arg) {
44942         LDKRawInvoice this_arg_conv;
44943         this_arg_conv.inner = (void*)(this_arg & (~1));
44944         this_arg_conv.is_owned = false;
44945         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44946         LDKInvoiceFeatures ret_var = RawInvoice_features(&this_arg_conv);
44947         uint32_t ret_ref = 0;
44948         if ((uintptr_t)ret_var.inner > 4096) {
44949                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44950                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44951         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44952                 ret_ref = (uintptr_t)ret_var.inner;
44953                 if (ret_var.is_owned) {
44954                         ret_ref |= 1;
44955                 }
44956         }
44957         return ret_ref;
44958 }
44959
44960 uint32_tArray  __attribute__((export_name("TS_RawInvoice_private_routes"))) TS_RawInvoice_private_routes(uint32_t this_arg) {
44961         LDKRawInvoice this_arg_conv;
44962         this_arg_conv.inner = (void*)(this_arg & (~1));
44963         this_arg_conv.is_owned = false;
44964         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44965         LDKCVec_PrivateRouteZ ret_var = RawInvoice_private_routes(&this_arg_conv);
44966         uint32_tArray ret_arr = NULL;
44967         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
44968         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 8);
44969         for (size_t o = 0; o < ret_var.datalen; o++) {
44970                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
44971                 uint32_t ret_conv_14_ref = 0;
44972                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44973                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44974                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
44975                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
44976                 if (ret_conv_14_var.is_owned) {
44977                         ret_conv_14_ref |= 1;
44978                 }
44979                 ret_arr_ptr[o] = ret_conv_14_ref;
44980         }
44981         
44982         FREE(ret_var.data);
44983         return ret_arr;
44984 }
44985
44986 uint32_t  __attribute__((export_name("TS_RawInvoice_amount_pico_btc"))) TS_RawInvoice_amount_pico_btc(uint32_t this_arg) {
44987         LDKRawInvoice this_arg_conv;
44988         this_arg_conv.inner = (void*)(this_arg & (~1));
44989         this_arg_conv.is_owned = false;
44990         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44991         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
44992         *ret_copy = RawInvoice_amount_pico_btc(&this_arg_conv);
44993         uint32_t ret_ref = (uintptr_t)ret_copy;
44994         return ret_ref;
44995 }
44996
44997 uint32_t  __attribute__((export_name("TS_RawInvoice_currency"))) TS_RawInvoice_currency(uint32_t this_arg) {
44998         LDKRawInvoice this_arg_conv;
44999         this_arg_conv.inner = (void*)(this_arg & (~1));
45000         this_arg_conv.is_owned = false;
45001         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45002         uint32_t ret_conv = LDKCurrency_to_js(RawInvoice_currency(&this_arg_conv));
45003         return ret_conv;
45004 }
45005
45006 uint32_t  __attribute__((export_name("TS_PositiveTimestamp_from_unix_timestamp"))) TS_PositiveTimestamp_from_unix_timestamp(int64_t unix_seconds) {
45007         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
45008         *ret_conv = PositiveTimestamp_from_unix_timestamp(unix_seconds);
45009         return (uint32_t)ret_conv;
45010 }
45011
45012 uint32_t  __attribute__((export_name("TS_PositiveTimestamp_from_duration_since_epoch"))) TS_PositiveTimestamp_from_duration_since_epoch(int64_t duration) {
45013         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
45014         *ret_conv = PositiveTimestamp_from_duration_since_epoch(duration);
45015         return (uint32_t)ret_conv;
45016 }
45017
45018 int64_t  __attribute__((export_name("TS_PositiveTimestamp_as_unix_timestamp"))) TS_PositiveTimestamp_as_unix_timestamp(uint32_t this_arg) {
45019         LDKPositiveTimestamp this_arg_conv;
45020         this_arg_conv.inner = (void*)(this_arg & (~1));
45021         this_arg_conv.is_owned = false;
45022         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45023         int64_t ret_conv = PositiveTimestamp_as_unix_timestamp(&this_arg_conv);
45024         return ret_conv;
45025 }
45026
45027 int64_t  __attribute__((export_name("TS_PositiveTimestamp_as_duration_since_epoch"))) TS_PositiveTimestamp_as_duration_since_epoch(uint32_t this_arg) {
45028         LDKPositiveTimestamp this_arg_conv;
45029         this_arg_conv.inner = (void*)(this_arg & (~1));
45030         this_arg_conv.is_owned = false;
45031         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45032         int64_t ret_conv = PositiveTimestamp_as_duration_since_epoch(&this_arg_conv);
45033         return ret_conv;
45034 }
45035
45036 uint32_t  __attribute__((export_name("TS_Invoice_into_signed_raw"))) TS_Invoice_into_signed_raw(uint32_t this_arg) {
45037         LDKInvoice this_arg_conv;
45038         this_arg_conv.inner = (void*)(this_arg & (~1));
45039         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
45040         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45041         this_arg_conv = Invoice_clone(&this_arg_conv);
45042         LDKSignedRawInvoice ret_var = Invoice_into_signed_raw(this_arg_conv);
45043         uint32_t ret_ref = 0;
45044         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45045         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45046         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45047         ret_ref = (uintptr_t)ret_var.inner;
45048         if (ret_var.is_owned) {
45049                 ret_ref |= 1;
45050         }
45051         return ret_ref;
45052 }
45053
45054 uint32_t  __attribute__((export_name("TS_Invoice_check_signature"))) TS_Invoice_check_signature(uint32_t this_arg) {
45055         LDKInvoice this_arg_conv;
45056         this_arg_conv.inner = (void*)(this_arg & (~1));
45057         this_arg_conv.is_owned = false;
45058         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45059         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
45060         *ret_conv = Invoice_check_signature(&this_arg_conv);
45061         return (uint32_t)ret_conv;
45062 }
45063
45064 uint32_t  __attribute__((export_name("TS_Invoice_from_signed"))) TS_Invoice_from_signed(uint32_t signed_invoice) {
45065         LDKSignedRawInvoice signed_invoice_conv;
45066         signed_invoice_conv.inner = (void*)(signed_invoice & (~1));
45067         signed_invoice_conv.is_owned = (signed_invoice & 1) || (signed_invoice == 0);
45068         CHECK_INNER_FIELD_ACCESS_OR_NULL(signed_invoice_conv);
45069         signed_invoice_conv = SignedRawInvoice_clone(&signed_invoice_conv);
45070         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
45071         *ret_conv = Invoice_from_signed(signed_invoice_conv);
45072         return (uint32_t)ret_conv;
45073 }
45074
45075 int64_t  __attribute__((export_name("TS_Invoice_duration_since_epoch"))) TS_Invoice_duration_since_epoch(uint32_t this_arg) {
45076         LDKInvoice this_arg_conv;
45077         this_arg_conv.inner = (void*)(this_arg & (~1));
45078         this_arg_conv.is_owned = false;
45079         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45080         int64_t ret_conv = Invoice_duration_since_epoch(&this_arg_conv);
45081         return ret_conv;
45082 }
45083
45084 int8_tArray  __attribute__((export_name("TS_Invoice_payment_hash"))) TS_Invoice_payment_hash(uint32_t this_arg) {
45085         LDKInvoice this_arg_conv;
45086         this_arg_conv.inner = (void*)(this_arg & (~1));
45087         this_arg_conv.is_owned = false;
45088         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45089         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
45090         memcpy(ret_arr->elems, *Invoice_payment_hash(&this_arg_conv), 32);
45091         return ret_arr;
45092 }
45093
45094 int8_tArray  __attribute__((export_name("TS_Invoice_payee_pub_key"))) TS_Invoice_payee_pub_key(uint32_t this_arg) {
45095         LDKInvoice this_arg_conv;
45096         this_arg_conv.inner = (void*)(this_arg & (~1));
45097         this_arg_conv.is_owned = false;
45098         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45099         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
45100         memcpy(ret_arr->elems, Invoice_payee_pub_key(&this_arg_conv).compressed_form, 33);
45101         return ret_arr;
45102 }
45103
45104 int8_tArray  __attribute__((export_name("TS_Invoice_payment_secret"))) TS_Invoice_payment_secret(uint32_t this_arg) {
45105         LDKInvoice this_arg_conv;
45106         this_arg_conv.inner = (void*)(this_arg & (~1));
45107         this_arg_conv.is_owned = false;
45108         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45109         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
45110         memcpy(ret_arr->elems, *Invoice_payment_secret(&this_arg_conv), 32);
45111         return ret_arr;
45112 }
45113
45114 uint32_t  __attribute__((export_name("TS_Invoice_features"))) TS_Invoice_features(uint32_t this_arg) {
45115         LDKInvoice this_arg_conv;
45116         this_arg_conv.inner = (void*)(this_arg & (~1));
45117         this_arg_conv.is_owned = false;
45118         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45119         LDKInvoiceFeatures ret_var = Invoice_features(&this_arg_conv);
45120         uint32_t ret_ref = 0;
45121         if ((uintptr_t)ret_var.inner > 4096) {
45122                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45123                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45124         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45125                 ret_ref = (uintptr_t)ret_var.inner;
45126                 if (ret_var.is_owned) {
45127                         ret_ref |= 1;
45128                 }
45129         }
45130         return ret_ref;
45131 }
45132
45133 int8_tArray  __attribute__((export_name("TS_Invoice_recover_payee_pub_key"))) TS_Invoice_recover_payee_pub_key(uint32_t this_arg) {
45134         LDKInvoice this_arg_conv;
45135         this_arg_conv.inner = (void*)(this_arg & (~1));
45136         this_arg_conv.is_owned = false;
45137         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45138         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
45139         memcpy(ret_arr->elems, Invoice_recover_payee_pub_key(&this_arg_conv).compressed_form, 33);
45140         return ret_arr;
45141 }
45142
45143 int64_t  __attribute__((export_name("TS_Invoice_expiry_time"))) TS_Invoice_expiry_time(uint32_t this_arg) {
45144         LDKInvoice this_arg_conv;
45145         this_arg_conv.inner = (void*)(this_arg & (~1));
45146         this_arg_conv.is_owned = false;
45147         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45148         int64_t ret_conv = Invoice_expiry_time(&this_arg_conv);
45149         return ret_conv;
45150 }
45151
45152 jboolean  __attribute__((export_name("TS_Invoice_would_expire"))) TS_Invoice_would_expire(uint32_t this_arg, int64_t at_time) {
45153         LDKInvoice this_arg_conv;
45154         this_arg_conv.inner = (void*)(this_arg & (~1));
45155         this_arg_conv.is_owned = false;
45156         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45157         jboolean ret_conv = Invoice_would_expire(&this_arg_conv, at_time);
45158         return ret_conv;
45159 }
45160
45161 int64_t  __attribute__((export_name("TS_Invoice_min_final_cltv_expiry"))) TS_Invoice_min_final_cltv_expiry(uint32_t this_arg) {
45162         LDKInvoice this_arg_conv;
45163         this_arg_conv.inner = (void*)(this_arg & (~1));
45164         this_arg_conv.is_owned = false;
45165         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45166         int64_t ret_conv = Invoice_min_final_cltv_expiry(&this_arg_conv);
45167         return ret_conv;
45168 }
45169
45170 uint32_tArray  __attribute__((export_name("TS_Invoice_private_routes"))) TS_Invoice_private_routes(uint32_t this_arg) {
45171         LDKInvoice this_arg_conv;
45172         this_arg_conv.inner = (void*)(this_arg & (~1));
45173         this_arg_conv.is_owned = false;
45174         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45175         LDKCVec_PrivateRouteZ ret_var = Invoice_private_routes(&this_arg_conv);
45176         uint32_tArray ret_arr = NULL;
45177         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
45178         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 8);
45179         for (size_t o = 0; o < ret_var.datalen; o++) {
45180                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
45181                 uint32_t ret_conv_14_ref = 0;
45182                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45183                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45184                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
45185                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
45186                 if (ret_conv_14_var.is_owned) {
45187                         ret_conv_14_ref |= 1;
45188                 }
45189                 ret_arr_ptr[o] = ret_conv_14_ref;
45190         }
45191         
45192         FREE(ret_var.data);
45193         return ret_arr;
45194 }
45195
45196 uint32_tArray  __attribute__((export_name("TS_Invoice_route_hints"))) TS_Invoice_route_hints(uint32_t this_arg) {
45197         LDKInvoice this_arg_conv;
45198         this_arg_conv.inner = (void*)(this_arg & (~1));
45199         this_arg_conv.is_owned = false;
45200         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45201         LDKCVec_RouteHintZ ret_var = Invoice_route_hints(&this_arg_conv);
45202         uint32_tArray ret_arr = NULL;
45203         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
45204         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 8);
45205         for (size_t l = 0; l < ret_var.datalen; l++) {
45206                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
45207                 uint32_t ret_conv_11_ref = 0;
45208                 CHECK((((uintptr_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45209                 CHECK((((uintptr_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45210                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
45211                 ret_conv_11_ref = (uintptr_t)ret_conv_11_var.inner;
45212                 if (ret_conv_11_var.is_owned) {
45213                         ret_conv_11_ref |= 1;
45214                 }
45215                 ret_arr_ptr[l] = ret_conv_11_ref;
45216         }
45217         
45218         FREE(ret_var.data);
45219         return ret_arr;
45220 }
45221
45222 uint32_t  __attribute__((export_name("TS_Invoice_currency"))) TS_Invoice_currency(uint32_t this_arg) {
45223         LDKInvoice this_arg_conv;
45224         this_arg_conv.inner = (void*)(this_arg & (~1));
45225         this_arg_conv.is_owned = false;
45226         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45227         uint32_t ret_conv = LDKCurrency_to_js(Invoice_currency(&this_arg_conv));
45228         return ret_conv;
45229 }
45230
45231 uint32_t  __attribute__((export_name("TS_Invoice_amount_milli_satoshis"))) TS_Invoice_amount_milli_satoshis(uint32_t this_arg) {
45232         LDKInvoice this_arg_conv;
45233         this_arg_conv.inner = (void*)(this_arg & (~1));
45234         this_arg_conv.is_owned = false;
45235         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45236         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
45237         *ret_copy = Invoice_amount_milli_satoshis(&this_arg_conv);
45238         uint32_t ret_ref = (uintptr_t)ret_copy;
45239         return ret_ref;
45240 }
45241
45242 uint32_t  __attribute__((export_name("TS_Description_new"))) TS_Description_new(jstring description) {
45243         LDKStr description_conv = str_ref_to_owned_c(description);
45244         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
45245         *ret_conv = Description_new(description_conv);
45246         return (uint32_t)ret_conv;
45247 }
45248
45249 jstring  __attribute__((export_name("TS_Description_into_inner"))) TS_Description_into_inner(uint32_t this_arg) {
45250         LDKDescription this_arg_conv;
45251         this_arg_conv.inner = (void*)(this_arg & (~1));
45252         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
45253         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45254         this_arg_conv = Description_clone(&this_arg_conv);
45255         LDKStr ret_str = Description_into_inner(this_arg_conv);
45256         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
45257         Str_free(ret_str);
45258         return ret_conv;
45259 }
45260
45261 uint32_t  __attribute__((export_name("TS_ExpiryTime_from_seconds"))) TS_ExpiryTime_from_seconds(int64_t seconds) {
45262         LDKExpiryTime ret_var = ExpiryTime_from_seconds(seconds);
45263         uint32_t ret_ref = 0;
45264         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45265         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45266         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45267         ret_ref = (uintptr_t)ret_var.inner;
45268         if (ret_var.is_owned) {
45269                 ret_ref |= 1;
45270         }
45271         return ret_ref;
45272 }
45273
45274 uint32_t  __attribute__((export_name("TS_ExpiryTime_from_duration"))) TS_ExpiryTime_from_duration(int64_t duration) {
45275         LDKExpiryTime ret_var = ExpiryTime_from_duration(duration);
45276         uint32_t ret_ref = 0;
45277         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45278         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45279         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45280         ret_ref = (uintptr_t)ret_var.inner;
45281         if (ret_var.is_owned) {
45282                 ret_ref |= 1;
45283         }
45284         return ret_ref;
45285 }
45286
45287 int64_t  __attribute__((export_name("TS_ExpiryTime_as_seconds"))) TS_ExpiryTime_as_seconds(uint32_t this_arg) {
45288         LDKExpiryTime this_arg_conv;
45289         this_arg_conv.inner = (void*)(this_arg & (~1));
45290         this_arg_conv.is_owned = false;
45291         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45292         int64_t ret_conv = ExpiryTime_as_seconds(&this_arg_conv);
45293         return ret_conv;
45294 }
45295
45296 int64_t  __attribute__((export_name("TS_ExpiryTime_as_duration"))) TS_ExpiryTime_as_duration(uint32_t this_arg) {
45297         LDKExpiryTime this_arg_conv;
45298         this_arg_conv.inner = (void*)(this_arg & (~1));
45299         this_arg_conv.is_owned = false;
45300         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45301         int64_t ret_conv = ExpiryTime_as_duration(&this_arg_conv);
45302         return ret_conv;
45303 }
45304
45305 uint32_t  __attribute__((export_name("TS_PrivateRoute_new"))) TS_PrivateRoute_new(uint32_t hops) {
45306         LDKRouteHint hops_conv;
45307         hops_conv.inner = (void*)(hops & (~1));
45308         hops_conv.is_owned = (hops & 1) || (hops == 0);
45309         CHECK_INNER_FIELD_ACCESS_OR_NULL(hops_conv);
45310         hops_conv = RouteHint_clone(&hops_conv);
45311         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
45312         *ret_conv = PrivateRoute_new(hops_conv);
45313         return (uint32_t)ret_conv;
45314 }
45315
45316 uint32_t  __attribute__((export_name("TS_PrivateRoute_into_inner"))) TS_PrivateRoute_into_inner(uint32_t this_arg) {
45317         LDKPrivateRoute this_arg_conv;
45318         this_arg_conv.inner = (void*)(this_arg & (~1));
45319         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
45320         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45321         this_arg_conv = PrivateRoute_clone(&this_arg_conv);
45322         LDKRouteHint ret_var = PrivateRoute_into_inner(this_arg_conv);
45323         uint32_t ret_ref = 0;
45324         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45325         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45326         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45327         ret_ref = (uintptr_t)ret_var.inner;
45328         if (ret_var.is_owned) {
45329                 ret_ref |= 1;
45330         }
45331         return ret_ref;
45332 }
45333
45334 uint32_t  __attribute__((export_name("TS_CreationError_clone"))) TS_CreationError_clone(uint32_t orig) {
45335         LDKCreationError* orig_conv = (LDKCreationError*)(orig & ~1);
45336         uint32_t ret_conv = LDKCreationError_to_js(CreationError_clone(orig_conv));
45337         return ret_conv;
45338 }
45339
45340 uint32_t  __attribute__((export_name("TS_CreationError_description_too_long"))) TS_CreationError_description_too_long() {
45341         uint32_t ret_conv = LDKCreationError_to_js(CreationError_description_too_long());
45342         return ret_conv;
45343 }
45344
45345 uint32_t  __attribute__((export_name("TS_CreationError_route_too_long"))) TS_CreationError_route_too_long() {
45346         uint32_t ret_conv = LDKCreationError_to_js(CreationError_route_too_long());
45347         return ret_conv;
45348 }
45349
45350 uint32_t  __attribute__((export_name("TS_CreationError_timestamp_out_of_bounds"))) TS_CreationError_timestamp_out_of_bounds() {
45351         uint32_t ret_conv = LDKCreationError_to_js(CreationError_timestamp_out_of_bounds());
45352         return ret_conv;
45353 }
45354
45355 uint32_t  __attribute__((export_name("TS_CreationError_invalid_amount"))) TS_CreationError_invalid_amount() {
45356         uint32_t ret_conv = LDKCreationError_to_js(CreationError_invalid_amount());
45357         return ret_conv;
45358 }
45359
45360 uint32_t  __attribute__((export_name("TS_CreationError_missing_route_hints"))) TS_CreationError_missing_route_hints() {
45361         uint32_t ret_conv = LDKCreationError_to_js(CreationError_missing_route_hints());
45362         return ret_conv;
45363 }
45364
45365 jboolean  __attribute__((export_name("TS_CreationError_eq"))) TS_CreationError_eq(uint32_t a, uint32_t b) {
45366         LDKCreationError* a_conv = (LDKCreationError*)(a & ~1);
45367         LDKCreationError* b_conv = (LDKCreationError*)(b & ~1);
45368         jboolean ret_conv = CreationError_eq(a_conv, b_conv);
45369         return ret_conv;
45370 }
45371
45372 jstring  __attribute__((export_name("TS_CreationError_to_str"))) TS_CreationError_to_str(uint32_t o) {
45373         LDKCreationError* o_conv = (LDKCreationError*)(o & ~1);
45374         LDKStr ret_str = CreationError_to_str(o_conv);
45375         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
45376         Str_free(ret_str);
45377         return ret_conv;
45378 }
45379
45380 uint32_t  __attribute__((export_name("TS_SemanticError_clone"))) TS_SemanticError_clone(uint32_t orig) {
45381         LDKSemanticError* orig_conv = (LDKSemanticError*)(orig & ~1);
45382         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_clone(orig_conv));
45383         return ret_conv;
45384 }
45385
45386 uint32_t  __attribute__((export_name("TS_SemanticError_no_payment_hash"))) TS_SemanticError_no_payment_hash() {
45387         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_no_payment_hash());
45388         return ret_conv;
45389 }
45390
45391 uint32_t  __attribute__((export_name("TS_SemanticError_multiple_payment_hashes"))) TS_SemanticError_multiple_payment_hashes() {
45392         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_multiple_payment_hashes());
45393         return ret_conv;
45394 }
45395
45396 uint32_t  __attribute__((export_name("TS_SemanticError_no_description"))) TS_SemanticError_no_description() {
45397         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_no_description());
45398         return ret_conv;
45399 }
45400
45401 uint32_t  __attribute__((export_name("TS_SemanticError_multiple_descriptions"))) TS_SemanticError_multiple_descriptions() {
45402         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_multiple_descriptions());
45403         return ret_conv;
45404 }
45405
45406 uint32_t  __attribute__((export_name("TS_SemanticError_no_payment_secret"))) TS_SemanticError_no_payment_secret() {
45407         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_no_payment_secret());
45408         return ret_conv;
45409 }
45410
45411 uint32_t  __attribute__((export_name("TS_SemanticError_multiple_payment_secrets"))) TS_SemanticError_multiple_payment_secrets() {
45412         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_multiple_payment_secrets());
45413         return ret_conv;
45414 }
45415
45416 uint32_t  __attribute__((export_name("TS_SemanticError_invalid_features"))) TS_SemanticError_invalid_features() {
45417         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_invalid_features());
45418         return ret_conv;
45419 }
45420
45421 uint32_t  __attribute__((export_name("TS_SemanticError_invalid_recovery_id"))) TS_SemanticError_invalid_recovery_id() {
45422         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_invalid_recovery_id());
45423         return ret_conv;
45424 }
45425
45426 uint32_t  __attribute__((export_name("TS_SemanticError_invalid_signature"))) TS_SemanticError_invalid_signature() {
45427         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_invalid_signature());
45428         return ret_conv;
45429 }
45430
45431 uint32_t  __attribute__((export_name("TS_SemanticError_imprecise_amount"))) TS_SemanticError_imprecise_amount() {
45432         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_imprecise_amount());
45433         return ret_conv;
45434 }
45435
45436 jboolean  __attribute__((export_name("TS_SemanticError_eq"))) TS_SemanticError_eq(uint32_t a, uint32_t b) {
45437         LDKSemanticError* a_conv = (LDKSemanticError*)(a & ~1);
45438         LDKSemanticError* b_conv = (LDKSemanticError*)(b & ~1);
45439         jboolean ret_conv = SemanticError_eq(a_conv, b_conv);
45440         return ret_conv;
45441 }
45442
45443 jstring  __attribute__((export_name("TS_SemanticError_to_str"))) TS_SemanticError_to_str(uint32_t o) {
45444         LDKSemanticError* o_conv = (LDKSemanticError*)(o & ~1);
45445         LDKStr ret_str = SemanticError_to_str(o_conv);
45446         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
45447         Str_free(ret_str);
45448         return ret_conv;
45449 }
45450
45451 void  __attribute__((export_name("TS_SignOrCreationError_free"))) TS_SignOrCreationError_free(uint32_t this_ptr) {
45452         if ((this_ptr & 1) != 0) return;
45453         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
45454         CHECK_ACCESS(this_ptr_ptr);
45455         LDKSignOrCreationError this_ptr_conv = *(LDKSignOrCreationError*)(this_ptr_ptr);
45456         FREE((void*)this_ptr);
45457         SignOrCreationError_free(this_ptr_conv);
45458 }
45459
45460 static inline uintptr_t SignOrCreationError_clone_ptr(LDKSignOrCreationError *NONNULL_PTR arg) {
45461         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
45462         *ret_copy = SignOrCreationError_clone(arg);
45463 uint32_t ret_ref = (uintptr_t)ret_copy;
45464         return ret_ref;
45465 }
45466 uint32_t  __attribute__((export_name("TS_SignOrCreationError_clone_ptr"))) TS_SignOrCreationError_clone_ptr(uint32_t arg) {
45467         LDKSignOrCreationError* arg_conv = (LDKSignOrCreationError*)arg;
45468         uint32_t ret_conv = SignOrCreationError_clone_ptr(arg_conv);
45469         return ret_conv;
45470 }
45471
45472 uint32_t  __attribute__((export_name("TS_SignOrCreationError_clone"))) TS_SignOrCreationError_clone(uint32_t orig) {
45473         LDKSignOrCreationError* orig_conv = (LDKSignOrCreationError*)orig;
45474         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
45475         *ret_copy = SignOrCreationError_clone(orig_conv);
45476         uint32_t ret_ref = (uintptr_t)ret_copy;
45477         return ret_ref;
45478 }
45479
45480 uint32_t  __attribute__((export_name("TS_SignOrCreationError_sign_error"))) TS_SignOrCreationError_sign_error() {
45481         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
45482         *ret_copy = SignOrCreationError_sign_error();
45483         uint32_t ret_ref = (uintptr_t)ret_copy;
45484         return ret_ref;
45485 }
45486
45487 uint32_t  __attribute__((export_name("TS_SignOrCreationError_creation_error"))) TS_SignOrCreationError_creation_error(uint32_t a) {
45488         LDKCreationError a_conv = LDKCreationError_from_js(a);
45489         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
45490         *ret_copy = SignOrCreationError_creation_error(a_conv);
45491         uint32_t ret_ref = (uintptr_t)ret_copy;
45492         return ret_ref;
45493 }
45494
45495 jboolean  __attribute__((export_name("TS_SignOrCreationError_eq"))) TS_SignOrCreationError_eq(uint32_t a, uint32_t b) {
45496         LDKSignOrCreationError* a_conv = (LDKSignOrCreationError*)a;
45497         LDKSignOrCreationError* b_conv = (LDKSignOrCreationError*)b;
45498         jboolean ret_conv = SignOrCreationError_eq(a_conv, b_conv);
45499         return ret_conv;
45500 }
45501
45502 jstring  __attribute__((export_name("TS_SignOrCreationError_to_str"))) TS_SignOrCreationError_to_str(uint32_t o) {
45503         LDKSignOrCreationError* o_conv = (LDKSignOrCreationError*)o;
45504         LDKStr ret_str = SignOrCreationError_to_str(o_conv);
45505         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
45506         Str_free(ret_str);
45507         return ret_conv;
45508 }
45509
45510 void  __attribute__((export_name("TS_InvoicePayer_free"))) TS_InvoicePayer_free(uint32_t this_obj) {
45511         LDKInvoicePayer this_obj_conv;
45512         this_obj_conv.inner = (void*)(this_obj & (~1));
45513         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
45514         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45515         InvoicePayer_free(this_obj_conv);
45516 }
45517
45518 void  __attribute__((export_name("TS_Payer_free"))) TS_Payer_free(uint32_t this_ptr) {
45519         if ((this_ptr & 1) != 0) return;
45520         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
45521         CHECK_ACCESS(this_ptr_ptr);
45522         LDKPayer this_ptr_conv = *(LDKPayer*)(this_ptr_ptr);
45523         FREE((void*)this_ptr);
45524         Payer_free(this_ptr_conv);
45525 }
45526
45527 void  __attribute__((export_name("TS_Router_free"))) TS_Router_free(uint32_t this_ptr) {
45528         if ((this_ptr & 1) != 0) return;
45529         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
45530         CHECK_ACCESS(this_ptr_ptr);
45531         LDKRouter this_ptr_conv = *(LDKRouter*)(this_ptr_ptr);
45532         FREE((void*)this_ptr);
45533         Router_free(this_ptr_conv);
45534 }
45535
45536 void  __attribute__((export_name("TS_Retry_free"))) TS_Retry_free(uint32_t this_ptr) {
45537         if ((this_ptr & 1) != 0) return;
45538         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
45539         CHECK_ACCESS(this_ptr_ptr);
45540         LDKRetry this_ptr_conv = *(LDKRetry*)(this_ptr_ptr);
45541         FREE((void*)this_ptr);
45542         Retry_free(this_ptr_conv);
45543 }
45544
45545 static inline uintptr_t Retry_clone_ptr(LDKRetry *NONNULL_PTR arg) {
45546         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
45547         *ret_copy = Retry_clone(arg);
45548 uint32_t ret_ref = (uintptr_t)ret_copy;
45549         return ret_ref;
45550 }
45551 uint32_t  __attribute__((export_name("TS_Retry_clone_ptr"))) TS_Retry_clone_ptr(uint32_t arg) {
45552         LDKRetry* arg_conv = (LDKRetry*)arg;
45553         uint32_t ret_conv = Retry_clone_ptr(arg_conv);
45554         return ret_conv;
45555 }
45556
45557 uint32_t  __attribute__((export_name("TS_Retry_clone"))) TS_Retry_clone(uint32_t orig) {
45558         LDKRetry* orig_conv = (LDKRetry*)orig;
45559         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
45560         *ret_copy = Retry_clone(orig_conv);
45561         uint32_t ret_ref = (uintptr_t)ret_copy;
45562         return ret_ref;
45563 }
45564
45565 uint32_t  __attribute__((export_name("TS_Retry_attempts"))) TS_Retry_attempts(uint32_t a) {
45566         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
45567         *ret_copy = Retry_attempts(a);
45568         uint32_t ret_ref = (uintptr_t)ret_copy;
45569         return ret_ref;
45570 }
45571
45572 jboolean  __attribute__((export_name("TS_Retry_eq"))) TS_Retry_eq(uint32_t a, uint32_t b) {
45573         LDKRetry* a_conv = (LDKRetry*)a;
45574         LDKRetry* b_conv = (LDKRetry*)b;
45575         jboolean ret_conv = Retry_eq(a_conv, b_conv);
45576         return ret_conv;
45577 }
45578
45579 int64_t  __attribute__((export_name("TS_Retry_hash"))) TS_Retry_hash(uint32_t o) {
45580         LDKRetry* o_conv = (LDKRetry*)o;
45581         int64_t ret_conv = Retry_hash(o_conv);
45582         return ret_conv;
45583 }
45584
45585 void  __attribute__((export_name("TS_PaymentError_free"))) TS_PaymentError_free(uint32_t this_ptr) {
45586         if ((this_ptr & 1) != 0) return;
45587         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
45588         CHECK_ACCESS(this_ptr_ptr);
45589         LDKPaymentError this_ptr_conv = *(LDKPaymentError*)(this_ptr_ptr);
45590         FREE((void*)this_ptr);
45591         PaymentError_free(this_ptr_conv);
45592 }
45593
45594 static inline uintptr_t PaymentError_clone_ptr(LDKPaymentError *NONNULL_PTR arg) {
45595         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
45596         *ret_copy = PaymentError_clone(arg);
45597 uint32_t ret_ref = (uintptr_t)ret_copy;
45598         return ret_ref;
45599 }
45600 uint32_t  __attribute__((export_name("TS_PaymentError_clone_ptr"))) TS_PaymentError_clone_ptr(uint32_t arg) {
45601         LDKPaymentError* arg_conv = (LDKPaymentError*)arg;
45602         uint32_t ret_conv = PaymentError_clone_ptr(arg_conv);
45603         return ret_conv;
45604 }
45605
45606 uint32_t  __attribute__((export_name("TS_PaymentError_clone"))) TS_PaymentError_clone(uint32_t orig) {
45607         LDKPaymentError* orig_conv = (LDKPaymentError*)orig;
45608         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
45609         *ret_copy = PaymentError_clone(orig_conv);
45610         uint32_t ret_ref = (uintptr_t)ret_copy;
45611         return ret_ref;
45612 }
45613
45614 uint32_t  __attribute__((export_name("TS_PaymentError_invoice"))) TS_PaymentError_invoice(jstring a) {
45615         LDKStr a_conv = str_ref_to_owned_c(a);
45616         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
45617         *ret_copy = PaymentError_invoice(a_conv);
45618         uint32_t ret_ref = (uintptr_t)ret_copy;
45619         return ret_ref;
45620 }
45621
45622 uint32_t  __attribute__((export_name("TS_PaymentError_routing"))) TS_PaymentError_routing(uint32_t a) {
45623         LDKLightningError a_conv;
45624         a_conv.inner = (void*)(a & (~1));
45625         a_conv.is_owned = (a & 1) || (a == 0);
45626         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
45627         a_conv = LightningError_clone(&a_conv);
45628         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
45629         *ret_copy = PaymentError_routing(a_conv);
45630         uint32_t ret_ref = (uintptr_t)ret_copy;
45631         return ret_ref;
45632 }
45633
45634 uint32_t  __attribute__((export_name("TS_PaymentError_sending"))) TS_PaymentError_sending(uint32_t a) {
45635         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
45636         CHECK_ACCESS(a_ptr);
45637         LDKPaymentSendFailure a_conv = *(LDKPaymentSendFailure*)(a_ptr);
45638         a_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)a) & ~1));
45639         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
45640         *ret_copy = PaymentError_sending(a_conv);
45641         uint32_t ret_ref = (uintptr_t)ret_copy;
45642         return ret_ref;
45643 }
45644
45645 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) {
45646         void* payer_ptr = (void*)(((uintptr_t)payer) & ~1);
45647         CHECK_ACCESS(payer_ptr);
45648         LDKPayer payer_conv = *(LDKPayer*)(payer_ptr);
45649         if (payer_conv.free == LDKPayer_JCalls_free) {
45650                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
45651                 LDKPayer_JCalls_cloned(&payer_conv);
45652         }
45653         void* router_ptr = (void*)(((uintptr_t)router) & ~1);
45654         CHECK_ACCESS(router_ptr);
45655         LDKRouter router_conv = *(LDKRouter*)(router_ptr);
45656         if (router_conv.free == LDKRouter_JCalls_free) {
45657                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
45658                 LDKRouter_JCalls_cloned(&router_conv);
45659         }
45660         LDKMultiThreadedLockableScore scorer_conv;
45661         scorer_conv.inner = (void*)(scorer & (~1));
45662         scorer_conv.is_owned = false;
45663         CHECK_INNER_FIELD_ACCESS_OR_NULL(scorer_conv);
45664         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
45665         CHECK_ACCESS(logger_ptr);
45666         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
45667         if (logger_conv.free == LDKLogger_JCalls_free) {
45668                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
45669                 LDKLogger_JCalls_cloned(&logger_conv);
45670         }
45671         void* event_handler_ptr = (void*)(((uintptr_t)event_handler) & ~1);
45672         CHECK_ACCESS(event_handler_ptr);
45673         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
45674         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
45675                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
45676                 LDKEventHandler_JCalls_cloned(&event_handler_conv);
45677         }
45678         void* retry_ptr = (void*)(((uintptr_t)retry) & ~1);
45679         CHECK_ACCESS(retry_ptr);
45680         LDKRetry retry_conv = *(LDKRetry*)(retry_ptr);
45681         retry_conv = Retry_clone((LDKRetry*)(((uintptr_t)retry) & ~1));
45682         LDKInvoicePayer ret_var = InvoicePayer_new(payer_conv, router_conv, &scorer_conv, logger_conv, event_handler_conv, retry_conv);
45683         uint32_t ret_ref = 0;
45684         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45685         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45686         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45687         ret_ref = (uintptr_t)ret_var.inner;
45688         if (ret_var.is_owned) {
45689                 ret_ref |= 1;
45690         }
45691         return ret_ref;
45692 }
45693
45694 uint32_t  __attribute__((export_name("TS_InvoicePayer_pay_invoice"))) TS_InvoicePayer_pay_invoice(uint32_t this_arg, uint32_t invoice) {
45695         LDKInvoicePayer this_arg_conv;
45696         this_arg_conv.inner = (void*)(this_arg & (~1));
45697         this_arg_conv.is_owned = false;
45698         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45699         LDKInvoice invoice_conv;
45700         invoice_conv.inner = (void*)(invoice & (~1));
45701         invoice_conv.is_owned = false;
45702         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
45703         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
45704         *ret_conv = InvoicePayer_pay_invoice(&this_arg_conv, &invoice_conv);
45705         return (uint32_t)ret_conv;
45706 }
45707
45708 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) {
45709         LDKInvoicePayer this_arg_conv;
45710         this_arg_conv.inner = (void*)(this_arg & (~1));
45711         this_arg_conv.is_owned = false;
45712         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45713         LDKInvoice invoice_conv;
45714         invoice_conv.inner = (void*)(invoice & (~1));
45715         invoice_conv.is_owned = false;
45716         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
45717         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
45718         *ret_conv = InvoicePayer_pay_zero_value_invoice(&this_arg_conv, &invoice_conv, amount_msats);
45719         return (uint32_t)ret_conv;
45720 }
45721
45722 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) {
45723         LDKInvoicePayer this_arg_conv;
45724         this_arg_conv.inner = (void*)(this_arg & (~1));
45725         this_arg_conv.is_owned = false;
45726         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45727         LDKPublicKey pubkey_ref;
45728         CHECK(pubkey->arr_len == 33);
45729         memcpy(pubkey_ref.compressed_form, pubkey->elems, 33); FREE(pubkey);
45730         LDKThirtyTwoBytes payment_preimage_ref;
45731         CHECK(payment_preimage->arr_len == 32);
45732         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
45733         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
45734         *ret_conv = InvoicePayer_pay_pubkey(&this_arg_conv, pubkey_ref, payment_preimage_ref, amount_msats, final_cltv_expiry_delta);
45735         return (uint32_t)ret_conv;
45736 }
45737
45738 void  __attribute__((export_name("TS_InvoicePayer_remove_cached_payment"))) TS_InvoicePayer_remove_cached_payment(uint32_t this_arg, int8_tArray payment_hash) {
45739         LDKInvoicePayer this_arg_conv;
45740         this_arg_conv.inner = (void*)(this_arg & (~1));
45741         this_arg_conv.is_owned = false;
45742         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45743         unsigned char payment_hash_arr[32];
45744         CHECK(payment_hash->arr_len == 32);
45745         memcpy(payment_hash_arr, payment_hash->elems, 32); FREE(payment_hash);
45746         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
45747         InvoicePayer_remove_cached_payment(&this_arg_conv, payment_hash_ref);
45748 }
45749
45750 uint32_t  __attribute__((export_name("TS_InvoicePayer_as_EventHandler"))) TS_InvoicePayer_as_EventHandler(uint32_t this_arg) {
45751         LDKInvoicePayer this_arg_conv;
45752         this_arg_conv.inner = (void*)(this_arg & (~1));
45753         this_arg_conv.is_owned = false;
45754         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45755         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
45756         *ret_ret = InvoicePayer_as_EventHandler(&this_arg_conv);
45757         return (uint32_t)ret_ret;
45758 }
45759
45760 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) {
45761         LDKChannelManager channelmanager_conv;
45762         channelmanager_conv.inner = (void*)(channelmanager & (~1));
45763         channelmanager_conv.is_owned = false;
45764         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
45765         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
45766         CHECK_ACCESS(keys_manager_ptr);
45767         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
45768         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
45769                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
45770                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
45771         }
45772         LDKCurrency network_conv = LDKCurrency_from_js(network);
45773         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
45774         CHECK_ACCESS(amt_msat_ptr);
45775         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
45776         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
45777         LDKSha256 description_hash_conv;
45778         description_hash_conv.inner = (void*)(description_hash & (~1));
45779         description_hash_conv.is_owned = (description_hash & 1) || (description_hash == 0);
45780         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
45781         description_hash_conv = Sha256_clone(&description_hash_conv);
45782         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
45783         *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);
45784         return (uint32_t)ret_conv;
45785 }
45786
45787 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) {
45788         LDKChannelManager channelmanager_conv;
45789         channelmanager_conv.inner = (void*)(channelmanager & (~1));
45790         channelmanager_conv.is_owned = false;
45791         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
45792         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
45793         CHECK_ACCESS(keys_manager_ptr);
45794         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
45795         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
45796                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
45797                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
45798         }
45799         LDKCurrency network_conv = LDKCurrency_from_js(network);
45800         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
45801         CHECK_ACCESS(amt_msat_ptr);
45802         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
45803         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
45804         LDKStr description_conv = str_ref_to_owned_c(description);
45805         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
45806         *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);
45807         return (uint32_t)ret_conv;
45808 }
45809
45810 void  __attribute__((export_name("TS_DefaultRouter_free"))) TS_DefaultRouter_free(uint32_t this_obj) {
45811         LDKDefaultRouter this_obj_conv;
45812         this_obj_conv.inner = (void*)(this_obj & (~1));
45813         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
45814         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45815         DefaultRouter_free(this_obj_conv);
45816 }
45817
45818 uint32_t  __attribute__((export_name("TS_DefaultRouter_new"))) TS_DefaultRouter_new(uint32_t network_graph, uint32_t logger, int8_tArray random_seed_bytes) {
45819         LDKNetworkGraph network_graph_conv;
45820         network_graph_conv.inner = (void*)(network_graph & (~1));
45821         network_graph_conv.is_owned = false;
45822         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
45823         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
45824         CHECK_ACCESS(logger_ptr);
45825         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
45826         if (logger_conv.free == LDKLogger_JCalls_free) {
45827                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
45828                 LDKLogger_JCalls_cloned(&logger_conv);
45829         }
45830         LDKThirtyTwoBytes random_seed_bytes_ref;
45831         CHECK(random_seed_bytes->arr_len == 32);
45832         memcpy(random_seed_bytes_ref.data, random_seed_bytes->elems, 32); FREE(random_seed_bytes);
45833         LDKDefaultRouter ret_var = DefaultRouter_new(&network_graph_conv, logger_conv, random_seed_bytes_ref);
45834         uint32_t ret_ref = 0;
45835         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45836         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45837         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45838         ret_ref = (uintptr_t)ret_var.inner;
45839         if (ret_var.is_owned) {
45840                 ret_ref |= 1;
45841         }
45842         return ret_ref;
45843 }
45844
45845 uint32_t  __attribute__((export_name("TS_DefaultRouter_as_Router"))) TS_DefaultRouter_as_Router(uint32_t this_arg) {
45846         LDKDefaultRouter this_arg_conv;
45847         this_arg_conv.inner = (void*)(this_arg & (~1));
45848         this_arg_conv.is_owned = false;
45849         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45850         LDKRouter* ret_ret = MALLOC(sizeof(LDKRouter), "LDKRouter");
45851         *ret_ret = DefaultRouter_as_Router(&this_arg_conv);
45852         return (uint32_t)ret_ret;
45853 }
45854
45855 uint32_t  __attribute__((export_name("TS_ChannelManager_as_Payer"))) TS_ChannelManager_as_Payer(uint32_t this_arg) {
45856         LDKChannelManager this_arg_conv;
45857         this_arg_conv.inner = (void*)(this_arg & (~1));
45858         this_arg_conv.is_owned = false;
45859         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45860         LDKPayer* ret_ret = MALLOC(sizeof(LDKPayer), "LDKPayer");
45861         *ret_ret = ChannelManager_as_Payer(&this_arg_conv);
45862         return (uint32_t)ret_ret;
45863 }
45864
45865 uint32_t  __attribute__((export_name("TS_SiPrefix_from_str"))) TS_SiPrefix_from_str(jstring s) {
45866         LDKStr s_conv = str_ref_to_owned_c(s);
45867         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
45868         *ret_conv = SiPrefix_from_str(s_conv);
45869         return (uint32_t)ret_conv;
45870 }
45871
45872 uint32_t  __attribute__((export_name("TS_Invoice_from_str"))) TS_Invoice_from_str(jstring s) {
45873         LDKStr s_conv = str_ref_to_owned_c(s);
45874         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
45875         *ret_conv = Invoice_from_str(s_conv);
45876         return (uint32_t)ret_conv;
45877 }
45878
45879 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_from_str"))) TS_SignedRawInvoice_from_str(jstring s) {
45880         LDKStr s_conv = str_ref_to_owned_c(s);
45881         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
45882         *ret_conv = SignedRawInvoice_from_str(s_conv);
45883         return (uint32_t)ret_conv;
45884 }
45885
45886 jstring  __attribute__((export_name("TS_ParseError_to_str"))) TS_ParseError_to_str(uint32_t o) {
45887         LDKParseError* o_conv = (LDKParseError*)o;
45888         LDKStr ret_str = ParseError_to_str(o_conv);
45889         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
45890         Str_free(ret_str);
45891         return ret_conv;
45892 }
45893
45894 jstring  __attribute__((export_name("TS_ParseOrSemanticError_to_str"))) TS_ParseOrSemanticError_to_str(uint32_t o) {
45895         LDKParseOrSemanticError* o_conv = (LDKParseOrSemanticError*)o;
45896         LDKStr ret_str = ParseOrSemanticError_to_str(o_conv);
45897         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
45898         Str_free(ret_str);
45899         return ret_conv;
45900 }
45901
45902 jstring  __attribute__((export_name("TS_Invoice_to_str"))) TS_Invoice_to_str(uint32_t o) {
45903         LDKInvoice o_conv;
45904         o_conv.inner = (void*)(o & (~1));
45905         o_conv.is_owned = false;
45906         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
45907         LDKStr ret_str = Invoice_to_str(&o_conv);
45908         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
45909         Str_free(ret_str);
45910         return ret_conv;
45911 }
45912
45913 jstring  __attribute__((export_name("TS_SignedRawInvoice_to_str"))) TS_SignedRawInvoice_to_str(uint32_t o) {
45914         LDKSignedRawInvoice o_conv;
45915         o_conv.inner = (void*)(o & (~1));
45916         o_conv.is_owned = false;
45917         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
45918         LDKStr ret_str = SignedRawInvoice_to_str(&o_conv);
45919         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
45920         Str_free(ret_str);
45921         return ret_conv;
45922 }
45923
45924 jstring  __attribute__((export_name("TS_Currency_to_str"))) TS_Currency_to_str(uint32_t o) {
45925         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
45926         LDKStr ret_str = Currency_to_str(o_conv);
45927         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
45928         Str_free(ret_str);
45929         return ret_conv;
45930 }
45931
45932 jstring  __attribute__((export_name("TS_SiPrefix_to_str"))) TS_SiPrefix_to_str(uint32_t o) {
45933         LDKSiPrefix* o_conv = (LDKSiPrefix*)(o & ~1);
45934         LDKStr ret_str = SiPrefix_to_str(o_conv);
45935         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
45936         Str_free(ret_str);
45937         return ret_conv;
45938 }
45939